X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=xmltooling%2Fsignature%2FSignature.h;h=cfadb9c17f7cae4a026bdceeafc744984ed96c5b;hb=83de10b45721b7882182aaa8a6df0c729db8fc01;hp=db95c2061b7e006aacfb5a15ba5d5eb6274a6dd9;hpb=8077ed4912098fe679baa38d89b5352925180461;p=shibboleth%2Fcpp-xmltooling.git diff --git a/xmltooling/signature/Signature.h b/xmltooling/signature/Signature.h index db95c20..cfadb9c 100644 --- a/xmltooling/signature/Signature.h +++ b/xmltooling/signature/Signature.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2006 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. */ @@ -24,11 +24,10 @@ #define __xmltooling_sig_h__ #include -#include -#include -#include +#include -#include +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 */ @@ -122,8 +136,10 @@ namespace xmlsignature { /** * Compute and append the signature based on the assigned * ContentReference, KeyInfo, and signing key. + * + * @param credential optional source of signing key and KeyInfo */ - virtual void sign()=0; + virtual void sign(const xmltooling::Credential* credential=NULL)=0; /** * Type-safe clone operation. @@ -178,16 +194,21 @@ 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 virtual Signature* buildObject( +#else + virtual xmltooling::XMLObject* buildObject( +#endif const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL ) const; @@ -196,18 +217,13 @@ namespace xmlsignature { * * @return empty Signature object */ +#ifdef HAVE_COVARIANT_RETURNS virtual Signature* buildObject() const; - - static Signature* buildSignature() { - const SignatureBuilder* b = dynamic_cast( - xmltooling::XMLObjectBuilder::getBuilder( - xmltooling::QName(xmlconstants::XMLSIG_NS,Signature::LOCAL_NAME) - ) - ); - if (b) - return b->buildObject(); - throw xmltooling::XMLObjectException("Unable to obtain typed builder for Signature."); - } +#else + virtual xmltooling::XMLObject* buildObject() const; +#endif + /** Singleton builder. */ + static Signature* buildSignature(); }; DECL_XMLTOOLING_EXCEPTION(SignatureException,XMLTOOL_EXCEPTIONAPI(XMLTOOL_API),xmlsignature,xmltooling::XMLSecurityException,Exceptions in signature processing);