blautenb 2003/11/22 01:58:48
Modified: c/src/dsig DSIGSignature.hpp DSIGSignature.cpp
Log:
Added creation and manipulation of Object elements
Revision Changes Path
1.18 +48 -1 xml-security/c/src/dsig/DSIGSignature.hpp
Index: DSIGSignature.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/dsig/DSIGSignature.hpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- DSIGSignature.hpp 6 Oct 2003 12:16:37 -0000 1.17
+++ DSIGSignature.hpp 22 Nov 2003 09:58:48 -0000 1.18
@@ -92,6 +92,7 @@
class DSIGKeyInfoPGPData;
class DSIGKeyInfoSPKIData;
class DSIGKeyInfoMgmtData;
+class DSIGObject;
/**
* @ingroup pubsig
@@ -695,10 +696,52 @@
//@}
+ /** @name Object handling */
+ //@{
+
+ /**
+ * \brief Append an object container
+ *
+ * Create a new Object (i.e. a Signature <Object> which is a container
+ * element used to hold information that needs to be signed within the
+ * signature - i.e. in enveloping mode
+ *
+ * @returns the newly created DSIGObject
+ */
+
+ DSIGObject * appendObject(void);
+
+ /**
+ * \brief Find the number of ds:Object nodes within the Signature
+ *
+ * @returns the number of ds:Object nodes held in the Signature, 0 if
none
+ */
+
+ int getObjectLength(void);
+
+ /**
+ * \brief Get a particular ds:Object from within the Signature
+ *
+ * @returns the ith Object from the list of ds:Object nodes in the
signature.
+ * Items are ordered in tree order.
+ */
+
+ DSIGObject * getObjectItem(int i);
+
+ //@}
+
friend class XSECProvider;
private:
+ // For holding DSIGObject nodes
+#if defined(XSEC_NO_NAMESPACES)
+ typedef vector<DSIGObject *> ObjectVectorType;
+#else
+ typedef std::vector<DSIGObject *> ObjectVectorType;
+#endif
+
+
// Internal functions
void createKeyInfoElement(void);
bool verifySignatureOnlyInternal(void);
@@ -726,6 +769,10 @@
// Resolvers
XSECKeyInfoResolver * mp_KeyInfoResolver;
+
+ // Objects
+
+ ObjectVectorType m_objects;
// Not implemented constructors
1.27 +61 -2 xml-security/c/src/dsig/DSIGSignature.cpp
Index: DSIGSignature.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/dsig/DSIGSignature.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- DSIGSignature.cpp 6 Oct 2003 12:16:37 -0000 1.26
+++ DSIGSignature.cpp 22 Nov 2003 09:58:48 -0000 1.27
@@ -72,6 +72,7 @@
#include <xsec/dsig/DSIGSignature.hpp>
#include <xsec/dsig/DSIGConstants.hpp>
#include <xsec/dsig/DSIGKeyInfoX509.hpp>
+#include <xsec/dsig/DSIGObject.hpp>
#include <xsec/dsig/DSIGReference.hpp>
#include <xsec/dsig/DSIGTransformList.hpp>
#include <xsec/transformers/TXFMDocObject.hpp>
@@ -360,6 +361,41 @@
}
+//
--------------------------------------------------------------------------------
+// Object Handling
+//
--------------------------------------------------------------------------------
+
+DSIGObject * DSIGSignature::appendObject(void) {
+
+ DSIGObject * ret;
+ XSECnew(ret, DSIGObject(mp_env));
+ DOMElement * elt = ret->createBlankObject();
+
+ mp_sigNode->appendChild(elt);
+ mp_env->doPrettyPrint(mp_sigNode);
+
+ m_objects.push_back(ret);
+
+ return ret;
+
+}
+
+int DSIGSignature::getObjectLength(void) {
+
+ return m_objects.size();
+
+}
+
+DSIGObject * DSIGSignature::getObjectItem(int i) {
+
+ if ( i < 0 || i >= m_objects.size()) {
+ throw XSECException(XSECException::ObjectError,
+ "DSIGSignature::getObjectItem - index out of range");
+ }
+
+ return m_objects[i];
+
+}
//
--------------------------------------------------------------------------------
// Signature
@@ -441,6 +477,10 @@
mp_KeyInfoResolver = NULL;
}
+ // Delete any object items
+ for (int i = 0; i < m_objects.size(); ++i) {
+ delete (m_objects[i]);
+ }
}
@@ -772,13 +812,32 @@
strEquals(getDSIGLocalName(tmpElt), "KeyInfo")))
tmpElt = tmpElt->getNextSibling();
- if (tmpElt != 0) {
+ if (tmpElt != 0 && strEquals(getDSIGLocalName(tmpElt), "KeyInfo")) {
// Have a keyInfo
mp_KeyInfoNode = tmpElt; // In case we later
want to manipulate it
m_keyInfoList.loadListFromXML(tmpElt);
+
+ tmpElt = findNextElementChild(tmpElt);
+ }
+
+ while (tmpElt != 0 && strEquals(getDSIGLocalName(tmpElt), "Object")) {
+
+ DSIGObject * obj;
+ XSECnew(obj, DSIGObject(mp_env, tmpElt));
+ obj->load();
+
+ m_objects.push_back(obj);
+
+ tmpElt = findNextElementChild(tmpElt);
+
+ }
+
+ if (tmpElt != 0) {
+ throw XSECException(XSECException::ExpectedDSIGChildNotFound,
+ "DSIGSignature::load - Unexpected (non Object) Element
found at end of signature");
}
}