*/\r
\r
/**\r
- * XMLSecSignature.cpp\r
+ * XMLSecSignatureImpl.cpp\r
* \r
- * Signature classes for XMLSec-based signature-handling\r
+ * Signature class for XMLSec-based signature-handling\r
*/\r
\r
#include "internal.h"\r
#include "exceptions.h"\r
-#include "signature/impl/XMLSecSignature.h"\r
+#include "impl/UnknownElement.h"\r
+#include "signature/impl/XMLSecSignatureImpl.h"\r
#include "util/NDC.h"\r
+#include "util/XMLConstants.h"\r
#include "util/XMLHelper.h"\r
\r
#include <log4cpp/Category.hh>\r
#include <xercesc/framework/MemBufInputSource.hpp>\r
#include <xercesc/framework/Wrapper4InputSource.hpp>\r
-#include <xercesc/util/XMLUniDefs.hpp>\r
#include <xsec/dsig/DSIGKeyInfoX509.hpp>\r
#include <xsec/enc/XSECCryptoException.hpp>\r
#include <xsec/framework/XSECException.hpp>\r
using namespace log4cpp;\r
using namespace std;\r
\r
-const XMLCh xmltooling::Signature::LOCAL_NAME[] = {\r
- chLatin_S, chLatin_i, chLatin_g, chLatin_n, chLatin_a, chLatin_t, chLatin_u, chLatin_r, chLatin_e, chNull\r
-}; \r
+#if defined (_MSC_VER)\r
+ #pragma warning( push )\r
+ #pragma warning( disable : 4250 4251 )\r
+#endif\r
+\r
+namespace xmltooling {\r
+ \r
+ class XMLTOOL_DLLLOCAL XMLSecSignatureImpl : public UnknownElementImpl, public virtual Signature\r
+ {\r
+ public:\r
+ XMLSecSignatureImpl() : UnknownElementImpl(XMLConstants::XMLSIG_NS, Signature::LOCAL_NAME, XMLConstants::XMLSIG_PREFIX),\r
+ m_signature(NULL), m_c14n(NULL), m_sm(NULL) {}\r
+ virtual ~XMLSecSignatureImpl();\r
+ \r
+ void releaseDOM();\r
+ XMLObject* clone() const;\r
\r
-const XMLCh xmltooling::Signature::PREFIX[] = {\r
- chLatin_d, chLatin_s, chNull\r
-}; \r
+ DOMElement* marshall(DOMDocument* document=NULL, MarshallingContext* ctx=NULL) const;\r
+ DOMElement* marshall(DOMElement* parentElement, MarshallingContext* ctx=NULL) const;\r
+ XMLObject* unmarshall(DOMElement* element, bool bindDocument=false);\r
+ \r
+ // Getters\r
+ const XMLCh* getCanonicalizationMethod() const { return m_c14n ? m_c14n : DSIGConstants::s_unicodeStrURIEXC_C14N_NOC; }\r
+ const XMLCh* getSignatureAlgorithm() const { return m_sm ? m_sm : DSIGConstants::s_unicodeStrURIRSA_SHA1; }\r
+\r
+ // Setters\r
+ void setCanonicalizationMethod(const XMLCh* c14n) { m_c14n = prepareForAssignment(m_c14n,c14n); }\r
+ void setSignatureAlgorithm(const XMLCh* sm) { m_sm = prepareForAssignment(m_sm,sm); }\r
+\r
+ void sign(const SigningContext& ctx);\r
+ void verify(const VerifyingContext& ctx) const;\r
+\r
+ private:\r
+ mutable DSIGSignature* m_signature;\r
+ XMLCh* m_c14n;\r
+ XMLCh* m_sm;\r
+ };\r
+ \r
+};\r
+\r
+#if defined (_MSC_VER)\r
+ #pragma warning( pop )\r
+#endif\r
\r
XMLSecSignatureImpl::~XMLSecSignatureImpl()\r
{\r
setDOM(element, bindDocument);\r
return this;\r
}\r
+\r
+Signature* XMLSecSignatureBuilder::buildObject(const XMLCh* ns, const XMLCh* name, const XMLCh* prefix) const\r
+{\r
+ if (!XMLString::equals(ns,XMLConstants::XMLSIG_NS) || !XMLString::equals(name,Signature::LOCAL_NAME))\r
+ throw XMLObjectException("XMLSecSignatureBuilder requires standard Signature element name.");\r
+ return buildObject();\r
+}\r
+\r
+Signature* XMLSecSignatureBuilder::buildObject() const\r
+{\r
+ return new XMLSecSignatureImpl();\r
+}\r