Add code paths for new xmlsec APIs, and allow for undetermined signature algorithm.
[shibboleth/cpp-xmltooling.git] / xmltooling / signature / Signature.h
index d26ccb8..cfadb9c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2001-2007 Internet2
+ *  Copyright 2001-2010 Internet2
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
  */
 
 /**
- * @file Signature.h
+ * @file xmltooling/signature/Signature.h
  * 
  * XMLObject representing XML Digital Signature, version 20020212, Signature element. 
  */
 #define __xmltooling_sig_h__
 
 #include <xmltooling/exceptions.h>
-#include <xmltooling/XMLObjectBuilder.h>
-#include <xmltooling/signature/ContentReference.h>
-#include <xmltooling/util/XMLConstants.h>
+#include <xmltooling/ConcreteXMLObjectBuilder.h>
 
-#include <xsec/dsig/DSIGSignature.hpp>
+class DSIGSignature;
+class XSECCryptoKey;
 
 /**
  * @namespace xmlsignature
@@ -36,6 +35,7 @@
  */
 namespace xmlsignature {
 
+    class XMLTOOL_API ContentReference;
     class XMLTOOL_API KeyInfo;
 
     /**
@@ -46,13 +46,27 @@ namespace xmlsignature {
     class XMLTOOL_API Signature : public virtual xmltooling::XMLObject
     {
     public:
-        virtual ~Signature() {}
+        virtual ~Signature();
 
         /** Element local name */
         static const XMLCh LOCAL_NAME[];
 
         /**
-         * Sets the canonicalization method for the ds:SignedInfo element
+         * Gets the canonicalization method for the ds:SignedInfo element.
+         * 
+         * @return the canonicalization method
+         */
+        virtual const XMLCh* getCanonicalizationMethod() const=0;
+        
+        /**
+         * Gets the signing algorithm for the signature.
+         * 
+         * @return    the signature algorithm, or NULL if indeterminate
+         */
+        virtual const XMLCh* getSignatureAlgorithm() const=0;
+
+        /**
+         * Sets the canonicalization method for the ds:SignedInfo element.
          * 
          * @param c14n  the canonicalization method
          */
@@ -180,13 +194,14 @@ namespace xmlsignature {
             );
 
     protected:
-        Signature() {}
+        /** Default constructor. */
+        Signature();
     };
 
     /**
      * Builder for Signature objects.
      */
-    class XMLTOOL_API SignatureBuilder : public xmltooling::XMLObjectBuilder
+    class XMLTOOL_API SignatureBuilder : public xmltooling::ConcreteXMLObjectBuilder
     {
     public:
 #ifdef HAVE_COVARIANT_RETURNS
@@ -208,21 +223,7 @@ namespace xmlsignature {
         virtual xmltooling::XMLObject* buildObject() const;
 #endif
         /** Singleton builder. */
-        static Signature* buildSignature() {
-            const SignatureBuilder* b = dynamic_cast<const SignatureBuilder*>(
-                xmltooling::XMLObjectBuilder::getBuilder(
-                    xmltooling::QName(xmlconstants::XMLSIG_NS,Signature::LOCAL_NAME)
-                    )
-                );
-            if (b) {
-#ifdef HAVE_COVARIANT_RETURNS
-                return b->buildObject();
-#else
-                return dynamic_cast<Signature*>(b->buildObject());
-#endif
-            }
-            throw xmltooling::XMLObjectException("Unable to obtain typed builder for Signature.");
-        }
+        static Signature* buildSignature();
     };
 
     DECL_XMLTOOLING_EXCEPTION(SignatureException,XMLTOOL_EXCEPTIONAPI(XMLTOOL_API),xmlsignature,xmltooling::XMLSecurityException,Exceptions in signature processing);