From: Scott Cantor Date: Sat, 26 Sep 2009 03:38:36 +0000 (+0000) Subject: Reducing header overuse, non-inlining selected methods (CPPOST-35). X-Git-Tag: 1.3~25 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fcpp-xmltooling.git;a=commitdiff_plain;h=30654333446e3148ff35914b2fe087da0719889b Reducing header overuse, non-inlining selected methods (CPPOST-35). --- diff --git a/xmltooling/AbstractAttributeExtensibleXMLObject.h b/xmltooling/AbstractAttributeExtensibleXMLObject.h index 49372ce..9698e5b 100644 --- a/xmltooling/AbstractAttributeExtensibleXMLObject.h +++ b/xmltooling/AbstractAttributeExtensibleXMLObject.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007 Internet2 + * Copyright 2001-2009 Internet2 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,10 +23,11 @@ #ifndef __xmltooling_absattrextxmlobj_h__ #define __xmltooling_absattrextxmlobj_h__ -#include #include #include +#include + #if defined (_MSC_VER) #pragma warning( push ) #pragma warning( disable : 4250 4251 ) diff --git a/xmltooling/exceptions.h b/xmltooling/exceptions.h index 43b17fb..7ed53d7 100644 --- a/xmltooling/exceptions.h +++ b/xmltooling/exceptions.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007 Internet2 + * Copyright 2001-2009 Internet2 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,17 +17,18 @@ /** * @file xmltooling/exceptions.h * - * Exception classes + * Exception classes. */ #ifndef __xmltooling_exceptions_h__ #define __xmltooling_exceptions_h__ +#include + #include #include #include #include -#include /** * Declares a derived exception class diff --git a/xmltooling/security/ChainingTrustEngine.h b/xmltooling/security/ChainingTrustEngine.h index bd97ac9..696e539 100644 --- a/xmltooling/security/ChainingTrustEngine.h +++ b/xmltooling/security/ChainingTrustEngine.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007 Internet2 + * Copyright 2001-2009 Internet2 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,9 +58,7 @@ namespace xmltooling { * * @param newEngine trust engine to add */ - void addTrustEngine(TrustEngine* newEngine) { - m_engines.push_back(newEngine); - } + void addTrustEngine(TrustEngine* newEngine); /** * Removes a trust engine. The caller must delete the engine if necessary. @@ -68,15 +66,7 @@ namespace xmltooling { * @param oldEngine trust engine to remove * @return the old engine */ - TrustEngine* removeTrustEngine(TrustEngine* oldEngine) { - for (std::vector::iterator i=m_engines.begin(); i!=m_engines.end(); i++) { - if (oldEngine==(*i)) { - m_engines.erase(i); - return oldEngine; - } - } - return NULL; - } + TrustEngine* removeTrustEngine(TrustEngine* oldEngine); bool validate( xmlsignature::Signature& sig, diff --git a/xmltooling/security/CredentialCriteria.h b/xmltooling/security/CredentialCriteria.h index 4011bba..bb75ef1 100644 --- a/xmltooling/security/CredentialCriteria.h +++ b/xmltooling/security/CredentialCriteria.h @@ -23,15 +23,16 @@ #if !defined(__xmltooling_credcrit_h__) && !defined(XMLTOOLING_NO_XMLSEC) #define __xmltooling_credcrit_h__ -#include -#include -#include -#include -#include +#include #include -#include -#include + +class DSIGKeyInfoList; + +namespace xmlsignature { + class XMLTOOL_API KeyInfo; + class XMLTOOL_API Signature; +}; namespace xmltooling { @@ -42,12 +43,10 @@ namespace xmltooling { { MAKE_NONCOPYABLE(CredentialCriteria); public: - CredentialCriteria() : m_keyUsage(Credential::UNSPECIFIED_CREDENTIAL), m_keySize(0), m_key(NULL), - m_keyInfo(NULL), m_nativeKeyInfo(NULL), m_credential(NULL) { - } - virtual ~CredentialCriteria() { - delete m_credential; - } + /** Default constructor. */ + CredentialCriteria(); + + virtual ~CredentialCriteria(); /** * Determines whether the supplied Credential matches this CredentialCriteria. @@ -138,18 +137,7 @@ namespace xmltooling { * * @param algorithm XML algorithm specifier */ - void setXMLAlgorithm(const XMLCh* algorithm) { - if (algorithm) { - std::pair mapped = - XMLToolingConfig::getConfig().mapXMLAlgorithmToKeyAlgorithm(algorithm); - setKeyAlgorithm(mapped.first); - setKeySize(mapped.second); - } - else { - setKeyAlgorithm(NULL); - setKeySize(0); - } - } + void setXMLAlgorithm(const XMLCh* algorithm); /** * Gets key name criteria. diff --git a/xmltooling/security/KeyInfoCredentialContext.h b/xmltooling/security/KeyInfoCredentialContext.h index 31bcc0e..589d2cf 100644 --- a/xmltooling/security/KeyInfoCredentialContext.h +++ b/xmltooling/security/KeyInfoCredentialContext.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007 Internet2 + * Copyright 2001-2009 Internet2 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,8 +24,8 @@ #define __xmltooling_keyinfocredctx_h__ #include -#include -#include + +class DSIGKeyInfoList; namespace xmlsignature { class XMLTOOL_API KeyInfo; @@ -41,12 +41,16 @@ namespace xmltooling { public: /** * Constructor + * + * @param keyInfo surrounding KeyInfo context object */ KeyInfoCredentialContext(const xmlsignature::KeyInfo* keyInfo=NULL) : m_keyInfo(keyInfo), m_nativeKeyInfo(NULL) { } /** * Constructor + * + * @param keyInfo surrounding native KeyInfo context object */ KeyInfoCredentialContext(DSIGKeyInfoList* keyInfo) : m_keyInfo(NULL), m_nativeKeyInfo(keyInfo) { } diff --git a/xmltooling/security/KeyInfoResolver.h b/xmltooling/security/KeyInfoResolver.h index bb74477..b2f5350 100644 --- a/xmltooling/security/KeyInfoResolver.h +++ b/xmltooling/security/KeyInfoResolver.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007 Internet2 + * Copyright 2001-2009 Internet2 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,14 +23,20 @@ #if !defined(__xmltooling_keyres_h__) && !defined(XMLTOOLING_NO_XMLSEC) #define __xmltooling_keyres_h__ -#include -#include +#include -#include +class DSIGKeyInfoList; + +namespace xmlsignature { + class XMLTOOL_API KeyInfo; + class XMLTOOL_API Signature; +}; namespace xmltooling { + class XMLTOOL_API Credential; class XMLTOOL_API CredentialCriteria; + class XMLTOOL_API KeyInfoCredentialContext; /** * Resolves credentials from KeyInfo information. diff --git a/xmltooling/security/OpenSSLCryptoX509CRL.h b/xmltooling/security/OpenSSLCryptoX509CRL.h index 55b40a6..fd243ae 100644 --- a/xmltooling/security/OpenSSLCryptoX509CRL.h +++ b/xmltooling/security/OpenSSLCryptoX509CRL.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007 The Apache Software Foundation. + * Copyright 2001-2009 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ /** * @file xmltooling/security/OpenSSLCryptoX509CRL.h * - * OpenSSL-based class for handling X.509 CRLs + * OpenSSL-based class for handling X.509 CRLs. */ #if !defined(__xmltooling_opensslx509crl_h__) && !defined(XMLTOOLING_NO_XMLSEC) @@ -25,7 +25,6 @@ #include -#include #include #include @@ -35,14 +34,15 @@ namespace xmltooling { */ class XMLTOOL_API OpenSSLCryptoX509CRL : public XSECCryptoX509CRL { public: + /** Default constructor. */ OpenSSLCryptoX509CRL() : mp_X509CRL(NULL), m_DERX509CRL("") {} virtual ~OpenSSLCryptoX509CRL(); - virtual const XMLCh* getProviderName() const { + const XMLCh* getProviderName() const { return DSIGConstants::s_unicodeStrPROVOpenSSL; } - virtual void loadX509CRLBase64Bin(const char* buf, unsigned int len); - virtual safeBuffer& getDEREncodingSB(void) { + void loadX509CRLBase64Bin(const char* buf, unsigned int len); + safeBuffer& getDEREncodingSB(void) { return m_DERX509CRL; } @@ -62,12 +62,7 @@ namespace xmltooling { return mp_X509CRL; } - XSECCryptoX509CRL* clone() const { - OpenSSLCryptoX509CRL* copy = new OpenSSLCryptoX509CRL(); - copy->mp_X509CRL = X509_CRL_dup(mp_X509CRL); - copy->m_DERX509CRL = m_DERX509CRL; - return copy; - } + XSECCryptoX509CRL* clone() const; private: X509_CRL* mp_X509CRL; diff --git a/xmltooling/security/SecurityHelper.h b/xmltooling/security/SecurityHelper.h index 3dfe9e8..3b69ada 100644 --- a/xmltooling/security/SecurityHelper.h +++ b/xmltooling/security/SecurityHelper.h @@ -23,15 +23,17 @@ #if !defined(__xmltooling_sechelper_h__) && !defined(XMLTOOLING_NO_XMLSEC) #define __xmltooling_sechelper_h__ -#include -#include +#include #include -#include -#include + +class XSECCryptoKey; +class XSECCryptoX509; namespace xmltooling { class XMLTOOL_API Credential; + class XMLTOOL_API SOAPTransport; + class XMLTOOL_API XSECCryptoX509CRL; /** * A helper class for working with keys, certificates, etc. diff --git a/xmltooling/security/impl/AbstractPKIXTrustEngine.cpp b/xmltooling/security/impl/AbstractPKIXTrustEngine.cpp index e718cb8..a20f034 100644 --- a/xmltooling/security/impl/AbstractPKIXTrustEngine.cpp +++ b/xmltooling/security/impl/AbstractPKIXTrustEngine.cpp @@ -25,6 +25,7 @@ #include "logging.h" #include "security/AbstractPKIXTrustEngine.h" #include "signature/KeyInfo.h" +#include "signature/Signature.h" #include #include diff --git a/xmltooling/security/impl/ChainingCredentialResolver.cpp b/xmltooling/security/impl/ChainingCredentialResolver.cpp index abbe6b2..cc8e5a0 100644 --- a/xmltooling/security/impl/ChainingCredentialResolver.cpp +++ b/xmltooling/security/impl/ChainingCredentialResolver.cpp @@ -27,6 +27,7 @@ #include "util/NDC.h" #include "util/XMLHelper.h" +#include #include using namespace xmltooling::logging; diff --git a/xmltooling/security/impl/ChainingTrustEngine.cpp b/xmltooling/security/impl/ChainingTrustEngine.cpp index 358d3b9..dbf9cc7 100644 --- a/xmltooling/security/impl/ChainingTrustEngine.cpp +++ b/xmltooling/security/impl/ChainingTrustEngine.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007 Internet2 + * Copyright 2001-2009 Internet2 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ /** * ChainingTrustEngine.cpp * - * TrustEngine that uses multiple engines in sequence. + * OpenSSLTrustEngine that uses multiple engines in sequence. */ #include "internal.h" @@ -26,6 +26,7 @@ #include "security/ChainingTrustEngine.h" #include "util/XMLHelper.h" +#include #include using namespace xmlsignature; @@ -77,6 +78,22 @@ ChainingTrustEngine::~ChainingTrustEngine() { for_each(m_engines.begin(), m_engines.end(), xmltooling::cleanup()); } +void ChainingTrustEngine::addTrustEngine(TrustEngine* newEngine) +{ + m_engines.push_back(newEngine); +} + +TrustEngine* ChainingTrustEngine::removeTrustEngine(TrustEngine* oldEngine) +{ + for (vector::iterator i=m_engines.begin(); i!=m_engines.end(); i++) { + if (oldEngine==(*i)) { + m_engines.erase(i); + return oldEngine; + } + } + return NULL; +} + bool ChainingTrustEngine::validate(Signature& sig, const CredentialResolver& credResolver, CredentialCriteria* criteria) const { for (vector::const_iterator i=m_sigEngines.begin(); i!=m_sigEngines.end(); ++i) { diff --git a/xmltooling/security/impl/CredentialCriteria.cpp b/xmltooling/security/impl/CredentialCriteria.cpp index e584c9e..12a6993 100644 --- a/xmltooling/security/impl/CredentialCriteria.cpp +++ b/xmltooling/security/impl/CredentialCriteria.cpp @@ -22,19 +22,46 @@ #include "internal.h" #include "logging.h" +#include "XMLToolingConfig.h" #include "security/X509Credential.h" #include "security/CredentialCriteria.h" #include "security/KeyInfoResolver.h" #include "security/SecurityHelper.h" +#include "signature/Signature.h" #include #include +#include #include #include using namespace xmltooling; using namespace std; +CredentialCriteria::CredentialCriteria() + : m_keyUsage(Credential::UNSPECIFIED_CREDENTIAL), m_keySize(0), m_key(NULL), + m_keyInfo(NULL), m_nativeKeyInfo(NULL), m_credential(NULL) +{ +} + +CredentialCriteria::~CredentialCriteria() +{ + delete m_credential; +} + +void CredentialCriteria::setXMLAlgorithm(const XMLCh* algorithm) +{ + if (algorithm) { + pair mapped = XMLToolingConfig::getConfig().mapXMLAlgorithmToKeyAlgorithm(algorithm); + setKeyAlgorithm(mapped.first); + setKeySize(mapped.second); + } + else { + setKeyAlgorithm(NULL); + setKeySize(0); + } +} + void CredentialCriteria::setKeyInfo(const xmlsignature::KeyInfo* keyInfo, int extraction) { delete m_credential; diff --git a/xmltooling/security/impl/ExplicitKeyTrustEngine.cpp b/xmltooling/security/impl/ExplicitKeyTrustEngine.cpp index 0cdb78a..21af839 100644 --- a/xmltooling/security/impl/ExplicitKeyTrustEngine.cpp +++ b/xmltooling/security/impl/ExplicitKeyTrustEngine.cpp @@ -27,6 +27,7 @@ #include "security/CredentialResolver.h" #include "security/OpenSSLTrustEngine.h" #include "security/SignatureTrustEngine.h" +#include "signature/Signature.h" #include "signature/SignatureValidator.h" #include "util/NDC.h" diff --git a/xmltooling/security/impl/OpenSSLCryptoX509CRL.cpp b/xmltooling/security/impl/OpenSSLCryptoX509CRL.cpp index e5c594e..fc8f7c6 100644 --- a/xmltooling/security/impl/OpenSSLCryptoX509CRL.cpp +++ b/xmltooling/security/impl/OpenSSLCryptoX509CRL.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007 The Apache Software Foundation. + * Copyright 2001-2009 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ /** * OpenSSLCryptoX509CRL.cpp * - * OpenSSL-based class for handling X.509 CRLs + * OpenSSL-based class for handling X.509 CRLs. */ #include "internal.h" @@ -110,3 +110,11 @@ void OpenSSLCryptoX509CRL::loadX509CRLBase64Bin(const char* buf, unsigned int le m_DERX509CRL.sbStrcpyIn(buf); } + +XSECCryptoX509CRL* OpenSSLCryptoX509CRL::clone() const +{ + OpenSSLCryptoX509CRL* copy = new OpenSSLCryptoX509CRL(); + copy->mp_X509CRL = X509_CRL_dup(mp_X509CRL); + copy->m_DERX509CRL = m_DERX509CRL; + return copy; +} diff --git a/xmltooling/signature/ContentReference.h b/xmltooling/signature/ContentReference.h index c093d69..a24c9d0 100644 --- a/xmltooling/signature/ContentReference.h +++ b/xmltooling/signature/ContentReference.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007 Internet2 + * Copyright 2001-2009 Internet2 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,22 +17,17 @@ /** * @file xmltooling/signature/ContentReference.h * - * Interface for creating signature references + * Interface for creating signature references. */ #if !defined(__xmltooling_sigref_h__) && !defined(XMLTOOLING_NO_XMLSEC) #define __xmltooling_sigref_h__ -#include -#include +#include -#if defined (_MSC_VER) - #pragma warning( push ) - #pragma warning( disable : 4250 4251 ) -#endif +class DSIGSignature; namespace xmlsignature { - /** * Interface for creating signature references based on application requirements. */ @@ -50,13 +45,9 @@ namespace xmlsignature { virtual void createReferences(DSIGSignature* sig)=0; protected: + /** Default constructor. */ ContentReference() {} }; - }; -#if defined (_MSC_VER) - #pragma warning( pop ) -#endif - #endif /* __xmltooling_sigref_h__ */ diff --git a/xmltooling/signature/Signature.h b/xmltooling/signature/Signature.h index 77aabda..58b5570 100644 --- a/xmltooling/signature/Signature.h +++ b/xmltooling/signature/Signature.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007 Internet2 + * Copyright 2001-2009 Internet2 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,10 +25,9 @@ #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; /** @@ -194,13 +194,14 @@ namespace xmlsignature { ); protected: + /** 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 @@ -222,21 +223,7 @@ namespace xmlsignature { virtual xmltooling::XMLObject* buildObject() const; #endif /** Singleton builder. */ - static Signature* buildSignature() { - const SignatureBuilder* b = dynamic_cast( - xmltooling::XMLObjectBuilder::getBuilder( - xmltooling::QName(xmlconstants::XMLSIG_NS,Signature::LOCAL_NAME) - ) - ); - if (b) { -#ifdef HAVE_COVARIANT_RETURNS - return b->buildObject(); -#else - return dynamic_cast(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); diff --git a/xmltooling/signature/SignatureValidator.h b/xmltooling/signature/SignatureValidator.h index 61fc5ca..e948e40 100644 --- a/xmltooling/signature/SignatureValidator.h +++ b/xmltooling/signature/SignatureValidator.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007 Internet2 + * Copyright 2001-2009 Internet2 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,12 +23,18 @@ #if !defined(__xmltooling_sigval_h__) && !defined(XMLTOOLING_NO_XMLSEC) #define __xmltooling_sigval_h__ -#include -#include #include +class XSECCryptoKey; + +namespace xmltooling { + class XMLTOOL_API Credential; +}; + namespace xmlsignature { + class XMLTOOL_API Signature; + /** * Validator for signatures based on a Credential */ @@ -40,18 +46,18 @@ namespace xmlsignature { * * @param key the key to use */ - SignatureValidator(XSECCryptoKey* key=NULL) : m_key(key), m_credential(NULL) {} + SignatureValidator(XSECCryptoKey* key=NULL); /** * Constructor using a Credential * * @param credential the credential to use */ - SignatureValidator(const xmltooling::Credential* credential) : m_key(NULL), m_credential(credential) {} + SignatureValidator(const xmltooling::Credential* credential); virtual ~SignatureValidator() {} - virtual void validate(const xmltooling::XMLObject* xmlObject) const; + void validate(const xmltooling::XMLObject* xmlObject) const; /** * Type-safe validator. @@ -65,20 +71,14 @@ namespace xmlsignature { * * @param key the key to attach */ - void setKey(XSECCryptoKey* key) { - m_key = key; - m_credential = NULL; - } + void setKey(XSECCryptoKey* key); /** * Replace the current Credential, if any, with a new one. * * @param credential the Credential to attach */ - void setCredential(const xmltooling::Credential* credential) { - m_key = NULL; - m_credential = credential; - } + void setCredential(const xmltooling::Credential* credential); protected: /** Verification key. */ diff --git a/xmltooling/signature/impl/SignatureValidator.cpp b/xmltooling/signature/impl/SignatureValidator.cpp index 667a439..4c7df2b 100644 --- a/xmltooling/signature/impl/SignatureValidator.cpp +++ b/xmltooling/signature/impl/SignatureValidator.cpp @@ -21,6 +21,8 @@ */ #include "internal.h" +#include "security/Credential.h" +#include "signature/Signature.h" #include "signature/SignatureValidator.h" #include @@ -30,6 +32,26 @@ using namespace xmlsignature; using namespace xmltooling; using namespace std; +SignatureValidator::SignatureValidator(XSECCryptoKey* key) : m_key(key), m_credential(NULL) +{ +} + +SignatureValidator::SignatureValidator(const Credential* credential) : m_key(NULL), m_credential(credential) +{ +} + +void SignatureValidator::setKey(XSECCryptoKey* key) +{ + m_key = key; + m_credential = NULL; +} + +void SignatureValidator::setCredential(const Credential* credential) +{ + m_key = NULL; + m_credential = credential; +} + void SignatureValidator::validate(const XMLObject* xmlObject) const { const Signature* sigObj=dynamic_cast(xmlObject); diff --git a/xmltooling/signature/impl/XMLSecSignatureImpl.cpp b/xmltooling/signature/impl/XMLSecSignatureImpl.cpp index f3072c6..1ef0838 100644 --- a/xmltooling/signature/impl/XMLSecSignatureImpl.cpp +++ b/xmltooling/signature/impl/XMLSecSignatureImpl.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2001-2007 Internet2 +* Copyright 2001-2009 Internet2 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ #include "logging.h" #include "impl/UnknownElement.h" #include "security/Credential.h" +#include "signature/ContentReference.h" #include "signature/KeyInfo.h" #include "signature/Signature.h" #include "util/NDC.h" @@ -451,6 +452,20 @@ SignatureBuilder::buildObject() const return new XMLSecSignatureImpl(); } +Signature* SignatureBuilder::buildSignature() { + const SignatureBuilder* b = dynamic_cast( + XMLObjectBuilder::getBuilder(xmltooling::QName(xmlconstants::XMLSIG_NS,Signature::LOCAL_NAME)) + ); + if (b) { +#ifdef HAVE_COVARIANT_RETURNS + return b->buildObject(); +#else + return dynamic_cast(b->buildObject()); +#endif + } + throw XMLObjectException("Unable to obtain typed builder for Signature."); +} + const XMLCh Signature::LOCAL_NAME[] = UNICODE_LITERAL_9(S,i,g,n,a,t,u,r,e); // Raw signature methods. diff --git a/xmltooling/util/NDC.h b/xmltooling/util/NDC.h index b280984..8363a34 100644 --- a/xmltooling/util/NDC.h +++ b/xmltooling/util/NDC.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007 Internet2 + * Copyright 2001-2009 Internet2 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,9 +23,10 @@ #ifndef __xmltooling_ndc_h__ #define __xmltooling_ndc_h__ -#include #include +#include + namespace xmltooling { /** @@ -33,6 +34,7 @@ namespace xmltooling { */ class XMLTOOL_API NDC { + MAKE_NONCOPYABLE(NDC); public: /** * Constructor pushes logging context onto diagnostic stack @@ -50,8 +52,6 @@ namespace xmltooling { * Destructor pops context off of diagnostic stack */ ~NDC(); - - MAKE_NONCOPYABLE(NDC); }; }; diff --git a/xmltooling/util/PathResolver.cpp b/xmltooling/util/PathResolver.cpp index e25000f..ff69c40 100644 --- a/xmltooling/util/PathResolver.cpp +++ b/xmltooling/util/PathResolver.cpp @@ -36,6 +36,18 @@ PathResolver::PathResolver() : m_defaultPackage(PACKAGE_NAME), m_defaultPrefix(" setCfgDir("/etc"); } +bool PathResolver::isAbsolute(const char* s) const +{ + switch (*s) { + case '/': + case '\\': + return true; + case '.': + return (*(s+1) == '.' || *(s+1) == '/' || *(s+1) == '\\'); + } + return *(s+1) == ':'; +} + const string& PathResolver::resolve(string& s, file_type_t filetype, const char* pkgname, const char* prefix) const { if (!isAbsolute(s.c_str())) { diff --git a/xmltooling/util/PathResolver.h b/xmltooling/util/PathResolver.h index 4f12ee8..80ce6c4 100644 --- a/xmltooling/util/PathResolver.h +++ b/xmltooling/util/PathResolver.h @@ -128,16 +128,7 @@ namespace xmltooling { virtual const std::string& resolve(std::string& s, file_type_t filetype, const char* pkgname=NULL, const char* prefix=NULL) const; private: - bool isAbsolute(const char* s) const { - switch (*s) { - case '/': - case '\\': - return true; - case '.': - return (*(s+1) == '.' || *(s+1) == '/' || *(s+1) == '\\'); - } - return *(s+1) == ':'; - } + bool isAbsolute(const char* s) const; std::string m_defaultPackage,m_defaultPrefix,m_lib,m_log,m_xml,m_run,m_cfg; }; diff --git a/xmltooling/util/ReloadableXMLFile.cpp b/xmltooling/util/ReloadableXMLFile.cpp index a28ff5b..0ea5ca5 100644 --- a/xmltooling/util/ReloadableXMLFile.cpp +++ b/xmltooling/util/ReloadableXMLFile.cpp @@ -51,6 +51,12 @@ static const XMLCh reloadChanges[] = UNICODE_LITERAL_13(r,e,l,o,a,d,C,h,a,n,g static const XMLCh reloadInterval[] = UNICODE_LITERAL_14(r,e,l,o,a,d,I,n,t,e,r,v,a,l); static const XMLCh backingFilePath[] = UNICODE_LITERAL_15(b,a,c,k,i,n,g,F,i,l,e,P,a,t,h); + +ReloadableXMLFile::~ReloadableXMLFile() +{ + delete m_lock; +} + ReloadableXMLFile::ReloadableXMLFile(const DOMElement* e, Category& log) : m_root(e), m_local(true), m_validate(false), m_filestamp(0), m_reloadInterval(0), m_lock(NULL), m_log(log) { @@ -284,3 +290,14 @@ Lockable* ReloadableXMLFile::lock() m_lock->rdlock(); return this; } + +void ReloadableXMLFile::unlock() +{ + if (m_lock) + m_lock->unlock(); +} + +pair ReloadableXMLFile::load() +{ + return load(false); +} diff --git a/xmltooling/util/ReloadableXMLFile.h b/xmltooling/util/ReloadableXMLFile.h index d8dda9e..fb66882 100644 --- a/xmltooling/util/ReloadableXMLFile.h +++ b/xmltooling/util/ReloadableXMLFile.h @@ -25,7 +25,6 @@ #include #include -#include #include #include @@ -33,13 +32,14 @@ namespace xmltooling { + class XMLTOOL_API RWLock; + /** * Base class for file-based XML configuration. */ class XMLTOOL_API ReloadableXMLFile : protected virtual Lockable { - MAKE_NONCOPYABLE(ReloadableXMLFile); - + MAKE_NONCOPYABLE(ReloadableXMLFile); protected: /** * Constructor taking a DOM element supporting the following content: @@ -64,9 +64,7 @@ namespace xmltooling { */ ReloadableXMLFile(const xercesc::DOMElement* e, logging::Category& log); - virtual ~ReloadableXMLFile() { - delete m_lock; - } + virtual ~ReloadableXMLFile(); /** * Loads configuration material. @@ -78,9 +76,7 @@ namespace xmltooling { * @return a pair consisting of a flag indicating whether to take ownership of * the document, and the root element of the tree to load */ - virtual std::pair load() { - return load(false); - } + virtual std::pair load(); /** Root of the original DOM element passed into constructor. */ const xercesc::DOMElement* m_root; @@ -111,11 +107,7 @@ namespace xmltooling { public: Lockable* lock(); - - void unlock() { - if (m_lock) - m_lock->unlock(); - } + void unlock(); private: std::pair load(bool backup); diff --git a/xmltooling/util/ReplayCache.cpp b/xmltooling/util/ReplayCache.cpp index 7d21b7a..7b53891 100644 --- a/xmltooling/util/ReplayCache.cpp +++ b/xmltooling/util/ReplayCache.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007 Internet2 + * Copyright 2001-2009 Internet2 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ #include "internal.h" #include "util/ReplayCache.h" +#include "util/StorageService.h" using namespace xmltooling; using namespace std; diff --git a/xmltooling/util/ReplayCache.h b/xmltooling/util/ReplayCache.h index 7cbc367..0f0d6e2 100644 --- a/xmltooling/util/ReplayCache.h +++ b/xmltooling/util/ReplayCache.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007 Internet2 + * Copyright 2001-2009 Internet2 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,16 +23,18 @@ #if !defined(__xmltooling_replay_h__) && !defined(XMLTOOLING_LITE) #define __xmltooling_replay_h__ -#include +#include namespace xmltooling { + class XMLTOOL_API StorageService; + /** * Helper class on top of StorageService for detecting message replay. */ class XMLTOOL_API ReplayCache { - MAKE_NONCOPYABLE(ReplayCache); + MAKE_NONCOPYABLE(ReplayCache); public: /** diff --git a/xmltooling/util/StorageService.h b/xmltooling/util/StorageService.h index 3c82ea7..2948b8e 100644 --- a/xmltooling/util/StorageService.h +++ b/xmltooling/util/StorageService.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007 Internet2 + * Copyright 2001-2009 Internet2 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,13 +17,13 @@ /** * @file xmltooling/util/StorageService.h * - * Generic data storage interface + * Generic data storage interface. */ #if !defined(__xmltooling_storage_h__) && !defined(XMLTOOLING_LITE) #define __xmltooling_storage_h__ -#include +#include #include diff --git a/xmltooling/util/TemplateEngine.cpp b/xmltooling/util/TemplateEngine.cpp index 1e86975..4062fca 100644 --- a/xmltooling/util/TemplateEngine.cpp +++ b/xmltooling/util/TemplateEngine.cpp @@ -21,6 +21,7 @@ */ #include "internal.h" +#include "io/GenericRequest.h" #include "util/TemplateEngine.h" using namespace xmltooling; @@ -30,6 +31,18 @@ namespace { static const pair emptyPair; } +const char* TemplateEngine::TemplateParameters::getParameter(const char* name) const +{ + map::const_iterator i=m_map.find(name); + return (i!=m_map.end() ? i->second.c_str() : (m_request ? m_request->getParameter(name) : NULL)); +} + +const multimap* TemplateEngine::TemplateParameters::getLoopCollection(const char* name) const +{ + map< string,multimap >::const_iterator i=m_collectionMap.find(name); + return (i!=m_collectionMap.end() ? &(i->second) : NULL); +} + void TemplateEngine::setTagPrefix(const char* tagPrefix) { keytag = string("<") + tagPrefix + " "; diff --git a/xmltooling/util/TemplateEngine.h b/xmltooling/util/TemplateEngine.h index 2349b1e..a501f62 100644 --- a/xmltooling/util/TemplateEngine.h +++ b/xmltooling/util/TemplateEngine.h @@ -23,7 +23,7 @@ #ifndef __xmltooling_template_h__ #define __xmltooling_template_h__ -#include +#include #include #include @@ -37,6 +37,8 @@ namespace xmltooling { + class XMLTOOL_API GenericRequest; + /** * Simple template replacement engine. Supports the following: *
    @@ -53,8 +55,9 @@ namespace xmltooling { */ class XMLTOOL_API TemplateEngine { - MAKE_NONCOPYABLE(TemplateEngine); + MAKE_NONCOPYABLE(TemplateEngine); public: + /** Default constructor. */ TemplateEngine() { setTagPrefix("mlp"); } @@ -73,7 +76,6 @@ namespace xmltooling { * Allows callers to supply a more dynamic lookup mechanism to supplement a basic map. */ class XMLTOOL_API TemplateParameters { - // MAKE_NONCOPYABLE(TemplateParameters); public: TemplateParameters() : m_request(NULL) {} virtual ~TemplateParameters() {} @@ -93,10 +95,7 @@ namespace xmltooling { * @param name name of parameter * @return value of parameter, or NULL */ - virtual const char* getParameter(const char* name) const { - std::map::const_iterator i=m_map.find(name); - return (i!=m_map.end() ? i->second.c_str() : (m_request ? m_request->getParameter(name) : NULL)); - } + virtual const char* getParameter(const char* name) const; /** * Returns a named collection of sub-parameters to pass into a loop. @@ -104,10 +103,7 @@ namespace xmltooling { * @param name name of sub-collection * @return pointer to a multimap of sub-parameters, or NULL */ - virtual const std::multimap* getLoopCollection(const char* name) const { - std::map< std::string,std::multimap >::const_iterator i=m_collectionMap.find(name); - return (i!=m_collectionMap.end() ? &(i->second) : NULL); - } + virtual const std::multimap* getLoopCollection(const char* name) const; }; /** diff --git a/xmltooling/util/Threads.h b/xmltooling/util/Threads.h index e3eee29..e75f9b5 100644 --- a/xmltooling/util/Threads.h +++ b/xmltooling/util/Threads.h @@ -23,7 +23,6 @@ #ifndef _xmltooling_threads_h #define _xmltooling_threads_h -#include #include #include diff --git a/xmltooling/util/URLEncoder.cpp b/xmltooling/util/URLEncoder.cpp index 55a8187..88e316c 100644 --- a/xmltooling/util/URLEncoder.cpp +++ b/xmltooling/util/URLEncoder.cpp @@ -75,3 +75,9 @@ string URLEncoder::encode(const char* s) const } return ret; } + +bool URLEncoder::isBad(char ch) const +{ + static char badchars[]="=&/?:\"\\+<>#%{}|^~[],`;@"; + return (ch<=0x20 || ch>=0x7F || strchr(badchars,ch)); +} diff --git a/xmltooling/util/URLEncoder.h b/xmltooling/util/URLEncoder.h index ec4bba6..f07080a 100644 --- a/xmltooling/util/URLEncoder.h +++ b/xmltooling/util/URLEncoder.h @@ -17,8 +17,7 @@ /** * @file xmltooling/util/URLEncoder.h * - * Interface to a URL-encoding mechanism along with a - * default implementation. + * Interface to a URL-encoding mechanism along with a default implementation. */ #ifndef __xmltool_urlenc_h__ @@ -38,7 +37,9 @@ namespace xmltooling { class XMLTOOL_API URLEncoder { MAKE_NONCOPYABLE(URLEncoder); public: + /** Default constructor. */ URLEncoder() {} + virtual ~URLEncoder() {} /** @@ -64,10 +65,7 @@ namespace xmltooling { * @param ch the character to check * @return true iff the character should be encoded */ - virtual bool isBad(char ch) const { - static char badchars[]="=&/?:\"\\+<>#%{}|^~[],`;@"; - return (ch<=0x20 || ch>=0x7F || strchr(badchars,ch)); - } + virtual bool isBad(char ch) const; }; }; diff --git a/xmltooling/util/XMLHelper.cpp b/xmltooling/util/XMLHelper.cpp index 87a165c..9ebde32 100644 --- a/xmltooling/util/XMLHelper.cpp +++ b/xmltooling/util/XMLHelper.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007 Internet2 + * Copyright 2001-2009 Internet2 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,8 @@ #include "internal.h" #include "exceptions.h" +#include "QName.h" +#include "XMLObject.h" #include "util/XMLHelper.h" #include "util/XMLConstants.h" @@ -269,9 +271,9 @@ void XMLHelper::serialize(const DOMNode* n, std::string& buf, bool pretty) XercesJanitor janitor(serializer); if (pretty && serializer->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, pretty)) serializer->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, pretty); - DOMLSOutput *theOutput = static_cast(impl)->createLSOutput(); - XercesJanitor j_theOutput(theOutput); - theOutput->setEncoding(UTF8); + DOMLSOutput *theOutput = static_cast(impl)->createLSOutput(); + XercesJanitor j_theOutput(theOutput); + theOutput->setEncoding(UTF8); theOutput->setByteStream(&target); if (!serializer->write(n, theOutput)) throw XMLParserException("unable to serialize XML"); @@ -322,9 +324,9 @@ ostream& XMLHelper::serialize(const DOMNode* n, ostream& out, bool pretty) XercesJanitor janitor(serializer); if (pretty && serializer->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, pretty)) serializer->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, pretty); - DOMLSOutput *theOutput = static_cast(impl)->createLSOutput(); - XercesJanitor j_theOutput(theOutput); - theOutput->setEncoding(UTF8); + DOMLSOutput *theOutput = static_cast(impl)->createLSOutput(); + XercesJanitor j_theOutput(theOutput); + theOutput->setEncoding(UTF8); theOutput->setByteStream(&target); if (!serializer->write(n, theOutput)) throw XMLParserException("unable to serialize XML"); diff --git a/xmltooling/util/XMLHelper.h b/xmltooling/util/XMLHelper.h index 08a4e80..81c86c4 100644 --- a/xmltooling/util/XMLHelper.h +++ b/xmltooling/util/XMLHelper.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007 Internet2 + * Copyright 2001-2009 Internet2 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,13 +23,16 @@ #ifndef __xmltooling_xmlhelper_h__ #define __xmltooling_xmlhelper_h__ -#include -#include +#include #include +#include namespace xmltooling { + class XMLTOOL_API QName; + class XMLTOOL_API XMLObject; + /** * RAII wrapper for Xerces resources. */ diff --git a/xmltoolingtest/SecurityHelperTest.h b/xmltoolingtest/SecurityHelperTest.h index 6d57690..e5812a6 100644 --- a/xmltoolingtest/SecurityHelperTest.h +++ b/xmltoolingtest/SecurityHelperTest.h @@ -18,6 +18,9 @@ #include +#include +#include + class SecurityHelperTest : public CxxTest::TestSuite { vector certs; diff --git a/xmltoolingtest/SignatureTest.h b/xmltoolingtest/SignatureTest.h index 138ce55..93d6c3b 100644 --- a/xmltoolingtest/SignatureTest.h +++ b/xmltoolingtest/SignatureTest.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007 Internet2 + * Copyright 2001-2009 Internet2 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,12 +19,14 @@ #include #include #include +#include #include #include #include #include #include +#include class TestContext : public ContentReference {