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/04/19 12:55:38 UTC
cvs commit: xml-security/c/src/xkms/impl XKMSKeyBindingAbstractTypeImpl.cpp XKMSKeyBindingAbstractTypeImpl.hpp XKMSLocateRequestImpl.cpp XKMSLocateRequestImpl.hpp XKMSMessageAbstractTypeImpl.cpp XKMSMessageAbstractTypeImpl.hpp XKMSMessageFactoryImpl.cpp XKMSMessageFactoryImpl.hpp XKMSQueryKeyBindingImpl.cpp XKMSQueryKeyBindingImpl.hpp XKMSRequestAbstractTypeImpl.cpp XKMSRequestAbstractTypeImpl.hpp
blautenb 2004/04/19 03:55:38
Modified: c/Projects/VC6.0/xsec/xsec_lib xsec_lib.dsp
c/src/dsig DSIGKeyInfoX509.cpp
c/src/tools/xklient xklient.cpp
c/src/utils/winutils XSECSOAPRequestorSimpleWin32.cpp
c/src/xkms XKMSConstants.hpp XKMSKeyBindingAbstractType.hpp
XKMSLocateRequest.hpp XKMSMessageFactory.hpp
c/src/xkms/impl XKMSKeyBindingAbstractTypeImpl.cpp
XKMSKeyBindingAbstractTypeImpl.hpp
XKMSLocateRequestImpl.cpp XKMSLocateRequestImpl.hpp
XKMSMessageAbstractTypeImpl.cpp
XKMSMessageAbstractTypeImpl.hpp
XKMSMessageFactoryImpl.cpp
XKMSMessageFactoryImpl.hpp
XKMSQueryKeyBindingImpl.cpp
XKMSQueryKeyBindingImpl.hpp
XKMSRequestAbstractTypeImpl.cpp
XKMSRequestAbstractTypeImpl.hpp
Log:
Skeleton For creating LocateRequest and submitting to remote site over HTTP
Revision Changes Path
1.28 +4 -0 xml-security/c/Projects/VC6.0/xsec/xsec_lib/xsec_lib.dsp
Index: xsec_lib.dsp
===================================================================
RCS file: /home/cvs/xml-security/c/Projects/VC6.0/xsec/xsec_lib/xsec_lib.dsp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- xsec_lib.dsp 16 Apr 2004 12:07:23 -0000 1.27
+++ xsec_lib.dsp 19 Apr 2004 10:55:37 -0000 1.28
@@ -1164,5 +1164,9 @@
SOURCE=..\..\..\..\src\xkms\XKMSRespondWith.hpp
# End Source File
# End Group
+# Begin Source File
+
+SOURCE=..\..\..\..\src\enc\XSECCryptoX509.cpp
+# End Source File
# End Target
# End Project
1.15 +2 -1 xml-security/c/src/dsig/DSIGKeyInfoX509.cpp
Index: DSIGKeyInfoX509.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/dsig/DSIGKeyInfoX509.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- DSIGKeyInfoX509.cpp 7 Mar 2004 03:20:51 -0000 1.14
+++ DSIGKeyInfoX509.cpp 19 Apr 2004 10:55:37 -0000 1.15
@@ -553,6 +553,7 @@
X509Holder * h;
XSECnew(h, X509Holder);
+ m_X509List.push_back(h);
h->mp_encodedX509 = b64Txt->getNodeValue();
h->mp_cryptoX509 = XSECPlatformUtils::g_cryptoProvider->X509();
char * charX509 = XMLString::transcode(h->mp_encodedX509);
1.2 +237 -6 xml-security/c/src/tools/xklient/xklient.cpp
Index: xklient.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/tools/xklient/xklient.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- xklient.cpp 16 Apr 2004 12:07:23 -0000 1.1
+++ xklient.cpp 19 Apr 2004 10:55:37 -0000 1.2
@@ -29,6 +29,7 @@
#include <xsec/framework/XSECProvider.hpp>
#include <xsec/canon/XSECC14n20010315.hpp>
#include <xsec/dsig/DSIGSignature.hpp>
+#include <xsec/dsig/DSIGKeyInfoX509.hpp>
#include <xsec/framework/XSECException.hpp>
#include <xsec/enc/XSECCryptoException.hpp>
#include <xsec/utils/XSECDOMUtils.hpp>
@@ -38,6 +39,10 @@
#include <xsec/xkms/XKMSLocateRequest.hpp>
#include <xsec/xkms/XKMSQueryKeyBinding.hpp>
+#if defined(_WIN32)
+# include <xsec/utils/winutils/XSECSOAPRequestorSimpleWin32.hpp>
+#endif
+
// General
#include <memory.h>
@@ -55,6 +60,7 @@
#include <xercesc/dom/DOM.hpp>
#include <xercesc/parsers/XercesDOMParser.hpp>
+#include <xercesc/framework/StdOutFormatTarget.hpp>
#include <xercesc/util/XMLException.hpp>
#include <xercesc/util/XMLUri.hpp>
#include <xercesc/util/Janitor.hpp>
@@ -92,11 +98,17 @@
enum eProcessingMode {
ModeNone, // No mode yet set
- ModeMsgDump // We are here to simply parse and dump an XKMS message
+ ModeMsgDump, // We are here to simply parse and dump an XKMS message
+ ModeMsgCreate, // Creating a msg from scratch
+ ModeDoRequest, // Create a message and send to service
};
char * g_inputFile = NULL;
+char * g_msgType = NULL;
+char * g_serviceURI = NULL;
+char * g_certFile = NULL;
+bool g_txtOut = false;
// --------------------------------------------------------------------------------
// General functions
@@ -149,6 +161,169 @@
}
+void outputDoc(DOMDocument * doc) {
+
+ XMLCh tempStr[100];
+ XMLString::transcode("Core", tempStr, 99);
+ DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(tempStr);
+
+ DOMWriter *theSerializer = ((DOMImplementationLS*)impl)->createDOMWriter();
+
+ theSerializer->setEncoding(MAKE_UNICODE_STRING("UTF-8"));
+ if (theSerializer->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint, false))
+ theSerializer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, false);
+
+
+ XMLFormatTarget *formatTarget = new StdOutFormatTarget();
+
+ cerr << endl;
+
+ theSerializer->writeNode(formatTarget, *doc);
+
+ cout << endl;
+
+ cerr << endl;
+
+ delete theSerializer;
+ delete formatTarget;
+
+}
+
+XSECCryptoX509 * loadX509(const char * infile) {
+
+ FILE * f = fopen(infile, "r");
+ if (f == NULL)
+ return NULL;
+
+ safeBuffer sb;
+ char buf[1024];
+
+ int i = fread(buf, 1, 1024, f);
+ int j = 0;
+ while (i != 0) {
+ sb.sbMemcpyIn(j, buf, i);
+ j += i;
+ i = fread(buf, 1, 1024, f);
+ }
+
+ sb[j] = '\0';
+
+ XSECCryptoX509 * ret =
+ XSECPlatformUtils::g_cryptoProvider->X509();
+
+ ret->loadX509PEM(sb.rawCharBuffer());
+
+ return ret;
+
+}
+
+// --------------------------------------------------------------------------------
+// Create a message
+// --------------------------------------------------------------------------------
+
+int createMessage(char * msgType, XSECProvider &prov, DOMDocument **doc, XKMSMessageAbstractType **msg) {
+
+ XKMSMessageFactory * factory = prov.getXKMSMessageFactory();
+
+ // Create a new message
+ if (!stricmp(msgType, "LocateRequest")) {
+
+ XKMSLocateRequest * lr = factory->createLocateRequest(MAKE_UNICODE_STRING(g_serviceURI), doc);
+
+ if (g_certFile != NULL) {
+ XSECCryptoX509 * x = loadX509(g_certFile);
+ if (x == NULL) {
+ delete lr;
+ (*doc)->release();
+ cerr << "Error opening Certificate file : " << g_certFile << endl;
+ return 1;
+ }
+
+ Janitor<XSECCryptoX509> j_x(x);
+
+ XKMSQueryKeyBinding * qkb = lr->addQueryKeyBinding();
+ DSIGKeyInfoX509 * kix = qkb->appendX509Data();
+ safeBuffer sb = x->getDEREncodingSB();
+ kix->appendX509Certificate(sb.sbStrToXMLCh());
+
+ }
+
+ *msg = lr;
+ }
+ else {
+
+ cerr << "Unknown message type : " << msgType << endl;
+ return 2;
+
+ }
+
+ return 0;
+
+}
+
+// --------------------------------------------------------------------------------
+// doRequest
+// --------------------------------------------------------------------------------
+
+int doRequest(char * msgType) {
+
+ XSECProvider prov;
+ XKMSMessageFactory * factory = prov.getXKMSMessageFactory();
+
+ // Create a new message
+ XKMSMessageAbstractType * msg;
+ DOMDocument * doc;
+
+ if (createMessage(msgType, prov, &doc, &msg) != 0)
+ return 2;
+
+ if (g_txtOut) {
+
+ outputDoc(doc);
+
+ }
+
+#if defined(_WIN32)
+ XSECSOAPRequestorSimpleWin32 req(MAKE_UNICODE_STRING(g_serviceURI));
+ req.doRequest(doc);
+#endif
+
+ delete msg;
+ doc->release();
+
+ return 0;
+
+}
+
+// --------------------------------------------------------------------------------
+// MsgCreate
+// --------------------------------------------------------------------------------
+
+int doMessageCreate(char * msgType) {
+
+ XSECProvider prov;
+ XKMSMessageFactory * factory = prov.getXKMSMessageFactory();
+
+ // Create a new message
+ XKMSMessageAbstractType * msg;
+ DOMDocument * doc;
+
+ if (createMessage(msgType, prov, &doc, &msg) != 0)
+ return 2;
+
+ if (g_txtOut) {
+
+ outputDoc(doc);
+
+ }
+
+ delete msg;
+ doc->release();
+
+ return 0;
+
+}
+
// --------------------------------------------------------------------------------
// MsgDump
// --------------------------------------------------------------------------------
@@ -401,11 +576,22 @@
void printUsage(void) {
- cerr << "\nUsage: siging {msgdump} [options]\n\n";
- cerr << " msgdump : Read an XKMS message and print details\n";
+ cerr << "\nUsage: siging {msgdump|msgcreate [type]} [options]\n\n";
+ cerr << " msgdump : Read an XKMS message and print details\n";
+ cerr << " msgcreate : Create a message of type :\n";
+ cerr << " LocateRequest\n";
+ cerr << " dorequest : Create message of type : \n";
+ cerr << " LocateRequest\n";
+ cerr << " send to service URI and output result\n\n";
cerr << " Where options are :\n\n";
cerr << " --infile/-i {filename}\n";
- cerr << " File to read as input\n\n";
+ cerr << " File to read as input\n";
+ cerr << " --text/-t\n";
+ cerr << " Print any created XML to screen\n";
+ cerr << " --add-cert/-a {filename}\n";
+ cerr << " Add the cert in the specified file to msg\n";
+ cerr << " --service/-s\n";
+ cerr << " Service URI to use in created messages\n\n";
}
@@ -413,18 +599,35 @@
eProcessingMode mode = ModeNone;
+
if (argc < 2) {
printUsage();
return 2;
}
+ int paramCount = 2;
+
if (!stricmp (argv[1], "msgdump")) {
mode = ModeMsgDump;
}
+ else if (!stricmp (argv[1], "msgcreate")) {
+
+ mode=ModeMsgCreate;
+ g_msgType = argv[paramCount];
+ paramCount++;
+ }
+
+ else if (!stricmp (argv[1], "dorequest")) {
+
+ mode=ModeDoRequest;
+ g_msgType = argv[paramCount];
+ paramCount++;
+ }
+
else {
printUsage();
@@ -433,7 +636,6 @@
}
// Run through parameters
- int paramCount = 2;
while (paramCount < argc) {
@@ -445,6 +647,27 @@
g_inputFile = argv[paramCount];
paramCount++;
}
+
+ else if (stricmp(argv[paramCount], "--add-cert") == 0 || stricmp(argv[paramCount], "-a") == 0) {
+ if (++paramCount >= argc) {
+ printUsage();
+ return 2;
+ }
+ g_certFile = argv[paramCount];
+ paramCount++;
+ }
+ else if (stricmp(argv[paramCount], "--text") == 0 || stricmp(argv[paramCount], "-t") == 0) {
+ g_txtOut = true;
+ paramCount++;
+ }
+ else if (stricmp(argv[paramCount], "--service") == 0 || stricmp(argv[paramCount], "-s") == 0) {
+ if (++paramCount >= argc) {
+ printUsage();
+ return 2;
+ }
+ g_serviceURI = argv[paramCount];
+ paramCount++;
+ }
else {
printUsage();
return 2;
@@ -456,7 +679,15 @@
case ModeMsgDump :
return doMsgDump();
+
+ case ModeMsgCreate :
+
+ return doMessageCreate(g_msgType);
+ case ModeDoRequest :
+
+ return doRequest(g_msgType);
+
default :
cerr << "Catastrophic error - somehow I don't know what I'm doing!\n";
1.2 +11 -17 xml-security/c/src/utils/winutils/XSECSOAPRequestorSimpleWin32.cpp
Index: XSECSOAPRequestorSimpleWin32.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/utils/winutils/XSECSOAPRequestorSimpleWin32.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XSECSOAPRequestorSimpleWin32.cpp 16 Apr 2004 12:07:23 -0000 1.1
+++ XSECSOAPRequestorSimpleWin32.cpp 19 Apr 2004 10:55:37 -0000 1.2
@@ -134,25 +134,18 @@
makeQName(str, s_prefix, s_Envelope);
DOMDocument *doc = impl->createDocument(
- XKMSConstants::s_unicodeStrURISOAP12,
+ XKMSConstants::s_unicodeStrURISOAP11,
str.rawXMLChBuffer(),
NULL);// DOMDocumentType()); // document type object (DTD).
DOMElement *rootElem = doc->getDocumentElement();
- makeQName(str, s_prefix, s_Header);
- DOMElement *header = doc->createElementNS(
- XKMSConstants::s_unicodeStrURISOAP12,
- str.rawXMLChBuffer());
-
- rootElem->appendChild(header);
-
makeQName(str, s_prefix, s_Body);
DOMElement *body = doc->createElementNS(
- XKMSConstants::s_unicodeStrURISOAP12,
+ XKMSConstants::s_unicodeStrURISOAP11,
str.rawXMLChBuffer());
- header->appendChild(body);
+ rootElem->appendChild(body);
// Now replicate the request into the document
DOMElement * reqElement = (DOMElement *) doc->importNode(request->getDocumentElement(), true);
@@ -303,7 +296,7 @@
}
strcat(fBuffer, " HTTP/1.0\r\n");
- strcat(fBuffer, "Content-Type: text/xml\r\n");
+ strcat(fBuffer, "Content-Type: text/xml; charset=utf-8\r\n");
strcat(fBuffer, "Host: ");
@@ -318,12 +311,13 @@
strcat(fBuffer, "Content-Length: ");
int i = (int) strlen(fBuffer);
- _itoa(strlen(content)+2, fBuffer+i, 10);
+ _itoa(strlen(content), fBuffer+i, 10);
strcat(fBuffer, "\r\n");
+ strcat(fBuffer, "SOAPAction: \"\"\r\n");
- strcat(fBuffer, "Connection: Close\r\n");
- strcat(fBuffer, "Cache-Control: no-cache\r\n");
- strcat(fBuffer, "\r\n\r\n");
+/* strcat(fBuffer, "Connection: Close\r\n");
+ strcat(fBuffer, "Cache-Control: no-cache\r\n");*/
+ strcat(fBuffer, "\r\n");
// Now the content
strcat(fBuffer, content);
@@ -345,7 +339,7 @@
//
memset(fBuffer, 0, sizeof(fBuffer));
aLent = XSECBinHTTPURIInputStream::recv((unsigned short) s, fBuffer, sizeof(fBuffer)-1, 0);
- if (aLent == SOCKET_ERROR || aLent == 0)
+ if (aLent == SOCKET_ERROR || aLent == 0)
{
// Call WSAGetLastError() to get the error number.
throw XSECException(XSECException::HTTPURIInputStreamError,
1.2 +3 -3 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XKMSConstants.hpp 16 Apr 2004 12:07:24 -0000 1.1
+++ XKMSConstants.hpp 19 Apr 2004 10:55:37 -0000 1.2
@@ -32,8 +32,8 @@
// Name Spaces
#define URI_ID_XKMS "http://www.w3.org/2002/03/xkms#"
-#define URI_ID_SOAP11 "http://schemas.xmlsoap.org/soap/envelope"
-#define URI_ID_SOAP12 "http://www.w3.org/2002/06/soap-envelope"
+#define URI_ID_SOAP11 "http://schemas.xmlsoap.org/soap/envelope/"
+#define URI_ID_SOAP12 "http://www.w3.org/2002/06/soap-envelope/"
// --------------------------------------------------------------------------------
1.2 +126 -1 xml-security/c/src/xkms/XKMSKeyBindingAbstractType.hpp
Index: XKMSKeyBindingAbstractType.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/xkms/XKMSKeyBindingAbstractType.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XKMSKeyBindingAbstractType.hpp 16 Apr 2004 12:07:24 -0000 1.1
+++ XKMSKeyBindingAbstractType.hpp 19 Apr 2004 10:55:37 -0000 1.2
@@ -31,6 +31,13 @@
#include <xsec/framework/XSECDefs.hpp>
class DSIGKeyInfoList;
+class DSIGKeyInfoMgmtData;
+class DSIGKeyInfoName;
+class DSIGKeyInfoPGPData;
+class DSIGKeyInfoSPKIData;
+class DSIGKeyInfoValue;
+class DSIGKeyInfoX509;
+
XSEC_DECLARE_XERCES_CLASS(DOMElement);
@@ -194,6 +201,124 @@
*/
virtual void setExchangeKeyUsage(void) = 0;
+
+ //@}
+
+ /** @name KeyInfo Element Manipulation */
+
+ //@{
+
+ /**
+ * \brief Get the list of \<KeyInfo\> elements.
+ *
+ * <p>This function recovers list that contains the KeyInfo elements
+ * read in from the DOM document.</p>
+ *
+ * @returns A pointer to the (library owned) KeyInfo list, or NULL
+ * if none exists in the KeyBinding.
+ */
+
+ virtual DSIGKeyInfoList * getKeyInfoList(void) = 0;
+
+ /**
+ * \brief Clear out all KeyInfo elements in the KeyBinding.
+ *
+ * This function will delete all KeyInfo elements from both the KeyBinding
+ * object <em>and the associated DOM</em>.
+ *
+ */
+
+ virtual void clearKeyInfo(void) = 0;
+
+ /**
+ * \brief Append a DSA KeyValue element
+ *
+ * Add a new KeyInfo element for a DSA Value
+ *
+ * @param P Base64 encoded value of P
+ * @param Q Base64 encoded value of Q
+ * @param G Base64 encoded value of G
+ * @param Y Base64 encoded value of Y
+ * @returns A pointer to the created object.
+ */
+
+ virtual DSIGKeyInfoValue * appendDSAKeyValue(const XMLCh * P,
+ const XMLCh * Q,
+ const XMLCh * G,
+ const XMLCh * Y) = 0;
+
+ /**
+ * \brief Append a RSA KeyValue element
+ *
+ * Add a new KeyInfo element for a RSA Value
+ *
+ * @param modulus Base64 encoded value of the modulus
+ * @param exponent Base64 encoded value of exponent
+ * @returns A pointer to the created object.
+ */
+
+ virtual DSIGKeyInfoValue * appendRSAKeyValue(const XMLCh * modulus,
+ const XMLCh * exponent) = 0;
+
+ /**
+ * \brief Append a X509Data element.
+ *
+ * Add a new KeyInfo element for X509 data.
+ *
+ * @note The added element is empty. The caller must make use of the
+ * returned object to set the required values.
+ *
+ * @returns A pointer to the created object.
+ */
+
+ virtual DSIGKeyInfoX509 * appendX509Data(void) = 0;
+
+ /**
+ * \brief Append a KeyName element.
+ *
+ * Add a new KeyInfo element for a key name.
+ *
+ * @param name The name of the key to set in the XML
+ * @param isDName Treat the name as a Distinguished name and encode accordingly
+ * @returns A pointer to the created object
+ */
+
+ virtual DSIGKeyInfoName * appendKeyName(const XMLCh * name, bool isDName = false) = 0;
+
+ /**
+ * \brief Append a PGPData element.
+ *
+ * Add a new KeyInfo element for a PGP key.
+ *
+ * @param id The ID of the key to set in the XML (base64 encoded - NULL if none)
+ * @param packet The Packet information to set in the XML (base64 encoded -
+ * NULL if none)
+ * @returns A pointer to the created object
+ */
+
+ virtual DSIGKeyInfoPGPData * appendPGPData(const XMLCh * id, const XMLCh * packet) = 0;
+
+ /**
+ * \brief Append a SPKIData element
+ *
+ * Add a new KeyInfo element for a set of SPKI S-expressions
+ *
+ * @param sexp The initial S-expression to set in the SPKIData element
+ * @returns A pointer to the created object
+ */
+
+ virtual DSIGKeyInfoSPKIData * appendSPKIData(const XMLCh * sexp) = 0;
+
+ /**
+ * \brief Append a MgmtData element
+ *
+ * Add a new KeyInfo element for Management Data
+ *
+ * @param data The string to set in the MgmtData element
+ * @returns A pointer to the created object
+ */
+
+ virtual DSIGKeyInfoMgmtData * appendMgmtData(const XMLCh * data) = 0;
//@}
1.2 +17 -1 xml-security/c/src/xkms/XKMSLocateRequest.hpp
Index: XKMSLocateRequest.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/xkms/XKMSLocateRequest.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XKMSLocateRequest.hpp 16 Apr 2004 12:07:24 -0000 1.1
+++ XKMSLocateRequest.hpp 19 Apr 2004 10:55:37 -0000 1.2
@@ -98,6 +98,22 @@
//@}
+ /** @name Setter Interface Methods */
+ //@{
+
+ /** \brief Add a QueryKeyBinding element
+ *
+ * Set a QueryKeyBinding element in the LocateRequest message. The returned
+ * object can be manipulated to add KeyInfo elements to the LocateRequest.
+ *
+ * @returns A pointer to the newly created QueryKeyBinding object, or
+ * the pointer to extant object if one already existed.
+ */
+
+ virtual XKMSQueryKeyBinding * addQueryKeyBinding(void) = 0;
+
+ //@}
+
private:
// Unimplemented
1.2 +48 -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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XKMSMessageFactory.hpp 16 Apr 2004 12:07:24 -0000 1.1
+++ XKMSMessageFactory.hpp 19 Apr 2004 10:55:37 -0000 1.2
@@ -32,6 +32,7 @@
#include <xsec/xkms/XKMSMessageAbstractType.hpp>
class DSIGSignature;
+class XKMSLocateRequest;
XSEC_DECLARE_XERCES_CLASS(DOMElement);
@@ -90,6 +91,52 @@
virtual XKMSMessageAbstractType * newMessageFromDOM(
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * elt) = 0;
+
+ //@}
+
+ /** @name Methods for building new messages from scratch */
+ //@{
+
+ /**
+ * \brief Create a new \<LocateRequest\> message.
+ *
+ * Generates a new LocateRequest 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 XKMSLocateRequest structure
+ */
+
+ virtual XKMSLocateRequest * createLocateRequest(
+ const XMLCh * service,
+ XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * doc,
+ const XMLCh * id = NULL) = 0;
+
+ /**
+ * \brief Create a new \<LocateRequest\> message and surrounding document
+ *
+ * Generates a new LocateRequest 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 XKMSLocateRequest structure
+ * @note Like all the xsec library functions, the document is owned by
+ * the calling application. Deleteing the LocateRequest object will not
+ * delete the DOM document as well.
+ */
+
+ virtual XKMSLocateRequest * createLocateRequest(
+ const XMLCh * service,
+ XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument **doc,
+ const XMLCh * id = NULL) = 0;
//@}
1.2 +173 -3 xml-security/c/src/xkms/impl/XKMSKeyBindingAbstractTypeImpl.cpp
Index: XKMSKeyBindingAbstractTypeImpl.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/xkms/impl/XKMSKeyBindingAbstractTypeImpl.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XKMSKeyBindingAbstractTypeImpl.cpp 16 Apr 2004 12:07:24 -0000 1.1
+++ XKMSKeyBindingAbstractTypeImpl.cpp 19 Apr 2004 10:55:38 -0000 1.2
@@ -25,6 +25,7 @@
#include <xsec/framework/XSECDefs.hpp>
#include <xsec/framework/XSECError.hpp>
+#include <xsec/framework/XSECEnv.hpp>
#include <xsec/xkms/XKMSConstants.hpp>
#include <xsec/utils/XSECDOMUtils.hpp>
#include <xsec/dsig/DSIGKeyInfoList.hpp>
@@ -40,6 +41,20 @@
// --------------------------------------------------------------------------------
XKMSKeyBindingAbstractTypeImpl::XKMSKeyBindingAbstractTypeImpl(
+ const XSECEnv * env) :
+mp_keyBindingAbstractTypeElement(NULL),
+mp_idAttr(NULL),
+mp_keyUsageEncryptionElement(NULL),
+mp_keyUsageSignatureElement(NULL),
+mp_keyUsageExchangeElement(NULL),
+mp_keyInfoElement(NULL),
+mp_env(env) {
+
+ XSECnew(mp_keyInfoList, DSIGKeyInfoList(mp_env));
+
+}
+
+XKMSKeyBindingAbstractTypeImpl::XKMSKeyBindingAbstractTypeImpl(
const XSECEnv * env,
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * node) :
mp_keyBindingAbstractTypeElement(node),
@@ -47,8 +62,10 @@
mp_keyUsageEncryptionElement(NULL),
mp_keyUsageSignatureElement(NULL),
mp_keyUsageExchangeElement(NULL),
-mp_env(env),
-mp_keyInfoList(NULL) {
+mp_keyInfoElement(NULL),
+mp_env(env) {
+
+ XSECnew(mp_keyInfoList, DSIGKeyInfoList(mp_env));
}
@@ -84,6 +101,8 @@
XSECnew(mp_keyInfoList, DSIGKeyInfoList(mp_env));
mp_keyInfoList->loadListFromXML(tmpElt);
+ mp_keyInfoElement = tmpElt;
+
tmpElt = findNextElementChild(tmpElt);
}
@@ -115,6 +134,25 @@
}
+// --------------------------------------------------------------------------------
+// Create Blank
+// --------------------------------------------------------------------------------
+
+DOMElement * XKMSKeyBindingAbstractTypeImpl::createBlankKeyBindingAbstractType(const XMLCh * tag) {
+
+ // Get some setup values
+ safeBuffer str;
+ DOMDocument *doc = mp_env->getParentDocument();
+ const XMLCh * prefix = mp_env->getXKMSNSPrefix();
+
+ makeQName(str, prefix, tag);
+
+ mp_keyBindingAbstractTypeElement = doc->createElementNS(XKMSConstants::s_unicodeStrURIXKMS,
+ str.rawXMLChBuffer());
+
+ return mp_keyBindingAbstractTypeElement;
+
+}
// --------------------------------------------------------------------------------
// Getter methods
@@ -159,6 +197,138 @@
}
+// --------------------------------------------------------------------------------
+// KeyInfo elements
+// --------------------------------------------------------------------------------
+
+DSIGKeyInfoList * XKMSKeyBindingAbstractTypeImpl::getKeyInfoList() {
+
+ return mp_keyInfoList;
+
+}
+
+void XKMSKeyBindingAbstractTypeImpl::clearKeyInfo(void) {
+
+ if (mp_keyInfoElement == NULL)
+ return;
+
+ if (mp_keyBindingAbstractTypeElement->removeChild(mp_keyInfoElement) != mp_keyInfoElement) {
+
+ throw XSECException(XSECException::ExpectedDSIGChildNotFound,
+ "Attempted to remove KeyInfo node but it is no longer a child of <KeyBindingAbstractType>");
+
+ }
+
+ mp_keyInfoElement->release(); // No longer required
+
+ mp_keyInfoElement = NULL;
+
+ // Clear out the list
+ mp_keyInfoList->empty();
+
+}
+
+void XKMSKeyBindingAbstractTypeImpl::createKeyInfoElement(void) {
+
+ if (mp_keyInfoElement != NULL)
+ return;
+
+ safeBuffer str;
+
+ const XMLCh * prefixNS = mp_env->getDSIGNSPrefix();
+ makeQName(str, prefixNS, "KeyInfo");
+
+ mp_keyInfoElement = mp_keyInfoList->createKeyInfo();
+
+ // Needs to be first element
+ DOMNode * insertBefore = mp_keyBindingAbstractTypeElement->getFirstChild();
+
+ if (insertBefore != NULL) {
+
+ mp_keyBindingAbstractTypeElement->insertBefore(mp_keyInfoElement, insertBefore);
+ if (mp_env->getPrettyPrintFlag() == true)
+ mp_keyBindingAbstractTypeElement->insertBefore(mp_env->getParentDocument()->createTextNode(DSIGConstants::s_unicodeStrNL), insertBefore);
+
+ }
+
+ else {
+
+ mp_keyBindingAbstractTypeElement->appendChild(mp_keyInfoElement);
+ mp_env->doPrettyPrint(mp_keyBindingAbstractTypeElement);
+
+ }
+
+ // Need to add the DS namespace
+
+ if (prefixNS[0] == '\0') {
+ str.sbTranscodeIn("xmlns");
+ }
+ else {
+ str.sbTranscodeIn("xmlns:");
+ str.sbXMLChCat(prefixNS);
+ }
+
+ mp_keyInfoElement->setAttributeNS(DSIGConstants::s_unicodeStrURIXMLNS,
+ str.rawXMLChBuffer(),
+ DSIGConstants::s_unicodeStrURIDSIG);
+
+}
+
+
+DSIGKeyInfoName * XKMSKeyBindingAbstractTypeImpl::appendKeyName(const XMLCh * name, bool isDName) {
+
+ createKeyInfoElement();
+ return mp_keyInfoList->appendKeyName(name, isDName);
+
+}
+
+
+DSIGKeyInfoValue * XKMSKeyBindingAbstractTypeImpl::appendDSAKeyValue(const XMLCh * P,
+ const XMLCh * Q,
+ const XMLCh * G,
+ const XMLCh * Y) {
+
+ createKeyInfoElement();
+ return mp_keyInfoList->appendDSAKeyValue(P, Q, G, Y);
+
+}
+
+DSIGKeyInfoValue * XKMSKeyBindingAbstractTypeImpl::appendRSAKeyValue(const XMLCh * modulus,
+ const XMLCh * exponent) {
+
+ createKeyInfoElement();
+ return mp_keyInfoList->appendRSAKeyValue(modulus, exponent);
+
+}
+
+
+DSIGKeyInfoX509 * XKMSKeyBindingAbstractTypeImpl::appendX509Data(void) {
+
+ createKeyInfoElement();
+ return mp_keyInfoList->appendX509Data();
+
+}
+
+DSIGKeyInfoPGPData * XKMSKeyBindingAbstractTypeImpl::appendPGPData(const XMLCh * id, const XMLCh * packet) {
+
+ createKeyInfoElement();
+ return mp_keyInfoList->appendPGPData(id, packet);
+
+}
+
+DSIGKeyInfoSPKIData * XKMSKeyBindingAbstractTypeImpl::appendSPKIData(const XMLCh * sexp) {
+
+ createKeyInfoElement();
+ return mp_keyInfoList->appendSPKIData(sexp);
+
+}
+
+DSIGKeyInfoMgmtData * XKMSKeyBindingAbstractTypeImpl::appendMgmtData(const XMLCh * data) {
+
+ createKeyInfoElement();
+ return mp_keyInfoList->appendMgmtData(data);
+
+}
// --------------------------------------------------------------------------------
// Setter methods
1.2 +52 -2 xml-security/c/src/xkms/impl/XKMSKeyBindingAbstractTypeImpl.hpp
Index: XKMSKeyBindingAbstractTypeImpl.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/xkms/impl/XKMSKeyBindingAbstractTypeImpl.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XKMSKeyBindingAbstractTypeImpl.hpp 16 Apr 2004 12:07:24 -0000 1.1
+++ XKMSKeyBindingAbstractTypeImpl.hpp 19 Apr 2004 10:55:38 -0000 1.2
@@ -43,6 +43,10 @@
/* Constructors and Destructors */
XKMSKeyBindingAbstractTypeImpl(
+ const XSECEnv * env
+ );
+
+ XKMSKeyBindingAbstractTypeImpl(
const XSECEnv * env,
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * node
);
@@ -52,6 +56,10 @@
// Load
void load(void);
+ // Create
+ XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *
+ createBlankKeyBindingAbstractType(const XMLCh * tag);
+
/* Getter Interface Methods */
virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * getElement(void) const;
@@ -69,6 +77,22 @@
virtual void setSignatureKeyUsage(void);
virtual void setExchangeKeyUsage(void);
+ /* Key Info methods */
+ virtual DSIGKeyInfoList * getKeyInfoList();
+ virtual void clearKeyInfo(void);
+ virtual DSIGKeyInfoValue * appendDSAKeyValue(const XMLCh * P,
+ const XMLCh * Q,
+ const XMLCh * G,
+ const XMLCh * Y);
+ virtual DSIGKeyInfoValue * appendRSAKeyValue(const XMLCh * modulus,
+ const XMLCh * exponent);
+ virtual DSIGKeyInfoX509 * appendX509Data(void);
+ virtual DSIGKeyInfoName * appendKeyName(const XMLCh * name, bool isDName = false);
+ virtual DSIGKeyInfoPGPData * appendPGPData(const XMLCh * id, const XMLCh * packet);
+ virtual DSIGKeyInfoSPKIData * appendSPKIData(const XMLCh * sexp);
+ virtual DSIGKeyInfoMgmtData * appendMgmtData(const XMLCh * data);
+
+
protected:
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement
@@ -85,8 +109,12 @@
* mp_keyUsageEncryptionElement;
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement
* mp_keyUsageExchangeElement;
+ XERCES_CPP_NAMESPACE_QUALIFIER DOMElement
+ * mp_keyInfoElement;
DSIGKeyInfoList * mp_keyInfoList;
+ void createKeyInfoElement(void);
+
// Unimplemented
XKMSKeyBindingAbstractTypeImpl(void);
XKMSKeyBindingAbstractTypeImpl(const XKMSKeyBindingAbstractTypeImpl &);
@@ -116,7 +144,29 @@
virtual void setSignatureKeyUsage(void) \
{XKMSKeyBindingAbstractTypeImpl::setSignatureKeyUsage();} \
virtual void setExchangeKeyUsage(void) \
- {XKMSKeyBindingAbstractTypeImpl::setExchangeKeyUsage();}
+ {XKMSKeyBindingAbstractTypeImpl::setExchangeKeyUsage();} \
+ virtual DSIGKeyInfoList * getKeyInfoList() \
+ {return XKMSKeyBindingAbstractTypeImpl::getKeyInfoList();} \
+ virtual void clearKeyInfo(void) \
+ {XKMSKeyBindingAbstractTypeImpl::clearKeyInfo();} \
+ virtual DSIGKeyInfoValue * appendDSAKeyValue(const XMLCh * P, \
+ const XMLCh * Q, \
+ const XMLCh * G, \
+ const XMLCh * Y) \
+ {return XKMSKeyBindingAbstractTypeImpl::appendDSAKeyValue(P,Q,G,Y);} \
+ virtual DSIGKeyInfoValue * appendRSAKeyValue(const XMLCh * modulus, \
+ const XMLCh * exponent) \
+ {return XKMSKeyBindingAbstractTypeImpl::appendRSAKeyValue(modulus,exponent);} \
+ virtual DSIGKeyInfoX509 * appendX509Data(void) \
+ {return XKMSKeyBindingAbstractTypeImpl::appendX509Data();} \
+ virtual DSIGKeyInfoName * appendKeyName(const XMLCh * name, bool isDName = false) \
+ {return XKMSKeyBindingAbstractTypeImpl::appendKeyName(name,isDName);} \
+ virtual DSIGKeyInfoPGPData * appendPGPData(const XMLCh * id, const XMLCh * packet) \
+ {return XKMSKeyBindingAbstractTypeImpl::appendPGPData(id,packet);} \
+ virtual DSIGKeyInfoSPKIData * appendSPKIData(const XMLCh * sexp) \
+ {return XKMSKeyBindingAbstractTypeImpl::appendSPKIData(sexp);} \
+ virtual DSIGKeyInfoMgmtData * appendMgmtData(const XMLCh * data) \
+ {return XKMSKeyBindingAbstractTypeImpl::appendMgmtData(data);}
#endif /* XKMSKEYBINDINGABSTRACTTYPEIMPL_INCLUDE */
1.2 +51 -3 xml-security/c/src/xkms/impl/XKMSLocateRequestImpl.cpp
Index: XKMSLocateRequestImpl.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/xkms/impl/XKMSLocateRequestImpl.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XKMSLocateRequestImpl.cpp 16 Apr 2004 12:07:24 -0000 1.1
+++ XKMSLocateRequestImpl.cpp 19 Apr 2004 10:55:38 -0000 1.2
@@ -25,6 +25,7 @@
#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>
@@ -39,6 +40,14 @@
// --------------------------------------------------------------------------------
XKMSLocateRequestImpl::XKMSLocateRequestImpl(
+ const XSECEnv * env) :
+XKMSRequestAbstractTypeImpl(env),
+mp_queryKeyBindingElement(NULL),
+mp_queryKeyBinding(NULL) {
+
+}
+
+XKMSLocateRequestImpl::XKMSLocateRequestImpl(
const XSECEnv * env,
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * node) :
XKMSRequestAbstractTypeImpl(env, node),
@@ -90,19 +99,34 @@
XSECnew(mp_queryKeyBinding, XKMSQueryKeyBindingImpl(mp_env, tmpElt));
mp_queryKeyBinding->load();
+ mp_queryKeyBindingElement = tmpElt;
}
}
// --------------------------------------------------------------------------------
+// Create a blank one
+// --------------------------------------------------------------------------------
+DOMElement * XKMSLocateRequestImpl::createBlankLocateRequest(
+ const XMLCh * service,
+ const XMLCh * id) {
+
+ return XKMSRequestAbstractTypeImpl::createBlankMessageAbstractType(
+ XKMSConstants::s_tagLocateRequest, service, id);
+// return XKMSRequestAbstractTypeImpl::createBlankMessageAbstractType(
+// MAKE_UNICODE_STRING("ValidateRequest"), service, id);
+
+}
+
+// --------------------------------------------------------------------------------
// Get interface methods
// --------------------------------------------------------------------------------
-XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * XKMSLocateRequestImpl::getElement(void) const {
+DOMElement * XKMSLocateRequestImpl::getElement(void) const {
- return NULL;
+ return mp_messageAbstractTypeElement;
}
@@ -119,3 +143,27 @@
}
+// --------------------------------------------------------------------------------
+// Setter methods
+// --------------------------------------------------------------------------------
+
+XKMSQueryKeyBinding * XKMSLocateRequestImpl::addQueryKeyBinding(void) {
+
+ if (mp_queryKeyBinding != NULL)
+ return mp_queryKeyBinding;
+
+
+ // OK - Nothing exists, so we need to create from scratch
+
+ XSECnew(mp_queryKeyBinding, XKMSQueryKeyBindingImpl(mp_env));
+ mp_queryKeyBindingElement = mp_queryKeyBinding->createBlankQueryKeyBinding();
+
+ if (mp_messageAbstractTypeElement->getFirstChild() == NULL) {
+ mp_env->doPrettyPrint(mp_messageAbstractTypeElement);
+ }
+ mp_messageAbstractTypeElement->appendChild(mp_queryKeyBindingElement);
+ mp_env->doPrettyPrint(mp_messageAbstractTypeElement);
+
+ return mp_queryKeyBinding;
+
+}
1.2 +17 -1 xml-security/c/src/xkms/impl/XKMSLocateRequestImpl.hpp
Index: XKMSLocateRequestImpl.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/xkms/impl/XKMSLocateRequestImpl.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XKMSLocateRequestImpl.hpp 16 Apr 2004 12:07:24 -0000 1.1
+++ XKMSLocateRequestImpl.hpp 19 Apr 2004 10:55:38 -0000 1.2
@@ -41,6 +41,10 @@
public:
XKMSLocateRequestImpl(
+ const XSECEnv * env
+ );
+
+ XKMSLocateRequestImpl(
const XSECEnv * env,
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * node
);
@@ -50,11 +54,21 @@
// Load elements
void load();
+ // Creation
+ XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *
+ createBlankLocateRequest(
+ const XMLCh * service,
+ const XMLCh * id = NULL);
+
+
/* Getter Interface Methods */
virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * getElement(void) const;
virtual XKMSQueryKeyBinding * getQueryKeyBinding(void);
+ /* Setter interface methods */
+ virtual XKMSQueryKeyBinding * addQueryKeyBinding(void);
+
/* Implemented from MessageAbstractType */
virtual messageType getMessageType(void);
@@ -94,6 +108,8 @@
private:
+ XERCES_CPP_NAMESPACE_QUALIFIER DOMElement
+ * mp_queryKeyBindingElement;
XKMSQueryKeyBindingImpl * mp_queryKeyBinding;
// Unimplemented
1.2 +83 -2 xml-security/c/src/xkms/impl/XKMSMessageAbstractTypeImpl.cpp
Index: XKMSMessageAbstractTypeImpl.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/xkms/impl/XKMSMessageAbstractTypeImpl.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XKMSMessageAbstractTypeImpl.cpp 16 Apr 2004 12:07:24 -0000 1.1
+++ XKMSMessageAbstractTypeImpl.cpp 19 Apr 2004 10:55:38 -0000 1.2
@@ -31,6 +31,7 @@
#include <xsec/xkms/XKMSConstants.hpp>
#include <xercesc/dom/DOM.hpp>
+#include <xercesc/util/XMLUniDefs.hpp>
#include "XKMSMessageAbstractTypeImpl.hpp"
@@ -41,11 +42,29 @@
// --------------------------------------------------------------------------------
XKMSMessageAbstractTypeImpl::XKMSMessageAbstractTypeImpl(
+ const XSECEnv * env) :
+
+mp_env(env),
+mp_messageAbstractTypeElement(NULL),
+mp_idAttr(NULL),
+mp_serviceAttr(NULL),
+mp_nonceAttr(NULL),
+mp_signatureElement(NULL),
+mp_signature(NULL) {
+
+}
+
+XKMSMessageAbstractTypeImpl::XKMSMessageAbstractTypeImpl(
const XSECEnv * env,
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * node) :
mp_env(env),
-mp_messageAbstractTypeElement(node) {
+mp_messageAbstractTypeElement(node),
+mp_idAttr(NULL),
+mp_serviceAttr(NULL),
+mp_nonceAttr(NULL),
+mp_signatureElement(NULL),
+mp_signature(NULL) {
}
@@ -112,6 +131,68 @@
mp_signature->load();
}
+
+}
+
+// --------------------------------------------------------------------------------
+// Create blank
+// --------------------------------------------------------------------------------
+
+DOMElement * XKMSMessageAbstractTypeImpl::createBlankMessageAbstractType(
+ const XMLCh * tag,
+ const XMLCh * service,
+ const XMLCh * id) {
+
+ // Get some setup values
+ safeBuffer str;
+ DOMDocument *doc = mp_env->getParentDocument();
+ const XMLCh * prefix = mp_env->getXKMSNSPrefix();
+
+ makeQName(str, prefix, tag);
+
+ mp_messageAbstractTypeElement = doc->createElementNS(XKMSConstants::s_unicodeStrURIXKMS,
+ str.rawXMLChBuffer());
+
+ // Set namespace
+ if (prefix[0] == chNull) {
+ str.sbTranscodeIn("xmlns");
+ }
+ else {
+ str.sbTranscodeIn("xmlns:");
+ str.sbXMLChCat(prefix);
+ }
+
+ mp_messageAbstractTypeElement->setAttributeNS(DSIGConstants::s_unicodeStrURIXMLNS,
+ str.rawXMLChBuffer(),
+ XKMSConstants::s_unicodeStrURIXKMS);
+
+ mp_env->doPrettyPrint(mp_messageAbstractTypeElement);
+
+ // Setup the service URI
+ mp_messageAbstractTypeElement->setAttributeNS(NULL,
+ XKMSConstants::s_tagService,
+ service);
+ mp_serviceAttr =
+ mp_messageAbstractTypeElement->getAttributeNodeNS(NULL, XKMSConstants::s_tagService);
+
+
+ // Setup the id
+ XMLCh anAtt[] = {chLatin_a,chLatin_n,chLatin_A,chLatin_t,chLatin_t,chNull};
+ const XMLCh * myId;
+ if (id != NULL)
+ myId = id;
+ else
+ myId = anAtt;
+
+ mp_messageAbstractTypeElement->setAttributeNS(NULL, XKMSConstants::s_tagId, myId);
+ mp_messageAbstractTypeElement->setIdAttributeNS(NULL, XKMSConstants::s_tagId);
+ mp_idAttr =
+ mp_messageAbstractTypeElement->getAttributeNodeNS(NULL, XKMSConstants::s_tagId);
+
+ // Nonce is blank at start
+ mp_nonceAttr = NULL;
+
+ return mp_messageAbstractTypeElement;
}
1.2 +12 -1 xml-security/c/src/xkms/impl/XKMSMessageAbstractTypeImpl.hpp
Index: XKMSMessageAbstractTypeImpl.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/xkms/impl/XKMSMessageAbstractTypeImpl.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XKMSMessageAbstractTypeImpl.hpp 16 Apr 2004 12:07:24 -0000 1.1
+++ XKMSMessageAbstractTypeImpl.hpp 19 Apr 2004 10:55:38 -0000 1.2
@@ -45,6 +45,10 @@
/* Constructors and Destructors */
XKMSMessageAbstractTypeImpl(
+ const XSECEnv * env
+ );
+
+ XKMSMessageAbstractTypeImpl(
const XSECEnv * env,
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * node
);
@@ -53,6 +57,13 @@
// load
void load(void);
+
+ // Create from scratch - tag is the element name to create
+ XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *
+ createBlankMessageAbstractType(
+ const XMLCh * tag,
+ const XMLCh * service,
+ const XMLCh * id = NULL);
/* Message Manipulation Methods */
1.2 +51 -1 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XKMSMessageFactoryImpl.cpp 16 Apr 2004 12:07:24 -0000 1.1
+++ XKMSMessageFactoryImpl.cpp 19 Apr 2004 10:55:38 -0000 1.2
@@ -29,9 +29,13 @@
#include <xsec/utils/XSECDOMUtils.hpp>
#include <xsec/xkms/XKMSConstants.hpp>
+#include <xercesc/dom/DOM.hpp>
+
#include "XKMSMessageFactoryImpl.hpp"
#include "XKMSLocateRequestImpl.hpp"
+XERCES_CPP_NAMESPACE_USE
+
// --------------------------------------------------------------------------------
// Construct/Destruct
// --------------------------------------------------------------------------------
@@ -41,6 +45,8 @@
// Factory isn't tied to a particular document
XSECnew(mp_env, XSECEnv(NULL));
+ mp_env->setDSIGNSPrefix(MAKE_UNICODE_STRING("ds"));
+
};
XKMSMessageFactoryImpl::~XKMSMessageFactoryImpl(void) {
@@ -111,4 +117,48 @@
return NULL;
+}
+
+// --------------------------------------------------------------------------------
+// Construction from scratch
+// --------------------------------------------------------------------------------
+
+XKMSLocateRequest * XKMSMessageFactoryImpl::createLocateRequest(
+ const XMLCh * service,
+ XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * doc,
+ const XMLCh * id) {
+
+ XKMSLocateRequestImpl * lri;
+
+ XSECEnv * tenv;
+ XSECnew(tenv, XSECEnv(*mp_env));
+ tenv->setParentDocument(doc);
+
+ XSECnew(lri, XKMSLocateRequestImpl(tenv));
+ lri->createBlankLocateRequest(service, id);
+
+ return lri;
+
+}
+
+
+XKMSLocateRequest * XKMSMessageFactoryImpl::createLocateRequest(
+ 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
+ XKMSLocateRequest * lri = createLocateRequest(service, *doc, id);
+ (*doc)->appendChild(lri->getElement());
+
+ return lri;
}
1.2 +12 -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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XKMSMessageFactoryImpl.hpp 16 Apr 2004 12:07:24 -0000 1.1
+++ XKMSMessageFactoryImpl.hpp 19 Apr 2004 10:55:38 -0000 1.2
@@ -47,6 +47,17 @@
virtual XKMSMessageAbstractType * newMessageFromDOM(
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * elt);
+ /* Construction from scratch */
+ virtual XKMSLocateRequest * createLocateRequest(
+ const XMLCh * service,
+ XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * doc,
+ const XMLCh * id = NULL);
+ virtual XKMSLocateRequest * createLocateRequest(
+ const XMLCh * service,
+ XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument **doc,
+ const XMLCh * id = NULL);
+
+
/* Environment Manipulation */
virtual void setDSIGNSPrefix(const XMLCh * prefix);
virtual void setECNSPrefix(const XMLCh * prefix);
1.2 +25 -1 xml-security/c/src/xkms/impl/XKMSQueryKeyBindingImpl.cpp
Index: XKMSQueryKeyBindingImpl.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/xkms/impl/XKMSQueryKeyBindingImpl.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XKMSQueryKeyBindingImpl.cpp 16 Apr 2004 12:07:24 -0000 1.1
+++ XKMSQueryKeyBindingImpl.cpp 19 Apr 2004 10:55:38 -0000 1.2
@@ -27,14 +27,26 @@
#include <xsec/framework/XSECDefs.hpp>
#include <xsec/framework/XSECError.hpp>
+#include <xsec/xkms/XKMSConstants.hpp>
+
+#include <xercesc/dom/DOM.hpp>
#include "XKMSQueryKeyBindingImpl.hpp"
+XERCES_CPP_NAMESPACE_USE
+
// --------------------------------------------------------------------------------
// Construct/Destruct
// --------------------------------------------------------------------------------
XKMSQueryKeyBindingImpl::XKMSQueryKeyBindingImpl(
+ const XSECEnv * env
+ ) :
+XKMSKeyBindingAbstractTypeImpl(env) {
+
+}
+
+XKMSQueryKeyBindingImpl::XKMSQueryKeyBindingImpl(
const XSECEnv * env,
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * node
) :
@@ -58,3 +70,15 @@
XKMSKeyBindingAbstractTypeImpl::load();
}
+
+// --------------------------------------------------------------------------------
+// Create
+// --------------------------------------------------------------------------------
+
+DOMElement * XKMSQueryKeyBindingImpl::createBlankQueryKeyBinding(void) {
+
+ return XKMSKeyBindingAbstractTypeImpl::
+ createBlankKeyBindingAbstractType(XKMSConstants::s_tagQueryKeyBinding);
+
+}
+
1.2 +9 -1 xml-security/c/src/xkms/impl/XKMSQueryKeyBindingImpl.hpp
Index: XKMSQueryKeyBindingImpl.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/xkms/impl/XKMSQueryKeyBindingImpl.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XKMSQueryKeyBindingImpl.hpp 16 Apr 2004 12:07:24 -0000 1.1
+++ XKMSQueryKeyBindingImpl.hpp 19 Apr 2004 10:55:38 -0000 1.2
@@ -38,6 +38,10 @@
public:
XKMSQueryKeyBindingImpl(
+ const XSECEnv * env
+ );
+
+ XKMSQueryKeyBindingImpl(
const XSECEnv * env,
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * node
);
@@ -46,6 +50,10 @@
// Load
void load(void);
+
+ // Create
+ XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *
+ createBlankQueryKeyBinding(void);
// Import methods from XKMSKeyBindingAbstractType
XKMS_KEYBINDINGABSTRACTYPE_IMPL_METHODS
1.2 +22 -2 xml-security/c/src/xkms/impl/XKMSRequestAbstractTypeImpl.cpp
Index: XKMSRequestAbstractTypeImpl.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/xkms/impl/XKMSRequestAbstractTypeImpl.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XKMSRequestAbstractTypeImpl.cpp 16 Apr 2004 12:07:24 -0000 1.1
+++ XKMSRequestAbstractTypeImpl.cpp 19 Apr 2004 10:55:38 -0000 1.2
@@ -42,8 +42,15 @@
// --------------------------------------------------------------------------------
XKMSRequestAbstractTypeImpl::XKMSRequestAbstractTypeImpl(
+ const XSECEnv * env) :
+XKMSMessageAbstractTypeImpl(env)
+{
+
+}
+
+XKMSRequestAbstractTypeImpl::XKMSRequestAbstractTypeImpl(
const XSECEnv * env,
- XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * node) :
+ DOMElement * node) :
XKMSMessageAbstractTypeImpl(env, node)
{
@@ -84,6 +91,19 @@
}
XKMSMessageAbstractTypeImpl::load();
+
+}
+
+// --------------------------------------------------------------------------------
+// Create from scratch
+// --------------------------------------------------------------------------------
+
+DOMElement * XKMSRequestAbstractTypeImpl::createBlankRequestAbstractType(
+ const XMLCh * tag,
+ const XMLCh * service,
+ const XMLCh * id) {
+
+ return XKMSMessageAbstractTypeImpl::createBlankMessageAbstractType(tag, service, id);
}
1.2 +11 -1 xml-security/c/src/xkms/impl/XKMSRequestAbstractTypeImpl.hpp
Index: XKMSRequestAbstractTypeImpl.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/xkms/impl/XKMSRequestAbstractTypeImpl.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XKMSRequestAbstractTypeImpl.hpp 16 Apr 2004 12:07:24 -0000 1.1
+++ XKMSRequestAbstractTypeImpl.hpp 19 Apr 2004 10:55:38 -0000 1.2
@@ -43,6 +43,9 @@
/* Constructors and Destructors */
XKMSRequestAbstractTypeImpl(
+ const XSECEnv * env
+ );
+ XKMSRequestAbstractTypeImpl(
const XSECEnv * env,
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * node
);
@@ -50,6 +53,13 @@
virtual ~XKMSRequestAbstractTypeImpl();
virtual void load(void);
+
+ // Create from scratch - tag is the element name to create
+ XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *
+ createBlankRequestAbstractType(
+ const XMLCh * tag,
+ const XMLCh * service,
+ const XMLCh * id = NULL);
/* Getter Interface Methods */