You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by sc...@apache.org on 2010/02/04 05:15:29 UTC
svn commit: r906356 - in /xml/security/trunk/c/src/dsig: DSIGKeyInfoX509.cpp
DSIGKeyInfoX509.hpp DSIGSignature.cpp DSIGSignature.hpp
Author: scantor
Date: Thu Feb 4 04:15:28 2010
New Revision: 906356
URL: http://svn.apache.org/viewvc?rev=906356&view=rev
Log:
https://issues.apache.org/bugzilla/show_bug.cgi?id=45867
Modified:
xml/security/trunk/c/src/dsig/DSIGKeyInfoX509.cpp
xml/security/trunk/c/src/dsig/DSIGKeyInfoX509.hpp
xml/security/trunk/c/src/dsig/DSIGSignature.cpp
xml/security/trunk/c/src/dsig/DSIGSignature.hpp
Modified: xml/security/trunk/c/src/dsig/DSIGKeyInfoX509.cpp
URL: http://svn.apache.org/viewvc/xml/security/trunk/c/src/dsig/DSIGKeyInfoX509.cpp?rev=906356&r1=906355&r2=906356&view=diff
==============================================================================
--- xml/security/trunk/c/src/dsig/DSIGKeyInfoX509.cpp (original)
+++ xml/security/trunk/c/src/dsig/DSIGKeyInfoX509.cpp Thu Feb 4 04:15:28 2010
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2005 The Apache Software Foundation.
+ * Copyright 2002-2010 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.
@@ -45,18 +45,16 @@
mp_X509IssuerName(NULL),
mp_X509SerialNumber(NULL),
mp_X509SubjectName(NULL),
-mp_X509CRL(NULL),
mp_X509SKI(NULL),
mp_rawRetrievalURI(NULL),
mp_X509SubjectNameTextNode(0),
mp_X509IssuerNameTextNode(0),
mp_X509SerialNumberTextNode(0),
-mp_X509CRLTextNode(0),
mp_X509SKITextNode(0) {
mp_keyInfoDOMNode = X509Data;
m_X509List.clear();
-
+ m_X509CRLList.clear();
}
DSIGKeyInfoX509::DSIGKeyInfoX509(const XSECEnv * env) :
@@ -64,18 +62,16 @@
mp_X509IssuerName(NULL),
mp_X509SerialNumber(NULL),
mp_X509SubjectName(NULL),
-mp_X509CRL(NULL),
mp_X509SKI(NULL),
mp_rawRetrievalURI(NULL),
mp_X509SubjectNameTextNode(0),
mp_X509IssuerNameTextNode(0),
mp_X509SerialNumberTextNode(0),
-mp_X509CRLTextNode(0),
mp_X509SKITextNode(0) {
mp_keyInfoDOMNode = 0;
m_X509List.clear();
-
+ m_X509CRLList.clear();
}
@@ -101,6 +97,7 @@
}
m_X509List.clear();
+ m_X509CRLList.clear();
if (mp_rawRetrievalURI != NULL)
XSEC_RELEASE_XMLCH(mp_rawRetrievalURI);
@@ -238,17 +235,14 @@
else if (strEquals(getDSIGLocalName(tmpElt), "X509CRL")) {
- child = findFirstChildOfType(tmpElt, DOMNode::TEXT_NODE);
+ DOMNode *crlElt = findFirstChildOfType(tmpElt, DOMNode::TEXT_NODE);
- if (child == NULL) {
+ if (crlElt != 0) {
- throw XSECException(XSECException::ExpectedDSIGChildNotFound,
- "Expected TEXT_NODE child of <X509CRL>");
+ // Add to the list
+ m_X509CRLList.push_back(crlElt->getNodeValue());
- }
-
- mp_X509CRLTextNode = child;
- mp_X509CRL = child->getNodeValue();
+ }
}
else if (strEquals(getDSIGLocalName(tmpElt), "X509SKI")) {
@@ -299,7 +293,23 @@
const XMLCh * DSIGKeyInfoX509::getX509CRL(void) const {
- return mp_X509CRL;
+ return m_X509CRLList.empty() ? NULL : m_X509CRLList.front();
+
+}
+
+int DSIGKeyInfoX509::getX509CRLListSize(void) const {
+
+ return (int) m_X509CRLList.size();
+
+}
+
+
+const XMLCh * DSIGKeyInfoX509::getX509CRLItem(int item) const {
+
+ if (item >=0 && (unsigned int) item < m_X509CRLList.size())
+ return m_X509CRLList[item];
+
+ return 0;
}
@@ -321,8 +331,6 @@
}
-
-
const XMLCh * DSIGKeyInfoX509::getCertificateItem(int item) const {
if (item >=0 && (unsigned int) item < m_X509List.size())
@@ -377,33 +385,27 @@
}
void DSIGKeyInfoX509::setX509CRL(const XMLCh * crl) {
+ appendX509CRL(crl);
+}
- if (mp_X509CRLTextNode == 0) {
-
- safeBuffer str;
- DOMDocument *doc = mp_env->getParentDocument();
- const XMLCh * prefix = mp_env->getDSIGNSPrefix();
-
- makeQName(str, prefix, "X509CRL");
-
- DOMElement * s = doc->createElementNS(DSIGConstants::s_unicodeStrURIDSIG, str.rawXMLChBuffer());
- mp_X509CRLTextNode = doc->createTextNode(crl);
- s->appendChild(mp_X509CRLTextNode);
-
- // Add to the over-arching node
- mp_keyInfoDOMNode->appendChild(s);
- mp_env->doPrettyPrint(mp_keyInfoDOMNode);
+void DSIGKeyInfoX509::appendX509CRL(const XMLCh * crl) {
- }
+ safeBuffer str;
+ DOMDocument *doc = mp_env->getParentDocument();
+ const XMLCh * prefix = mp_env->getDSIGNSPrefix();
- else {
+ makeQName(str, prefix, "X509CRL");
- mp_X509CRLTextNode->setNodeValue(crl);
+ DOMElement * s = doc->createElementNS(DSIGConstants::s_unicodeStrURIDSIG, str.rawXMLChBuffer());
+ DOMNode * b64Txt = doc->createTextNode(crl);
+ s->appendChild(b64Txt);
- }
+ mp_keyInfoDOMNode->appendChild(s);
+ mp_env->doPrettyPrint(mp_keyInfoDOMNode);
- mp_X509CRL = mp_X509CRLTextNode->getNodeValue();
+ // Add to the list
+ m_X509CRLList.push_back(b64Txt->getNodeValue());
}
void DSIGKeyInfoX509::setX509SKI(const XMLCh * ski) {
Modified: xml/security/trunk/c/src/dsig/DSIGKeyInfoX509.hpp
URL: http://svn.apache.org/viewvc/xml/security/trunk/c/src/dsig/DSIGKeyInfoX509.hpp?rev=906356&r1=906355&r2=906356&view=diff
==============================================================================
--- xml/security/trunk/c/src/dsig/DSIGKeyInfoX509.hpp (original)
+++ xml/security/trunk/c/src/dsig/DSIGKeyInfoX509.hpp Thu Feb 4 04:15:28 2010
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2005 The Apache Software Foundation.
+ * Copyright 2002-2010 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.
@@ -62,8 +62,10 @@
#if defined(XSEC_NO_NAMESPACES)
typedef vector<X509Holder *> X509ListType;
+ typedef vector<const XMLCh *> X509CRLListType;
#else
typedef std::vector<X509Holder *> X509ListType;
+ typedef std::vector<const XMLCh *> X509CRLListType;
#endif
#if defined(XSEC_SIZE_T_IN_NAMESPACE_STD)
@@ -168,10 +170,10 @@
const XMLCh * getX509IssuerSerialNumber(void) const;
/**
- * \brief Get any associated CRL
+ * \brief Get the first associated CRL
*
* Return the string containing the base64 encoded CRL that was held in
- * the X509CRL node
+ * the first X509CRL node
*
* @returns A pointer to the string containing the CRL
* (0 if not set)
@@ -179,6 +181,28 @@
const XMLCh * getX509CRL(void) const;
+ /**
+ * \brief Find the number of CRLs held
+ *
+ * Find the number of CRLs held in the X509Data structures.
+ *
+ * @returns The number of CRLs
+ */
+
+ int getX509CRLListSize(void) const;
+
+ /**
+ * \brief Get the DER encoded CRL pointed to in the list.
+ *
+ * Use the index to find the required CRL and return a pointer
+ * to the buffer containing the encoded CRL.
+ *
+ * @returns A pointer to the buffer containing the CRL or 0 if
+ * no CRL exists at that point in the list.
+ */
+
+ const XMLCh * getX509CRLItem(int item) const;
+
/**
* \brief Get the SKI value (if set)
*
@@ -300,15 +324,28 @@
void setX509IssuerSerial(const XMLCh * name, const XMLCh * serial);
/**
- * \brief Set the CRL element
+ * \brief Add a CRL.
*
- * If an X509CRL exists, replace the value with that provided,
- * otherwise create a new element and set the value appropriately.
+ * Append an X509CRL element to the list of CRLs
+ * stored at the end of this KeyInfo element.
*
- * @param crl The base64 encoded string containing the CRL
+ * @param crl A pointer to the base64 encoded CRL,
+ * exactly as it will appear in the XML structure.
*/
void setX509CRL(const XMLCh * crl);
+
+ /**
+ * \brief Add a CRL.
+ *
+ * Append an X509CRL element to the list of CRLs
+ * stored at the end of this KeyInfo element.
+ *
+ * @param crl A pointer to the base64 encoded CRL,
+ * exactly as it will appear in the XML structure.
+ */
+
+ void appendX509CRL(const XMLCh * crl);
/**
* \brief Set the SKI element
@@ -356,10 +393,10 @@
DSIGKeyInfoX509();
X509ListType m_X509List; // The X509 structures
+ X509CRLListType m_X509CRLList; // The X509CRL list
XMLCh * mp_X509IssuerName; // Parameters from KeyInfo (not cert)
const XMLCh * mp_X509SerialNumber;
XMLCh * mp_X509SubjectName;
- const XMLCh * mp_X509CRL;
const XMLCh * mp_X509SKI;
XMLCh * mp_rawRetrievalURI;
@@ -368,7 +405,6 @@
XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * mp_X509SubjectNameTextNode;
XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * mp_X509IssuerNameTextNode;
XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * mp_X509SerialNumberTextNode;
- XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * mp_X509CRLTextNode;
XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * mp_X509SKITextNode;
};
Modified: xml/security/trunk/c/src/dsig/DSIGSignature.cpp
URL: http://svn.apache.org/viewvc/xml/security/trunk/c/src/dsig/DSIGSignature.cpp?rev=906356&r1=906355&r2=906356&view=diff
==============================================================================
--- xml/security/trunk/c/src/dsig/DSIGSignature.cpp (original)
+++ xml/security/trunk/c/src/dsig/DSIGSignature.cpp Thu Feb 4 04:15:28 2010
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2005 The Apache Software Foundation.
+ * Copyright 2002-2010 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.
@@ -319,19 +319,26 @@
}
+
// --------------------------------------------------------------------------------
// Get the list of references
// --------------------------------------------------------------------------------
DSIGReferenceList * DSIGSignature::getReferenceList(void) {
- return mp_signedInfo->getReferenceList();
+ return mp_signedInfo ? mp_signedInfo->getReferenceList() : NULL;
}
const DSIGReferenceList * DSIGSignature::getReferenceList(void) const {
- return mp_signedInfo->getReferenceList();
+ return mp_signedInfo ? mp_signedInfo->getReferenceList() : NULL;
+
+}
+
+const XMLCh * DSIGSignature::getAlgorithmURI() const {
+
+ return mp_signedInfo ? mp_signedInfo->getAlgorithmURI() : NULL;
}
Modified: xml/security/trunk/c/src/dsig/DSIGSignature.hpp
URL: http://svn.apache.org/viewvc/xml/security/trunk/c/src/dsig/DSIGSignature.hpp?rev=906356&r1=906355&r2=906356&view=diff
==============================================================================
--- xml/security/trunk/c/src/dsig/DSIGSignature.hpp (original)
+++ xml/security/trunk/c/src/dsig/DSIGSignature.hpp Thu Feb 4 04:15:28 2010
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2005 The Apache Software Foundation.
+ * Copyright 2002-2010 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.
@@ -535,6 +535,15 @@
mp_signedInfo->getCanonicalizationMethod() : CANON_NONE);}
+ /**
+ * \brief Get the Algorithm URI
+ *
+ * @returns the URI associated with the Algorithm used to generate
+ * the signature
+ */
+
+ const XMLCh * getAlgorithmURI() const;
+
/**
* \brief Get the hash method
*