You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by bl...@apache.org on 2004/10/03 01:12:30 UTC
cvs commit: xml-security/c/src/xkms/impl XKMSPendingRequestImpl.cpp XKMSPendingRequestImpl.hpp XKMSMessageFactoryImpl.cpp XKMSMessageFactoryImpl.hpp
blautenb 2004/10/02 16:12:30
Modified: c/src/xkms XKMSConstants.cpp XKMSConstants.hpp
XKMSMessageAbstractType.hpp XKMSMessageFactory.hpp
c/src/xkms/impl XKMSMessageFactoryImpl.cpp
XKMSMessageFactoryImpl.hpp
Added: c/src/xkms XKMSPendingRequest.hpp
c/src/xkms/impl XKMSPendingRequestImpl.cpp
XKMSPendingRequestImpl.hpp
Log:
Support for pending requests
Revision Changes Path
1.11 +47 -1 xml-security/c/src/xkms/XKMSConstants.cpp
Index: XKMSConstants.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/xkms/XKMSConstants.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- XKMSConstants.cpp 21 Sep 2004 12:33:52 -0000 1.10
+++ XKMSConstants.cpp 2 Oct 2004 23:12:30 -0000 1.11
@@ -375,6 +375,37 @@
chNull
};
+const XMLCh XKMSConstants::s_tagPending[] = {
+
+ chLatin_P,
+ chLatin_e,
+ chLatin_n,
+ chLatin_d,
+ chLatin_i,
+ chLatin_n,
+ chLatin_g,
+ chNull
+};
+
+const XMLCh XKMSConstants::s_tagPendingRequest[] = {
+
+ chLatin_P,
+ chLatin_e,
+ chLatin_n,
+ chLatin_d,
+ chLatin_i,
+ chLatin_n,
+ chLatin_g,
+ chLatin_R,
+ chLatin_e,
+ chLatin_q,
+ chLatin_u,
+ chLatin_e,
+ chLatin_s,
+ chLatin_t,
+ chNull
+};
+
const XMLCh XKMSConstants::s_tagQueryKeyBinding[] = {
chLatin_Q,
@@ -462,6 +493,21 @@
chLatin_i,
chLatin_t,
chLatin_h,
+ chNull
+};
+
+const XMLCh XKMSConstants::s_tagResponseId[] = {
+
+ chLatin_R,
+ chLatin_e,
+ chLatin_s,
+ chLatin_p,
+ chLatin_o,
+ chLatin_n,
+ chLatin_s,
+ chLatin_e,
+ chLatin_I,
+ chLatin_d,
chNull
};
1.13 +4 -1 xml-security/c/src/xkms/XKMSConstants.hpp
Index: XKMSConstants.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/xkms/XKMSConstants.hpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- XKMSConstants.hpp 21 Sep 2004 12:33:52 -0000 1.12
+++ XKMSConstants.hpp 2 Oct 2004 23:12:30 -0000 1.13
@@ -72,11 +72,14 @@
static const XMLCh s_tagOpaqueClientData[];
static const XMLCh s_tagOpaqueData[];
static const XMLCh s_tagOriginalRequestId[];
+ static const XMLCh s_tagPending[];
+ static const XMLCh s_tagPendingRequest[];
static const XMLCh s_tagQueryKeyBinding[];
static const XMLCh s_tagRepresent[];
static const XMLCh s_tagRequestId[];
static const XMLCh s_tagRequestSignatureValue[];
static const XMLCh s_tagRespondWith[];
+ static const XMLCh s_tagResponseId[];
static const XMLCh s_tagResponseMechanism[];
static const XMLCh s_tagResult[];
static const XMLCh s_tagResultMajor[];
1.7 +2 -1 xml-security/c/src/xkms/XKMSMessageAbstractType.hpp
Index: XKMSMessageAbstractType.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/xkms/XKMSMessageAbstractType.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- XKMSMessageAbstractType.hpp 21 Sep 2004 12:33:52 -0000 1.6
+++ XKMSMessageAbstractType.hpp 2 Oct 2004 23:12:30 -0000 1.7
@@ -102,6 +102,7 @@
LocateResult, /** A LocateResult message */
ValidateRequest, /** A ValidateRequest message */
ValidateResult, /** A ValidateResult message */
+ PendingRequest, /** A PendingRequest message (Asynchronous protocol */
Result /** A non-specific result message */
};
1.7 +43 -1 xml-security/c/src/xkms/XKMSMessageFactory.hpp
Index: XKMSMessageFactory.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/xkms/XKMSMessageFactory.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- XKMSMessageFactory.hpp 21 Sep 2004 12:33:52 -0000 1.6
+++ XKMSMessageFactory.hpp 2 Oct 2004 23:12:30 -0000 1.7
@@ -41,6 +41,7 @@
class XKMSResult;
class XKMSValidateRequest;
class XKMSValidateResult;
+class XKMSPendingRequest;
XSEC_DECLARE_XERCES_CLASS(DOMElement);
@@ -224,6 +225,47 @@
*/
virtual XKMSValidateRequest * createValidateRequest(
+ const XMLCh * service,
+ XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument **doc,
+ const XMLCh * id = NULL) = 0;
+
+ /**
+ * \brief Create a new \<PendingRequest\> message.
+ *
+ * Generates a new PendingRequest message from scratch, building the DOM
+ * as it goes.
+ *
+ * @param service URI
+ * @param doc Document to create the DOM structure within. The caller
+ * will need to embed the DOM structure at the appropriate place in the
+ * document (using a call to getElement to find the top level element)
+ * @param id Value to set in the Id field. If NULL, the library will
+ * generate a new Unique Id value.
+ * @returns the new XKMSPendingRequest structure
+ */
+
+ virtual XKMSPendingRequest * createPendingRequest(
+ const XMLCh * service,
+ XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * doc,
+ const XMLCh * id = NULL) = 0;
+
+ /**
+ * \brief Create a new \<PendingRequest\> message and surrounding document
+ *
+ * Generates a new PendingRequest message from scratch, building the DOM
+ * as it goes.
+ *
+ * @param service URI
+ * @param doc Will be used to return the newly created document element in.
+ * @param id Value to set in the Id field. If NULL, the library will
+ * generate a new Unique Id value.
+ * @returns the new XKMSPendingRequest structure
+ * @note Like all the xsec library functions, the document is owned by
+ * the calling application. Deleting the PendingRequest object will not
+ * delete the DOM document as well.
+ */
+
+ virtual XKMSPendingRequest * createPendingRequest(
const XMLCh * service,
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument **doc,
const XMLCh * id = NULL) = 0;
1.1 xml-security/c/src/xkms/XKMSPendingRequest.hpp
Index: XKMSPendingRequest.hpp
===================================================================
/*
* Copyright 2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* imitations under the License.
*/
/*
* XSEC
*
* XKMSPendingRequest := Interface for PendingRequest Messages
*
* $Id: XKMSPendingRequest.hpp,v 1.1 2004/10/02 23:12:30 blautenb Exp $
*
*/
#ifndef XKMSPENDINGREQUEST_INCLUDE
#define XKMSPENDINGREQUEST_INCLUDE
// XSEC Includes
#include <xsec/framework/XSECDefs.hpp>
#include <xsec/xkms/XKMSRequestAbstractType.hpp>
class XKMSQueryKeyBinding;
/**
* @ingroup xkms
* @{
*/
/**
* @brief Interface definition for the PendingRequest elements
*
* The \<PendingRequest\> is used in Asynchronous processing. A client
* uses the PendingRequest element to request a response to a request that
* was placed in the past, and to which the service originally provided
* a "Pending" response - i.e. work yet to be done.
*
* The schema definition for PendingRequest is as follows :
*
* \verbatim
<!-- PendingRequest -->
<element name="PendingRequest" type="xkms:PendingRequestType"/>
<complexType name="PendingRequestType">
<complexContent>
<extension base="xkms:RequestAbstractType">
<attribute name="ResponseId" type="NCName" use="required"/>
</extension>
</complexContent>
</complexType>
<!-- /PendingRequest -->
\endverbatim
*/
class XKMSPendingRequest : virtual public XKMSRequestAbstractType {
/** @name Constructors and Destructors */
//@{
protected:
XKMSPendingRequest() {};
public:
virtual ~XKMSPendingRequest() {};
/** @name Getter Interface Methods */
//@{
/**
* \brief Return the element at the base of the message
*/
virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * getElement(void) const = 0;
/**
* \brief Return the ResponseId
*
* The ResponseId equates to the Id of the first response the service returned,
* which must (by definition) have had a response code of "Pending". Together
* with the OriginalRequestId, this can be used by the service to uniquley
* identify the original request for which this PendingRequest refers.
*
* @return A pointer to the XMLCh string holding the ResponseId
*/
virtual const XMLCh * getResponseId(void) const = 0;
//@}
/** @name Setter Interface Methods */
//@{
/**
* \brief Set the ResponseId
*
* Allows a calling application to over-ride the configured responseId
*
* @param responseId The new responseId for this element
*/
virtual void setResponseId(const XMLCh * responseId) = 0;
//@}
private:
// Unimplemented
XKMSPendingRequest(const XKMSPendingRequest &);
XKMSPendingRequest & operator = (const XKMSPendingRequest &);
};
#endif /* XKMSPENDINGREQUEST_INCLUDE */
1.9 +59 -5 xml-security/c/src/xkms/impl/XKMSMessageFactoryImpl.cpp
Index: XKMSMessageFactoryImpl.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/xkms/impl/XKMSMessageFactoryImpl.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- XKMSMessageFactoryImpl.cpp 21 Sep 2004 12:33:52 -0000 1.8
+++ XKMSMessageFactoryImpl.cpp 2 Oct 2004 23:12:30 -0000 1.9
@@ -40,6 +40,7 @@
#include "XKMSResultImpl.hpp"
#include "XKMSValidateRequestImpl.hpp"
#include "XKMSValidateResultImpl.hpp"
+#include "XKMSPendingRequestImpl.hpp"
XERCES_CPP_NAMESPACE_USE
@@ -236,6 +237,19 @@
}
+ else if (strEquals(name, XKMSConstants::s_tagPendingRequest)) {
+
+ // This is a <PendingRequest> message
+ XKMSPendingRequestImpl * ret;
+ XSECnew(ret, XKMSPendingRequestImpl(new XSECEnv(*mp_env), elt));
+ Janitor<XKMSPendingRequestImpl> j_ret(ret);
+
+ ret->load();
+
+ j_ret.release();
+ return ret;
+
+ }
return NULL;
@@ -363,6 +377,46 @@
return vri;
}
+XKMSPendingRequest * XKMSMessageFactoryImpl::createPendingRequest(
+ const XMLCh * service,
+ XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * doc,
+ const XMLCh * id) {
+
+ XKMSPendingRequestImpl * pri;
+
+ XSECEnv * tenv;
+ XSECnew(tenv, XSECEnv(*mp_env));
+ tenv->setParentDocument(doc);
+
+ XSECnew(pri, XKMSPendingRequestImpl(tenv));
+ pri->createBlankPendingRequest(service, id);
+
+ return pri;
+
+}
+
+
+XKMSPendingRequest * XKMSMessageFactoryImpl::createPendingRequest(
+ const XMLCh * service,
+ XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument **doc,
+ const XMLCh * id) {
+
+
+ // Create a document to put the element in
+
+ XMLCh tempStr[100];
+ XMLString::transcode("Core", tempStr, 99);
+ DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(tempStr);
+
+ *doc = impl->createDocument();
+
+ // Embed the new structure in the document
+ XKMSPendingRequest * pri = createPendingRequest(service, *doc, id);
+ (*doc)->appendChild(pri->getElement());
+
+ return pri;
+}
+
// --------------------------------------------------------------------------------
// Create a result based on a request
// --------------------------------------------------------------------------------
@@ -553,17 +607,18 @@
if (msg->getMessageType() == XKMSMessageAbstractType::LocateRequest) {
XKMSLocateRequest * lr = dynamic_cast<XKMSLocateRequest*>(msg);
return lr;
-
}
if (msg->getMessageType() == XKMSMessageAbstractType::ValidateRequest) {
XKMSValidateRequest * vr = dynamic_cast<XKMSValidateRequest*>(msg);
return vr;
-
}
if (msg->getMessageType() == XKMSMessageAbstractType::CompoundRequest) {
XKMSCompoundRequest * cr = dynamic_cast<XKMSCompoundRequest*>(msg);
return cr;
-
+ }
+ if (msg->getMessageType() == XKMSMessageAbstractType::PendingRequest) {
+ XKMSPendingRequest * pr = dynamic_cast<XKMSPendingRequest*>(msg);
+ return pr;
}
return NULL;
}
@@ -573,7 +628,6 @@
if (msg->getMessageType() == XKMSMessageAbstractType::LocateResult) {
XKMSLocateResult * lr = dynamic_cast<XKMSLocateResult*>(msg);
return lr;
-
}
if (msg->getMessageType() == XKMSMessageAbstractType::ValidateResult) {
XKMSValidateResult * vr = dynamic_cast<XKMSValidateResult*>(msg);
1.9 +11 -1 xml-security/c/src/xkms/impl/XKMSMessageFactoryImpl.hpp
Index: XKMSMessageFactoryImpl.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/xkms/impl/XKMSMessageFactoryImpl.hpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- XKMSMessageFactoryImpl.hpp 21 Sep 2004 12:33:52 -0000 1.8
+++ XKMSMessageFactoryImpl.hpp 2 Oct 2004 23:12:30 -0000 1.9
@@ -76,6 +76,16 @@
const XMLCh * service,
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument **doc,
const XMLCh * id = NULL);
+ virtual XKMSPendingRequest * createPendingRequest(
+ const XMLCh * service,
+ XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *doc,
+ const XMLCh * id = NULL);
+ virtual XKMSPendingRequest * createPendingRequest(
+ const XMLCh * service,
+ XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument **doc,
+ const XMLCh * id = NULL);
+
+
virtual XKMSLocateResult * createLocateResult(
XKMSLocateRequest * request,
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * doc,
1.1 xml-security/c/src/xkms/impl/XKMSPendingRequestImpl.cpp
Index: XKMSPendingRequestImpl.cpp
===================================================================
/*
* Copyright 2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* imitations under the License.
*/
/*
* XSEC
*
* XKMSPendingRequestImpl := Implementation of PendingRequest Messages
*
* $Id: XKMSPendingRequestImpl.cpp,v 1.1 2004/10/02 23:12:30 blautenb Exp $
*
*/
#include <xsec/framework/XSECDefs.hpp>
#include <xsec/framework/XSECError.hpp>
#include <xsec/framework/XSECEnv.hpp>
#include <xsec/utils/XSECDOMUtils.hpp>
#include <xsec/xkms/XKMSConstants.hpp>
#include "XKMSPendingRequestImpl.hpp"
#include <xercesc/dom/DOM.hpp>
XERCES_CPP_NAMESPACE_USE
// --------------------------------------------------------------------------------
// Construct/Destruct
// --------------------------------------------------------------------------------
XKMSPendingRequestImpl::XKMSPendingRequestImpl(
const XSECEnv * env) :
XKMSRequestAbstractTypeImpl(env),
mp_responseIdAttr(NULL) {
}
XKMSPendingRequestImpl::XKMSPendingRequestImpl(
const XSECEnv * env,
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * node) :
XKMSRequestAbstractTypeImpl(env, node),
mp_responseIdAttr(NULL) {
}
XKMSPendingRequestImpl::~XKMSPendingRequestImpl() {
}
// --------------------------------------------------------------------------------
// Load from DOM
// --------------------------------------------------------------------------------
// Load elements
void XKMSPendingRequestImpl::load() {
if (mp_messageAbstractTypeElement == NULL) {
// Attempt to load an empty element
throw XSECException(XSECException::XKMSError,
"XKMSPendingRequest::load - called on empty DOM");
}
if (!strEquals(getXKMSLocalName(mp_messageAbstractTypeElement),
XKMSConstants::s_tagPendingRequest)) {
throw XSECException(XSECException::XKMSError,
"XKMSPendingRequest::load - called incorrect node");
}
// Load the base message
XKMSRequestAbstractTypeImpl::load();
// Now check for ResponseId attribute
mp_responseIdAttr =
mp_messageAbstractTypeElement->getAttributeNodeNS(NULL, XKMSConstants::s_tagResponseId);
if (mp_responseIdAttr == NULL) {
// Attempt to load an empty element
throw XSECException(XSECException::ExpectedXKMSChildNotFound,
"XKMSPendingRequest::load - No ResponseId attribute found");
}
}
// --------------------------------------------------------------------------------
// Create a blank one
// --------------------------------------------------------------------------------
DOMElement * XKMSPendingRequestImpl::createBlankPendingRequest(
const XMLCh * service,
const XMLCh * id) {
return XKMSRequestAbstractTypeImpl::createBlankMessageAbstractType(
XKMSConstants::s_tagPendingRequest, service, id);
// return XKMSRequestAbstractTypeImpl::createBlankMessageAbstractType(
// MAKE_UNICODE_STRING("ValidateRequest"), service, id);
}
// --------------------------------------------------------------------------------
// Get interface methods
// --------------------------------------------------------------------------------
XKMSMessageAbstractType::messageType XKMSPendingRequestImpl::getMessageType(void) {
return XKMSMessageAbstractType::PendingRequest;
}
const XMLCh * XKMSPendingRequestImpl::getResponseId(void) const {
if (mp_responseIdAttr == NULL) {
// Attempt read when not initialised
throw XSECException(XSECException::MessageAbstractTypeError,
"XKMSPendingRequest::getResponseId - called on non-initialised structure");
}
return mp_responseIdAttr->getNodeValue();
}
// --------------------------------------------------------------------------------
// Setter methods
// --------------------------------------------------------------------------------
void XKMSPendingRequestImpl::setResponseId(const XMLCh * responseId) {
if (mp_messageAbstractTypeElement == NULL) {
// Attempt update when not initialised
throw XSECException(XSECException::MessageAbstractTypeError,
"XKMSPendingRequest::setResponseId - called on non-initialised structure");
}
mp_messageAbstractTypeElement->setAttributeNS(NULL, XKMSConstants::s_tagResponseId, responseId);
mp_responseIdAttr =
mp_messageAbstractTypeElement->getAttributeNodeNS(NULL, XKMSConstants::s_tagResponseId);
}
1.1 xml-security/c/src/xkms/impl/XKMSPendingRequestImpl.hpp
Index: XKMSPendingRequestImpl.hpp
===================================================================
/*
* Copyright 2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* imitations under the License.
*/
/*
* XSEC
*
* XKMSPendingRequestImpl := Implementation of PendingRequest Messages
*
* $Id: XKMSPendingRequestImpl.hpp,v 1.1 2004/10/02 23:12:30 blautenb Exp $
*
*/
#ifndef XKMSPENDINGREQUESTIMPL_INCLUDE
#define XKMSPENDINGREQUESTIMPL_INCLUDE
// XSEC Includes
#include <xsec/framework/XSECDefs.hpp>
#include <xsec/xkms/XKMSPendingRequest.hpp>
#include "XKMSRequestAbstractTypeImpl.hpp"
class XKMSPendingRequestImpl : public XKMSRequestAbstractTypeImpl, public XKMSPendingRequest {
public:
XKMSPendingRequestImpl(
const XSECEnv * env
);
XKMSPendingRequestImpl(
const XSECEnv * env,
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * node
);
virtual ~XKMSPendingRequestImpl();
// Load elements
void load();
// Creation
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *
createBlankPendingRequest(
const XMLCh * service,
const XMLCh * id = NULL);
/* Getter Interface Methods */
virtual const XMLCh * getResponseId(void) const;
/* Setter interface methods */
virtual void setResponseId(const XMLCh * responseId);
/* Implemented from MessageAbstractType */
virtual messageType getMessageType(void);
/* Forced inheritance from XKMSMessageAbstractTypeImpl */
XKMS_MESSAGEABSTRACTYPE_IMPL_METHODS
/* Forced inheritance from RequestAbstractType */
XKMS_REQUESTABSTRACTYPE_IMPL_METHODS
private:
XERCES_CPP_NAMESPACE_QUALIFIER DOMAttr
* mp_responseIdAttr;
// Unimplemented
XKMSPendingRequestImpl(const XKMSPendingRequestImpl &);
XKMSPendingRequestImpl & operator = (const XKMSPendingRequestImpl &);
};
#endif /* XKMSPENDINGREQUESTIMPL_INCLUDE */