Reducing header overuse, non-inlining selected methods (CPPOST-35).
authorScott Cantor <cantor.2@osu.edu>
Sat, 26 Sep 2009 03:38:36 +0000 (03:38 +0000)
committerScott Cantor <cantor.2@osu.edu>
Sat, 26 Sep 2009 03:38:36 +0000 (03:38 +0000)
36 files changed:
xmltooling/AbstractAttributeExtensibleXMLObject.h
xmltooling/exceptions.h
xmltooling/security/ChainingTrustEngine.h
xmltooling/security/CredentialCriteria.h
xmltooling/security/KeyInfoCredentialContext.h
xmltooling/security/KeyInfoResolver.h
xmltooling/security/OpenSSLCryptoX509CRL.h
xmltooling/security/SecurityHelper.h
xmltooling/security/impl/AbstractPKIXTrustEngine.cpp
xmltooling/security/impl/ChainingCredentialResolver.cpp
xmltooling/security/impl/ChainingTrustEngine.cpp
xmltooling/security/impl/CredentialCriteria.cpp
xmltooling/security/impl/ExplicitKeyTrustEngine.cpp
xmltooling/security/impl/OpenSSLCryptoX509CRL.cpp
xmltooling/signature/ContentReference.h
xmltooling/signature/Signature.h
xmltooling/signature/SignatureValidator.h
xmltooling/signature/impl/SignatureValidator.cpp
xmltooling/signature/impl/XMLSecSignatureImpl.cpp
xmltooling/util/NDC.h
xmltooling/util/PathResolver.cpp
xmltooling/util/PathResolver.h
xmltooling/util/ReloadableXMLFile.cpp
xmltooling/util/ReloadableXMLFile.h
xmltooling/util/ReplayCache.cpp
xmltooling/util/ReplayCache.h
xmltooling/util/StorageService.h
xmltooling/util/TemplateEngine.cpp
xmltooling/util/TemplateEngine.h
xmltooling/util/Threads.h
xmltooling/util/URLEncoder.cpp
xmltooling/util/URLEncoder.h
xmltooling/util/XMLHelper.cpp
xmltooling/util/XMLHelper.h
xmltoolingtest/SecurityHelperTest.h
xmltoolingtest/SignatureTest.h

index 49372ce..9698e5b 100644 (file)
@@ -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.
 #ifndef __xmltooling_absattrextxmlobj_h__
 #define __xmltooling_absattrextxmlobj_h__
 
-#include <map>
 #include <xmltooling/AbstractXMLObject.h>
 #include <xmltooling/AttributeExtensibleXMLObject.h>
 
+#include <map>
+
 #if defined (_MSC_VER)
     #pragma warning( push )
     #pragma warning( disable : 4250 4251 )
index 43b17fb..7ed53d7 100644 (file)
@@ -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.
 /**
  * @file xmltooling/exceptions.h
  * 
- * Exception classes
+ * Exception classes.
  */
  
 #ifndef __xmltooling_exceptions_h__
 #define __xmltooling_exceptions_h__
 
+#include <xmltooling/base.h>
+
 #include <map>
 #include <string>
 #include <vector>
 #include <iostream>
-#include <xmltooling/base.h>
 
 /**
  * Declares a derived exception class
index bd97ac9..696e539 100644 (file)
@@ -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<TrustEngine*>::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,
index 4011bba..bb75ef1 100644 (file)
 #if !defined(__xmltooling_credcrit_h__) && !defined(XMLTOOLING_NO_XMLSEC)
 #define __xmltooling_credcrit_h__
 
-#include <xmltooling/XMLToolingConfig.h>
-#include <xmltooling/security/KeyInfoResolver.h>
-#include <xmltooling/security/Credential.h>
-#include <xmltooling/signature/KeyInfo.h>
-#include <xmltooling/signature/Signature.h>
+#include <xmltooling/base.h>
 
 #include <set>
-#include <xsec/dsig/DSIGKeyInfoList.hpp>
-#include <xsec/dsig/DSIGKeyInfoName.hpp>
+
+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<const char*,unsigned int> 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.
index 31bcc0e..589d2cf 100644 (file)
@@ -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 <xmltooling/security/CredentialContext.h>
-#include <xmltooling/signature/Signature.h>
-#include <xsec/dsig/DSIGKeyInfoList.hpp>
+
+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) {
         }
index bb74477..b2f5350 100644 (file)
@@ -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.
 #if !defined(__xmltooling_keyres_h__) && !defined(XMLTOOLING_NO_XMLSEC)
 #define __xmltooling_keyres_h__
 
-#include <xmltooling/security/Credential.h>
-#include <xmltooling/security/KeyInfoCredentialContext.h>
+#include <xmltooling/base.h>
 
-#include <xsec/dsig/DSIGKeyInfoList.hpp>
+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.
index 55b40a6..fd243ae 100644 (file)
@@ -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 <xmltooling/security/XSECCryptoX509CRL.h>
 
-#include <openssl/bio.h>
 #include <openssl/x509v3.h>
 #include <xsec/utils/XSECSafeBuffer.hpp>
 
@@ -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;
index 3dfe9e8..3b69ada 100644 (file)
 #if !defined(__xmltooling_sechelper_h__) && !defined(XMLTOOLING_NO_XMLSEC)
 #define __xmltooling_sechelper_h__
 
-#include <xmltooling/security/XSECCryptoX509CRL.h>
-#include <xmltooling/soap/SOAPTransport.h>
+#include <xmltooling/base.h>
 
 #include <vector>
-#include <xsec/enc/XSECCryptoKey.hpp>
-#include <xsec/enc/XSECCryptoX509.hpp>
+
+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.
index e718cb8..a20f034 100644 (file)
@@ -25,6 +25,7 @@
 #include "logging.h"
 #include "security/AbstractPKIXTrustEngine.h"
 #include "signature/KeyInfo.h"
+#include "signature/Signature.h"
 
 #include <openssl/x509_vfy.h>
 #include <openssl/x509v3.h>
index abbe6b2..cc8e5a0 100644 (file)
@@ -27,6 +27,7 @@
 #include "util/NDC.h"
 #include "util/XMLHelper.h"
 
+#include <algorithm>
 #include <xercesc/util/XMLUniDefs.hpp>
 
 using namespace xmltooling::logging;
index 358d3b9..dbf9cc7 100644 (file)
@@ -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 <algorithm>
 #include <xercesc/util/XMLUniDefs.hpp>
 
 using namespace xmlsignature;
@@ -77,6 +78,22 @@ ChainingTrustEngine::~ChainingTrustEngine() {
     for_each(m_engines.begin(), m_engines.end(), xmltooling::cleanup<TrustEngine>());
 }
 
+void ChainingTrustEngine::addTrustEngine(TrustEngine* newEngine)
+{
+    m_engines.push_back(newEngine);
+}
+
+TrustEngine* ChainingTrustEngine::removeTrustEngine(TrustEngine* oldEngine)
+{
+    for (vector<TrustEngine*>::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<SignatureTrustEngine*>::const_iterator i=m_sigEngines.begin(); i!=m_sigEngines.end(); ++i) {
index e584c9e..12a6993 100644 (file)
 
 #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 <openssl/dsa.h>
 #include <openssl/rsa.h>
+#include <xsec/dsig/DSIGKeyInfoList.hpp>
 #include <xsec/enc/OpenSSL/OpenSSLCryptoKeyDSA.hpp>
 #include <xsec/enc/OpenSSL/OpenSSLCryptoKeyRSA.hpp>
 
 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<const char*,unsigned int> 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;
index 0cdb78a..21af839 100644 (file)
@@ -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"
 
index e5c594e..fc8f7c6 100644 (file)
@@ -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;
+}
index c093d69..a24c9d0 100644 (file)
@@ -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.
 /**
  * @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 <vector>
-#include <xsec/dsig/DSIGSignature.hpp>
+#include <xmltooling/base.h>
 
-#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__ */
index 77aabda..58b5570 100644 (file)
@@ -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.
 
 #include <xmltooling/ConcreteXMLObjectBuilder.h>
 #include <xmltooling/exceptions.h>
-#include <xmltooling/signature/ContentReference.h>
-#include <xmltooling/util/XMLConstants.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;
 
     /**
@@ -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<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);
index 61fc5ca..e948e40 100644 (file)
@@ -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.
 #if !defined(__xmltooling_sigval_h__) && !defined(XMLTOOLING_NO_XMLSEC)
 #define __xmltooling_sigval_h__
 
-#include <xmltooling/security/Credential.h>
-#include <xmltooling/signature/Signature.h>
 #include <xmltooling/validation/Validator.h>
 
+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. */
index 667a439..4c7df2b 100644 (file)
@@ -21,6 +21,8 @@
  */
  
 #include "internal.h"
+#include "security/Credential.h"
+#include "signature/Signature.h"
 #include "signature/SignatureValidator.h"
 
 #include <xsec/enc/XSECCryptoException.hpp>
@@ -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<const Signature*>(xmlObject);
index f3072c6..1ef0838 100644 (file)
@@ -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<const SignatureBuilder*>(
+        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 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.
index b280984..8363a34 100644 (file)
@@ -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.
 #ifndef __xmltooling_ndc_h__
 #define __xmltooling_ndc_h__
 
-#include <string>
 #include <xmltooling/base.h>
 
+#include <string>
+
 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);
     };
 
 };
index e25000f..ff69c40 100644 (file)
@@ -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())) {
index 4f12ee8..80ce6c4 100644 (file)
@@ -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;
     };
index a28ff5b..0ea5ca5 100644 (file)
@@ -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);\r
 static const XMLCh backingFilePath[] =  UNICODE_LITERAL_15(b,a,c,k,i,n,g,F,i,l,e,P,a,t,h);\r
 \r
+
+ReloadableXMLFile::~ReloadableXMLFile()
+{
+    delete m_lock;
+}
+\r
 ReloadableXMLFile::ReloadableXMLFile(const DOMElement* e, Category& log)\r
     : m_root(e), m_local(true), m_validate(false), m_filestamp(0), m_reloadInterval(0), m_lock(NULL), m_log(log)\r
 {\r
@@ -284,3 +290,14 @@ Lockable* ReloadableXMLFile::lock()
     m_lock->rdlock();\r
     return this;\r
 }\r
+\r
+void ReloadableXMLFile::unlock()
+{
+    if (m_lock)
+        m_lock->unlock();
+}
+\r
+pair<bool,DOMElement*> ReloadableXMLFile::load()
+{
+    return load(false);
+}
index d8dda9e..fb66882 100644 (file)
@@ -25,7 +25,6 @@
 
 #include <xmltooling/logging.h>
 #include <xmltooling/Lockable.h>
-#include <xmltooling/util/Threads.h>
 
 #include <ctime>
 #include <string>
 
 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<bool,xercesc::DOMElement*> load() {
-            return load(false);
-        }
+        virtual std::pair<bool,xercesc::DOMElement*> 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<bool,xercesc::DOMElement*> load(bool backup);
index 7d21b7a..7b53891 100644 (file)
@@ -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;
index 7cbc367..0f0d6e2 100644 (file)
@@ -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.
 #if !defined(__xmltooling_replay_h__) && !defined(XMLTOOLING_LITE)
 #define __xmltooling_replay_h__
 
-#include <xmltooling/util/StorageService.h>
+#include <xmltooling/base.h>
 
 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:
         
         /**
index 3c82ea7..2948b8e 100644 (file)
@@ -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.
 /**
  * @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 <xmltooling/XMLObject.h>
+#include <xmltooling/base.h>
 
 #include <ctime>
 
index 1e86975..4062fca 100644 (file)
@@ -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<const string,string> emptyPair;
 }
 
+const char* TemplateEngine::TemplateParameters::getParameter(const char* name) const
+{
+    map<string,string>::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<string,string>* TemplateEngine::TemplateParameters::getLoopCollection(const char* name) const
+{
+    map< string,multimap<string,string> >::const_iterator i=m_collectionMap.find(name);
+    return (i!=m_collectionMap.end() ? &(i->second) : NULL);
+}
+
 void TemplateEngine::setTagPrefix(const char* tagPrefix)
 {
     keytag = string("<") + tagPrefix + " ";
index 2349b1e..a501f62 100644 (file)
@@ -23,7 +23,7 @@
 #ifndef __xmltooling_template_h__
 #define __xmltooling_template_h__
 
-#include <xmltooling/io/GenericRequest.h>
+#include <xmltooling/base.h>
 
 #include <map>
 #include <string>
@@ -37,6 +37,8 @@
 
 namespace xmltooling {
 
+    class XMLTOOL_API GenericRequest;
+
     /**
      * Simple template replacement engine. Supports the following:
      * <ul>
@@ -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<std::string,std::string>::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<std::string,std::string>* getLoopCollection(const char* name) const {
-                std::map< std::string,std::multimap<std::string,std::string> >::const_iterator i=m_collectionMap.find(name);
-                return (i!=m_collectionMap.end() ? &(i->second) : NULL);
-            }
+            virtual const std::multimap<std::string,std::string>* getLoopCollection(const char* name) const;
         };
 
         /**
index e3eee29..e75f9b5 100644 (file)
@@ -23,7 +23,6 @@
 #ifndef _xmltooling_threads_h
 #define _xmltooling_threads_h
 
-#include <xmltooling/base.h>
 #include <xmltooling/exceptions.h>
 
 #include <signal.h>
index 55a8187..88e316c 100644 (file)
@@ -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));
+}
index ec4bba6..f07080a 100644 (file)
@@ -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;
     };
 };
 
index 87a165c..9ebde32 100644 (file)
@@ -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<DOMLSSerializer> janitor(serializer);
     if (pretty && serializer->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, pretty))
         serializer->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, pretty);
-    DOMLSOutput *theOutput = static_cast<DOMImplementationLS*>(impl)->createLSOutput();\r
-    XercesJanitor<DOMLSOutput> j_theOutput(theOutput);\r
-    theOutput->setEncoding(UTF8);\r
+    DOMLSOutput *theOutput = static_cast<DOMImplementationLS*>(impl)->createLSOutput();
+    XercesJanitor<DOMLSOutput> 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<DOMLSSerializer> janitor(serializer);
     if (pretty && serializer->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, pretty))
         serializer->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, pretty);
-    DOMLSOutput *theOutput = static_cast<DOMImplementationLS*>(impl)->createLSOutput();\r
-    XercesJanitor<DOMLSOutput> j_theOutput(theOutput);\r
-    theOutput->setEncoding(UTF8);\r
+    DOMLSOutput *theOutput = static_cast<DOMImplementationLS*>(impl)->createLSOutput();
+    XercesJanitor<DOMLSOutput> j_theOutput(theOutput);
+    theOutput->setEncoding(UTF8);
     theOutput->setByteStream(&target);
     if (!serializer->write(n, theOutput))
         throw XMLParserException("unable to serialize XML");
index 08a4e80..81c86c4 100644 (file)
@@ -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.
 #ifndef __xmltooling_xmlhelper_h__
 #define __xmltooling_xmlhelper_h__
 
-#include <xmltooling/XMLObject.h>
-#include <xercesc/dom/DOM.hpp>
+#include <xmltooling/base.h>
 
 #include <iostream>
+#include <xercesc/dom/DOM.hpp>
 
 namespace xmltooling {
 
+    class XMLTOOL_API QName;
+    class XMLTOOL_API XMLObject;
+
     /**
      * RAII wrapper for Xerces resources.
      */
index 6d57690..e5812a6 100644 (file)
@@ -18,6 +18,9 @@
 
 #include <xmltooling/security/SecurityHelper.h>
 
+#include <xsec/enc/XSECCryptoKey.hpp>
+#include <xsec/enc/XSECCryptoX509.hpp>
+
 class SecurityHelperTest : public CxxTest::TestSuite {
     vector<XSECCryptoX509*> certs;
 
index 138ce55..93d6c3b 100644 (file)
@@ -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.
 #include <xmltooling/security/Credential.h>
 #include <xmltooling/security/CredentialCriteria.h>
 #include <xmltooling/security/CredentialResolver.h>
+#include <xmltooling/signature/ContentReference.h>
 #include <xmltooling/signature/KeyInfo.h>
 #include <xmltooling/signature/SignatureValidator.h>
 
 #include <fstream>
 #include <xercesc/util/XMLUniDefs.hpp>
 #include <xsec/dsig/DSIGReference.hpp>
+#include <xsec/dsig/DSIGSignature.hpp>
 
 class TestContext : public ContentReference
 {