#if !defined(__xmltooling_signctx_h__) && !defined(XMLTOOLING_NO_XMLSEC)\r
#define __xmltooling_signctx_h__\r
\r
+#include <xmltooling/signature/KeyInfo.h>\r
+\r
#include <vector>\r
#include <xsec/dsig/DSIGSignature.hpp>\r
\r
* \r
* @return an immutable collection of certificates to embed\r
*/\r
- virtual const std::vector<XSECCryptoX509*>& getX509Certificates() const=0;\r
- \r
+ virtual const std::vector<XSECCryptoX509*>* getX509Certificates() const=0;\r
+\r
+ /**\r
+ * Gets a KeyInfo structure to embed.\r
+ * Ownership of the object MUST be transferred to the caller.\r
+ * This method will only be called if no certificates are returned from\r
+ * the getX509Certificates() method.\r
+ * \r
+ * @return pointer to a KeyInfo structure, will be freed by caller\r
+ */\r
+ virtual KeyInfo* getKeyInfo() const=0;\r
+\r
/**\r
* Gets the signing key to use.\r
* Must be compatible with the intended signature algorithm. Ownership of the key\r
try {\r
log.debug("creating signature content");\r
ctx.createSignature(m_signature);\r
- const std::vector<XSECCryptoX509*>& certs=ctx.getX509Certificates();\r
- if (!certs.empty()) {\r
+ const std::vector<XSECCryptoX509*>* certs=ctx.getX509Certificates();\r
+ if (certs && !certs->empty()) {\r
DSIGKeyInfoX509* x509Data=m_signature->appendX509Data();\r
- for_each(certs.begin(),certs.end(),bind1st(_addcert(),x509Data));\r
+ for_each(certs->begin(),certs->end(),bind1st(_addcert(),x509Data));\r
+ }\r
+ else {\r
+ auto_ptr<KeyInfo> keyInfo(ctx.getKeyInfo());\r
+ if (keyInfo.get()) {\r
+ DOMElement* domElement=keyInfo->marshall(m_signature->getParentDocument());\r
+ getDOM()->appendChild(domElement);\r
+ }\r
}\r
\r
log.debug("computing signature");\r
sig->verify();\r
}\r
\r
- const std::vector<XSECCryptoX509*>& getX509Certificates() const { return m_certs; }\r
+ const std::vector<XSECCryptoX509*>* getX509Certificates() const { return &m_certs; }\r
+ KeyInfo* getKeyInfo() const { return NULL; }\r
XSECCryptoKey* getSigningKey() const { return m_key->clone(); }\r
};\r
\r