From 1ffcb743f90aeb3da11054316f3d005ff7edbf7b Mon Sep 17 00:00:00 2001 From: Scott Cantor Date: Fri, 13 Oct 2006 19:15:51 +0000 Subject: [PATCH] Fix linefeeds --- saml/SAMLConfig.h | 426 +- saml/binding/ArtifactMap.h | 176 +- saml/binding/MessageDecoder.h | 548 +-- saml/binding/MessageEncoder.h | 342 +- saml/binding/SAMLArtifact.h | 316 +- saml/binding/URLEncoder.h | 148 +- saml/encryption/EncryptedKeyResolver.cpp | 74 +- saml/encryption/EncryptedKeyResolver.h | 124 +- saml/saml1/binding/SAMLArtifactType0001.h | 194 +- saml/saml1/binding/SAMLArtifactType0002.h | 168 +- saml/saml2/binding/SAML2Artifact.h | 122 +- saml/saml2/binding/SAML2ArtifactType0004.h | 198 +- saml/saml2/core/impl/Protocols20Impl.cpp | 4082 ++++++++++---------- saml/saml2/metadata/ChainingMetadataProvider.h | 202 +- .../metadata/impl/ChainingMetadataProvider.cpp | 352 +- saml/security/AbstractPKIXTrustEngine.h | 294 +- saml/security/ChainingTrustEngine.h | 198 +- saml/security/MetadataKeyInfoIterator.h | 160 +- saml/security/TrustEngine.h | 178 +- saml/security/X509TrustEngine.h | 156 +- saml/security/impl/AbstractPKIXTrustEngine.cpp | 744 ++-- saml/security/impl/ChainingTrustEngine.cpp | 198 +- saml/security/impl/ExplicitKeyTrustEngine.cpp | 236 +- saml/signature/ContentReference.cpp | 136 +- saml/signature/ContentReference.h | 160 +- saml/signature/SignableObject.h | 114 +- saml/signature/SignatureProfileValidator.cpp | 152 +- saml/signature/SignatureProfileValidator.h | 92 +- saml/util/SAMLConstants.cpp | 356 +- saml/util/SAMLConstants.h | 262 +- saml/version.h | 148 +- samltest/ArtifactMapTest.h | 106 +- samltest/SAMLArtifactCreationTest.h | 170 +- samltest/SAMLArtifactType0001Test.h | 90 +- samltest/SAMLArtifactType0002Test.h | 86 +- samltest/SAMLArtifactType0004Test.h | 92 +- samltest/saml1/binding/SAML1ArtifactTest.h | 288 +- samltest/saml1/binding/SAML1POSTTest.h | 294 +- samltest/saml1/core/impl/ActionTest.h | 134 +- samltest/saml1/core/impl/AdviceTest.h | 146 +- .../saml1/core/impl/AssertionIDReferenceTest.h | 122 +- samltest/saml1/core/impl/AssertionTest.h | 296 +- samltest/saml1/core/impl/AttributeDesignatorTest.h | 132 +- samltest/saml1/core/impl/AttributeStatementTest.h | 138 +- samltest/saml1/core/impl/AttributeTest.h | 174 +- .../core/impl/AudienceRestrictionConditionTest.h | 112 +- samltest/saml1/core/impl/AudienceTest.h | 120 +- .../saml1/core/impl/AuthenticationStatementTest.h | 192 +- samltest/saml2/binding/SAML2ArtifactTest.h | 290 +- samltest/saml2/binding/SAML2POSTTest.h | 294 +- samltest/saml2/core/impl/Action20Test.h | 122 +- samltest/saml2/core/impl/Advice20Test.h | 178 +- samltest/saml2/core/impl/ArtifactResolve20Test.h | 246 +- samltest/saml2/core/impl/ArtifactResponse20Test.h | 310 +- samltest/saml2/core/impl/Assertion20Test.h | 270 +- .../saml2/core/impl/AssertionIDRequest20Test.h | 250 +- samltest/saml2/core/impl/Attribute20Test.h | 214 +- samltest/saml2/core/impl/AttributeQuery20Test.h | 256 +- .../saml2/core/impl/AttributeStatement20Test.h | 138 +- .../saml2/core/impl/AudienceRestriction20Test.h | 128 +- samltest/saml2/core/impl/AuthnContext20Test.h | 144 +- samltest/saml2/core/impl/AuthnQuery20Test.h | 264 +- samltest/saml2/core/impl/AuthnRequest20Test.h | 362 +- samltest/saml2/core/impl/AuthnStatement20Test.h | 222 +- .../saml2/core/impl/AuthzDecisionQuery20Test.h | 276 +- .../saml2/core/impl/AuthzDecisionStatement20Test.h | 164 +- samltest/saml2/core/impl/Conditions20Test.h | 254 +- samltest/saml2/core/impl/Evidence20Test.h | 170 +- samltest/saml2/core/impl/IDPEntry20Test.h | 154 +- samltest/saml2/core/impl/IDPList20Test.h | 136 +- samltest/saml2/core/impl/Issuer20Test.h | 186 +- .../core/impl/KeyInfoConfirmationDataType20Test.h | 248 +- samltest/saml2/core/impl/LogoutRequest20Test.h | 292 +- samltest/saml2/core/impl/LogoutResponse20Test.h | 278 +- .../saml2/core/impl/ManageNameIDRequest20Test.h | 274 +- .../saml2/core/impl/ManageNameIDResponse20Test.h | 278 +- samltest/saml2/core/impl/NameID20Test.h | 186 +- .../saml2/core/impl/NameIDMappingRequest20Test.h | 268 +- .../saml2/core/impl/NameIDMappingResponse20Test.h | 292 +- samltest/saml2/core/impl/NameIDPolicy20Test.h | 152 +- samltest/saml2/core/impl/NameIDType20Test.h | 278 +- samltest/saml2/core/impl/NewEncryptedID20Test.h | 142 +- samltest/saml2/core/impl/ProxyRestriction20Test.h | 170 +- .../saml2/core/impl/RequestedAuthnContext20Test.h | 190 +- samltest/saml2/core/impl/Response20Test.h | 362 +- samltest/saml2/core/impl/Scoping20Test.h | 182 +- samltest/saml2/core/impl/Status20Test.h | 132 +- samltest/saml2/core/impl/StatusCode20Test.h | 132 +- samltest/saml2/core/impl/StatusDetail20Test.h | 122 +- samltest/saml2/core/impl/Subject20Test.h | 142 +- .../saml2/core/impl/SubjectConfirmation20Test.h | 154 +- .../core/impl/SubjectConfirmationData20Test.h | 238 +- samltest/saml2/core/impl/SubjectLocality20Test.h | 138 +- .../metadata/FilesystemMetadataProviderTest.h | 292 +- samltest/samltest.h | 138 +- samltest/security/AbstractPKIXTrustEngineTest.h | 284 +- samltest/security/ExplicitKeyTrustEngineTest.h | 182 +- samltest/signature/SAML1AssertionTest.h | 206 +- samltest/signature/SAML1RequestTest.h | 206 +- samltest/signature/SAML1ResponseTest.h | 272 +- samltest/signature/SAML2AssertionTest.h | 222 +- samltest/signature/SAMLSignatureTestBase.h | 112 +- 102 files changed, 12670 insertions(+), 12670 deletions(-) diff --git a/saml/SAMLConfig.h b/saml/SAMLConfig.h index 6945ab4..566c2d1 100644 --- a/saml/SAMLConfig.h +++ b/saml/SAMLConfig.h @@ -1,213 +1,213 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file saml/SAMLConfig.h - * - * Library configuration - */ - -#ifndef __saml_config_h__ -#define __saml_config_h__ - -#include - -#include -#include - -#include - -/** - * @namespace opensaml - * Common classes for OpenSAML library - */ -namespace opensaml { - - class SAML_API ArtifactMap; - class SAML_API MessageEncoder; - class SAML_API MessageDecoder; - class SAML_API SAMLArtifact; - class SAML_API TrustEngine; - class SAML_API URLEncoder; - - namespace saml2md { - class SAML_API MetadataProvider; - class SAML_API MetadataFilter; - }; - -#if defined (_MSC_VER) - #pragma warning( push ) - #pragma warning( disable : 4250 4251 ) -#endif - - /** - * Singleton object that manages library startup/shutdown.configuration. - */ - class SAML_API SAMLConfig - { - MAKE_NONCOPYABLE(SAMLConfig); - public: - virtual ~SAMLConfig() {} - - /** - * Returns the global configuration object for the library. - * - * @return reference to the global library configuration object - */ - static SAMLConfig& getConfig(); - - /** - * Initializes library - * - * Each process using the library MUST call this function exactly once - * before using any library classes. The flag controls whether this is the - * "dominant" library or not and can allow the SAML library to be loaded - * as an extension of XMLTooling rather than subsuming it. - * - * @param initXMLTooling true iff this method should initialize the XMLTooling layer - * @return true iff initialization was successful - */ - virtual bool init(bool initXMLTooling=true)=0; - - /** - * Shuts down library - * - * Each process using the library SHOULD call this function exactly once - * before terminating itself. The flag controls whether this is the - * "dominant" library or not and can allow the SAML library to be loaded - * as an extension of XMLTooling rather than subsuming it. - * - * @param termXMLTooling true iff this method should shutdown the XMLTooling layer - */ - virtual void term(bool termXMLTooling=true)=0; - - /** - * Sets the global ArtifactMap instance. - * This method must be externally synchronized with any code that uses the object. - * Any previously set object is destroyed. - * - * @param artifactMap new ArtifactMap instance to store - */ - void setArtifactMap(ArtifactMap* artifactMap); - - /** - * Returns the global ArtifactMap instance. - * - * @return global ArtifactMap or NULL - */ - ArtifactMap* getArtifactMap() const { - return m_artifactMap; - } - - /** - * Sets the global URLEncoder instance. - * This method must be externally synchronized with any code that uses the object. - * Any previously set object is destroyed. - * - * @param urlEncoder new URLEncoder instance to store - */ - void setURLEncoder(URLEncoder* urlEncoder); - - /** - * Returns the global URLEncoder instance. - * - * @return global URLEncoder or NULL - */ - URLEncoder* getURLEncoder() const { - return m_urlEncoder; - } - - /** - * Generate random information using the underlying security library - * - * @param buf buffer for the information - * @param len number of bytes to write into buffer - */ - virtual void generateRandomBytes(void* buf, unsigned int len)=0; - - /** - * Generate random information using the underlying security library - * - * @param buf string buffer for the information - * @param len number of bytes to write into buffer - */ - virtual void generateRandomBytes(std::string& buf, unsigned int len)=0; - - /** - * Generate a valid XML identifier of the form _X{32} where X is a - * random hex character. The caller is responsible for freeing the result. - * - * @return a valid null-terminated XML ID - */ - virtual XMLCh* generateIdentifier()=0; - - /** - * Generate the SHA-1 hash of a string - * - * @param s NULL-terminated string to hash - * @param toHex true iff the result should be encoded in hexadecimal form or left as raw bytes - * - * @return SHA-1 hash of the data - */ - virtual std::string hashSHA1(const char* s, bool toHex=false)=0; - - /** - * Manages factories for MessageDecoder plugins. - */ - xmltooling::PluginManager MessageDecoderManager; - - /** - * Manages factories for MessageEncoder plugins. - */ - xmltooling::PluginManager MessageEncoderManager; - - /** - * Manages factories for SAMLArtifact plugins. - */ - xmltooling::PluginManager SAMLArtifactManager; - - /** - * Manages factories for TrustEngine plugins. - */ - xmltooling::PluginManager TrustEngineManager; - - /** - * Manages factories for MetadataProvider plugins. - */ - xmltooling::PluginManager MetadataProviderManager; - - /** - * Manages factories for MetadataFilter plugins. - */ - xmltooling::PluginManager MetadataFilterManager; - - protected: - SAMLConfig() : m_artifactMap(NULL), m_urlEncoder(NULL) {} - - /** Global ArtifactMap instance for use by artifact-related functions. */ - ArtifactMap* m_artifactMap; - - /** Global URLEncoder instance for use by URL-related functions. */ - URLEncoder* m_urlEncoder; - }; - -#if defined (_MSC_VER) - #pragma warning( pop ) -#endif - -}; - -#endif /* __saml_config_h__ */ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file saml/SAMLConfig.h + * + * Library configuration + */ + +#ifndef __saml_config_h__ +#define __saml_config_h__ + +#include + +#include +#include + +#include + +/** + * @namespace opensaml + * Common classes for OpenSAML library + */ +namespace opensaml { + + class SAML_API ArtifactMap; + class SAML_API MessageEncoder; + class SAML_API MessageDecoder; + class SAML_API SAMLArtifact; + class SAML_API TrustEngine; + class SAML_API URLEncoder; + + namespace saml2md { + class SAML_API MetadataProvider; + class SAML_API MetadataFilter; + }; + +#if defined (_MSC_VER) + #pragma warning( push ) + #pragma warning( disable : 4250 4251 ) +#endif + + /** + * Singleton object that manages library startup/shutdown.configuration. + */ + class SAML_API SAMLConfig + { + MAKE_NONCOPYABLE(SAMLConfig); + public: + virtual ~SAMLConfig() {} + + /** + * Returns the global configuration object for the library. + * + * @return reference to the global library configuration object + */ + static SAMLConfig& getConfig(); + + /** + * Initializes library + * + * Each process using the library MUST call this function exactly once + * before using any library classes. The flag controls whether this is the + * "dominant" library or not and can allow the SAML library to be loaded + * as an extension of XMLTooling rather than subsuming it. + * + * @param initXMLTooling true iff this method should initialize the XMLTooling layer + * @return true iff initialization was successful + */ + virtual bool init(bool initXMLTooling=true)=0; + + /** + * Shuts down library + * + * Each process using the library SHOULD call this function exactly once + * before terminating itself. The flag controls whether this is the + * "dominant" library or not and can allow the SAML library to be loaded + * as an extension of XMLTooling rather than subsuming it. + * + * @param termXMLTooling true iff this method should shutdown the XMLTooling layer + */ + virtual void term(bool termXMLTooling=true)=0; + + /** + * Sets the global ArtifactMap instance. + * This method must be externally synchronized with any code that uses the object. + * Any previously set object is destroyed. + * + * @param artifactMap new ArtifactMap instance to store + */ + void setArtifactMap(ArtifactMap* artifactMap); + + /** + * Returns the global ArtifactMap instance. + * + * @return global ArtifactMap or NULL + */ + ArtifactMap* getArtifactMap() const { + return m_artifactMap; + } + + /** + * Sets the global URLEncoder instance. + * This method must be externally synchronized with any code that uses the object. + * Any previously set object is destroyed. + * + * @param urlEncoder new URLEncoder instance to store + */ + void setURLEncoder(URLEncoder* urlEncoder); + + /** + * Returns the global URLEncoder instance. + * + * @return global URLEncoder or NULL + */ + URLEncoder* getURLEncoder() const { + return m_urlEncoder; + } + + /** + * Generate random information using the underlying security library + * + * @param buf buffer for the information + * @param len number of bytes to write into buffer + */ + virtual void generateRandomBytes(void* buf, unsigned int len)=0; + + /** + * Generate random information using the underlying security library + * + * @param buf string buffer for the information + * @param len number of bytes to write into buffer + */ + virtual void generateRandomBytes(std::string& buf, unsigned int len)=0; + + /** + * Generate a valid XML identifier of the form _X{32} where X is a + * random hex character. The caller is responsible for freeing the result. + * + * @return a valid null-terminated XML ID + */ + virtual XMLCh* generateIdentifier()=0; + + /** + * Generate the SHA-1 hash of a string + * + * @param s NULL-terminated string to hash + * @param toHex true iff the result should be encoded in hexadecimal form or left as raw bytes + * + * @return SHA-1 hash of the data + */ + virtual std::string hashSHA1(const char* s, bool toHex=false)=0; + + /** + * Manages factories for MessageDecoder plugins. + */ + xmltooling::PluginManager MessageDecoderManager; + + /** + * Manages factories for MessageEncoder plugins. + */ + xmltooling::PluginManager MessageEncoderManager; + + /** + * Manages factories for SAMLArtifact plugins. + */ + xmltooling::PluginManager SAMLArtifactManager; + + /** + * Manages factories for TrustEngine plugins. + */ + xmltooling::PluginManager TrustEngineManager; + + /** + * Manages factories for MetadataProvider plugins. + */ + xmltooling::PluginManager MetadataProviderManager; + + /** + * Manages factories for MetadataFilter plugins. + */ + xmltooling::PluginManager MetadataFilterManager; + + protected: + SAMLConfig() : m_artifactMap(NULL), m_urlEncoder(NULL) {} + + /** Global ArtifactMap instance for use by artifact-related functions. */ + ArtifactMap* m_artifactMap; + + /** Global URLEncoder instance for use by URL-related functions. */ + URLEncoder* m_urlEncoder; + }; + +#if defined (_MSC_VER) + #pragma warning( pop ) +#endif + +}; + +#endif /* __saml_config_h__ */ diff --git a/saml/binding/ArtifactMap.h b/saml/binding/ArtifactMap.h index 7f57f88..b8ea841 100644 --- a/saml/binding/ArtifactMap.h +++ b/saml/binding/ArtifactMap.h @@ -1,88 +1,88 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file saml/binding/ArtifactMap.h - * - * Helper class for SAMLArtifact mapping and retrieval. - */ - -#ifndef __saml_artmap_h__ -#define __saml_artmap_h__ - -#include -#include -#include -#include - -namespace opensaml { - - class SAML_API SAMLArtifact; - class SAML_DLLLOCAL ArtifactMappings; - - /** - * Helper class for SAMLArtifact mapping and retrieval. - */ - class SAML_API ArtifactMap - { - MAKE_NONCOPYABLE(ArtifactMap); - public: - - /** - * Creates a map on top of a particular storage service context, or in-memory. - * - * @param storage pointer to a StorageService, or NULL to keep map in memory - * @param context optional label for storage context - * @param artifactTTL time to live value, determines how long artifact remains valid - */ - ArtifactMap(xmltooling::StorageService* storage=NULL, const char* context=NULL, int artifactTTL=180); - - virtual ~ArtifactMap(); - - /** - * Associates XML content with an artifact and optionally a specific relying party. - * Specifying no relying party means that the first attempt to resolve the artifact - * will succeed. The XML content cannot have a parent object, and any existing references - * to the content will be invalidated. - * - * @param content the XML content to map to an artifact - * @param artifact the artifact representing the XML content - * @param relyingParty entityID of the party authorized to resolve the artifact - * @return the generated artifact - */ - virtual void storeContent(xmltooling::XMLObject* content, const SAMLArtifact* artifact, const char* relyingParty=NULL); - - /** - * Retrieves the XML content represented by the artifact. The identity of the - * relying party can be supplied, if known. If the wrong party tries to resolve - * an artifact, an exception will be thrown and the mapping will be removed. - * The caller is responsible for freeing the XML content returned. - * - * @param artifact the artifact representing the XML content - * @param relyingParty entityID of the party trying to resolve the artifact - * @return the XML content - */ - virtual xmltooling::XMLObject* retrieveContent(const SAMLArtifact* artifact, const char* relyingParty=NULL); - - private: - xmltooling::StorageService* m_storage; - std::string m_context; - ArtifactMappings* m_mappings; - int m_artifactTTL; - }; -}; - -#endif /* __saml_artmap_h__ */ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file saml/binding/ArtifactMap.h + * + * Helper class for SAMLArtifact mapping and retrieval. + */ + +#ifndef __saml_artmap_h__ +#define __saml_artmap_h__ + +#include +#include +#include +#include + +namespace opensaml { + + class SAML_API SAMLArtifact; + class SAML_DLLLOCAL ArtifactMappings; + + /** + * Helper class for SAMLArtifact mapping and retrieval. + */ + class SAML_API ArtifactMap + { + MAKE_NONCOPYABLE(ArtifactMap); + public: + + /** + * Creates a map on top of a particular storage service context, or in-memory. + * + * @param storage pointer to a StorageService, or NULL to keep map in memory + * @param context optional label for storage context + * @param artifactTTL time to live value, determines how long artifact remains valid + */ + ArtifactMap(xmltooling::StorageService* storage=NULL, const char* context=NULL, int artifactTTL=180); + + virtual ~ArtifactMap(); + + /** + * Associates XML content with an artifact and optionally a specific relying party. + * Specifying no relying party means that the first attempt to resolve the artifact + * will succeed. The XML content cannot have a parent object, and any existing references + * to the content will be invalidated. + * + * @param content the XML content to map to an artifact + * @param artifact the artifact representing the XML content + * @param relyingParty entityID of the party authorized to resolve the artifact + * @return the generated artifact + */ + virtual void storeContent(xmltooling::XMLObject* content, const SAMLArtifact* artifact, const char* relyingParty=NULL); + + /** + * Retrieves the XML content represented by the artifact. The identity of the + * relying party can be supplied, if known. If the wrong party tries to resolve + * an artifact, an exception will be thrown and the mapping will be removed. + * The caller is responsible for freeing the XML content returned. + * + * @param artifact the artifact representing the XML content + * @param relyingParty entityID of the party trying to resolve the artifact + * @return the XML content + */ + virtual xmltooling::XMLObject* retrieveContent(const SAMLArtifact* artifact, const char* relyingParty=NULL); + + private: + xmltooling::StorageService* m_storage; + std::string m_context; + ArtifactMappings* m_mappings; + int m_artifactTTL; + }; +}; + +#endif /* __saml_artmap_h__ */ diff --git a/saml/binding/MessageDecoder.h b/saml/binding/MessageDecoder.h index d0a29a0..364d6a5 100644 --- a/saml/binding/MessageDecoder.h +++ b/saml/binding/MessageDecoder.h @@ -1,274 +1,274 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file saml/binding/MessageDecoder.h - * - * Interface to SAML protocol binding message decoders. - */ - -#ifndef __saml_decoder_h__ -#define __saml_decoder_h__ - -#include - -#include - -namespace opensaml { - - class SAML_API SAMLArtifact; - class SAML_API X509TrustEngine; - namespace saml1p { - class SAML_API Response; - }; - namespace saml2p { - class SAML_API SAML2Artifact; - class SAML_API ArtifactResponse; - }; - namespace saml2md { - class SAML_API MetadataProvider; - class SAML_API IDPSSODescriptor; - class SAML_API RoleDescriptor; - class SAML_API SSODescriptorType; - } - - /** - * Interface to SAML protocol binding message decoders. - */ - class SAML_API MessageDecoder - { - MAKE_NONCOPYABLE(MessageDecoder); - public: - virtual ~MessageDecoder() {} - - /** - * Interface to caller-supplied shim for accessing HTTP request context. - * - * To supply information from the surrounding web server environment, - * a shim must be supplied in the form of this interface to adapt the - * library to different proprietary server APIs. - */ - class SAML_API HTTPRequest { - MAKE_NONCOPYABLE(HTTPRequest); - protected: - HTTPRequest() {} - public: - virtual ~HTTPRequest() {} - - /** - * Returns the HTTP method of the request (GET, POST, etc.) - * - * @return the HTTP method - */ - virtual const char* getMethod() const=0; - - /** - * Returns the complete request URL, including scheme, host, port. - * - * @return the request URL - */ - virtual const char* getRequestURL() const=0; - - /** - * Returns the HTTP query string appened to the request. The query - * string is returned without any decoding applied, everything found - * after the ? delimiter. - * - * @return the query string - */ - virtual const char* getQueryString() const=0; - - /** - * Returns a decoded named parameter value from the query string or form body. - * If a parameter has multiple values, only one will be returned. - * - * @param name the name of the parameter to return - * @return a single parameter value or NULL - */ - virtual const char* getParameter(const char* name) const=0; - - /** - * Returns all of the decoded values of a named parameter from the query string - * or form body. All values found will be returned. - * - * @param name the name of the parameter to return - * @param values a vector in which to return pointers to the decoded values - * @return the number of values returned - */ - virtual std::vector::size_type getParameters( - const char* name, std::vector& values - ) const=0; - }; - - /** - * Interface to caller-supplied artifact resolution mechanism. - * - * Resolving artifacts requires internally performing a SOAP-based - * call to the artifact source, usually in a mutually authenticated fashion. - * The potential options vary widely, so the work is encapsulated by this - * interface, though of course other library facilities may be used. - * - *

A MessageDecoder implementation will invoke the supplied interface - * when it requires an artifact be resolved. - */ - class SAML_API ArtifactResolver { - MAKE_NONCOPYABLE(ArtifactResolver); - protected: - ArtifactResolver() {} - - /** Flag controlling schema validation. */ - bool m_validate; - - public: - virtual ~ArtifactResolver() {} - - /** - * Controls schema validation of incoming XML messages. - * This is separate from other forms of programmatic validation of objects, - * but can detect a much wider range of syntax errors. - * - * @param validate true iff the resolver should use a validating XML parser - */ - void setValidating(bool validate=true) { - m_validate = validate; - } - - /** - * Resolves one or more SAML 1.x artifacts into a response containing a set of - * resolved Assertions. The caller is responsible for the resulting Response. - * - * @param authenticated output flag set to true iff the resolution channel was authenticated - * @param artifacts one or more SAML 1.x artifacts - * @param idpDescriptor reference to IdP role of artifact issuer - * @param trustEngine optional pointer to X509TrustEngine supplied to MessageDecoder - * @return the corresponding SAML Assertions wrapped in a Response. - */ - virtual saml1p::Response* resolve( - bool& authenticated, - const std::vector& artifacts, - const saml2md::IDPSSODescriptor& idpDescriptor, - const X509TrustEngine* trustEngine=NULL - ) const=0; - - /** - * Resolves a SAML 2.0 artifact into the corresponding SAML protocol message. - * The caller is responsible for the resulting ArtifactResponse message. - * - * @param authenticated output flag set to true iff the resolution channel was authenticated - * @param artifact reference to a SAML 2.0 artifact - * @param ssoDescriptor reference to SSO role of artifact issuer (may be SP or IdP) - * @param trustEngine optional pointer to X509TrustEngine supplied to MessageDecoder - * @return the corresponding SAML protocol message or NULL - */ - virtual saml2p::ArtifactResponse* resolve( - bool& authenticated, - const saml2p::SAML2Artifact& artifact, - const saml2md::SSODescriptorType& ssoDescriptor, - const X509TrustEngine* trustEngine=NULL - ) const=0; - }; - - /** - * Provides an ArtifactResolver implementation for the MessageDecoder to use. - * The implementation's lifetime must be longer than the lifetime of this object. - * This method must be externally synchronized. - * - * @param artifactResolver an ArtifactResolver implementation to use - */ - void setArtifactResolver(ArtifactResolver* artifactResolver) { - m_artifactResolver = artifactResolver; - if (m_artifactResolver) - m_artifactResolver->setValidating(m_validate); - } - - /** - * Controls schema validation of incoming XML messages. - * This is separate from other forms of programmatic validation of objects, - * but can detect a much wider range of syntax errors. - * - * @param validate true iff the decoder should use a validating XML parser - */ - void setValidating(bool validate=true) { - m_validate = validate; - if (m_artifactResolver) - m_artifactResolver->setValidating(m_validate); - } - - /** - * Decodes an HTTP request into a SAML protocol message, and returns related - * information about the issuer of the message and whether it can be trusted. - * If the HTTP request does not contain the information necessary to decode - * the request, a NULL will be returned. Errors during the decoding process - * will be raised as exceptions. - * - *

Artifact-based bindings require an ArtifactResolver be set to - * turn an artifact into the corresponding message. - * - *

In some cases, a message may be returned but not authenticated. The caller - * should examine the issuerTrusted output value to establish this. - * - * @param relayState RelayState/TARGET value accompanying message - * @param issuer role descriptor of issuing party - * @param issuerTrusted output flag set to true iff the message was authenticated - * (signed or obtained via secure backchannel) - * @param httpRequest reference to interface for accessing HTTP message to decode - * @param metadataProvider optional MetadataProvider instance to authenticate the message - * @param role optional, identifies the role (generally IdP or SP) of the peer who issued the message - * @param trustEngine optional TrustEngine to authenticate the message - * @return the decoded message, or NULL if the decoder did not recognize the request content - */ - virtual xmltooling::XMLObject* decode( - std::string& relayState, - const saml2md::RoleDescriptor*& issuer, - bool& issuerTrusted, - const HTTPRequest& httpRequest, - const saml2md::MetadataProvider* metadataProvider=NULL, - const xmltooling::QName* role=NULL, - const TrustEngine* trustEngine=NULL - ) const=0; - - protected: - MessageDecoder() : m_artifactResolver(NULL), m_validate(false) {} - - /** Pointer to an ArtifactResolver implementation. */ - ArtifactResolver* m_artifactResolver; - - /** Flag controlling schema validation. */ - bool m_validate; - }; - - /** - * Registers MessageDecoder plugins into the runtime. - */ - void SAML_API registerMessageDecoders(); - - /** MessageDecoder for SAML 1.x Browser/Artifact "binding" (really part of profile) */ - #define SAML1_ARTIFACT_DECODER "urn:oasis:names:tc:SAML:1.0:profiles:artifact-01" - - /** MessageDecoder for SAML 1.x Browser/POST "binding" (really part of profile) */ - #define SAML1_POST_DECODER "urn:oasis:names:tc:SAML:1.0:profiles:browser-post" - - /** MessageDecoder for SAML 2.0 HTTP-Artifact binding */ - #define SAML2_ARTIFACT_DECODER "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact" - - /** MessageDecoder for SAML 2.0 HTTP-POST binding */ - #define SAML2_POST_DECODER "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" - - /** MessageDecoder for SAML 2.0 HTTP-Redirect binding */ - #define SAML2_REDIRECT_DECODER "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" -}; - -#endif /* __saml_decoder_h__ */ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file saml/binding/MessageDecoder.h + * + * Interface to SAML protocol binding message decoders. + */ + +#ifndef __saml_decoder_h__ +#define __saml_decoder_h__ + +#include + +#include + +namespace opensaml { + + class SAML_API SAMLArtifact; + class SAML_API X509TrustEngine; + namespace saml1p { + class SAML_API Response; + }; + namespace saml2p { + class SAML_API SAML2Artifact; + class SAML_API ArtifactResponse; + }; + namespace saml2md { + class SAML_API MetadataProvider; + class SAML_API IDPSSODescriptor; + class SAML_API RoleDescriptor; + class SAML_API SSODescriptorType; + } + + /** + * Interface to SAML protocol binding message decoders. + */ + class SAML_API MessageDecoder + { + MAKE_NONCOPYABLE(MessageDecoder); + public: + virtual ~MessageDecoder() {} + + /** + * Interface to caller-supplied shim for accessing HTTP request context. + * + * To supply information from the surrounding web server environment, + * a shim must be supplied in the form of this interface to adapt the + * library to different proprietary server APIs. + */ + class SAML_API HTTPRequest { + MAKE_NONCOPYABLE(HTTPRequest); + protected: + HTTPRequest() {} + public: + virtual ~HTTPRequest() {} + + /** + * Returns the HTTP method of the request (GET, POST, etc.) + * + * @return the HTTP method + */ + virtual const char* getMethod() const=0; + + /** + * Returns the complete request URL, including scheme, host, port. + * + * @return the request URL + */ + virtual const char* getRequestURL() const=0; + + /** + * Returns the HTTP query string appened to the request. The query + * string is returned without any decoding applied, everything found + * after the ? delimiter. + * + * @return the query string + */ + virtual const char* getQueryString() const=0; + + /** + * Returns a decoded named parameter value from the query string or form body. + * If a parameter has multiple values, only one will be returned. + * + * @param name the name of the parameter to return + * @return a single parameter value or NULL + */ + virtual const char* getParameter(const char* name) const=0; + + /** + * Returns all of the decoded values of a named parameter from the query string + * or form body. All values found will be returned. + * + * @param name the name of the parameter to return + * @param values a vector in which to return pointers to the decoded values + * @return the number of values returned + */ + virtual std::vector::size_type getParameters( + const char* name, std::vector& values + ) const=0; + }; + + /** + * Interface to caller-supplied artifact resolution mechanism. + * + * Resolving artifacts requires internally performing a SOAP-based + * call to the artifact source, usually in a mutually authenticated fashion. + * The potential options vary widely, so the work is encapsulated by this + * interface, though of course other library facilities may be used. + * + *

A MessageDecoder implementation will invoke the supplied interface + * when it requires an artifact be resolved. + */ + class SAML_API ArtifactResolver { + MAKE_NONCOPYABLE(ArtifactResolver); + protected: + ArtifactResolver() {} + + /** Flag controlling schema validation. */ + bool m_validate; + + public: + virtual ~ArtifactResolver() {} + + /** + * Controls schema validation of incoming XML messages. + * This is separate from other forms of programmatic validation of objects, + * but can detect a much wider range of syntax errors. + * + * @param validate true iff the resolver should use a validating XML parser + */ + void setValidating(bool validate=true) { + m_validate = validate; + } + + /** + * Resolves one or more SAML 1.x artifacts into a response containing a set of + * resolved Assertions. The caller is responsible for the resulting Response. + * + * @param authenticated output flag set to true iff the resolution channel was authenticated + * @param artifacts one or more SAML 1.x artifacts + * @param idpDescriptor reference to IdP role of artifact issuer + * @param trustEngine optional pointer to X509TrustEngine supplied to MessageDecoder + * @return the corresponding SAML Assertions wrapped in a Response. + */ + virtual saml1p::Response* resolve( + bool& authenticated, + const std::vector& artifacts, + const saml2md::IDPSSODescriptor& idpDescriptor, + const X509TrustEngine* trustEngine=NULL + ) const=0; + + /** + * Resolves a SAML 2.0 artifact into the corresponding SAML protocol message. + * The caller is responsible for the resulting ArtifactResponse message. + * + * @param authenticated output flag set to true iff the resolution channel was authenticated + * @param artifact reference to a SAML 2.0 artifact + * @param ssoDescriptor reference to SSO role of artifact issuer (may be SP or IdP) + * @param trustEngine optional pointer to X509TrustEngine supplied to MessageDecoder + * @return the corresponding SAML protocol message or NULL + */ + virtual saml2p::ArtifactResponse* resolve( + bool& authenticated, + const saml2p::SAML2Artifact& artifact, + const saml2md::SSODescriptorType& ssoDescriptor, + const X509TrustEngine* trustEngine=NULL + ) const=0; + }; + + /** + * Provides an ArtifactResolver implementation for the MessageDecoder to use. + * The implementation's lifetime must be longer than the lifetime of this object. + * This method must be externally synchronized. + * + * @param artifactResolver an ArtifactResolver implementation to use + */ + void setArtifactResolver(ArtifactResolver* artifactResolver) { + m_artifactResolver = artifactResolver; + if (m_artifactResolver) + m_artifactResolver->setValidating(m_validate); + } + + /** + * Controls schema validation of incoming XML messages. + * This is separate from other forms of programmatic validation of objects, + * but can detect a much wider range of syntax errors. + * + * @param validate true iff the decoder should use a validating XML parser + */ + void setValidating(bool validate=true) { + m_validate = validate; + if (m_artifactResolver) + m_artifactResolver->setValidating(m_validate); + } + + /** + * Decodes an HTTP request into a SAML protocol message, and returns related + * information about the issuer of the message and whether it can be trusted. + * If the HTTP request does not contain the information necessary to decode + * the request, a NULL will be returned. Errors during the decoding process + * will be raised as exceptions. + * + *

Artifact-based bindings require an ArtifactResolver be set to + * turn an artifact into the corresponding message. + * + *

In some cases, a message may be returned but not authenticated. The caller + * should examine the issuerTrusted output value to establish this. + * + * @param relayState RelayState/TARGET value accompanying message + * @param issuer role descriptor of issuing party + * @param issuerTrusted output flag set to true iff the message was authenticated + * (signed or obtained via secure backchannel) + * @param httpRequest reference to interface for accessing HTTP message to decode + * @param metadataProvider optional MetadataProvider instance to authenticate the message + * @param role optional, identifies the role (generally IdP or SP) of the peer who issued the message + * @param trustEngine optional TrustEngine to authenticate the message + * @return the decoded message, or NULL if the decoder did not recognize the request content + */ + virtual xmltooling::XMLObject* decode( + std::string& relayState, + const saml2md::RoleDescriptor*& issuer, + bool& issuerTrusted, + const HTTPRequest& httpRequest, + const saml2md::MetadataProvider* metadataProvider=NULL, + const xmltooling::QName* role=NULL, + const TrustEngine* trustEngine=NULL + ) const=0; + + protected: + MessageDecoder() : m_artifactResolver(NULL), m_validate(false) {} + + /** Pointer to an ArtifactResolver implementation. */ + ArtifactResolver* m_artifactResolver; + + /** Flag controlling schema validation. */ + bool m_validate; + }; + + /** + * Registers MessageDecoder plugins into the runtime. + */ + void SAML_API registerMessageDecoders(); + + /** MessageDecoder for SAML 1.x Browser/Artifact "binding" (really part of profile) */ + #define SAML1_ARTIFACT_DECODER "urn:oasis:names:tc:SAML:1.0:profiles:artifact-01" + + /** MessageDecoder for SAML 1.x Browser/POST "binding" (really part of profile) */ + #define SAML1_POST_DECODER "urn:oasis:names:tc:SAML:1.0:profiles:browser-post" + + /** MessageDecoder for SAML 2.0 HTTP-Artifact binding */ + #define SAML2_ARTIFACT_DECODER "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact" + + /** MessageDecoder for SAML 2.0 HTTP-POST binding */ + #define SAML2_POST_DECODER "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" + + /** MessageDecoder for SAML 2.0 HTTP-Redirect binding */ + #define SAML2_REDIRECT_DECODER "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" +}; + +#endif /* __saml_decoder_h__ */ diff --git a/saml/binding/MessageEncoder.h b/saml/binding/MessageEncoder.h index acfdf15..668049a 100644 --- a/saml/binding/MessageEncoder.h +++ b/saml/binding/MessageEncoder.h @@ -1,171 +1,171 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file saml/binding/MessageEncoder.h - * - * Interface to SAML protocol binding message encoders. - */ - -#ifndef __saml_encoder_h__ -#define __saml_encoder_h__ - -#include - -#include -#include -#include -#include - -namespace opensaml { - - class SAML_API SAMLArtifact; - namespace saml2p { - class SAML_API SAML2Artifact; - }; - - /** - * Interface to SAML protocol binding message encoders. - */ - class SAML_API MessageEncoder - { - MAKE_NONCOPYABLE(MessageEncoder); - public: - virtual ~MessageEncoder() {} - - /** - * Interface to caller-supplied artifact generation mechanism. - * - * Generating an artifact for storage and retrieval requires knowledge of - * the sender's SourceID (or sometimes SourceLocation), and the relying party's - * preferred artifact type. This information can be supplied using whatever - * configuration or defaults are appropriate for the SAML application. - * A MessageEncoder implementation will invoke the supplied generator interface - * when it requires an artifact be created. - */ - class SAML_API ArtifactGenerator { - MAKE_NONCOPYABLE(ArtifactGenerator); - protected: - ArtifactGenerator() {} - public: - virtual ~ArtifactGenerator() {} - - /** - * Generate a SAML 1.x artifact suitable for consumption by the relying party. - * - * @param relyingParty the party that will recieve the artifact - * @return a SAML 1.x artifact with a random assertion handle - */ - virtual SAMLArtifact* generateSAML1Artifact(const char* relyingParty) const=0; - - /** - * Generate a SAML 2.0 artifact suitable for consumption by the relying party. - * - * @param relyingParty the party that will recieve the artifact - * @return a SAML 2.0 artifact with a random message handle - */ - virtual saml2p::SAML2Artifact* generateSAML2Artifact(const char* relyingParty) const=0; - }; - - /** - * Provides an ArtifactGenerator implementation for the MessageEncoder to use. - * The implementation's lifetime must be longer than the lifetime of this object. - * This method must be externally synchronized. - * - * @param artifactGenerator an ArtifactGenerator implementation to use - */ - void setArtifactGenerator(ArtifactGenerator* artifactGenerator) { - m_artifactGenerator = artifactGenerator; - } - - /** - * Encodes an XML object/message into a set of binding-specific data "fields". - * The XML content cannot have a parent object, and any existing references to - * the content will be invalidated if the encode method returns successfully. - * - * If a CredentialResolver is supplied, the message is also signed in a - * binding-specific manner. The CredentialResolver MUST - * be locked by the caller. - * - *

An embedded URLEncoder instance may be required by some bindings - * in order to produce predictable signature input. - * - *

Artifact-based bindings require an ArtifactGenerator be set to - * produce an artifact suitable for the intended recipient. - * - *

Note that the name/value pairs resulting from the encoding operation are - * NOT URL-encoded or otherwise transformed. It is the caller's - * responsibility to apply any necessary encoding when preparing the data for - * transport. - * - * @param outputFields name/value pairs containing the results of encoding the message - * @param xmlObject XML object/message to encode - * @param recipientID optional entityID of message recipient - * @param relayState optional RelayState value to accompany message - * @param credResolver optional CredentialResolver instance to supply signing material - * @param sigAlgorithm optional signature algorithm identifier - */ - virtual void encode( - std::map& outputFields, - xmltooling::XMLObject* xmlObject, - const char* recipientID=NULL, - const char* relayState=NULL, - const xmlsignature::CredentialResolver* credResolver=NULL, - const XMLCh* sigAlgorithm=NULL - ) const=0; - - protected: - MessageEncoder() : m_artifactGenerator(NULL) {} - - /** - * Helper function to build a new XML Signature with KeyInfo, based - * on the supplied CredentialResolver. - * - * @param credResolver CredentialResolver instance to supply signing material - * @param sigAlgorithm optional signature algorithm identifier - * @return a new Signature object - */ - xmlsignature::Signature* buildSignature( - const xmlsignature::CredentialResolver* credResolver, - const XMLCh* sigAlgorithm=NULL - ) const; - - /** Pointer to an ArtifactGenerator implementation. */ - const ArtifactGenerator* m_artifactGenerator; - }; - - /** - * Registers MessageEncoder plugins into the runtime. - */ - void SAML_API registerMessageEncoders(); - - /** MessageEncoder for SAML 1.x Browser/Artifact "binding" (really part of profile) */ - #define SAML1_ARTIFACT_ENCODER "urn:oasis:names:tc:SAML:1.0:profiles:artifact-01" - - /** MessageEncoder for SAML 1.x Browser/POST "binding" (really part of profile) */ - #define SAML1_POST_ENCODER "urn:oasis:names:tc:SAML:1.0:profiles:browser-post" - - /** MessageEncoder for SAML 2.0 HTTP-Artifact binding */ - #define SAML2_ARTIFACT_ENCODER "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact" - - /** MessageEncoder for SAML 2.0 HTTP-POST binding */ - #define SAML2_POST_ENCODER "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" - - /** MessageEncoder for SAML 2.0 HTTP-Redirect binding */ - #define SAML2_REDIRECT_ENCODER "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" -}; - -#endif /* __saml_encoder_h__ */ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file saml/binding/MessageEncoder.h + * + * Interface to SAML protocol binding message encoders. + */ + +#ifndef __saml_encoder_h__ +#define __saml_encoder_h__ + +#include + +#include +#include +#include +#include + +namespace opensaml { + + class SAML_API SAMLArtifact; + namespace saml2p { + class SAML_API SAML2Artifact; + }; + + /** + * Interface to SAML protocol binding message encoders. + */ + class SAML_API MessageEncoder + { + MAKE_NONCOPYABLE(MessageEncoder); + public: + virtual ~MessageEncoder() {} + + /** + * Interface to caller-supplied artifact generation mechanism. + * + * Generating an artifact for storage and retrieval requires knowledge of + * the sender's SourceID (or sometimes SourceLocation), and the relying party's + * preferred artifact type. This information can be supplied using whatever + * configuration or defaults are appropriate for the SAML application. + * A MessageEncoder implementation will invoke the supplied generator interface + * when it requires an artifact be created. + */ + class SAML_API ArtifactGenerator { + MAKE_NONCOPYABLE(ArtifactGenerator); + protected: + ArtifactGenerator() {} + public: + virtual ~ArtifactGenerator() {} + + /** + * Generate a SAML 1.x artifact suitable for consumption by the relying party. + * + * @param relyingParty the party that will recieve the artifact + * @return a SAML 1.x artifact with a random assertion handle + */ + virtual SAMLArtifact* generateSAML1Artifact(const char* relyingParty) const=0; + + /** + * Generate a SAML 2.0 artifact suitable for consumption by the relying party. + * + * @param relyingParty the party that will recieve the artifact + * @return a SAML 2.0 artifact with a random message handle + */ + virtual saml2p::SAML2Artifact* generateSAML2Artifact(const char* relyingParty) const=0; + }; + + /** + * Provides an ArtifactGenerator implementation for the MessageEncoder to use. + * The implementation's lifetime must be longer than the lifetime of this object. + * This method must be externally synchronized. + * + * @param artifactGenerator an ArtifactGenerator implementation to use + */ + void setArtifactGenerator(ArtifactGenerator* artifactGenerator) { + m_artifactGenerator = artifactGenerator; + } + + /** + * Encodes an XML object/message into a set of binding-specific data "fields". + * The XML content cannot have a parent object, and any existing references to + * the content will be invalidated if the encode method returns successfully. + * + * If a CredentialResolver is supplied, the message is also signed in a + * binding-specific manner. The CredentialResolver MUST + * be locked by the caller. + * + *

An embedded URLEncoder instance may be required by some bindings + * in order to produce predictable signature input. + * + *

Artifact-based bindings require an ArtifactGenerator be set to + * produce an artifact suitable for the intended recipient. + * + *

Note that the name/value pairs resulting from the encoding operation are + * NOT URL-encoded or otherwise transformed. It is the caller's + * responsibility to apply any necessary encoding when preparing the data for + * transport. + * + * @param outputFields name/value pairs containing the results of encoding the message + * @param xmlObject XML object/message to encode + * @param recipientID optional entityID of message recipient + * @param relayState optional RelayState value to accompany message + * @param credResolver optional CredentialResolver instance to supply signing material + * @param sigAlgorithm optional signature algorithm identifier + */ + virtual void encode( + std::map& outputFields, + xmltooling::XMLObject* xmlObject, + const char* recipientID=NULL, + const char* relayState=NULL, + const xmlsignature::CredentialResolver* credResolver=NULL, + const XMLCh* sigAlgorithm=NULL + ) const=0; + + protected: + MessageEncoder() : m_artifactGenerator(NULL) {} + + /** + * Helper function to build a new XML Signature with KeyInfo, based + * on the supplied CredentialResolver. + * + * @param credResolver CredentialResolver instance to supply signing material + * @param sigAlgorithm optional signature algorithm identifier + * @return a new Signature object + */ + xmlsignature::Signature* buildSignature( + const xmlsignature::CredentialResolver* credResolver, + const XMLCh* sigAlgorithm=NULL + ) const; + + /** Pointer to an ArtifactGenerator implementation. */ + const ArtifactGenerator* m_artifactGenerator; + }; + + /** + * Registers MessageEncoder plugins into the runtime. + */ + void SAML_API registerMessageEncoders(); + + /** MessageEncoder for SAML 1.x Browser/Artifact "binding" (really part of profile) */ + #define SAML1_ARTIFACT_ENCODER "urn:oasis:names:tc:SAML:1.0:profiles:artifact-01" + + /** MessageEncoder for SAML 1.x Browser/POST "binding" (really part of profile) */ + #define SAML1_POST_ENCODER "urn:oasis:names:tc:SAML:1.0:profiles:browser-post" + + /** MessageEncoder for SAML 2.0 HTTP-Artifact binding */ + #define SAML2_ARTIFACT_ENCODER "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact" + + /** MessageEncoder for SAML 2.0 HTTP-POST binding */ + #define SAML2_POST_ENCODER "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" + + /** MessageEncoder for SAML 2.0 HTTP-Redirect binding */ + #define SAML2_REDIRECT_ENCODER "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" +}; + +#endif /* __saml_encoder_h__ */ diff --git a/saml/binding/SAMLArtifact.h b/saml/binding/SAMLArtifact.h index aadac32..3c9f3e5 100644 --- a/saml/binding/SAMLArtifact.h +++ b/saml/binding/SAMLArtifact.h @@ -1,158 +1,158 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file saml/binding/SAMLArtifact.h - * - * Base class for SAML 1.x and 2.0 artifacts - */ - -#ifndef __saml_artifact_h__ -#define __saml_artifact_h__ - -#include - -#include -#include - -namespace opensaml { - - /** - * Base class for SAML 1.x and 2.0 artifacts. - */ - class SAML_API SAMLArtifact - { - SAMLArtifact& operator=(const SAMLArtifact& src); - public: - virtual ~SAMLArtifact() {} - - /** - * Returns artifact encoded into null-terminated base64 for transmission. - */ - virtual std::string encode() const; - - /** - * Builds a duplicate, independent artifact of the same type. - * - * @return the new artifact - */ - virtual SAMLArtifact* clone() const=0; - - /** - * Returns all of the raw binary data that makes up the artifact. - * The result is NOT null-terminated. - * - * @return the binary artifact data - */ - virtual std::string getBytes() const { - return m_raw; - } - - /** - * Returns the binary type code of the artifact. - * The result MAY contain embedded null characters. - * - * @return the binary type code - */ - virtual std::string getTypeCode() const { - return m_raw.substr(0,TYPECODE_LENGTH); - } - - /** - * Returns the binary artifact data following the type code. - * The result MAY contain embedded null characters. - * - * @return the binary artifact data - */ - virtual std::string getRemainingArtifact() const { - return m_raw.substr(TYPECODE_LENGTH); - } - - /** - * Returns a string that identifies the source of the artifact. - * The exact form this takes depends on the type but should match - * the syntax needed for metadata lookup. - * - * @return null-terminated source string - */ - virtual std::string getSource() const=0; - - /** - * Returns the binary data that references the message (2.0) or assertion (1.x) - * The exact form this takes depends on the type. - * The result MAY contain embedded null characters. - * - * @return the binary reference data - */ - virtual std::string getMessageHandle() const=0; - - /** Length of type code */ - static const unsigned int TYPECODE_LENGTH; - - /** - * Parses a base64-encoded null-terminated string into an artifact, - * if the type is known. - * - * @param s base64-encoded artifact - * @return the decoded artifact - */ - static SAMLArtifact* parse(const char* s); - - /** - * Parses a base64-encoded null-terminated string into an artifact, - * if the type is known. - * - * @param s base64-encoded artifact - * @return the decoded artifact - */ - static SAMLArtifact* parse(const XMLCh* s) { - xmltooling::auto_ptr_char temp(s); - return parse(temp.get()); - } - - /** - * Converts binary data to hex notation. - * - * @param s the bytes to convert - * @return the data in hex form, 2 characters per byte - */ - static std::string toHex(const std::string& s); - - protected: - SAMLArtifact() {} - - /** - * Decodes a base64-encoded artifact into its raw form. - * - * @param s NULL-terminated base64-encoded string - */ - SAMLArtifact(const char* s); - - SAMLArtifact(const SAMLArtifact& src) : m_raw(src.m_raw) {} - - /** Raw binary data that makes up an artifact. */ - std::string m_raw; - }; - - DECL_XMLTOOLING_EXCEPTION(ArtifactException,SAML_EXCEPTIONAPI(SAML_API),opensaml,xmltooling::XMLToolingException,Exceptions related to artifact parsing); - - /** - * Registers SAMLArtifact subclasses into the runtime. - */ - void SAML_API registerSAMLArtifacts(); -}; - -#endif /* __saml_artifact_h__ */ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file saml/binding/SAMLArtifact.h + * + * Base class for SAML 1.x and 2.0 artifacts + */ + +#ifndef __saml_artifact_h__ +#define __saml_artifact_h__ + +#include + +#include +#include + +namespace opensaml { + + /** + * Base class for SAML 1.x and 2.0 artifacts. + */ + class SAML_API SAMLArtifact + { + SAMLArtifact& operator=(const SAMLArtifact& src); + public: + virtual ~SAMLArtifact() {} + + /** + * Returns artifact encoded into null-terminated base64 for transmission. + */ + virtual std::string encode() const; + + /** + * Builds a duplicate, independent artifact of the same type. + * + * @return the new artifact + */ + virtual SAMLArtifact* clone() const=0; + + /** + * Returns all of the raw binary data that makes up the artifact. + * The result is NOT null-terminated. + * + * @return the binary artifact data + */ + virtual std::string getBytes() const { + return m_raw; + } + + /** + * Returns the binary type code of the artifact. + * The result MAY contain embedded null characters. + * + * @return the binary type code + */ + virtual std::string getTypeCode() const { + return m_raw.substr(0,TYPECODE_LENGTH); + } + + /** + * Returns the binary artifact data following the type code. + * The result MAY contain embedded null characters. + * + * @return the binary artifact data + */ + virtual std::string getRemainingArtifact() const { + return m_raw.substr(TYPECODE_LENGTH); + } + + /** + * Returns a string that identifies the source of the artifact. + * The exact form this takes depends on the type but should match + * the syntax needed for metadata lookup. + * + * @return null-terminated source string + */ + virtual std::string getSource() const=0; + + /** + * Returns the binary data that references the message (2.0) or assertion (1.x) + * The exact form this takes depends on the type. + * The result MAY contain embedded null characters. + * + * @return the binary reference data + */ + virtual std::string getMessageHandle() const=0; + + /** Length of type code */ + static const unsigned int TYPECODE_LENGTH; + + /** + * Parses a base64-encoded null-terminated string into an artifact, + * if the type is known. + * + * @param s base64-encoded artifact + * @return the decoded artifact + */ + static SAMLArtifact* parse(const char* s); + + /** + * Parses a base64-encoded null-terminated string into an artifact, + * if the type is known. + * + * @param s base64-encoded artifact + * @return the decoded artifact + */ + static SAMLArtifact* parse(const XMLCh* s) { + xmltooling::auto_ptr_char temp(s); + return parse(temp.get()); + } + + /** + * Converts binary data to hex notation. + * + * @param s the bytes to convert + * @return the data in hex form, 2 characters per byte + */ + static std::string toHex(const std::string& s); + + protected: + SAMLArtifact() {} + + /** + * Decodes a base64-encoded artifact into its raw form. + * + * @param s NULL-terminated base64-encoded string + */ + SAMLArtifact(const char* s); + + SAMLArtifact(const SAMLArtifact& src) : m_raw(src.m_raw) {} + + /** Raw binary data that makes up an artifact. */ + std::string m_raw; + }; + + DECL_XMLTOOLING_EXCEPTION(ArtifactException,SAML_EXCEPTIONAPI(SAML_API),opensaml,xmltooling::XMLToolingException,Exceptions related to artifact parsing); + + /** + * Registers SAMLArtifact subclasses into the runtime. + */ + void SAML_API registerSAMLArtifacts(); +}; + +#endif /* __saml_artifact_h__ */ diff --git a/saml/binding/URLEncoder.h b/saml/binding/URLEncoder.h index 2585d6d..27e9540 100644 --- a/saml/binding/URLEncoder.h +++ b/saml/binding/URLEncoder.h @@ -1,74 +1,74 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file saml/binding/URLEncoder.h - * - * Interface to a URL-encoding mechanism along with a - * default implementation. - */ - -#ifndef __saml_urlenc_h__ -#define __saml_urlenc_h__ - -#include - -namespace opensaml { - /** - * Interface to a URL-encoding mechanism along with a default implementation. - * - * Since URL-encoding is not canonical, it's important that the same - * encoder is used during some library operations and the calling code. - * Applications can supply an alternative implementation to the library - * if required. - */ - class SAML_API URLEncoder { - MAKE_NONCOPYABLE(URLEncoder); - public: - URLEncoder() {} - virtual ~URLEncoder() {} - - /** - * Produce a URL-safe but equivalent version of the input string. - * - * @param s input string to encode - * @return a string object containing the result of encoding the input - */ - virtual std::string encode(const char* s) const; - - /** - * Perform an in-place decoding operation on the input string. - * The resulting string will be NULL-terminated. - * - * @param s input string to decode in a writable buffer - */ - virtual void decode(char* s) const; - - protected: - /** - * Returns true iff the input character requires encoding. - * - * @param ch the character to check - * @return true iff the character should be encoded - */ - virtual bool isBad(char ch) const { - static char badchars[]="=&/?:\"\\+<>#%{}|^~[]`;@"; - return (strchr(badchars,ch) || ch<=0x20 || ch>=0x7F); - } - }; -}; - -#endif /* __saml_urlenc_h__ */ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file saml/binding/URLEncoder.h + * + * Interface to a URL-encoding mechanism along with a + * default implementation. + */ + +#ifndef __saml_urlenc_h__ +#define __saml_urlenc_h__ + +#include + +namespace opensaml { + /** + * Interface to a URL-encoding mechanism along with a default implementation. + * + * Since URL-encoding is not canonical, it's important that the same + * encoder is used during some library operations and the calling code. + * Applications can supply an alternative implementation to the library + * if required. + */ + class SAML_API URLEncoder { + MAKE_NONCOPYABLE(URLEncoder); + public: + URLEncoder() {} + virtual ~URLEncoder() {} + + /** + * Produce a URL-safe but equivalent version of the input string. + * + * @param s input string to encode + * @return a string object containing the result of encoding the input + */ + virtual std::string encode(const char* s) const; + + /** + * Perform an in-place decoding operation on the input string. + * The resulting string will be NULL-terminated. + * + * @param s input string to decode in a writable buffer + */ + virtual void decode(char* s) const; + + protected: + /** + * Returns true iff the input character requires encoding. + * + * @param ch the character to check + * @return true iff the character should be encoded + */ + virtual bool isBad(char ch) const { + static char badchars[]="=&/?:\"\\+<>#%{}|^~[]`;@"; + return (strchr(badchars,ch) || ch<=0x20 || ch>=0x7F); + } + }; +}; + +#endif /* __saml_urlenc_h__ */ diff --git a/saml/encryption/EncryptedKeyResolver.cpp b/saml/encryption/EncryptedKeyResolver.cpp index 5c9f652..a517aab 100644 --- a/saml/encryption/EncryptedKeyResolver.cpp +++ b/saml/encryption/EncryptedKeyResolver.cpp @@ -1,37 +1,37 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * EncryptedKeyResolver.cpp - * - * SAML-specific encrypted key resolver - */ - -#include "internal.h" -#include "encryption/EncryptedKeyResolver.h" - -using namespace xmlencryption; -using namespace std; - -EncryptedKey* opensaml::EncryptedKeyResolver::resolveKey(EncryptedData* encryptedData) -{ - const vector& keys=m_ref.getEncryptedKeys(); - for (vector::const_iterator i=keys.begin(); i!=keys.end(); i++) { - if (XMLString::equals(m_recipient,(*i)->getRecipient())) - return (*i); - } - return NULL; -} +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * EncryptedKeyResolver.cpp + * + * SAML-specific encrypted key resolver + */ + +#include "internal.h" +#include "encryption/EncryptedKeyResolver.h" + +using namespace xmlencryption; +using namespace std; + +EncryptedKey* opensaml::EncryptedKeyResolver::resolveKey(EncryptedData* encryptedData) +{ + const vector& keys=m_ref.getEncryptedKeys(); + for (vector::const_iterator i=keys.begin(); i!=keys.end(); i++) { + if (XMLString::equals(m_recipient,(*i)->getRecipient())) + return (*i); + } + return NULL; +} diff --git a/saml/encryption/EncryptedKeyResolver.h b/saml/encryption/EncryptedKeyResolver.h index 6f9d9c7..67a59b5 100644 --- a/saml/encryption/EncryptedKeyResolver.h +++ b/saml/encryption/EncryptedKeyResolver.h @@ -1,62 +1,62 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file saml/encryption/EncryptedKeyResolver.h - * - * SAML-specific encrypted key resolver - */ - -#ifndef __saml_enckeyres_h__ -#define __saml_enckeyres_h__ - -#include -#include -#include - -namespace opensaml { - - /** - * SAML-specific encrypted key resolver. - * - * SAML allows placement of keys alongside the encrypted data. This resolver - * recognizes the implied placement. - */ - class SAML_API EncryptedKeyResolver : public xmlencryption::EncryptedKeyResolver - { - public: - EncryptedKeyResolver(const saml2::EncryptedElementType& ref, const XMLCh* recipient=NULL) - : m_ref(ref), m_recipient(XMLString::replicate(recipient)) { - } - - virtual ~EncryptedKeyResolver() { - XMLString::release(&m_recipient); - } - - xmlencryption::EncryptedKey* resolveKey(xmlencryption::EncryptedData* encryptedData); - - EncryptedKeyResolver* clone() const { - return new EncryptedKeyResolver(m_ref, m_recipient); - } - - protected: - const saml2::EncryptedElementType& m_ref; - XMLCh* m_recipient; - }; - -}; - -#endif /* __saml_enckeyres_h__ */ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file saml/encryption/EncryptedKeyResolver.h + * + * SAML-specific encrypted key resolver + */ + +#ifndef __saml_enckeyres_h__ +#define __saml_enckeyres_h__ + +#include +#include +#include + +namespace opensaml { + + /** + * SAML-specific encrypted key resolver. + * + * SAML allows placement of keys alongside the encrypted data. This resolver + * recognizes the implied placement. + */ + class SAML_API EncryptedKeyResolver : public xmlencryption::EncryptedKeyResolver + { + public: + EncryptedKeyResolver(const saml2::EncryptedElementType& ref, const XMLCh* recipient=NULL) + : m_ref(ref), m_recipient(XMLString::replicate(recipient)) { + } + + virtual ~EncryptedKeyResolver() { + XMLString::release(&m_recipient); + } + + xmlencryption::EncryptedKey* resolveKey(xmlencryption::EncryptedData* encryptedData); + + EncryptedKeyResolver* clone() const { + return new EncryptedKeyResolver(m_ref, m_recipient); + } + + protected: + const saml2::EncryptedElementType& m_ref; + XMLCh* m_recipient; + }; + +}; + +#endif /* __saml_enckeyres_h__ */ diff --git a/saml/saml1/binding/SAMLArtifactType0001.h b/saml/saml1/binding/SAMLArtifactType0001.h index 837409e..9774ecc 100644 --- a/saml/saml1/binding/SAMLArtifactType0001.h +++ b/saml/saml1/binding/SAMLArtifactType0001.h @@ -1,97 +1,97 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file saml/saml1/binding/SAMLArtifactType0001.h - * - * Type 0x0001 SAML 1.x artifact class - */ - -#ifndef __saml_artifacttype0001_h__ -#define __saml_artifacttype0001_h__ - -#include - -namespace opensaml { - namespace saml1p { - - /** - * Type 0x0001 SAML 1.x artifact class - */ - class SAML_API SAMLArtifactType0001 : public SAMLArtifact - { - SAMLArtifactType0001& operator=(const SAMLArtifactType0001& src); - public: - /** - * Decodes a base64-encoded type 0x0001 artifact - * - * @param s NULL-terminated base64-encoded string - */ - SAMLArtifactType0001(const char* s); - - /** - * Constructs an artifact with the specified source ID, but a random assertion handle. - * - * @param sourceid SOURCEID_LENGTH bytes of binary data - */ - SAMLArtifactType0001(const std::string& sourceid); - - /** - * Constructs an artifact with the specified source ID and assertion handle. - * - * @param sourceid SOURCEID_LENGTH bytes of binary data - * @param handle HANDLE_LENGTH bytes of binary data - */ - SAMLArtifactType0001(const std::string& sourceid, const std::string& handle); - - virtual ~SAMLArtifactType0001() {} - - virtual SAMLArtifactType0001* clone() const { - return new SAMLArtifactType0001(*this); - } - - virtual std::string getSource() const { - return toHex(getSourceID()); - } - - /** - * Returns the binary data that identifies the source. - * The result MAY contain embedded null characters. - * - * @return the binary source ID - */ - virtual std::string getSourceID() const { - return m_raw.substr(TYPECODE_LENGTH,SOURCEID_LENGTH); // bytes 3-22 - } - - virtual std::string getMessageHandle() const { - return m_raw.substr(TYPECODE_LENGTH+SOURCEID_LENGTH, HANDLE_LENGTH); // bytes 23-42 - } - - /** Length of source ID */ - static const unsigned int SOURCEID_LENGTH; - - /** Length of assertion handle */ - static const unsigned int HANDLE_LENGTH; - - protected: - SAMLArtifactType0001(const SAMLArtifactType0001& src) : SAMLArtifact(src) {} - }; - - }; -}; - -#endif /* __saml_artifacttype0001_h__ */ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file saml/saml1/binding/SAMLArtifactType0001.h + * + * Type 0x0001 SAML 1.x artifact class + */ + +#ifndef __saml_artifacttype0001_h__ +#define __saml_artifacttype0001_h__ + +#include + +namespace opensaml { + namespace saml1p { + + /** + * Type 0x0001 SAML 1.x artifact class + */ + class SAML_API SAMLArtifactType0001 : public SAMLArtifact + { + SAMLArtifactType0001& operator=(const SAMLArtifactType0001& src); + public: + /** + * Decodes a base64-encoded type 0x0001 artifact + * + * @param s NULL-terminated base64-encoded string + */ + SAMLArtifactType0001(const char* s); + + /** + * Constructs an artifact with the specified source ID, but a random assertion handle. + * + * @param sourceid SOURCEID_LENGTH bytes of binary data + */ + SAMLArtifactType0001(const std::string& sourceid); + + /** + * Constructs an artifact with the specified source ID and assertion handle. + * + * @param sourceid SOURCEID_LENGTH bytes of binary data + * @param handle HANDLE_LENGTH bytes of binary data + */ + SAMLArtifactType0001(const std::string& sourceid, const std::string& handle); + + virtual ~SAMLArtifactType0001() {} + + virtual SAMLArtifactType0001* clone() const { + return new SAMLArtifactType0001(*this); + } + + virtual std::string getSource() const { + return toHex(getSourceID()); + } + + /** + * Returns the binary data that identifies the source. + * The result MAY contain embedded null characters. + * + * @return the binary source ID + */ + virtual std::string getSourceID() const { + return m_raw.substr(TYPECODE_LENGTH,SOURCEID_LENGTH); // bytes 3-22 + } + + virtual std::string getMessageHandle() const { + return m_raw.substr(TYPECODE_LENGTH+SOURCEID_LENGTH, HANDLE_LENGTH); // bytes 23-42 + } + + /** Length of source ID */ + static const unsigned int SOURCEID_LENGTH; + + /** Length of assertion handle */ + static const unsigned int HANDLE_LENGTH; + + protected: + SAMLArtifactType0001(const SAMLArtifactType0001& src) : SAMLArtifact(src) {} + }; + + }; +}; + +#endif /* __saml_artifacttype0001_h__ */ diff --git a/saml/saml1/binding/SAMLArtifactType0002.h b/saml/saml1/binding/SAMLArtifactType0002.h index 9c16081..d9cf460 100644 --- a/saml/saml1/binding/SAMLArtifactType0002.h +++ b/saml/saml1/binding/SAMLArtifactType0002.h @@ -1,84 +1,84 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file saml/saml1/binding/SAMLArtifactType0002.h - * - * Type 0x0002 SAML 1.x artifact class - */ - -#ifndef __saml_artifacttype0002_h__ -#define __saml_artifacttype0002_h__ - -#include - -namespace opensaml { - namespace saml1p { - - /** - * Type 0x0002 SAML 1.x artifact class - */ - class SAML_API SAMLArtifactType0002 : public SAMLArtifact - { - SAMLArtifactType0002& operator=(const SAMLArtifactType0002& src); - public: - /** - * Decodes a base64-encoded type 0x0002 artifact - * - * @param s NULL-terminated base64-encoded string - */ - SAMLArtifactType0002(const char* s); - - /** - * Constructs an artifact with the specified source URL, but a random assertion handle. - * - * @param sourceLocation source URL - */ - SAMLArtifactType0002(const std::string& sourceLocation); - - /** - * Constructs an artifact with the specified source URL and assertion handle. - * - * @param sourceLocation source URL - * @param handle HANDLE_LENGTH bytes of binary data - */ - SAMLArtifactType0002(const std::string& sourceLocation, const std::string& handle); - - virtual ~SAMLArtifactType0002() {} - - virtual SAMLArtifactType0002* clone() const { - return new SAMLArtifactType0002(*this); - } - - virtual std::string getMessageHandle() const { - return m_raw.substr(TYPECODE_LENGTH, HANDLE_LENGTH); // bytes 3-22 - } - - virtual std::string getSource() const { - return m_raw.c_str() + TYPECODE_LENGTH + HANDLE_LENGTH; // bytes 23-terminating null - } - - /** Length of assertion handle */ - static const unsigned int HANDLE_LENGTH; - - protected: - SAMLArtifactType0002(const SAMLArtifactType0002& src) : SAMLArtifact(src) {} - }; - - }; -}; - -#endif /* __saml_artifacttype0002_h__ */ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file saml/saml1/binding/SAMLArtifactType0002.h + * + * Type 0x0002 SAML 1.x artifact class + */ + +#ifndef __saml_artifacttype0002_h__ +#define __saml_artifacttype0002_h__ + +#include + +namespace opensaml { + namespace saml1p { + + /** + * Type 0x0002 SAML 1.x artifact class + */ + class SAML_API SAMLArtifactType0002 : public SAMLArtifact + { + SAMLArtifactType0002& operator=(const SAMLArtifactType0002& src); + public: + /** + * Decodes a base64-encoded type 0x0002 artifact + * + * @param s NULL-terminated base64-encoded string + */ + SAMLArtifactType0002(const char* s); + + /** + * Constructs an artifact with the specified source URL, but a random assertion handle. + * + * @param sourceLocation source URL + */ + SAMLArtifactType0002(const std::string& sourceLocation); + + /** + * Constructs an artifact with the specified source URL and assertion handle. + * + * @param sourceLocation source URL + * @param handle HANDLE_LENGTH bytes of binary data + */ + SAMLArtifactType0002(const std::string& sourceLocation, const std::string& handle); + + virtual ~SAMLArtifactType0002() {} + + virtual SAMLArtifactType0002* clone() const { + return new SAMLArtifactType0002(*this); + } + + virtual std::string getMessageHandle() const { + return m_raw.substr(TYPECODE_LENGTH, HANDLE_LENGTH); // bytes 3-22 + } + + virtual std::string getSource() const { + return m_raw.c_str() + TYPECODE_LENGTH + HANDLE_LENGTH; // bytes 23-terminating null + } + + /** Length of assertion handle */ + static const unsigned int HANDLE_LENGTH; + + protected: + SAMLArtifactType0002(const SAMLArtifactType0002& src) : SAMLArtifact(src) {} + }; + + }; +}; + +#endif /* __saml_artifacttype0002_h__ */ diff --git a/saml/saml2/binding/SAML2Artifact.h b/saml/saml2/binding/SAML2Artifact.h index 79e22c5..e84a334 100644 --- a/saml/saml2/binding/SAML2Artifact.h +++ b/saml/saml2/binding/SAML2Artifact.h @@ -1,61 +1,61 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file saml/saml2/core/SAML2Artifact.h - * - * Base class for SAML 2.0 artifacts - */ - -#ifndef __saml2_artifact_h__ -#define __saml2_artifact_h__ - -#include - -namespace opensaml { - namespace saml2p { - - /** - * Base class for SAML 2.0 artifacts - */ - class SAML_API SAML2Artifact : public SAMLArtifact - { - SAML2Artifact& operator=(const SAML2Artifact& src); - public: - virtual ~SAML2Artifact() {} - - /** - * Returns the endpoint index of the artifact. - * - * @return endpoint index - */ - virtual int getEndpointIndex() const; - - /** Length of endpoint index */ - static const unsigned int INDEX_LENGTH; - - protected: - SAML2Artifact() {} - - SAML2Artifact(const char* s) : SAMLArtifact(s) {} - - SAML2Artifact(const SAML2Artifact& src) : SAMLArtifact(src) {} - }; - - }; -}; - -#endif /* __saml2_artifact_h__ */ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file saml/saml2/core/SAML2Artifact.h + * + * Base class for SAML 2.0 artifacts + */ + +#ifndef __saml2_artifact_h__ +#define __saml2_artifact_h__ + +#include + +namespace opensaml { + namespace saml2p { + + /** + * Base class for SAML 2.0 artifacts + */ + class SAML_API SAML2Artifact : public SAMLArtifact + { + SAML2Artifact& operator=(const SAML2Artifact& src); + public: + virtual ~SAML2Artifact() {} + + /** + * Returns the endpoint index of the artifact. + * + * @return endpoint index + */ + virtual int getEndpointIndex() const; + + /** Length of endpoint index */ + static const unsigned int INDEX_LENGTH; + + protected: + SAML2Artifact() {} + + SAML2Artifact(const char* s) : SAMLArtifact(s) {} + + SAML2Artifact(const SAML2Artifact& src) : SAMLArtifact(src) {} + }; + + }; +}; + +#endif /* __saml2_artifact_h__ */ diff --git a/saml/saml2/binding/SAML2ArtifactType0004.h b/saml/saml2/binding/SAML2ArtifactType0004.h index 40e2eb5..b0e0b7a 100644 --- a/saml/saml2/binding/SAML2ArtifactType0004.h +++ b/saml/saml2/binding/SAML2ArtifactType0004.h @@ -1,99 +1,99 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file saml/saml2/core/SAML2ArtifactType0004.h - * - * Type 0x0004 SAML 2.0 artifact class - */ - -#ifndef __saml_artifacttype0004_h__ -#define __saml_artifacttype0004_h__ - -#include - -namespace opensaml { - namespace saml2p { - - /** - * Type 0x0004 SAML 2.0 artifact class - */ - class SAML_API SAML2ArtifactType0004 : public SAML2Artifact - { - SAML2ArtifactType0004& operator=(const SAML2ArtifactType0004& src); - public: - /** - * Decodes a base64-encoded type 0x0004 artifact - * - * @param s NULL-terminated base64-encoded string - */ - SAML2ArtifactType0004(const char* s); - - /** - * Constructs an artifact with the specified source ID and index, but a random message handle. - * - * @param sourceid SOURCEID_LENGTH bytes of binary data - * @param index endpoint index - */ - SAML2ArtifactType0004(const std::string& sourceid, int index); - - /** - * Constructs an artifact with the specified source ID and assertion handle. - * - * @param sourceid SOURCEID_LENGTH bytes of binary data - * @param index endpoint index - * @param handle HANDLE_LENGTH bytes of binary data - */ - SAML2ArtifactType0004(const std::string& sourceid, int index, const std::string& handle); - - virtual ~SAML2ArtifactType0004() {} - - virtual SAML2ArtifactType0004* clone() const { - return new SAML2ArtifactType0004(*this); - } - - virtual std::string getSource() const { - return toHex(getSourceID()); - } - - /** - * Returns the binary data that identifies the source. - * The result MAY contain embedded null characters. - * - * @return the binary source ID - */ - virtual std::string getSourceID() const { - return m_raw.substr(TYPECODE_LENGTH + INDEX_LENGTH, SOURCEID_LENGTH); // bytes 5-24 - } - - virtual std::string getMessageHandle() const { - return m_raw.substr(TYPECODE_LENGTH + INDEX_LENGTH + SOURCEID_LENGTH, HANDLE_LENGTH); // bytes 25-44 - } - - /** Length of source ID */ - static const unsigned int SOURCEID_LENGTH; - - /** Length of message handle */ - static const unsigned int HANDLE_LENGTH; - - protected: - SAML2ArtifactType0004(const SAML2ArtifactType0004& src) : SAML2Artifact(src) {} - }; - - }; -}; - -#endif /* __saml_artifacttype0004_h__ */ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file saml/saml2/core/SAML2ArtifactType0004.h + * + * Type 0x0004 SAML 2.0 artifact class + */ + +#ifndef __saml_artifacttype0004_h__ +#define __saml_artifacttype0004_h__ + +#include + +namespace opensaml { + namespace saml2p { + + /** + * Type 0x0004 SAML 2.0 artifact class + */ + class SAML_API SAML2ArtifactType0004 : public SAML2Artifact + { + SAML2ArtifactType0004& operator=(const SAML2ArtifactType0004& src); + public: + /** + * Decodes a base64-encoded type 0x0004 artifact + * + * @param s NULL-terminated base64-encoded string + */ + SAML2ArtifactType0004(const char* s); + + /** + * Constructs an artifact with the specified source ID and index, but a random message handle. + * + * @param sourceid SOURCEID_LENGTH bytes of binary data + * @param index endpoint index + */ + SAML2ArtifactType0004(const std::string& sourceid, int index); + + /** + * Constructs an artifact with the specified source ID and assertion handle. + * + * @param sourceid SOURCEID_LENGTH bytes of binary data + * @param index endpoint index + * @param handle HANDLE_LENGTH bytes of binary data + */ + SAML2ArtifactType0004(const std::string& sourceid, int index, const std::string& handle); + + virtual ~SAML2ArtifactType0004() {} + + virtual SAML2ArtifactType0004* clone() const { + return new SAML2ArtifactType0004(*this); + } + + virtual std::string getSource() const { + return toHex(getSourceID()); + } + + /** + * Returns the binary data that identifies the source. + * The result MAY contain embedded null characters. + * + * @return the binary source ID + */ + virtual std::string getSourceID() const { + return m_raw.substr(TYPECODE_LENGTH + INDEX_LENGTH, SOURCEID_LENGTH); // bytes 5-24 + } + + virtual std::string getMessageHandle() const { + return m_raw.substr(TYPECODE_LENGTH + INDEX_LENGTH + SOURCEID_LENGTH, HANDLE_LENGTH); // bytes 25-44 + } + + /** Length of source ID */ + static const unsigned int SOURCEID_LENGTH; + + /** Length of message handle */ + static const unsigned int HANDLE_LENGTH; + + protected: + SAML2ArtifactType0004(const SAML2ArtifactType0004& src) : SAML2Artifact(src) {} + }; + + }; +}; + +#endif /* __saml_artifacttype0004_h__ */ diff --git a/saml/saml2/core/impl/Protocols20Impl.cpp b/saml/saml2/core/impl/Protocols20Impl.cpp index f43d38d..45b7915 100644 --- a/saml/saml2/core/impl/Protocols20Impl.cpp +++ b/saml/saml2/core/impl/Protocols20Impl.cpp @@ -1,2041 +1,2041 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Protocols20Impl.cpp - * - * Implementation classes for SAML 2.0 Protocols schema - */ - -#include "internal.h" -#include "exceptions.h" -#include "saml/encryption/EncryptedKeyResolver.h" -#include "saml2/core/Protocols.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -using namespace opensaml::saml2p; -using namespace opensaml::saml2; -using namespace opensaml; -using namespace xmlsignature; -using namespace xmlencryption; -using namespace xmltooling; -using namespace std; - -#if defined (_MSC_VER) - #pragma warning( push ) - #pragma warning( disable : 4250 4251 ) -#endif - -namespace opensaml { - namespace saml2p { - - DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,Artifact); - DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,GetComplete); - DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,NewID); - DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,RequesterID); - DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,SessionIndex); - DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,StatusMessage); - - DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,RespondTo); - - //TODO need unit test for this, using objects from another namespace - class SAML_DLLLOCAL ExtensionsImpl : public virtual Extensions, - public AbstractElementProxy, - public AbstractDOMCachingXMLObject, - public AbstractXMLObjectMarshaller, - public AbstractXMLObjectUnmarshaller - { - public: - virtual ~ExtensionsImpl() {} - - ExtensionsImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) { - } - - ExtensionsImpl(const ExtensionsImpl& src) - : AbstractXMLObject(src), AbstractElementProxy(src), AbstractDOMCachingXMLObject(src) { - for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { - if (*i) { - getXMLObjects().push_back((*i)->clone()); - } - } - } - - IMPL_XMLOBJECT_CLONE(Extensions); - - protected: - void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - // Unknown child. - const XMLCh* nsURI=root->getNamespaceURI(); - if (!XMLString::equals(nsURI,SAMLConstants::SAML20P_NS) && nsURI && *nsURI) { - getXMLObjects().push_back(childXMLObject); - return; - } - - AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); - } - }; - - class SAML_DLLLOCAL StatusCodeImpl : public virtual StatusCode, - public AbstractComplexElement, - public AbstractDOMCachingXMLObject, - public AbstractXMLObjectMarshaller, - public AbstractXMLObjectUnmarshaller - { - void init() { - m_Value=NULL; - m_StatusCode=NULL; - m_children.push_back(NULL); - m_pos_StatusCode=m_children.begin(); - } - public: - virtual ~StatusCodeImpl() {} - - StatusCodeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) - { - init(); - } - - StatusCodeImpl(const StatusCodeImpl& src) - : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { - init(); - setValue(src.getValue()); - if (src.getStatusCode()) - setStatusCode(src.getStatusCode()->cloneStatusCode()); - } - - IMPL_XMLOBJECT_CLONE(StatusCode); - IMPL_STRING_ATTRIB(Value); - IMPL_TYPED_CHILD(StatusCode); - - protected: - void marshallAttributes(DOMElement* domElement) const { - MARSHALL_STRING_ATTRIB(Value,VALUE,NULL); - } - - void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_CHILD(StatusCode,SAMLConstants::SAML20P_NS,false); - AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); - } - - void processAttribute(const DOMAttr* attribute) { - PROC_STRING_ATTRIB(Value,VALUE,NULL); - AbstractXMLObjectUnmarshaller::processAttribute(attribute); - } - }; - - //TODO need unit tests for non-SAML namespace children - class SAML_DLLLOCAL StatusDetailImpl : public virtual StatusDetail, - public AbstractComplexElement, - public AbstractDOMCachingXMLObject, - public AbstractXMLObjectMarshaller, - public AbstractXMLObjectUnmarshaller - { - public: - virtual ~StatusDetailImpl() {} - - StatusDetailImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - - StatusDetailImpl(const StatusDetailImpl& src) - : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { - VectorOf(XMLObject) v=getDetails(); - for (vector::const_iterator i=src.m_Details.begin(); i!=src.m_Details.end(); i++) { - if (*i) { - v.push_back((*i)->clone()); - } - } - } - - IMPL_XMLOBJECT_CLONE(StatusDetail); - IMPL_XMLOBJECT_CHILDREN(Detail,m_children.end()); - - protected: - void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - getDetails().push_back(childXMLObject); - AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); - } - }; - - - class SAML_DLLLOCAL StatusImpl : public virtual Status, - public AbstractComplexElement, - public AbstractDOMCachingXMLObject, - public AbstractXMLObjectMarshaller, - public AbstractXMLObjectUnmarshaller - { - void init() { - m_StatusCode=NULL; - m_StatusMessage=NULL; - m_StatusDetail=NULL; - m_children.push_back(NULL); - m_children.push_back(NULL); - m_children.push_back(NULL); - m_pos_StatusCode=m_children.begin(); - m_pos_StatusMessage=m_pos_StatusCode; - ++m_pos_StatusMessage; - m_pos_StatusDetail=m_pos_StatusMessage; - ++m_pos_StatusDetail; - } - public: - virtual ~StatusImpl() { } - - StatusImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) { - init(); - } - - StatusImpl(const StatusImpl& src) - : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { - init(); - if (src.getStatusCode()) - setStatusCode(src.getStatusCode()->cloneStatusCode()); - if (src.getStatusMessage()) - setStatusMessage(src.getStatusMessage()->cloneStatusMessage()); - if (src.getStatusDetail()) - setStatusDetail(src.getStatusDetail()->cloneStatusDetail()); - } - - IMPL_XMLOBJECT_CLONE(Status); - IMPL_TYPED_CHILD(StatusCode); - IMPL_TYPED_CHILD(StatusMessage); - IMPL_TYPED_CHILD(StatusDetail); - - protected: - - void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_CHILD(StatusCode,SAMLConstants::SAML20P_NS,false); - PROC_TYPED_CHILD(StatusMessage,SAMLConstants::SAML20P_NS,false); - PROC_TYPED_CHILD(StatusDetail,SAMLConstants::SAML20P_NS,false); - AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); - } - - }; - - - class SAML_DLLLOCAL RequestAbstractTypeImpl : public virtual RequestAbstractType, - public AbstractComplexElement, - public AbstractDOMCachingXMLObject, - public AbstractXMLObjectMarshaller, - public AbstractXMLObjectUnmarshaller - { - void init() { - m_ID=NULL; - m_Version=NULL; - m_IssueInstant=NULL; - m_Destination=NULL; - m_Consent=NULL; - m_Issuer=NULL; - m_Signature=NULL; - m_Extensions=NULL; - m_children.push_back(NULL); - m_children.push_back(NULL); - m_children.push_back(NULL); - m_pos_Issuer=m_children.begin(); - m_pos_Signature=m_pos_Issuer; - ++m_pos_Signature; - m_pos_Extensions=m_pos_Signature; - ++m_pos_Extensions; - } - protected: - RequestAbstractTypeImpl() { - init(); - } - public: - virtual ~RequestAbstractTypeImpl() { - XMLString::release(&m_ID); - XMLString::release(&m_Version); - XMLString::release(&m_Destination); - XMLString::release(&m_Consent); - delete m_IssueInstant; - } - - RequestAbstractTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) { - init(); - } - - RequestAbstractTypeImpl(const RequestAbstractTypeImpl& src) - : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { - init(); - setID(src.getID()); - setVersion(src.getVersion()); - setIssueInstant(src.getIssueInstant()); - setDestination(src.getDestination()); - setConsent(src.getConsent()); - if (src.getIssuer()) - setIssuer(src.getIssuer()->cloneIssuer()); - if (src.getSignature()) - setSignature(src.getSignature()->cloneSignature()); - if (src.getExtensions()) - setExtensions(src.getExtensions()->cloneExtensions()); - } - - //IMPL_TYPED_CHILD(Signature); - // Need customized setter. - protected: - Signature* m_Signature; - list::iterator m_pos_Signature; - public: - Signature* getSignature() const { - return m_Signature; - } - - void setSignature(Signature* sig) { - prepareForAssignment(m_Signature,sig); - *m_pos_Signature=m_Signature=sig; - // Sync content reference back up. - if (m_Signature) - m_Signature->setContentReference(new opensaml::ContentReference(*this)); - } - - IMPL_STRING_ATTRIB(Version); - IMPL_ID_ATTRIB(ID); - IMPL_DATETIME_ATTRIB(IssueInstant,0); - IMPL_STRING_ATTRIB(Destination); - IMPL_STRING_ATTRIB(Consent); - IMPL_TYPED_FOREIGN_CHILD(Issuer,saml2); - IMPL_TYPED_CHILD(Extensions); - - protected: - void marshallAttributes(DOMElement* domElement) const { - if (!m_Version) - const_cast(this)->m_Version=XMLString::transcode("2.0"); - MARSHALL_STRING_ATTRIB(Version,VER,NULL); - if (!m_ID) - const_cast(this)->m_ID=SAMLConfig::getConfig().generateIdentifier(); - MARSHALL_ID_ATTRIB(ID,ID,NULL); - if (!m_IssueInstant) { - const_cast(this)->m_IssueInstantEpoch=time(NULL); - const_cast(this)->m_IssueInstant=new DateTime(m_IssueInstantEpoch); - } - MARSHALL_DATETIME_ATTRIB(IssueInstant,ISSUEINSTANT,NULL); - MARSHALL_STRING_ATTRIB(Destination,DESTINATION,NULL); - MARSHALL_STRING_ATTRIB(Consent,CONSENT,NULL); - } - - void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_FOREIGN_CHILD(Issuer,saml2,SAMLConstants::SAML20_NS,false); - PROC_TYPED_FOREIGN_CHILD(Signature,xmlsignature,XMLConstants::XMLSIG_NS,false); - PROC_TYPED_CHILD(Extensions,SAMLConstants::SAML20P_NS,false); - AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); - } - - void processAttribute(const DOMAttr* attribute) { - PROC_ID_ATTRIB(ID,ID,NULL); - PROC_STRING_ATTRIB(Version,VER,NULL); - PROC_DATETIME_ATTRIB(IssueInstant,ISSUEINSTANT,NULL); - PROC_STRING_ATTRIB(Destination,DESTINATION,NULL); - PROC_STRING_ATTRIB(Consent,CONSENT,NULL); - AbstractXMLObjectUnmarshaller::processAttribute(attribute); - } - }; - - - class SAML_DLLLOCAL AssertionIDRequestImpl : public virtual AssertionIDRequest, public RequestAbstractTypeImpl - { - public: - virtual ~AssertionIDRequestImpl() { } - - AssertionIDRequestImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - - AssertionIDRequestImpl(const AssertionIDRequestImpl& src) : AbstractXMLObject(src), RequestAbstractTypeImpl(src) { - VectorOf(AssertionIDRef) v=getAssertionIDRefs(); - for (vector::const_iterator i=src.m_AssertionIDRefs.begin(); i!=src.m_AssertionIDRefs.end(); i++) { - if (*i) { - v.push_back((*i)->cloneAssertionIDRef()); - } - } - - } - - IMPL_XMLOBJECT_CLONE(AssertionIDRequest); - RequestAbstractType* cloneRequestAbstractType() const { - return cloneAssertionIDRequest(); - } - - IMPL_TYPED_FOREIGN_CHILDREN(AssertionIDRef,saml2,m_children.end()); - - protected: - void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_FOREIGN_CHILDREN(AssertionIDRef,saml2,SAMLConstants::SAML20_NS,false); - RequestAbstractTypeImpl::processChildElement(childXMLObject,root); - } - }; - - class SAML_DLLLOCAL SubjectQueryImpl : public virtual SubjectQuery, public RequestAbstractTypeImpl - { - void init() - { - m_Subject = NULL; - m_children.push_back(NULL); - m_pos_Subject = m_pos_Extensions; - ++m_pos_Subject; - } - protected: - SubjectQueryImpl() { - init(); - } - public: - virtual ~SubjectQueryImpl() { } - - SubjectQueryImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) - { - init(); - } - - SubjectQueryImpl(const SubjectQueryImpl& src) : AbstractXMLObject(src), RequestAbstractTypeImpl(src) { - init(); - if (src.getSubject()) - setSubject(src.getSubject()->cloneSubject()); - } - - IMPL_TYPED_FOREIGN_CHILD(Subject,saml2); - - protected: - void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_FOREIGN_CHILD(Subject,saml2,SAMLConstants::SAML20_NS,false); - RequestAbstractTypeImpl::processChildElement(childXMLObject,root); - } - }; - - - class SAML_DLLLOCAL RequestedAuthnContextImpl : public virtual RequestedAuthnContext, - public AbstractComplexElement, - public AbstractDOMCachingXMLObject, - public AbstractXMLObjectMarshaller, - public AbstractXMLObjectUnmarshaller - { - void init() { - m_Comparison=NULL; - } - public: - virtual ~RequestedAuthnContextImpl() { - XMLString::release(&m_Comparison); - } - - RequestedAuthnContextImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) { - init(); - } - - RequestedAuthnContextImpl(const RequestedAuthnContextImpl& src) - : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { - init(); - setComparison(src.getComparison()); - for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { - if (*i) { - AuthnContextClassRef* classref=dynamic_cast(*i); - if (classref) { - getAuthnContextClassRefs().push_back(classref->cloneAuthnContextClassRef()); - continue; - } - - AuthnContextDeclRef* declref=dynamic_cast(*i); - if (declref) { - getAuthnContextDeclRefs().push_back(declref->cloneAuthnContextDeclRef()); - continue; - } - } - } - } - - IMPL_XMLOBJECT_CLONE(RequestedAuthnContext); - IMPL_STRING_ATTRIB(Comparison); - IMPL_TYPED_FOREIGN_CHILDREN(AuthnContextClassRef,saml2,m_children.end()); - IMPL_TYPED_FOREIGN_CHILDREN(AuthnContextDeclRef,saml2,m_children.end()); - - protected: - void marshallAttributes(DOMElement* domElement) const { - MARSHALL_STRING_ATTRIB(Comparison,COMPARISON,NULL); - } - - void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_FOREIGN_CHILDREN(AuthnContextClassRef,saml2,SAMLConstants::SAML20_NS,false); - PROC_TYPED_FOREIGN_CHILDREN(AuthnContextDeclRef,saml2,SAMLConstants::SAML20_NS,false); - AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); - } - - void processAttribute(const DOMAttr* attribute) { - PROC_STRING_ATTRIB(Comparison,COMPARISON,NULL); - AbstractXMLObjectUnmarshaller::processAttribute(attribute); - } - }; - - - class SAML_DLLLOCAL AuthnQueryImpl : public virtual AuthnQuery, public SubjectQueryImpl - { - void init() { - m_SessionIndex=NULL; - m_RequestedAuthnContext=NULL; - m_children.push_back(NULL); - m_pos_RequestedAuthnContext = m_pos_Subject; - ++m_pos_RequestedAuthnContext; - - } - public: - virtual ~AuthnQueryImpl() { - XMLString::release(&m_SessionIndex); - } - - AuthnQueryImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) - { - init(); - } - - AuthnQueryImpl(const AuthnQueryImpl& src) : AbstractXMLObject(src), SubjectQueryImpl(src) { - init(); - setSessionIndex(src.getSessionIndex()); - if (src.getRequestedAuthnContext()) - setRequestedAuthnContext(src.getRequestedAuthnContext()->cloneRequestedAuthnContext()); - } - - IMPL_XMLOBJECT_CLONE(AuthnQuery); - SubjectQuery* cloneSubjectQuery() const { - return cloneAuthnQuery(); - } - RequestAbstractType* cloneRequestAbstractType() const { - return cloneAuthnQuery(); - } - - IMPL_STRING_ATTRIB(SessionIndex); - IMPL_TYPED_CHILD(RequestedAuthnContext); - - protected: - void marshallAttributes(DOMElement* domElement) const { - MARSHALL_STRING_ATTRIB(SessionIndex,SESSIONINDEX,NULL); - SubjectQueryImpl::marshallAttributes(domElement); - } - - void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_CHILD(RequestedAuthnContext,SAMLConstants::SAML20P_NS,false); - SubjectQueryImpl::processChildElement(childXMLObject,root); - } - void processAttribute(const DOMAttr* attribute) { - PROC_STRING_ATTRIB(SessionIndex,SESSIONINDEX,NULL); - SubjectQueryImpl::processAttribute(attribute); - } - }; - - class SAML_DLLLOCAL AttributeQueryImpl : public virtual AttributeQuery, public SubjectQueryImpl - { - public: - virtual ~AttributeQueryImpl() { } - - AttributeQueryImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - - AttributeQueryImpl(const AttributeQueryImpl& src) : AbstractXMLObject(src), SubjectQueryImpl(src) { - for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { - if (*i) { - Attribute* attrib=dynamic_cast(*i); - if (attrib) { - getAttributes().push_back(attrib->cloneAttribute()); - continue; - } - } - } - - } - - IMPL_XMLOBJECT_CLONE(AttributeQuery); - SubjectQuery* cloneSubjectQuery() const { - return cloneAttributeQuery(); - } - RequestAbstractType* cloneRequestAbstractType() const { - return cloneAttributeQuery(); - } - - IMPL_TYPED_FOREIGN_CHILDREN(Attribute,saml2,m_children.end()); - - protected: - void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_FOREIGN_CHILDREN(Attribute,saml2,SAMLConstants::SAML20_NS,false); - SubjectQueryImpl::processChildElement(childXMLObject,root); - } - }; - - class SAML_DLLLOCAL AuthzDecisionQueryImpl : public virtual AuthzDecisionQuery, public SubjectQueryImpl - { - void init() { - m_Resource=NULL; - m_Evidence=NULL; - m_children.push_back(NULL); - m_pos_Evidence=m_pos_Subject; - ++m_pos_Evidence; - - } - public: - virtual ~AuthzDecisionQueryImpl() { - XMLString::release(&m_Resource); - } - - AuthzDecisionQueryImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) { - init(); - } - - AuthzDecisionQueryImpl(const AuthzDecisionQueryImpl& src) : AbstractXMLObject(src), SubjectQueryImpl(src) { - init(); - setResource(src.getResource()); - if (src.getEvidence()) - setEvidence(src.getEvidence()->cloneEvidence()); - for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { - if (*i) { - Action* action=dynamic_cast(*i); - if (action) { - getActions().push_back(action->cloneAction()); - continue; - } - } - } - } - - IMPL_XMLOBJECT_CLONE(AuthzDecisionQuery); - SubjectQuery* cloneSubjectQuery() const { - return cloneAuthzDecisionQuery(); - } - RequestAbstractType* cloneRequestAbstractType() const { - return cloneAuthzDecisionQuery(); - } - - IMPL_STRING_ATTRIB(Resource); - IMPL_TYPED_FOREIGN_CHILDREN(Action,saml2,m_pos_Evidence); - IMPL_TYPED_FOREIGN_CHILD(Evidence,saml2); - - protected: - void marshallAttributes(DOMElement* domElement) const { - MARSHALL_STRING_ATTRIB(Resource,RESOURCE,NULL); - SubjectQueryImpl::marshallAttributes(domElement); - } - - void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_FOREIGN_CHILD(Evidence,saml2,SAMLConstants::SAML20_NS,false); - PROC_TYPED_FOREIGN_CHILDREN(Action,saml2,SAMLConstants::SAML20_NS,false); - SubjectQueryImpl::processChildElement(childXMLObject,root); - } - void processAttribute(const DOMAttr* attribute) { - PROC_STRING_ATTRIB(Resource,RESOURCE,NULL); - SubjectQueryImpl::processAttribute(attribute); - } - }; - - class SAML_DLLLOCAL NameIDPolicyImpl : public virtual NameIDPolicy, - public AbstractSimpleElement, - public AbstractDOMCachingXMLObject, - public AbstractXMLObjectMarshaller, - public AbstractXMLObjectUnmarshaller - { - void init() { - m_Format=NULL; - m_SPNameQualifier=NULL; - m_AllowCreate=XMLConstants::XML_BOOL_NULL; - } - public: - virtual ~NameIDPolicyImpl() - { - XMLString::release(&m_Format); - XMLString::release(&m_SPNameQualifier); - } - - NameIDPolicyImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) - { - init(); - } - - NameIDPolicyImpl(const NameIDPolicyImpl& src) - : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { - init(); - setFormat(src.getFormat()); - setSPNameQualifier(src.getSPNameQualifier()); - AllowCreate(m_AllowCreate); - } - - IMPL_XMLOBJECT_CLONE(NameIDPolicy); - IMPL_STRING_ATTRIB(Format); - IMPL_STRING_ATTRIB(SPNameQualifier); - IMPL_BOOLEAN_ATTRIB(AllowCreate); - - protected: - void marshallAttributes(DOMElement* domElement) const { - MARSHALL_STRING_ATTRIB(Format,FORMAT,NULL); - MARSHALL_STRING_ATTRIB(SPNameQualifier,SPNAMEQUALIFIER,NULL); - MARSHALL_BOOLEAN_ATTRIB(AllowCreate,ALLOWCREATE,NULL); - } - - void processAttribute(const DOMAttr* attribute) { - PROC_STRING_ATTRIB(Format,FORMAT,NULL); - PROC_STRING_ATTRIB(SPNameQualifier,SPNAMEQUALIFIER,NULL); - PROC_BOOLEAN_ATTRIB(AllowCreate,ALLOWCREATE,NULL); - AbstractXMLObjectUnmarshaller::processAttribute(attribute); - } - }; - - class SAML_DLLLOCAL IDPEntryImpl : public virtual IDPEntry, - public AbstractSimpleElement, - public AbstractDOMCachingXMLObject, - public AbstractXMLObjectMarshaller, - public AbstractXMLObjectUnmarshaller - { - void init() { - m_ProviderID=NULL; - m_Name=NULL; - m_Loc=NULL; - } - public: - virtual ~IDPEntryImpl() - { - XMLString::release(&m_ProviderID); - XMLString::release(&m_Name); - XMLString::release(&m_Loc); - } - - IDPEntryImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) - { - init(); - } - - IDPEntryImpl(const IDPEntryImpl& src) - : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { - init(); - setProviderID(src.getProviderID()); - setName(src.getName()); - setLoc(src.getLoc()); - } - - IMPL_XMLOBJECT_CLONE(IDPEntry); - IMPL_STRING_ATTRIB(ProviderID); - IMPL_STRING_ATTRIB(Name); - IMPL_STRING_ATTRIB(Loc); - - protected: - void marshallAttributes(DOMElement* domElement) const { - MARSHALL_STRING_ATTRIB(ProviderID,PROVIDERID,NULL); - MARSHALL_STRING_ATTRIB(Name,NAME,NULL); - MARSHALL_STRING_ATTRIB(Loc,LOC,NULL); - } - - void processAttribute(const DOMAttr* attribute) { - PROC_STRING_ATTRIB(ProviderID,PROVIDERID,NULL); - PROC_STRING_ATTRIB(Name,NAME,NULL); - PROC_STRING_ATTRIB(Loc,LOC,NULL); - AbstractXMLObjectUnmarshaller::processAttribute(attribute); - } - }; - - class SAML_DLLLOCAL IDPListImpl : public virtual IDPList, - public AbstractComplexElement, - public AbstractDOMCachingXMLObject, - public AbstractXMLObjectMarshaller, - public AbstractXMLObjectUnmarshaller - { - void init() { - m_GetComplete=NULL; - m_children.push_back(NULL); - m_pos_GetComplete=m_children.begin(); - - } - public: - virtual ~IDPListImpl() { } - - IDPListImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) - { - init(); - } - - IDPListImpl(const IDPListImpl& src) - : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { - init(); - if (src.getGetComplete()) - setGetComplete(src.getGetComplete()->cloneGetComplete()); - for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { - if (*i) { - IDPEntry* entry=dynamic_cast(*i); - if (entry) { - getIDPEntrys().push_back(entry->cloneIDPEntry()); - continue; - } - } - } - } - - IMPL_XMLOBJECT_CLONE(IDPList); - IMPL_TYPED_CHILDREN(IDPEntry,m_pos_GetComplete); - IMPL_TYPED_CHILD(GetComplete); - - protected: - void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_CHILDREN(IDPEntry,SAMLConstants::SAML20P_NS,false); - PROC_TYPED_CHILD(GetComplete,SAMLConstants::SAML20P_NS,false); - AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); - } - }; - - - class SAML_DLLLOCAL ScopingImpl : public virtual Scoping, - public AbstractComplexElement, - public AbstractDOMCachingXMLObject, - public AbstractXMLObjectMarshaller, - public AbstractXMLObjectUnmarshaller - { - void init() { - m_ProxyCount=NULL; - m_IDPList=NULL; - m_children.push_back(NULL); - m_pos_IDPList=m_children.begin(); - - } - public: - virtual ~ScopingImpl() { - XMLString::release(&m_ProxyCount); - } - - ScopingImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) - { - init(); - } - - ScopingImpl(const ScopingImpl& src) - : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { - init(); - setProxyCount(m_ProxyCount); - if (src.getIDPList()) - setIDPList(src.getIDPList()->cloneIDPList()); - for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { - if (*i) { - RequesterID* reqid =dynamic_cast(*i); - if (reqid) { - getRequesterIDs().push_back(reqid->cloneRequesterID()); - continue; - } - } - } - } - - IMPL_XMLOBJECT_CLONE(Scoping); - IMPL_INTEGER_ATTRIB(ProxyCount); - IMPL_TYPED_CHILD(IDPList); - IMPL_TYPED_CHILDREN(RequesterID,m_children.end()); - - protected: - void marshallAttributes(DOMElement* domElement) const { - MARSHALL_INTEGER_ATTRIB(ProxyCount,PROXYCOUNT,NULL); - } - - void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_CHILD(IDPList,SAMLConstants::SAML20P_NS,false); - PROC_TYPED_CHILDREN(RequesterID,SAMLConstants::SAML20P_NS,false); - AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); - } - - void processAttribute(const DOMAttr* attribute) { - PROC_INTEGER_ATTRIB(ProxyCount,PROXYCOUNT,NULL); - AbstractXMLObjectUnmarshaller::processAttribute(attribute); - } - }; - - class SAML_DLLLOCAL AuthnRequestImpl : public virtual AuthnRequest, public RequestAbstractTypeImpl - { - void init() { - m_ForceAuthn=XMLConstants::XML_BOOL_NULL; - m_IsPassive=XMLConstants::XML_BOOL_NULL; - m_ProtocolBinding=NULL; - m_AssertionConsumerServiceIndex=NULL; - m_AssertionConsumerServiceURL=NULL; - m_AttributeConsumingServiceIndex=NULL; - m_ProviderName=NULL; - - m_Subject=NULL; - m_NameIDPolicy=NULL; - m_Conditions=NULL; - m_RequestedAuthnContext=NULL; - m_Scoping=NULL; - m_children.push_back(NULL); - m_children.push_back(NULL); - m_children.push_back(NULL); - m_children.push_back(NULL); - m_children.push_back(NULL); - m_pos_Subject=m_pos_Extensions; - ++m_pos_Subject; - m_pos_NameIDPolicy=m_pos_Subject; - ++m_pos_NameIDPolicy; - m_pos_Conditions=m_pos_NameIDPolicy; - ++m_pos_Conditions; - m_pos_RequestedAuthnContext=m_pos_Conditions; - ++m_pos_RequestedAuthnContext; - m_pos_Scoping=m_pos_RequestedAuthnContext; - ++m_pos_Scoping; - - } - public: - virtual ~AuthnRequestImpl() { - XMLString::release(&m_ProtocolBinding); - XMLString::release(&m_AssertionConsumerServiceURL); - XMLString::release(&m_ProviderName); - XMLString::release(&m_AssertionConsumerServiceIndex); - XMLString::release(&m_AttributeConsumingServiceIndex); - } - - AuthnRequestImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) - { - init(); - } - - AuthnRequestImpl(const AuthnRequestImpl& src) : AbstractXMLObject(src), RequestAbstractTypeImpl(src) { - init(); - - ForceAuthn(m_ForceAuthn); - IsPassive(m_IsPassive); - setProtocolBinding(src.getProtocolBinding()); - setAssertionConsumerServiceIndex(m_AssertionConsumerServiceIndex); - setAssertionConsumerServiceURL(src.getAssertionConsumerServiceURL()); - setAttributeConsumingServiceIndex(m_AttributeConsumingServiceIndex); - setProviderName(src.getProviderName()); - - if (src.getSubject()) - setSubject(src.getSubject()->cloneSubject()); - if (src.getNameIDPolicy()) - setNameIDPolicy(src.getNameIDPolicy()->cloneNameIDPolicy()); - if (src.getConditions()) - setConditions(src.getConditions()->cloneConditions()); - if (src.getRequestedAuthnContext()) - setRequestedAuthnContext(src.getRequestedAuthnContext()->cloneRequestedAuthnContext()); - if (src.getScoping()) - setScoping(src.getScoping()->cloneScoping()); - } - - IMPL_XMLOBJECT_CLONE(AuthnRequest); - RequestAbstractType* cloneRequestAbstractType() const { - return cloneAuthnRequest(); - } - - IMPL_BOOLEAN_ATTRIB(ForceAuthn); - IMPL_BOOLEAN_ATTRIB(IsPassive); - IMPL_STRING_ATTRIB(ProtocolBinding); - IMPL_INTEGER_ATTRIB(AssertionConsumerServiceIndex); - IMPL_STRING_ATTRIB(AssertionConsumerServiceURL); - IMPL_INTEGER_ATTRIB(AttributeConsumingServiceIndex); - IMPL_STRING_ATTRIB(ProviderName); - - IMPL_TYPED_FOREIGN_CHILD(Subject,saml2); - IMPL_TYPED_CHILD(NameIDPolicy); - IMPL_TYPED_FOREIGN_CHILD(Conditions,saml2); - IMPL_TYPED_CHILD(RequestedAuthnContext); - IMPL_TYPED_CHILD(Scoping); - - protected: - void marshallAttributes(DOMElement* domElement) const { - MARSHALL_BOOLEAN_ATTRIB(ForceAuthn,FORCEAUTHN,NULL); - MARSHALL_BOOLEAN_ATTRIB(IsPassive,ISPASSIVE,NULL); - MARSHALL_STRING_ATTRIB(ProtocolBinding,PROTOCOLBINDING,NULL); - MARSHALL_INTEGER_ATTRIB(AssertionConsumerServiceIndex,ASSERTIONCONSUMERSERVICEINDEX,NULL); - MARSHALL_STRING_ATTRIB(AssertionConsumerServiceURL,ASSERTIONCONSUMERSERVICEURL,NULL); - MARSHALL_INTEGER_ATTRIB(AttributeConsumingServiceIndex,ATTRIBUTECONSUMINGSERVICEINDEX,NULL); - MARSHALL_STRING_ATTRIB(ProviderName,PROVIDERNAME,NULL); - RequestAbstractTypeImpl::marshallAttributes(domElement); - } - - void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_FOREIGN_CHILD(Subject,saml2,SAMLConstants::SAML20_NS,false); - PROC_TYPED_CHILD(NameIDPolicy,SAMLConstants::SAML20P_NS,false); - PROC_TYPED_FOREIGN_CHILD(Conditions,saml2,SAMLConstants::SAML20_NS,false); - PROC_TYPED_CHILD(RequestedAuthnContext,SAMLConstants::SAML20P_NS,false); - PROC_TYPED_CHILD(Scoping,SAMLConstants::SAML20P_NS,false); - RequestAbstractTypeImpl::processChildElement(childXMLObject,root); - } - void processAttribute(const DOMAttr* attribute) { - PROC_BOOLEAN_ATTRIB(ForceAuthn,FORCEAUTHN,NULL); - PROC_BOOLEAN_ATTRIB(IsPassive,ISPASSIVE,NULL); - PROC_STRING_ATTRIB(ProtocolBinding,PROTOCOLBINDING,NULL); - PROC_INTEGER_ATTRIB(AssertionConsumerServiceIndex,ASSERTIONCONSUMERSERVICEINDEX,NULL); - PROC_STRING_ATTRIB(AssertionConsumerServiceURL,ASSERTIONCONSUMERSERVICEURL,NULL); - PROC_INTEGER_ATTRIB(AttributeConsumingServiceIndex,ATTRIBUTECONSUMINGSERVICEINDEX,NULL); - PROC_STRING_ATTRIB(ProviderName,PROVIDERNAME,NULL); - RequestAbstractTypeImpl::processAttribute(attribute); - } - }; - - class SAML_DLLLOCAL StatusResponseTypeImpl : public virtual StatusResponseType, - public AbstractComplexElement, - public AbstractDOMCachingXMLObject, - public AbstractXMLObjectMarshaller, - public AbstractXMLObjectUnmarshaller - { - void init() { - m_ID=NULL; - m_InResponseTo=NULL; - m_Version=NULL; - m_IssueInstant=NULL; - m_Destination=NULL; - m_Consent=NULL; - m_Issuer=NULL; - m_Signature=NULL; - m_Extensions=NULL; - m_Status=NULL; - m_children.push_back(NULL); - m_children.push_back(NULL); - m_children.push_back(NULL); - m_children.push_back(NULL); - m_pos_Issuer=m_children.begin(); - m_pos_Signature=m_pos_Issuer; - ++m_pos_Signature; - m_pos_Extensions=m_pos_Signature; - ++m_pos_Extensions; - m_pos_Status=m_pos_Extensions; - ++m_pos_Status; - } - protected: - StatusResponseTypeImpl() { - init(); - } - public: - virtual ~StatusResponseTypeImpl() { - XMLString::release(&m_ID); - XMLString::release(&m_InResponseTo); - XMLString::release(&m_Version); - XMLString::release(&m_Destination); - XMLString::release(&m_Consent); - delete m_IssueInstant; - } - - StatusResponseTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) - { - init(); - } - - StatusResponseTypeImpl(const StatusResponseTypeImpl& src) - : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { - init(); - setID(src.getID()); - setInResponseTo(src.getInResponseTo()); - setVersion(src.getVersion()); - setIssueInstant(src.getIssueInstant()); - setDestination(src.getDestination()); - setConsent(src.getConsent()); - if (src.getIssuer()) - setIssuer(src.getIssuer()->cloneIssuer()); - if (src.getSignature()) - setSignature(src.getSignature()->cloneSignature()); - if (src.getExtensions()) - setExtensions(src.getExtensions()->cloneExtensions()); - if (src.getStatus()) - setStatus(src.getStatus()->cloneStatus()); - } - - //IMPL_TYPED_CHILD(Signature); - // Need customized setter. - protected: - Signature* m_Signature; - list::iterator m_pos_Signature; - public: - Signature* getSignature() const { - return m_Signature; - } - - void setSignature(Signature* sig) { - prepareForAssignment(m_Signature,sig); - *m_pos_Signature=m_Signature=sig; - // Sync content reference back up. - if (m_Signature) - m_Signature->setContentReference(new opensaml::ContentReference(*this)); - } - - IMPL_STRING_ATTRIB(Version); - IMPL_ID_ATTRIB(ID); - IMPL_STRING_ATTRIB(InResponseTo); - IMPL_DATETIME_ATTRIB(IssueInstant,0); - IMPL_STRING_ATTRIB(Destination); - IMPL_STRING_ATTRIB(Consent); - IMPL_TYPED_FOREIGN_CHILD(Issuer,saml2); - IMPL_TYPED_CHILD(Extensions); - IMPL_TYPED_CHILD(Status); - - protected: - void marshallAttributes(DOMElement* domElement) const { - if (!m_Version) - const_cast(this)->m_Version=XMLString::transcode("2.0"); - MARSHALL_STRING_ATTRIB(Version,VER,NULL); - if (!m_ID) - const_cast(this)->m_ID=SAMLConfig::getConfig().generateIdentifier(); - MARSHALL_ID_ATTRIB(ID,ID,NULL); - if (!m_IssueInstant) { - const_cast(this)->m_IssueInstantEpoch=time(NULL); - const_cast(this)->m_IssueInstant=new DateTime(m_IssueInstantEpoch); - } - MARSHALL_DATETIME_ATTRIB(IssueInstant,ISSUEINSTANT,NULL); - MARSHALL_STRING_ATTRIB(Destination,DESTINATION,NULL); - MARSHALL_STRING_ATTRIB(Consent,CONSENT,NULL); - MARSHALL_STRING_ATTRIB(InResponseTo,INRESPONSETO,NULL); - } - - void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_FOREIGN_CHILD(Issuer,saml2,SAMLConstants::SAML20_NS,false); - PROC_TYPED_FOREIGN_CHILD(Signature,xmlsignature,XMLConstants::XMLSIG_NS,false); - PROC_TYPED_CHILD(Extensions,SAMLConstants::SAML20P_NS,false); - PROC_TYPED_CHILD(Status,SAMLConstants::SAML20P_NS,false); - AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); - } - - void processAttribute(const DOMAttr* attribute) { - PROC_ID_ATTRIB(ID,ID,NULL); - PROC_STRING_ATTRIB(Version,VER,NULL); - PROC_STRING_ATTRIB(InResponseTo,INRESPONSETO,NULL); - PROC_DATETIME_ATTRIB(IssueInstant,ISSUEINSTANT,NULL); - PROC_STRING_ATTRIB(Destination,DESTINATION,NULL); - PROC_STRING_ATTRIB(Consent,CONSENT,NULL); - AbstractXMLObjectUnmarshaller::processAttribute(attribute); - } - }; - - class SAML_DLLLOCAL ResponseImpl : public virtual Response, public StatusResponseTypeImpl - { - public: - virtual ~ResponseImpl() { } - - ResponseImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - - ResponseImpl(const ResponseImpl& src) : AbstractXMLObject(src), StatusResponseTypeImpl(src) { - for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { - if (*i) { - Assertion* assertion=dynamic_cast(*i); - if (assertion) { - getAssertions().push_back(assertion->cloneAssertion()); - continue; - } - EncryptedAssertion* encAssertion=dynamic_cast(*i); - if (encAssertion) { - getEncryptedAssertions().push_back(encAssertion->cloneEncryptedAssertion()); - continue; - } - } - } - - } - - IMPL_XMLOBJECT_CLONE(Response); - StatusResponseType* cloneStatusResponseType() const { - return cloneResponse(); - } - - IMPL_TYPED_FOREIGN_CHILDREN(Assertion,saml2,m_children.end()); - IMPL_TYPED_FOREIGN_CHILDREN(EncryptedAssertion,saml2,m_children.end()); - - protected: - void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_FOREIGN_CHILDREN(Assertion,saml2,SAMLConstants::SAML20_NS,false); - PROC_TYPED_FOREIGN_CHILDREN(EncryptedAssertion,saml2,SAMLConstants::SAML20_NS,false); - StatusResponseTypeImpl::processChildElement(childXMLObject,root); - } - }; - - class SAML_DLLLOCAL ArtifactResolveImpl : public virtual ArtifactResolve, public RequestAbstractTypeImpl - { - void init() { - m_Artifact=NULL; - m_children.push_back(NULL); - m_pos_Artifact=m_pos_Extensions; - ++m_pos_Artifact; - } - public: - virtual ~ArtifactResolveImpl() { } - - ArtifactResolveImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) - { - init(); - } - - ArtifactResolveImpl(const ArtifactResolveImpl& src) : AbstractXMLObject(src), RequestAbstractTypeImpl(src) { - init(); - if(src.getArtifact()) - setArtifact(src.getArtifact()->cloneArtifact()); - } - - IMPL_XMLOBJECT_CLONE(ArtifactResolve); - RequestAbstractType* cloneRequestAbstractType() const { - return cloneArtifactResolve(); - } - - IMPL_TYPED_CHILD(Artifact); - - protected: - void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_CHILD(Artifact,SAMLConstants::SAML20P_NS,false); - RequestAbstractTypeImpl::processChildElement(childXMLObject,root); - } - }; - - class SAML_DLLLOCAL ArtifactResponseImpl : public virtual ArtifactResponse, public StatusResponseTypeImpl - { - void init() { - m_Payload=NULL; - m_children.push_back(NULL); - m_pos_Payload=m_pos_Status; - ++m_pos_Payload; - } - public: - virtual ~ArtifactResponseImpl() { } - - ArtifactResponseImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) - { - init(); - } - - ArtifactResponseImpl(const ArtifactResponseImpl& src) : AbstractXMLObject(src), StatusResponseTypeImpl(src) { - init(); - if (src.getPayload()) - setPayload(getPayload()->clone()); - - } - - IMPL_XMLOBJECT_CLONE(ArtifactResponse); - StatusResponseType* cloneStatusResponseType() const { - return cloneArtifactResponse(); - } - - IMPL_XMLOBJECT_CHILD(Payload); - - protected: - void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - // These are valid elements for the parent StatusResponseType, so don't process these. - // If not one of these, then it must be the payload. - if ( - ! XMLHelper::isNodeNamed(root,SAMLConstants::SAML20_NS,saml2::Issuer::LOCAL_NAME) && - ! XMLHelper::isNodeNamed(root,XMLConstants::XMLSIG_NS,xmlsignature::Signature::LOCAL_NAME) && - ! XMLHelper::isNodeNamed(root,SAMLConstants::SAML20P_NS,saml2p::Extensions::LOCAL_NAME) && - ! XMLHelper::isNodeNamed(root,SAMLConstants::SAML20P_NS,saml2p::Status::LOCAL_NAME) - ) - { - setPayload(childXMLObject); - return; - } - - StatusResponseTypeImpl::processChildElement(childXMLObject,root); - } - }; - - class SAML_DLLLOCAL NewEncryptedIDImpl : public virtual NewEncryptedID, - public AbstractComplexElement, - public AbstractDOMCachingXMLObject, - public AbstractXMLObjectMarshaller, - public AbstractXMLObjectUnmarshaller - { - void init() { - m_EncryptedData=NULL; - m_children.push_back(NULL); - m_pos_EncryptedData=m_children.begin(); - } - - protected: - NewEncryptedIDImpl() - { - init(); - } - - public: - virtual ~NewEncryptedIDImpl() {} - - NewEncryptedIDImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) - { - init(); - } - - NewEncryptedIDImpl(const NewEncryptedIDImpl& src) - : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { - init(); - if (src.getEncryptedData()) - setEncryptedData(src.getEncryptedData()->cloneEncryptedData()); - VectorOf(xmlencryption::EncryptedKey) v=getEncryptedKeys(); - for (vector::const_iterator i=src.m_EncryptedKeys.begin(); i!=src.m_EncryptedKeys.end(); i++) { - if (*i) { - v.push_back((*i)->cloneEncryptedKey()); - } - } - } - - XMLObject* decrypt(KeyResolver* KEKresolver, const XMLCh* recipient) const - { - if (!m_EncryptedData) - throw DecryptionException("No encrypted data present."); - Decrypter decrypter(KEKresolver, new EncryptedKeyResolver(*this, recipient)); - DOMDocumentFragment* frag = decrypter.decryptData(m_EncryptedData); - if (frag->hasChildNodes() && frag->getFirstChild()==frag->getLastChild()) { - DOMNode* plaintext=frag->getFirstChild(); - if (plaintext->getNodeType()==DOMNode::ELEMENT_NODE) { - auto_ptr ret(XMLObjectBuilder::buildOneFromElement(static_cast(plaintext))); - ret->releaseThisAndChildrenDOM(); - return ret.release(); - } - } - frag->release(); - throw DecryptionException("Decryption did not result in a single element."); - } - - IMPL_XMLOBJECT_CLONE(NewEncryptedID); - EncryptedElementType* cloneEncryptedElementType() const { - return new NewEncryptedIDImpl(*this); - } - - IMPL_TYPED_FOREIGN_CHILD(EncryptedData,xmlencryption); - IMPL_TYPED_FOREIGN_CHILDREN(EncryptedKey,xmlencryption,m_children.end()); - - protected: - void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_FOREIGN_CHILD(EncryptedData,xmlencryption,XMLConstants::XMLENC_NS,false); - PROC_TYPED_FOREIGN_CHILDREN(EncryptedKey,xmlencryption,XMLConstants::XMLENC_NS,false); - AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); - } - }; - - class SAML_DLLLOCAL TerminateImpl : public virtual Terminate, - public AbstractSimpleElement, - public AbstractDOMCachingXMLObject, - public AbstractXMLObjectMarshaller, - public AbstractXMLObjectUnmarshaller - { - public: - virtual ~TerminateImpl() { } - - TerminateImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - - TerminateImpl(const TerminateImpl& src) - : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { - } - - IMPL_XMLOBJECT_CLONE(Terminate); - - protected: - // has no attributes or children - }; - - class SAML_DLLLOCAL ManageNameIDRequestImpl : public virtual ManageNameIDRequest, public RequestAbstractTypeImpl - { - void init() { - m_NameID=NULL; - m_EncryptedID=NULL; - m_NewID=NULL; - m_NewEncryptedID=NULL; - m_Terminate=NULL; - m_children.push_back(NULL); - m_children.push_back(NULL); - m_children.push_back(NULL); - m_children.push_back(NULL); - m_children.push_back(NULL); - m_pos_NameID=m_pos_Extensions; - ++m_pos_NameID; - m_pos_EncryptedID=m_pos_NameID; - ++m_pos_EncryptedID; - m_pos_NewID=m_pos_EncryptedID; - ++m_pos_NewID; - m_pos_NewEncryptedID=m_pos_NewID; - ++m_pos_NewEncryptedID; - m_pos_Terminate=m_pos_NewEncryptedID; - ++m_pos_Terminate; - - } - public: - virtual ~ManageNameIDRequestImpl() { } - - ManageNameIDRequestImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) - { - init(); - } - - ManageNameIDRequestImpl(const ManageNameIDRequestImpl& src) : AbstractXMLObject(src), RequestAbstractTypeImpl(src) { - init(); - - if (src.getNameID()) - setNameID(src.getNameID()->cloneNameID()); - if (src.getEncryptedID()) - setEncryptedID(src.getEncryptedID()->cloneEncryptedID()); - if (src.getNewID()) - setNewID(src.getNewID()->cloneNewID()); - if (src.getNewEncryptedID()) - setNewEncryptedID(src.getNewEncryptedID()->cloneNewEncryptedID()); - if (src.getTerminate()) - setTerminate(src.getTerminate()->cloneTerminate()); - - } - - IMPL_XMLOBJECT_CLONE(ManageNameIDRequest); - RequestAbstractType* cloneRequestAbstractType() const { - return cloneManageNameIDRequest(); - } - - IMPL_TYPED_FOREIGN_CHILD(NameID,saml2); - IMPL_TYPED_FOREIGN_CHILD(EncryptedID,saml2); - IMPL_TYPED_CHILD(NewID); - IMPL_TYPED_CHILD(NewEncryptedID); - IMPL_TYPED_CHILD(Terminate); - - protected: - void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_FOREIGN_CHILD(NameID,saml2,SAMLConstants::SAML20_NS,false); - PROC_TYPED_FOREIGN_CHILD(EncryptedID,saml2,SAMLConstants::SAML20_NS,false); - PROC_TYPED_CHILD(NewID,SAMLConstants::SAML20P_NS,false); - PROC_TYPED_CHILD(NewEncryptedID,SAMLConstants::SAML20P_NS,false); - PROC_TYPED_CHILD(Terminate,SAMLConstants::SAML20P_NS,false); - RequestAbstractTypeImpl::processChildElement(childXMLObject,root); - } - }; - - class SAML_DLLLOCAL ManageNameIDResponseImpl : public virtual ManageNameIDResponse, public StatusResponseTypeImpl - { - public: - virtual ~ManageNameIDResponseImpl() { } - - ManageNameIDResponseImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - - ManageNameIDResponseImpl(const ManageNameIDResponseImpl& src) : AbstractXMLObject(src), StatusResponseTypeImpl(src) { - } - - IMPL_XMLOBJECT_CLONE(ManageNameIDResponse); - StatusResponseType* cloneStatusResponseType() const { - return cloneManageNameIDResponse(); - } - }; - - class SAML_DLLLOCAL LogoutRequestImpl : public virtual LogoutRequest, public RequestAbstractTypeImpl - { - void init() { - m_Reason=NULL; - m_NotOnOrAfter=NULL; - - m_BaseID=NULL; - m_NameID=NULL; - m_EncryptedID=NULL; - m_children.push_back(NULL); - m_children.push_back(NULL); - m_children.push_back(NULL); - m_pos_BaseID=m_pos_Extensions; - ++m_pos_BaseID; - m_pos_NameID=m_pos_BaseID; - ++m_pos_NameID; - m_pos_EncryptedID=m_pos_NameID; - ++m_pos_EncryptedID; - - } - public: - virtual ~LogoutRequestImpl() { - XMLString::release(&m_Reason); - delete m_NotOnOrAfter; - } - - LogoutRequestImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) - { - init(); - } - - LogoutRequestImpl(const LogoutRequestImpl& src) : AbstractXMLObject(src), RequestAbstractTypeImpl(src) { - init(); - - setReason(src.getReason()); - setNotOnOrAfter(src.getNotOnOrAfter()); - - if (src.getBaseID()) - setBaseID(src.getBaseID()->cloneBaseID()); - if (src.getNameID()) - setNameID(src.getNameID()->cloneNameID()); - if (src.getEncryptedID()) - setEncryptedID(src.getEncryptedID()->cloneEncryptedID()); - - for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { - if (*i) { - SessionIndex* si = dynamic_cast(*i); - if (si) { - getSessionIndexs().push_back(si->cloneSessionIndex()); - continue; - } - } - } - } - - IMPL_XMLOBJECT_CLONE(LogoutRequest); - RequestAbstractType* cloneRequestAbstractType() const { - return cloneLogoutRequest(); - } - - IMPL_STRING_ATTRIB(Reason); - IMPL_DATETIME_ATTRIB(NotOnOrAfter,SAMLTIME_MAX); - IMPL_TYPED_FOREIGN_CHILD(BaseID,saml2); - IMPL_TYPED_FOREIGN_CHILD(NameID,saml2); - IMPL_TYPED_FOREIGN_CHILD(EncryptedID,saml2); - IMPL_TYPED_CHILDREN(SessionIndex,m_children.end()); - - protected: - void marshallAttributes(DOMElement* domElement) const { - MARSHALL_STRING_ATTRIB(Reason,REASON,NULL); - MARSHALL_DATETIME_ATTRIB(NotOnOrAfter,NOTONORAFTER,NULL); - RequestAbstractTypeImpl::marshallAttributes(domElement); - } - - void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_FOREIGN_CHILD(BaseID,saml2,SAMLConstants::SAML20_NS,false); - PROC_TYPED_FOREIGN_CHILD(NameID,saml2,SAMLConstants::SAML20_NS,false); - PROC_TYPED_FOREIGN_CHILD(EncryptedID,saml2,SAMLConstants::SAML20_NS,false); - PROC_TYPED_CHILDREN(SessionIndex,SAMLConstants::SAML20P_NS,false); - RequestAbstractTypeImpl::processChildElement(childXMLObject,root); - } - void processAttribute(const DOMAttr* attribute) { - PROC_STRING_ATTRIB(Reason,REASON,NULL); - PROC_DATETIME_ATTRIB(NotOnOrAfter,NOTONORAFTER,NULL); - RequestAbstractTypeImpl::processAttribute(attribute); - } - }; - - class SAML_DLLLOCAL LogoutResponseImpl : public virtual LogoutResponse, public StatusResponseTypeImpl - { - public: - virtual ~LogoutResponseImpl() { } - - LogoutResponseImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - - LogoutResponseImpl(const LogoutResponseImpl& src) : AbstractXMLObject(src), StatusResponseTypeImpl(src) { - } - - IMPL_XMLOBJECT_CLONE(LogoutResponse); - StatusResponseType* cloneStatusResponseType() const { - return cloneLogoutResponse(); - } - }; - - - class SAML_DLLLOCAL NameIDMappingRequestImpl : public virtual NameIDMappingRequest, public RequestAbstractTypeImpl - { - void init() { - m_BaseID=NULL; - m_NameID=NULL; - m_EncryptedID=NULL; - m_NameIDPolicy=NULL; - m_children.push_back(NULL); - m_children.push_back(NULL); - m_children.push_back(NULL); - m_children.push_back(NULL); - m_pos_BaseID=m_pos_Extensions; - ++m_pos_BaseID; - m_pos_NameID=m_pos_BaseID; - ++m_pos_NameID; - m_pos_EncryptedID=m_pos_NameID; - ++m_pos_EncryptedID; - m_pos_NameIDPolicy=m_pos_EncryptedID; - ++m_pos_NameIDPolicy; - - } - public: - virtual ~NameIDMappingRequestImpl() { } - - NameIDMappingRequestImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) - { - init(); - } - - NameIDMappingRequestImpl(const NameIDMappingRequestImpl& src) : AbstractXMLObject(src), RequestAbstractTypeImpl(src) { - init(); - - if (src.getBaseID()) - setBaseID(src.getBaseID()->cloneBaseID()); - if (src.getNameID()) - setNameID(src.getNameID()->cloneNameID()); - if (src.getEncryptedID()) - setEncryptedID(src.getEncryptedID()->cloneEncryptedID()); - if (src.getNameIDPolicy()) - setNameIDPolicy(src.getNameIDPolicy()->cloneNameIDPolicy()); - - } - - IMPL_XMLOBJECT_CLONE(NameIDMappingRequest); - RequestAbstractType* cloneRequestAbstractType() const { - return cloneNameIDMappingRequest(); - } - - IMPL_TYPED_FOREIGN_CHILD(BaseID,saml2); - IMPL_TYPED_FOREIGN_CHILD(NameID,saml2); - IMPL_TYPED_FOREIGN_CHILD(EncryptedID,saml2); - IMPL_TYPED_CHILD(NameIDPolicy); - - protected: - void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_FOREIGN_CHILD(BaseID,saml2,SAMLConstants::SAML20_NS,false); - PROC_TYPED_FOREIGN_CHILD(NameID,saml2,SAMLConstants::SAML20_NS,false); - PROC_TYPED_FOREIGN_CHILD(EncryptedID,saml2,SAMLConstants::SAML20_NS,false); - PROC_TYPED_CHILD(NameIDPolicy,SAMLConstants::SAML20P_NS,false); - RequestAbstractTypeImpl::processChildElement(childXMLObject,root); - } - }; - - class SAML_DLLLOCAL NameIDMappingResponseImpl : public virtual NameIDMappingResponse, public StatusResponseTypeImpl - { - void init() { - m_NameID=NULL; - m_EncryptedID=NULL; - m_children.push_back(NULL); - m_children.push_back(NULL); - m_pos_NameID=m_pos_Status; - ++m_pos_NameID; - m_pos_EncryptedID=m_pos_NameID; - ++m_pos_EncryptedID; - } - public: - virtual ~NameIDMappingResponseImpl() { } - - NameIDMappingResponseImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) - : AbstractXMLObject(nsURI, localName, prefix, schemaType) - { - init(); - } - - NameIDMappingResponseImpl(const NameIDMappingResponseImpl& src) : AbstractXMLObject(src), StatusResponseTypeImpl(src) { - init(); - - if (src.getNameID()) - setNameID(getNameID()->cloneNameID()); - if (src.getEncryptedID()) - setEncryptedID(getEncryptedID()->cloneEncryptedID()); - - } - - IMPL_XMLOBJECT_CLONE(NameIDMappingResponse); - StatusResponseType* cloneStatusResponseType() const { - return cloneNameIDMappingResponse(); - } - - IMPL_TYPED_FOREIGN_CHILD(NameID,saml2); - IMPL_TYPED_FOREIGN_CHILD(EncryptedID,saml2); - - protected: - void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_FOREIGN_CHILD(NameID,saml2,SAMLConstants::SAML20_NS,false); - PROC_TYPED_FOREIGN_CHILD(EncryptedID,saml2,SAMLConstants::SAML20_NS,false); - StatusResponseTypeImpl::processChildElement(childXMLObject,root); - } - }; - }; -}; - -#if defined (_MSC_VER) - #pragma warning( pop ) -#endif - -// Builder Implementations -IMPL_XMLOBJECTBUILDER(Artifact); -IMPL_XMLOBJECTBUILDER(ArtifactResolve); -IMPL_XMLOBJECTBUILDER(ArtifactResponse); -IMPL_XMLOBJECTBUILDER(AssertionIDRequest); -IMPL_XMLOBJECTBUILDER(AttributeQuery); -IMPL_XMLOBJECTBUILDER(AuthnQuery); -IMPL_XMLOBJECTBUILDER(AuthnRequest); -IMPL_XMLOBJECTBUILDER(AuthzDecisionQuery); -IMPL_XMLOBJECTBUILDER(Extensions); -IMPL_XMLOBJECTBUILDER(GetComplete); -IMPL_XMLOBJECTBUILDER(IDPEntry); -IMPL_XMLOBJECTBUILDER(IDPList); -IMPL_XMLOBJECTBUILDER(LogoutRequest); -IMPL_XMLOBJECTBUILDER(LogoutResponse); -IMPL_XMLOBJECTBUILDER(ManageNameIDRequest); -IMPL_XMLOBJECTBUILDER(ManageNameIDResponse); -IMPL_XMLOBJECTBUILDER(NameIDMappingRequest); -IMPL_XMLOBJECTBUILDER(NameIDMappingResponse); -IMPL_XMLOBJECTBUILDER(NameIDPolicy); -IMPL_XMLOBJECTBUILDER(NewEncryptedID); -IMPL_XMLOBJECTBUILDER(NewID); -IMPL_XMLOBJECTBUILDER(RequestedAuthnContext); -IMPL_XMLOBJECTBUILDER(RequesterID); -IMPL_XMLOBJECTBUILDER(Response); -IMPL_XMLOBJECTBUILDER(Scoping); -IMPL_XMLOBJECTBUILDER(SessionIndex); -IMPL_XMLOBJECTBUILDER(Status); -IMPL_XMLOBJECTBUILDER(StatusCode); -IMPL_XMLOBJECTBUILDER(StatusDetail); -IMPL_XMLOBJECTBUILDER(StatusMessage); -IMPL_XMLOBJECTBUILDER(Terminate); - -IMPL_XMLOBJECTBUILDER(RespondTo); - -// Unicode literals -const XMLCh Artifact::LOCAL_NAME[] = UNICODE_LITERAL_8(A,r,t,i,f,a,c,t); -const XMLCh ArtifactResolve::LOCAL_NAME[] = UNICODE_LITERAL_15(A,r,t,i,f,a,c,t,R,e,s,o,l,v,e); -const XMLCh ArtifactResolve::TYPE_NAME[] = UNICODE_LITERAL_19(A,r,t,i,f,a,c,t,R,e,s,o,l,v,e,T,y,p,e); -const XMLCh ArtifactResponse::LOCAL_NAME[] = UNICODE_LITERAL_16(A,r,t,i,f,a,c,t,R,e,s,p,o,n,s,e); -const XMLCh ArtifactResponse::TYPE_NAME[] = UNICODE_LITERAL_20(A,r,t,i,f,a,c,t,R,e,s,p,o,n,s,e,T,y,p,e); -const XMLCh AssertionIDRequest::LOCAL_NAME[] = UNICODE_LITERAL_18(A,s,s,e,r,t,i,o,n,I,D,R,e,q,u,e,s,t); -const XMLCh AssertionIDRequest::TYPE_NAME[] = UNICODE_LITERAL_22(A,s,s,e,r,t,i,o,n,I,D,R,e,q,u,e,s,t,T,y,p,e); -const XMLCh AttributeQuery::LOCAL_NAME[] = UNICODE_LITERAL_14(A,t,t,r,i,b,u,t,e,Q,u,e,r,y); -const XMLCh AttributeQuery::TYPE_NAME[] = UNICODE_LITERAL_18(A,t,t,r,i,b,u,t,e,Q,u,e,r,y,T,y,p,e); -const XMLCh AuthnQuery::LOCAL_NAME[] = UNICODE_LITERAL_10(A,u,t,h,n,Q,u,e,r,y); -const XMLCh AuthnQuery::TYPE_NAME[] = UNICODE_LITERAL_14(A,u,t,h,n,Q,u,e,r,y,T,y,p,e); -const XMLCh AuthnQuery::SESSIONINDEX_ATTRIB_NAME[] = UNICODE_LITERAL_12(S,e,s,s,i,o,n,I,n,d,e,x); -const XMLCh AuthnRequest::LOCAL_NAME[] = UNICODE_LITERAL_12(A,u,t,h,n,R,e,q,u,e,s,t); -const XMLCh AuthnRequest::TYPE_NAME[] = UNICODE_LITERAL_16(A,u,t,h,n,R,e,q,u,e,s,t,T,y,p,e); -const XMLCh AuthnRequest::FORCEAUTHN_ATTRIB_NAME[] = UNICODE_LITERAL_10(F,o,r,c,e,A,u,t,h,n); -const XMLCh AuthnRequest::ISPASSIVE_ATTRIB_NAME[] = UNICODE_LITERAL_9(I,s,P,a,s,s,i,v,e); -const XMLCh AuthnRequest::PROTOCOLBINDING_ATTRIB_NAME[] = UNICODE_LITERAL_15(P,r,o,t,o,c,o,l,B,i,n,d,i,n,g); -const XMLCh AuthnRequest::ASSERTIONCONSUMERSERVICEINDEX_ATTRIB_NAME[] = UNICODE_LITERAL_29(A,s,s,e,r,t,i,o,n,C,o,n,s,u,m,e,r,S,e,r,v,i,c,e,I,n,d,e,x); -const XMLCh AuthnRequest::ASSERTIONCONSUMERSERVICEURL_ATTRIB_NAME[] = UNICODE_LITERAL_27(A,s,s,e,r,t,i,o,n,C,o,n,s,u,m,e,r,S,e,r,v,i,c,e,U,R,L); -const XMLCh AuthnRequest::ATTRIBUTECONSUMINGSERVICEINDEX_ATTRIB_NAME[] = UNICODE_LITERAL_30(A,t,t,r,i,b,u,t,e,C,o,n,s,u,m,i,n,g,S,e,r,v,i,c,e,I,n,d,e,x); -const XMLCh AuthnRequest::PROVIDERNAME_ATTRIB_NAME[] = UNICODE_LITERAL_12(P,r,o,v,i,d,e,r,N,a,m,e); -const XMLCh AuthzDecisionQuery::LOCAL_NAME[] = UNICODE_LITERAL_18(A,u,t,h,z,D,e,c,i,s,i,o,n,Q,u,e,r,y); -const XMLCh AuthzDecisionQuery::TYPE_NAME[] = UNICODE_LITERAL_22(A,u,t,h,z,D,e,c,i,s,i,o,n,Q,u,e,r,y,T,y,p,e); -const XMLCh AuthzDecisionQuery::RESOURCE_ATTRIB_NAME[] = UNICODE_LITERAL_8(R,e,s,o,u,r,c,e); -const XMLCh Extensions::LOCAL_NAME[] = UNICODE_LITERAL_10(E,x,t,e,n,s,i,o,n,s); -const XMLCh Extensions::TYPE_NAME[] = UNICODE_LITERAL_14(E,x,t,e,n,s,i,o,n,s,T,y,p,e); -const XMLCh GetComplete::LOCAL_NAME[] = UNICODE_LITERAL_11(G,e,t,C,o,m,p,l,e,t,e); -const XMLCh IDPEntry::LOCAL_NAME[] = UNICODE_LITERAL_8(I,D,P,E,n,t,r,y); -const XMLCh IDPEntry::TYPE_NAME[] = UNICODE_LITERAL_12(I,D,P,E,n,t,r,y,T,y,p,e); -const XMLCh IDPEntry::PROVIDERID_ATTRIB_NAME[] = UNICODE_LITERAL_10(P,r,o,v,i,d,e,r,I,D); -const XMLCh IDPEntry::NAME_ATTRIB_NAME[] = UNICODE_LITERAL_4(N,a,m,e); -const XMLCh IDPEntry::LOC_ATTRIB_NAME[] = UNICODE_LITERAL_3(L,o,c); -const XMLCh IDPList::LOCAL_NAME[] = UNICODE_LITERAL_7(I,D,P,L,i,s,t); -const XMLCh IDPList::TYPE_NAME[] = UNICODE_LITERAL_11(I,D,P,L,i,s,t,T,y,p,e); -const XMLCh LogoutRequest::LOCAL_NAME[] = UNICODE_LITERAL_13(L,o,g,o,u,t,R,e,q,u,e,s,t); -const XMLCh LogoutRequest::TYPE_NAME[] = UNICODE_LITERAL_17(L,o,g,o,u,t,R,e,q,u,e,s,t,T,y,p,e); -const XMLCh LogoutRequest::REASON_ATTRIB_NAME[] = UNICODE_LITERAL_6(R,e,a,s,o,n); -const XMLCh LogoutRequest::NOTONORAFTER_ATTRIB_NAME[] = UNICODE_LITERAL_12(N,o,t,O,n,O,r,A,f,t,e,r); -const XMLCh LogoutResponse::LOCAL_NAME[] = UNICODE_LITERAL_14(L,o,g,o,u,t,R,e,s,p,o,n,s,e); -const XMLCh ManageNameIDRequest::LOCAL_NAME[] = UNICODE_LITERAL_19(M,a,n,a,g,e,N,a,m,e,I,D,R,e,q,u,e,s,t); -const XMLCh ManageNameIDRequest::TYPE_NAME[] = UNICODE_LITERAL_23(M,a,n,a,g,e,N,a,m,e,I,D,R,e,q,u,e,s,t,T,y,p,e); -const XMLCh ManageNameIDResponse::LOCAL_NAME[] = UNICODE_LITERAL_20(M,a,n,a,g,e,N,a,m,e,I,D,R,e,s,p,o,n,s,e); -const XMLCh NameIDMappingRequest::LOCAL_NAME[] = UNICODE_LITERAL_20(N,a,m,e,I,D,M,a,p,p,i,n,g,R,e,q,u,e,s,t); -const XMLCh NameIDMappingRequest::TYPE_NAME[] = UNICODE_LITERAL_24(N,a,m,e,I,D,M,a,p,p,i,n,g,R,e,q,u,e,s,t,T,y,p,e); -const XMLCh NameIDMappingResponse::LOCAL_NAME[] = UNICODE_LITERAL_21(N,a,m,e,I,D,M,a,p,p,i,n,g,R,e,s,p,o,n,s,e); -const XMLCh NameIDMappingResponse::TYPE_NAME[] = UNICODE_LITERAL_25(N,a,m,e,I,D,M,a,p,p,i,n,g,R,e,s,p,o,n,s,e,T,y,p,e); -const XMLCh NameIDPolicy::LOCAL_NAME[] = UNICODE_LITERAL_12(N,a,m,e,I,D,P,o,l,i,c,y); -const XMLCh NameIDPolicy::TYPE_NAME[] = UNICODE_LITERAL_16(N,a,m,e,I,D,P,o,l,i,c,y,T,y,p,e); -const XMLCh NameIDPolicy::FORMAT_ATTRIB_NAME[] = UNICODE_LITERAL_6(F,o,r,m,a,t); -const XMLCh NameIDPolicy::SPNAMEQUALIFIER_ATTRIB_NAME[] = UNICODE_LITERAL_15(S,P,N,a,m,e,Q,u,a,l,i,f,i,e,r); -const XMLCh NameIDPolicy::ALLOWCREATE_ATTRIB_NAME[] = UNICODE_LITERAL_11(A,l,l,o,w,C,r,e,a,t,e); -const XMLCh NewEncryptedID::LOCAL_NAME[] = UNICODE_LITERAL_14(N,e,w,E,n,c,r,y,p,t,e,d,I,D); -const XMLCh NewID::LOCAL_NAME[] = UNICODE_LITERAL_5(N,e,w,I,D); -const XMLCh RequesterID::LOCAL_NAME[] = UNICODE_LITERAL_11(R,e,q,u,e,s,t,e,r,I,D); -const XMLCh RequestedAuthnContext::LOCAL_NAME[] = UNICODE_LITERAL_21(R,e,q,u,e,s,t,e,d,A,u,t,h,n,C,o,n,t,e,x,t); -const XMLCh RequestedAuthnContext::TYPE_NAME[] = UNICODE_LITERAL_25(R,e,q,u,e,s,t,e,d,A,u,t,h,n,C,o,n,t,e,x,t,T,y,p,e); -const XMLCh RequestedAuthnContext::COMPARISON_ATTRIB_NAME[] = UNICODE_LITERAL_10(C,o,m,p,a,r,i,s,o,n); -const XMLCh RequestedAuthnContext::COMPARISON_EXACT[] = UNICODE_LITERAL_5(e,x,a,c,t); -const XMLCh RequestedAuthnContext::COMPARISON_MINIMUM[] = UNICODE_LITERAL_7(m,i,n,i,m,u,m); -const XMLCh RequestedAuthnContext::COMPARISON_MAXIMUM[] = UNICODE_LITERAL_7(m,a,x,i,m,u,m); -const XMLCh RequestedAuthnContext::COMPARISON_BETTER[] = UNICODE_LITERAL_6(b,e,t,t,e,r); -const XMLCh RequestAbstractType::LOCAL_NAME[] = {chNull}; -const XMLCh RequestAbstractType::TYPE_NAME[] = UNICODE_LITERAL_19(R,e,q,u,e,s,t,A,b,s,t,r,a,c,t,T,y,p,e); -const XMLCh RequestAbstractType::ID_ATTRIB_NAME[] = UNICODE_LITERAL_2(I,D); -const XMLCh RequestAbstractType::VER_ATTRIB_NAME[] = UNICODE_LITERAL_7(V,e,r,s,i,o,n); -const XMLCh RequestAbstractType::ISSUEINSTANT_ATTRIB_NAME[] = UNICODE_LITERAL_12(I,s,s,u,e,I,n,s,t,a,n,t); -const XMLCh RequestAbstractType::DESTINATION_ATTRIB_NAME[] = UNICODE_LITERAL_11(D,e,s,t,i,n,a,t,i,o,n); -const XMLCh RequestAbstractType::CONSENT_ATTRIB_NAME[] = UNICODE_LITERAL_7(C,o,n,s,e,n,t); -const XMLCh RespondTo::LOCAL_NAME[] = UNICODE_LITERAL_9(R,e,s,p,o,n,d,T,o); -const XMLCh Response::LOCAL_NAME[] = UNICODE_LITERAL_8(R,e,s,p,o,n,s,e); -const XMLCh Response::TYPE_NAME[] = UNICODE_LITERAL_12(R,e,s,p,o,n,s,e,T,y,p,e); -const XMLCh Scoping::LOCAL_NAME[] = UNICODE_LITERAL_7(S,c,o,p,i,n,g); -const XMLCh Scoping::TYPE_NAME[] = UNICODE_LITERAL_11(S,c,o,p,i,n,g,T,y,p,e); -const XMLCh Scoping::PROXYCOUNT_ATTRIB_NAME[] = UNICODE_LITERAL_10(P,r,o,x,y,C,o,u,n,t); -const XMLCh SessionIndex::LOCAL_NAME[] = UNICODE_LITERAL_12(S,e,s,s,i,o,n,I,n,d,e,x); -const XMLCh Status::LOCAL_NAME[] = UNICODE_LITERAL_6(S,t,a,t,u,s); -const XMLCh Status::TYPE_NAME[] = UNICODE_LITERAL_10(S,t,a,t,u,s,T,y,p,e); -const XMLCh StatusCode::LOCAL_NAME[] = UNICODE_LITERAL_10(S,t,a,t,u,s,C,o,d,e); -const XMLCh StatusCode::TYPE_NAME[] = UNICODE_LITERAL_14(S,t,a,t,u,s,C,o,d,e,T,y,p,e); -const XMLCh StatusCode::VALUE_ATTRIB_NAME[] = UNICODE_LITERAL_5(V,a,l,u,e); -const XMLCh StatusDetail::LOCAL_NAME[] = UNICODE_LITERAL_12(S,t,a,t,u,s,D,e,t,a,i,l); -const XMLCh StatusDetail::TYPE_NAME[] = UNICODE_LITERAL_16(S,t,a,t,u,s,D,e,t,a,i,l,T,y,p,e); -const XMLCh StatusMessage::LOCAL_NAME[] = UNICODE_LITERAL_13(S,t,a,t,u,s,M,e,s,s,a,g,e); -const XMLCh StatusResponseType::LOCAL_NAME[] = {chNull}; -const XMLCh StatusResponseType::TYPE_NAME[] = UNICODE_LITERAL_18(S,t,a,t,u,s,R,e,s,p,o,n,s,e,T,y,p,e); -const XMLCh StatusResponseType::ID_ATTRIB_NAME[] = UNICODE_LITERAL_2(I,D); -const XMLCh StatusResponseType::INRESPONSETO_ATTRIB_NAME[] = UNICODE_LITERAL_12(I,n,R,e,s,p,o,n,s,e,T,o); -const XMLCh StatusResponseType::VER_ATTRIB_NAME[] = UNICODE_LITERAL_7(V,e,r,s,i,o,n); -const XMLCh StatusResponseType::ISSUEINSTANT_ATTRIB_NAME[] = UNICODE_LITERAL_12(I,s,s,u,e,I,n,s,t,a,n,t); -const XMLCh StatusResponseType::DESTINATION_ATTRIB_NAME[] = UNICODE_LITERAL_11(D,e,s,t,i,n,a,t,i,o,n); -const XMLCh StatusResponseType::CONSENT_ATTRIB_NAME[] = UNICODE_LITERAL_7(C,o,n,s,e,n,t); -const XMLCh SubjectQuery::LOCAL_NAME[] = UNICODE_LITERAL_12(S,u,b,j,e,c,t,Q,u,e,r,y); -const XMLCh SubjectQuery::TYPE_NAME[] = UNICODE_LITERAL_24(S,u,b,j,e,c,t,Q,u,e,r,y,A,b,s,t,r,a,c,t,T,y,p,e); -const XMLCh Terminate::LOCAL_NAME[] = UNICODE_LITERAL_9(T,e,r,m,i,n,a,t,e); -const XMLCh Terminate::TYPE_NAME[] = UNICODE_LITERAL_13(T,e,r,m,i,n,a,t,e,T,y,p,e); - -// Unicode literals: LogoutRequest element, Reason attribute -const XMLCh LogoutRequest::REASON_USER[] = // urn:oasis:names:tc:SAML:2.0:logout:user -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_l, chLatin_o, chLatin_g, chLatin_o, chLatin_u, chLatin_t, chColon, - chLatin_u, chLatin_s, chLatin_e, chLatin_r, chNull -}; - -const XMLCh LogoutRequest::REASON_ADMIN[] = // urn:oasis:names:tc:SAML:2.0:logout:admin -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_l, chLatin_o, chLatin_g, chLatin_o, chLatin_u, chLatin_t, chColon, - chLatin_a, chLatin_d, chLatin_m, chLatin_i, chLatin_n, chNull -}; - - -const XMLCh LogoutRequest::REASON_GLOBAL_TIMEOUT[] = // urn:oasis:names:tc:SAML:2.0:logout:global-timeout -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_l, chLatin_o, chLatin_g, chLatin_o, chLatin_u, chLatin_t, chColon, - chLatin_g, chLatin_l, chLatin_o, chLatin_b, chLatin_a, chLatin_l, - chDash, chLatin_t, chLatin_i, chLatin_m, chLatin_e, chLatin_o, chLatin_u, chLatin_t, chNull -}; - - -const XMLCh LogoutRequest::REASON_SP_TIMEOUT[] = // urn:oasis:names:tc:SAML:2.0:logout:sp-timeout -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_l, chLatin_o, chLatin_g, chLatin_o, chLatin_u, chLatin_t, chColon, - chLatin_s, chLatin_p, chDash, chLatin_t, chLatin_i, chLatin_m, chLatin_e, chLatin_o, chLatin_u, chLatin_t, chNull -}; - - -// Unicode literals, StatusCode Value -const XMLCh StatusCode::SUCCESS[] = // urn:oasis:names:tc:SAML:2.0:status:Success -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, - chLatin_S, chLatin_u, chLatin_c, chLatin_c, chLatin_e, chLatin_s, chLatin_s, chNull -}; - -const XMLCh StatusCode::REQUESTER[] = // urn:oasis:names:tc:SAML:2.0:status:Requester -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, - chLatin_R, chLatin_e, chLatin_q, chLatin_u, chLatin_e, chLatin_s, chLatin_t, chLatin_e, chLatin_r, chNull -}; - -const XMLCh StatusCode::RESPONDER[] = // urn:oasis:names:tc:SAML:2.0:status:Responder -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, - chLatin_R, chLatin_e, chLatin_s, chLatin_p, chLatin_o, chLatin_n, chLatin_d, chLatin_e, chLatin_r, chNull -}; - -const XMLCh StatusCode::VERSION_MISMATCH[] = // urn:oasis:names:tc:SAML:2.0:status:VersionMismatch -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, - chLatin_V, chLatin_e, chLatin_r, chLatin_s, chLatin_i, chLatin_o, chLatin_n, - chLatin_M, chLatin_i, chLatin_s, chLatin_m, chLatin_a, chLatin_t, chLatin_c, chLatin_h, chNull -}; - -const XMLCh StatusCode::AUTHN_FAILED[] = // urn:oasis:names:tc:SAML:2.0:status:AuthnFailed -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, - chLatin_A, chLatin_u, chLatin_t, chLatin_h, chLatin_n, - chLatin_F, chLatin_a, chLatin_i, chLatin_l, chLatin_e, chLatin_d, chNull -}; - -const XMLCh StatusCode::INVALID_ATTR_NAME_OR_VALUE[] = // urn:oasis:names:tc:SAML:2.0:status:InvalidAttrNameOrValue -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, - chLatin_I, chLatin_n, chLatin_v, chLatin_a, chLatin_l, chLatin_i, chLatin_d, - chLatin_A, chLatin_t, chLatin_t, chLatin_r, chLatin_N, chLatin_a, chLatin_m, chLatin_e, - chLatin_O, chLatin_r, chLatin_V, chLatin_a, chLatin_l, chLatin_u, chLatin_e, chNull -}; - -const XMLCh StatusCode::INVALID_NAMEID_POLICY[] = // urn:oasis:names:tc:SAML:2.0:status:InvalidNameIDPolicy -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, - chLatin_I, chLatin_n, chLatin_v, chLatin_a, chLatin_l, chLatin_i, chLatin_d, - chLatin_N, chLatin_a, chLatin_m, chLatin_e, chLatin_I, chLatin_D, - chLatin_P, chLatin_o, chLatin_l, chLatin_i, chLatin_c, chLatin_y, chNull -}; - -const XMLCh StatusCode::NO_AUTHN_CONTEXT[] = // urn:oasis:names:tc:SAML:2.0:status:NoAuthnContext -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, - chLatin_N, chLatin_o, chLatin_A, chLatin_u, chLatin_t, chLatin_h, chLatin_n, - chLatin_C, chLatin_o, chLatin_n, chLatin_t, chLatin_e, chLatin_x, chLatin_t, chNull -}; - -const XMLCh StatusCode::NO_AVAILABLE_IDP[] = // urn:oasis:names:tc:SAML:2.0:status:NoAvailableIDP -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, - chLatin_N, chLatin_o, chLatin_A, chLatin_v, chLatin_a, chLatin_i, chLatin_l, chLatin_a, chLatin_b, chLatin_l, chLatin_e, - chLatin_I, chLatin_D, chLatin_P, chNull -}; - -const XMLCh StatusCode::NO_PASSIVE[] = // urn:oasis:names:tc:SAML:2.0:status:NoPassive -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, - chLatin_N, chLatin_o, chLatin_P, chLatin_a, chLatin_s, chLatin_s, chLatin_i, chLatin_v, chLatin_e, chNull -}; - -const XMLCh StatusCode::NO_SUPPORTED_IDP[] = // urn:oasis:names:tc:SAML:2.0:status:NoSupportedIDP -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, - chLatin_N, chLatin_o, chLatin_S, chLatin_u, chLatin_p, chLatin_p, chLatin_o, chLatin_r, chLatin_t, chLatin_e, chLatin_d, - chLatin_I, chLatin_D, chLatin_P, chNull -}; - -const XMLCh StatusCode::PARTIAL_LOGOUT[] = // urn:oasis:names:tc:SAML:2.0:status:PartialLogout -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, - chLatin_P, chLatin_a, chLatin_r, chLatin_t, chLatin_i, chLatin_a, chLatin_l, - chLatin_L, chLatin_o, chLatin_g, chLatin_o, chLatin_u, chLatin_t, chNull -}; - -const XMLCh StatusCode::PROXY_COUNT_EXCEEDED[] = // urn:oasis:names:tc:SAML:2.0:status:ProxyCountExceeded -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, - chLatin_P, chLatin_r, chLatin_o, chLatin_x, chLatin_y, chLatin_C, chLatin_o, chLatin_u, chLatin_n, chLatin_t, - chLatin_E, chLatin_x, chLatin_c, chLatin_e, chLatin_e, chLatin_d, chLatin_e, chLatin_d, chNull -}; - -const XMLCh StatusCode::REQUEST_DENIED[] = // urn:oasis:names:tc:SAML:2.0:status:RequestDenied -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, - chLatin_R, chLatin_e, chLatin_q, chLatin_u, chLatin_e, chLatin_s, chLatin_t, - chLatin_D, chLatin_e, chLatin_n, chLatin_i, chLatin_e, chLatin_d, chNull -}; - -const XMLCh StatusCode::REQUEST_UNSUPPORTED[] = // urn:oasis:names:tc:SAML:2.0:status:RequestUnsupported -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, - chLatin_R, chLatin_e, chLatin_q, chLatin_u, chLatin_e, chLatin_s, chLatin_t, - chLatin_U, chLatin_n, chLatin_s, chLatin_u, chLatin_p, chLatin_p, chLatin_o, chLatin_r, chLatin_t, chLatin_e, chLatin_d, chNull -}; - -const XMLCh StatusCode::REQUEST_VERSION_DEPRECATED[] = // urn:oasis:names:tc:SAML:2.0:status:RequestVersionDeprecated -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, - chLatin_R, chLatin_e, chLatin_q, chLatin_u, chLatin_e, chLatin_s, chLatin_t, - chLatin_V, chLatin_e, chLatin_r, chLatin_s, chLatin_i, chLatin_o, chLatin_n, - chLatin_D, chLatin_e, chLatin_p, chLatin_r, chLatin_e, chLatin_c, chLatin_a, chLatin_t, chLatin_e, chLatin_d, chNull -}; - -const XMLCh StatusCode::REQUEST_VERSION_TOO_HIGH[] = // urn:oasis:names:tc:SAML:2.0:status:RequestVersionTooHigh -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, - chLatin_R, chLatin_e, chLatin_q, chLatin_u, chLatin_e, chLatin_s, chLatin_t, - chLatin_V, chLatin_e, chLatin_r, chLatin_s, chLatin_i, chLatin_o, chLatin_n, - chLatin_T, chLatin_o, chLatin_o, chLatin_H, chLatin_i, chLatin_g, chLatin_h, chNull -}; - -const XMLCh StatusCode::REQUEST_VERSION_TOO_LOW[] = // urn:oasis:names:tc:SAML:2.0:status:RequestVersionTooLow -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, - chLatin_R, chLatin_e, chLatin_q, chLatin_u, chLatin_e, chLatin_s, chLatin_t, - chLatin_V, chLatin_e, chLatin_r, chLatin_s, chLatin_i, chLatin_o, chLatin_n, - chLatin_T, chLatin_o, chLatin_o, chLatin_L, chLatin_o, chLatin_w, chNull -}; - -const XMLCh StatusCode::RESOURCE_NOT_RECOGNIZED[] = // urn:oasis:names:tc:SAML:2.0:status:ResourceNotRecognized -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, - chLatin_R, chLatin_e, chLatin_s, chLatin_o, chLatin_u, chLatin_r, chLatin_c, chLatin_e, - chLatin_N, chLatin_o, chLatin_t, - chLatin_R, chLatin_e, chLatin_c, chLatin_o, chLatin_g, chLatin_n, chLatin_i, chLatin_z, chLatin_e, chLatin_d, chNull -}; - -const XMLCh StatusCode::TOO_MANY_RESPONSES[] = // urn:oasis:names:tc:SAML:2.0:status:TooManyResponses -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, - chLatin_T, chLatin_o, chLatin_o, chLatin_M, chLatin_a, chLatin_n, chLatin_y, - chLatin_R, chLatin_e, chLatin_s, chLatin_p, chLatin_o, chLatin_n, chLatin_s, chLatin_e, chLatin_s, chNull -}; - -const XMLCh StatusCode::UNKNOWN_ATTR_PROFILE[] = // urn:oasis:names:tc:SAML:2.0:status:UnknownAttrProfile -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, - chLatin_U, chLatin_n, chLatin_k, chLatin_n, chLatin_o, chLatin_w, chLatin_n, - chLatin_A, chLatin_t, chLatin_t, chLatin_r, - chLatin_P, chLatin_r, chLatin_o, chLatin_f, chLatin_i, chLatin_l, chLatin_e, chNull -}; - -const XMLCh StatusCode::UNKNOWN_PRINCIPAL[] = // urn:oasis:names:tc:SAML:2.0:status:UnknownPrincipal -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, - chLatin_U, chLatin_n, chLatin_k, chLatin_n, chLatin_o, chLatin_w, chLatin_n, - chLatin_P, chLatin_r, chLatin_i, chLatin_n, chLatin_c, chLatin_i, chLatin_p, chLatin_a, chLatin_l, chNull -}; - -const XMLCh StatusCode::UNSUPPORTED_BINDING[] = // urn:oasis:names:tc:SAML:2.0:status:UnsupportedBinding -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, - chLatin_U, chLatin_n, chLatin_s, chLatin_u, chLatin_p, chLatin_p, chLatin_o, chLatin_r, chLatin_t, chLatin_e, chLatin_d, - chLatin_B, chLatin_i, chLatin_n, chLatin_d, chLatin_i, chLatin_n, chLatin_g, chNull -}; - +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Protocols20Impl.cpp + * + * Implementation classes for SAML 2.0 Protocols schema + */ + +#include "internal.h" +#include "exceptions.h" +#include "saml/encryption/EncryptedKeyResolver.h" +#include "saml2/core/Protocols.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +using namespace opensaml::saml2p; +using namespace opensaml::saml2; +using namespace opensaml; +using namespace xmlsignature; +using namespace xmlencryption; +using namespace xmltooling; +using namespace std; + +#if defined (_MSC_VER) + #pragma warning( push ) + #pragma warning( disable : 4250 4251 ) +#endif + +namespace opensaml { + namespace saml2p { + + DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,Artifact); + DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,GetComplete); + DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,NewID); + DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,RequesterID); + DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,SessionIndex); + DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,StatusMessage); + + DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,RespondTo); + + //TODO need unit test for this, using objects from another namespace + class SAML_DLLLOCAL ExtensionsImpl : public virtual Extensions, + public AbstractElementProxy, + public AbstractDOMCachingXMLObject, + public AbstractXMLObjectMarshaller, + public AbstractXMLObjectUnmarshaller + { + public: + virtual ~ExtensionsImpl() {} + + ExtensionsImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { + } + + ExtensionsImpl(const ExtensionsImpl& src) + : AbstractXMLObject(src), AbstractElementProxy(src), AbstractDOMCachingXMLObject(src) { + for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { + if (*i) { + getXMLObjects().push_back((*i)->clone()); + } + } + } + + IMPL_XMLOBJECT_CLONE(Extensions); + + protected: + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { + // Unknown child. + const XMLCh* nsURI=root->getNamespaceURI(); + if (!XMLString::equals(nsURI,SAMLConstants::SAML20P_NS) && nsURI && *nsURI) { + getXMLObjects().push_back(childXMLObject); + return; + } + + AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); + } + }; + + class SAML_DLLLOCAL StatusCodeImpl : public virtual StatusCode, + public AbstractComplexElement, + public AbstractDOMCachingXMLObject, + public AbstractXMLObjectMarshaller, + public AbstractXMLObjectUnmarshaller + { + void init() { + m_Value=NULL; + m_StatusCode=NULL; + m_children.push_back(NULL); + m_pos_StatusCode=m_children.begin(); + } + public: + virtual ~StatusCodeImpl() {} + + StatusCodeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) + { + init(); + } + + StatusCodeImpl(const StatusCodeImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { + init(); + setValue(src.getValue()); + if (src.getStatusCode()) + setStatusCode(src.getStatusCode()->cloneStatusCode()); + } + + IMPL_XMLOBJECT_CLONE(StatusCode); + IMPL_STRING_ATTRIB(Value); + IMPL_TYPED_CHILD(StatusCode); + + protected: + void marshallAttributes(DOMElement* domElement) const { + MARSHALL_STRING_ATTRIB(Value,VALUE,NULL); + } + + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { + PROC_TYPED_CHILD(StatusCode,SAMLConstants::SAML20P_NS,false); + AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); + } + + void processAttribute(const DOMAttr* attribute) { + PROC_STRING_ATTRIB(Value,VALUE,NULL); + AbstractXMLObjectUnmarshaller::processAttribute(attribute); + } + }; + + //TODO need unit tests for non-SAML namespace children + class SAML_DLLLOCAL StatusDetailImpl : public virtual StatusDetail, + public AbstractComplexElement, + public AbstractDOMCachingXMLObject, + public AbstractXMLObjectMarshaller, + public AbstractXMLObjectUnmarshaller + { + public: + virtual ~StatusDetailImpl() {} + + StatusDetailImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } + + StatusDetailImpl(const StatusDetailImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { + VectorOf(XMLObject) v=getDetails(); + for (vector::const_iterator i=src.m_Details.begin(); i!=src.m_Details.end(); i++) { + if (*i) { + v.push_back((*i)->clone()); + } + } + } + + IMPL_XMLOBJECT_CLONE(StatusDetail); + IMPL_XMLOBJECT_CHILDREN(Detail,m_children.end()); + + protected: + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { + getDetails().push_back(childXMLObject); + AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); + } + }; + + + class SAML_DLLLOCAL StatusImpl : public virtual Status, + public AbstractComplexElement, + public AbstractDOMCachingXMLObject, + public AbstractXMLObjectMarshaller, + public AbstractXMLObjectUnmarshaller + { + void init() { + m_StatusCode=NULL; + m_StatusMessage=NULL; + m_StatusDetail=NULL; + m_children.push_back(NULL); + m_children.push_back(NULL); + m_children.push_back(NULL); + m_pos_StatusCode=m_children.begin(); + m_pos_StatusMessage=m_pos_StatusCode; + ++m_pos_StatusMessage; + m_pos_StatusDetail=m_pos_StatusMessage; + ++m_pos_StatusDetail; + } + public: + virtual ~StatusImpl() { } + + StatusImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { + init(); + } + + StatusImpl(const StatusImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { + init(); + if (src.getStatusCode()) + setStatusCode(src.getStatusCode()->cloneStatusCode()); + if (src.getStatusMessage()) + setStatusMessage(src.getStatusMessage()->cloneStatusMessage()); + if (src.getStatusDetail()) + setStatusDetail(src.getStatusDetail()->cloneStatusDetail()); + } + + IMPL_XMLOBJECT_CLONE(Status); + IMPL_TYPED_CHILD(StatusCode); + IMPL_TYPED_CHILD(StatusMessage); + IMPL_TYPED_CHILD(StatusDetail); + + protected: + + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { + PROC_TYPED_CHILD(StatusCode,SAMLConstants::SAML20P_NS,false); + PROC_TYPED_CHILD(StatusMessage,SAMLConstants::SAML20P_NS,false); + PROC_TYPED_CHILD(StatusDetail,SAMLConstants::SAML20P_NS,false); + AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); + } + + }; + + + class SAML_DLLLOCAL RequestAbstractTypeImpl : public virtual RequestAbstractType, + public AbstractComplexElement, + public AbstractDOMCachingXMLObject, + public AbstractXMLObjectMarshaller, + public AbstractXMLObjectUnmarshaller + { + void init() { + m_ID=NULL; + m_Version=NULL; + m_IssueInstant=NULL; + m_Destination=NULL; + m_Consent=NULL; + m_Issuer=NULL; + m_Signature=NULL; + m_Extensions=NULL; + m_children.push_back(NULL); + m_children.push_back(NULL); + m_children.push_back(NULL); + m_pos_Issuer=m_children.begin(); + m_pos_Signature=m_pos_Issuer; + ++m_pos_Signature; + m_pos_Extensions=m_pos_Signature; + ++m_pos_Extensions; + } + protected: + RequestAbstractTypeImpl() { + init(); + } + public: + virtual ~RequestAbstractTypeImpl() { + XMLString::release(&m_ID); + XMLString::release(&m_Version); + XMLString::release(&m_Destination); + XMLString::release(&m_Consent); + delete m_IssueInstant; + } + + RequestAbstractTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { + init(); + } + + RequestAbstractTypeImpl(const RequestAbstractTypeImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { + init(); + setID(src.getID()); + setVersion(src.getVersion()); + setIssueInstant(src.getIssueInstant()); + setDestination(src.getDestination()); + setConsent(src.getConsent()); + if (src.getIssuer()) + setIssuer(src.getIssuer()->cloneIssuer()); + if (src.getSignature()) + setSignature(src.getSignature()->cloneSignature()); + if (src.getExtensions()) + setExtensions(src.getExtensions()->cloneExtensions()); + } + + //IMPL_TYPED_CHILD(Signature); + // Need customized setter. + protected: + Signature* m_Signature; + list::iterator m_pos_Signature; + public: + Signature* getSignature() const { + return m_Signature; + } + + void setSignature(Signature* sig) { + prepareForAssignment(m_Signature,sig); + *m_pos_Signature=m_Signature=sig; + // Sync content reference back up. + if (m_Signature) + m_Signature->setContentReference(new opensaml::ContentReference(*this)); + } + + IMPL_STRING_ATTRIB(Version); + IMPL_ID_ATTRIB(ID); + IMPL_DATETIME_ATTRIB(IssueInstant,0); + IMPL_STRING_ATTRIB(Destination); + IMPL_STRING_ATTRIB(Consent); + IMPL_TYPED_FOREIGN_CHILD(Issuer,saml2); + IMPL_TYPED_CHILD(Extensions); + + protected: + void marshallAttributes(DOMElement* domElement) const { + if (!m_Version) + const_cast(this)->m_Version=XMLString::transcode("2.0"); + MARSHALL_STRING_ATTRIB(Version,VER,NULL); + if (!m_ID) + const_cast(this)->m_ID=SAMLConfig::getConfig().generateIdentifier(); + MARSHALL_ID_ATTRIB(ID,ID,NULL); + if (!m_IssueInstant) { + const_cast(this)->m_IssueInstantEpoch=time(NULL); + const_cast(this)->m_IssueInstant=new DateTime(m_IssueInstantEpoch); + } + MARSHALL_DATETIME_ATTRIB(IssueInstant,ISSUEINSTANT,NULL); + MARSHALL_STRING_ATTRIB(Destination,DESTINATION,NULL); + MARSHALL_STRING_ATTRIB(Consent,CONSENT,NULL); + } + + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { + PROC_TYPED_FOREIGN_CHILD(Issuer,saml2,SAMLConstants::SAML20_NS,false); + PROC_TYPED_FOREIGN_CHILD(Signature,xmlsignature,XMLConstants::XMLSIG_NS,false); + PROC_TYPED_CHILD(Extensions,SAMLConstants::SAML20P_NS,false); + AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); + } + + void processAttribute(const DOMAttr* attribute) { + PROC_ID_ATTRIB(ID,ID,NULL); + PROC_STRING_ATTRIB(Version,VER,NULL); + PROC_DATETIME_ATTRIB(IssueInstant,ISSUEINSTANT,NULL); + PROC_STRING_ATTRIB(Destination,DESTINATION,NULL); + PROC_STRING_ATTRIB(Consent,CONSENT,NULL); + AbstractXMLObjectUnmarshaller::processAttribute(attribute); + } + }; + + + class SAML_DLLLOCAL AssertionIDRequestImpl : public virtual AssertionIDRequest, public RequestAbstractTypeImpl + { + public: + virtual ~AssertionIDRequestImpl() { } + + AssertionIDRequestImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } + + AssertionIDRequestImpl(const AssertionIDRequestImpl& src) : AbstractXMLObject(src), RequestAbstractTypeImpl(src) { + VectorOf(AssertionIDRef) v=getAssertionIDRefs(); + for (vector::const_iterator i=src.m_AssertionIDRefs.begin(); i!=src.m_AssertionIDRefs.end(); i++) { + if (*i) { + v.push_back((*i)->cloneAssertionIDRef()); + } + } + + } + + IMPL_XMLOBJECT_CLONE(AssertionIDRequest); + RequestAbstractType* cloneRequestAbstractType() const { + return cloneAssertionIDRequest(); + } + + IMPL_TYPED_FOREIGN_CHILDREN(AssertionIDRef,saml2,m_children.end()); + + protected: + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { + PROC_TYPED_FOREIGN_CHILDREN(AssertionIDRef,saml2,SAMLConstants::SAML20_NS,false); + RequestAbstractTypeImpl::processChildElement(childXMLObject,root); + } + }; + + class SAML_DLLLOCAL SubjectQueryImpl : public virtual SubjectQuery, public RequestAbstractTypeImpl + { + void init() + { + m_Subject = NULL; + m_children.push_back(NULL); + m_pos_Subject = m_pos_Extensions; + ++m_pos_Subject; + } + protected: + SubjectQueryImpl() { + init(); + } + public: + virtual ~SubjectQueryImpl() { } + + SubjectQueryImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) + { + init(); + } + + SubjectQueryImpl(const SubjectQueryImpl& src) : AbstractXMLObject(src), RequestAbstractTypeImpl(src) { + init(); + if (src.getSubject()) + setSubject(src.getSubject()->cloneSubject()); + } + + IMPL_TYPED_FOREIGN_CHILD(Subject,saml2); + + protected: + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { + PROC_TYPED_FOREIGN_CHILD(Subject,saml2,SAMLConstants::SAML20_NS,false); + RequestAbstractTypeImpl::processChildElement(childXMLObject,root); + } + }; + + + class SAML_DLLLOCAL RequestedAuthnContextImpl : public virtual RequestedAuthnContext, + public AbstractComplexElement, + public AbstractDOMCachingXMLObject, + public AbstractXMLObjectMarshaller, + public AbstractXMLObjectUnmarshaller + { + void init() { + m_Comparison=NULL; + } + public: + virtual ~RequestedAuthnContextImpl() { + XMLString::release(&m_Comparison); + } + + RequestedAuthnContextImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { + init(); + } + + RequestedAuthnContextImpl(const RequestedAuthnContextImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { + init(); + setComparison(src.getComparison()); + for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { + if (*i) { + AuthnContextClassRef* classref=dynamic_cast(*i); + if (classref) { + getAuthnContextClassRefs().push_back(classref->cloneAuthnContextClassRef()); + continue; + } + + AuthnContextDeclRef* declref=dynamic_cast(*i); + if (declref) { + getAuthnContextDeclRefs().push_back(declref->cloneAuthnContextDeclRef()); + continue; + } + } + } + } + + IMPL_XMLOBJECT_CLONE(RequestedAuthnContext); + IMPL_STRING_ATTRIB(Comparison); + IMPL_TYPED_FOREIGN_CHILDREN(AuthnContextClassRef,saml2,m_children.end()); + IMPL_TYPED_FOREIGN_CHILDREN(AuthnContextDeclRef,saml2,m_children.end()); + + protected: + void marshallAttributes(DOMElement* domElement) const { + MARSHALL_STRING_ATTRIB(Comparison,COMPARISON,NULL); + } + + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { + PROC_TYPED_FOREIGN_CHILDREN(AuthnContextClassRef,saml2,SAMLConstants::SAML20_NS,false); + PROC_TYPED_FOREIGN_CHILDREN(AuthnContextDeclRef,saml2,SAMLConstants::SAML20_NS,false); + AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); + } + + void processAttribute(const DOMAttr* attribute) { + PROC_STRING_ATTRIB(Comparison,COMPARISON,NULL); + AbstractXMLObjectUnmarshaller::processAttribute(attribute); + } + }; + + + class SAML_DLLLOCAL AuthnQueryImpl : public virtual AuthnQuery, public SubjectQueryImpl + { + void init() { + m_SessionIndex=NULL; + m_RequestedAuthnContext=NULL; + m_children.push_back(NULL); + m_pos_RequestedAuthnContext = m_pos_Subject; + ++m_pos_RequestedAuthnContext; + + } + public: + virtual ~AuthnQueryImpl() { + XMLString::release(&m_SessionIndex); + } + + AuthnQueryImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) + { + init(); + } + + AuthnQueryImpl(const AuthnQueryImpl& src) : AbstractXMLObject(src), SubjectQueryImpl(src) { + init(); + setSessionIndex(src.getSessionIndex()); + if (src.getRequestedAuthnContext()) + setRequestedAuthnContext(src.getRequestedAuthnContext()->cloneRequestedAuthnContext()); + } + + IMPL_XMLOBJECT_CLONE(AuthnQuery); + SubjectQuery* cloneSubjectQuery() const { + return cloneAuthnQuery(); + } + RequestAbstractType* cloneRequestAbstractType() const { + return cloneAuthnQuery(); + } + + IMPL_STRING_ATTRIB(SessionIndex); + IMPL_TYPED_CHILD(RequestedAuthnContext); + + protected: + void marshallAttributes(DOMElement* domElement) const { + MARSHALL_STRING_ATTRIB(SessionIndex,SESSIONINDEX,NULL); + SubjectQueryImpl::marshallAttributes(domElement); + } + + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { + PROC_TYPED_CHILD(RequestedAuthnContext,SAMLConstants::SAML20P_NS,false); + SubjectQueryImpl::processChildElement(childXMLObject,root); + } + void processAttribute(const DOMAttr* attribute) { + PROC_STRING_ATTRIB(SessionIndex,SESSIONINDEX,NULL); + SubjectQueryImpl::processAttribute(attribute); + } + }; + + class SAML_DLLLOCAL AttributeQueryImpl : public virtual AttributeQuery, public SubjectQueryImpl + { + public: + virtual ~AttributeQueryImpl() { } + + AttributeQueryImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } + + AttributeQueryImpl(const AttributeQueryImpl& src) : AbstractXMLObject(src), SubjectQueryImpl(src) { + for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { + if (*i) { + Attribute* attrib=dynamic_cast(*i); + if (attrib) { + getAttributes().push_back(attrib->cloneAttribute()); + continue; + } + } + } + + } + + IMPL_XMLOBJECT_CLONE(AttributeQuery); + SubjectQuery* cloneSubjectQuery() const { + return cloneAttributeQuery(); + } + RequestAbstractType* cloneRequestAbstractType() const { + return cloneAttributeQuery(); + } + + IMPL_TYPED_FOREIGN_CHILDREN(Attribute,saml2,m_children.end()); + + protected: + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { + PROC_TYPED_FOREIGN_CHILDREN(Attribute,saml2,SAMLConstants::SAML20_NS,false); + SubjectQueryImpl::processChildElement(childXMLObject,root); + } + }; + + class SAML_DLLLOCAL AuthzDecisionQueryImpl : public virtual AuthzDecisionQuery, public SubjectQueryImpl + { + void init() { + m_Resource=NULL; + m_Evidence=NULL; + m_children.push_back(NULL); + m_pos_Evidence=m_pos_Subject; + ++m_pos_Evidence; + + } + public: + virtual ~AuthzDecisionQueryImpl() { + XMLString::release(&m_Resource); + } + + AuthzDecisionQueryImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { + init(); + } + + AuthzDecisionQueryImpl(const AuthzDecisionQueryImpl& src) : AbstractXMLObject(src), SubjectQueryImpl(src) { + init(); + setResource(src.getResource()); + if (src.getEvidence()) + setEvidence(src.getEvidence()->cloneEvidence()); + for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { + if (*i) { + Action* action=dynamic_cast(*i); + if (action) { + getActions().push_back(action->cloneAction()); + continue; + } + } + } + } + + IMPL_XMLOBJECT_CLONE(AuthzDecisionQuery); + SubjectQuery* cloneSubjectQuery() const { + return cloneAuthzDecisionQuery(); + } + RequestAbstractType* cloneRequestAbstractType() const { + return cloneAuthzDecisionQuery(); + } + + IMPL_STRING_ATTRIB(Resource); + IMPL_TYPED_FOREIGN_CHILDREN(Action,saml2,m_pos_Evidence); + IMPL_TYPED_FOREIGN_CHILD(Evidence,saml2); + + protected: + void marshallAttributes(DOMElement* domElement) const { + MARSHALL_STRING_ATTRIB(Resource,RESOURCE,NULL); + SubjectQueryImpl::marshallAttributes(domElement); + } + + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { + PROC_TYPED_FOREIGN_CHILD(Evidence,saml2,SAMLConstants::SAML20_NS,false); + PROC_TYPED_FOREIGN_CHILDREN(Action,saml2,SAMLConstants::SAML20_NS,false); + SubjectQueryImpl::processChildElement(childXMLObject,root); + } + void processAttribute(const DOMAttr* attribute) { + PROC_STRING_ATTRIB(Resource,RESOURCE,NULL); + SubjectQueryImpl::processAttribute(attribute); + } + }; + + class SAML_DLLLOCAL NameIDPolicyImpl : public virtual NameIDPolicy, + public AbstractSimpleElement, + public AbstractDOMCachingXMLObject, + public AbstractXMLObjectMarshaller, + public AbstractXMLObjectUnmarshaller + { + void init() { + m_Format=NULL; + m_SPNameQualifier=NULL; + m_AllowCreate=XMLConstants::XML_BOOL_NULL; + } + public: + virtual ~NameIDPolicyImpl() + { + XMLString::release(&m_Format); + XMLString::release(&m_SPNameQualifier); + } + + NameIDPolicyImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) + { + init(); + } + + NameIDPolicyImpl(const NameIDPolicyImpl& src) + : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { + init(); + setFormat(src.getFormat()); + setSPNameQualifier(src.getSPNameQualifier()); + AllowCreate(m_AllowCreate); + } + + IMPL_XMLOBJECT_CLONE(NameIDPolicy); + IMPL_STRING_ATTRIB(Format); + IMPL_STRING_ATTRIB(SPNameQualifier); + IMPL_BOOLEAN_ATTRIB(AllowCreate); + + protected: + void marshallAttributes(DOMElement* domElement) const { + MARSHALL_STRING_ATTRIB(Format,FORMAT,NULL); + MARSHALL_STRING_ATTRIB(SPNameQualifier,SPNAMEQUALIFIER,NULL); + MARSHALL_BOOLEAN_ATTRIB(AllowCreate,ALLOWCREATE,NULL); + } + + void processAttribute(const DOMAttr* attribute) { + PROC_STRING_ATTRIB(Format,FORMAT,NULL); + PROC_STRING_ATTRIB(SPNameQualifier,SPNAMEQUALIFIER,NULL); + PROC_BOOLEAN_ATTRIB(AllowCreate,ALLOWCREATE,NULL); + AbstractXMLObjectUnmarshaller::processAttribute(attribute); + } + }; + + class SAML_DLLLOCAL IDPEntryImpl : public virtual IDPEntry, + public AbstractSimpleElement, + public AbstractDOMCachingXMLObject, + public AbstractXMLObjectMarshaller, + public AbstractXMLObjectUnmarshaller + { + void init() { + m_ProviderID=NULL; + m_Name=NULL; + m_Loc=NULL; + } + public: + virtual ~IDPEntryImpl() + { + XMLString::release(&m_ProviderID); + XMLString::release(&m_Name); + XMLString::release(&m_Loc); + } + + IDPEntryImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) + { + init(); + } + + IDPEntryImpl(const IDPEntryImpl& src) + : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { + init(); + setProviderID(src.getProviderID()); + setName(src.getName()); + setLoc(src.getLoc()); + } + + IMPL_XMLOBJECT_CLONE(IDPEntry); + IMPL_STRING_ATTRIB(ProviderID); + IMPL_STRING_ATTRIB(Name); + IMPL_STRING_ATTRIB(Loc); + + protected: + void marshallAttributes(DOMElement* domElement) const { + MARSHALL_STRING_ATTRIB(ProviderID,PROVIDERID,NULL); + MARSHALL_STRING_ATTRIB(Name,NAME,NULL); + MARSHALL_STRING_ATTRIB(Loc,LOC,NULL); + } + + void processAttribute(const DOMAttr* attribute) { + PROC_STRING_ATTRIB(ProviderID,PROVIDERID,NULL); + PROC_STRING_ATTRIB(Name,NAME,NULL); + PROC_STRING_ATTRIB(Loc,LOC,NULL); + AbstractXMLObjectUnmarshaller::processAttribute(attribute); + } + }; + + class SAML_DLLLOCAL IDPListImpl : public virtual IDPList, + public AbstractComplexElement, + public AbstractDOMCachingXMLObject, + public AbstractXMLObjectMarshaller, + public AbstractXMLObjectUnmarshaller + { + void init() { + m_GetComplete=NULL; + m_children.push_back(NULL); + m_pos_GetComplete=m_children.begin(); + + } + public: + virtual ~IDPListImpl() { } + + IDPListImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) + { + init(); + } + + IDPListImpl(const IDPListImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { + init(); + if (src.getGetComplete()) + setGetComplete(src.getGetComplete()->cloneGetComplete()); + for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { + if (*i) { + IDPEntry* entry=dynamic_cast(*i); + if (entry) { + getIDPEntrys().push_back(entry->cloneIDPEntry()); + continue; + } + } + } + } + + IMPL_XMLOBJECT_CLONE(IDPList); + IMPL_TYPED_CHILDREN(IDPEntry,m_pos_GetComplete); + IMPL_TYPED_CHILD(GetComplete); + + protected: + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { + PROC_TYPED_CHILDREN(IDPEntry,SAMLConstants::SAML20P_NS,false); + PROC_TYPED_CHILD(GetComplete,SAMLConstants::SAML20P_NS,false); + AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); + } + }; + + + class SAML_DLLLOCAL ScopingImpl : public virtual Scoping, + public AbstractComplexElement, + public AbstractDOMCachingXMLObject, + public AbstractXMLObjectMarshaller, + public AbstractXMLObjectUnmarshaller + { + void init() { + m_ProxyCount=NULL; + m_IDPList=NULL; + m_children.push_back(NULL); + m_pos_IDPList=m_children.begin(); + + } + public: + virtual ~ScopingImpl() { + XMLString::release(&m_ProxyCount); + } + + ScopingImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) + { + init(); + } + + ScopingImpl(const ScopingImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { + init(); + setProxyCount(m_ProxyCount); + if (src.getIDPList()) + setIDPList(src.getIDPList()->cloneIDPList()); + for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { + if (*i) { + RequesterID* reqid =dynamic_cast(*i); + if (reqid) { + getRequesterIDs().push_back(reqid->cloneRequesterID()); + continue; + } + } + } + } + + IMPL_XMLOBJECT_CLONE(Scoping); + IMPL_INTEGER_ATTRIB(ProxyCount); + IMPL_TYPED_CHILD(IDPList); + IMPL_TYPED_CHILDREN(RequesterID,m_children.end()); + + protected: + void marshallAttributes(DOMElement* domElement) const { + MARSHALL_INTEGER_ATTRIB(ProxyCount,PROXYCOUNT,NULL); + } + + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { + PROC_TYPED_CHILD(IDPList,SAMLConstants::SAML20P_NS,false); + PROC_TYPED_CHILDREN(RequesterID,SAMLConstants::SAML20P_NS,false); + AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); + } + + void processAttribute(const DOMAttr* attribute) { + PROC_INTEGER_ATTRIB(ProxyCount,PROXYCOUNT,NULL); + AbstractXMLObjectUnmarshaller::processAttribute(attribute); + } + }; + + class SAML_DLLLOCAL AuthnRequestImpl : public virtual AuthnRequest, public RequestAbstractTypeImpl + { + void init() { + m_ForceAuthn=XMLConstants::XML_BOOL_NULL; + m_IsPassive=XMLConstants::XML_BOOL_NULL; + m_ProtocolBinding=NULL; + m_AssertionConsumerServiceIndex=NULL; + m_AssertionConsumerServiceURL=NULL; + m_AttributeConsumingServiceIndex=NULL; + m_ProviderName=NULL; + + m_Subject=NULL; + m_NameIDPolicy=NULL; + m_Conditions=NULL; + m_RequestedAuthnContext=NULL; + m_Scoping=NULL; + m_children.push_back(NULL); + m_children.push_back(NULL); + m_children.push_back(NULL); + m_children.push_back(NULL); + m_children.push_back(NULL); + m_pos_Subject=m_pos_Extensions; + ++m_pos_Subject; + m_pos_NameIDPolicy=m_pos_Subject; + ++m_pos_NameIDPolicy; + m_pos_Conditions=m_pos_NameIDPolicy; + ++m_pos_Conditions; + m_pos_RequestedAuthnContext=m_pos_Conditions; + ++m_pos_RequestedAuthnContext; + m_pos_Scoping=m_pos_RequestedAuthnContext; + ++m_pos_Scoping; + + } + public: + virtual ~AuthnRequestImpl() { + XMLString::release(&m_ProtocolBinding); + XMLString::release(&m_AssertionConsumerServiceURL); + XMLString::release(&m_ProviderName); + XMLString::release(&m_AssertionConsumerServiceIndex); + XMLString::release(&m_AttributeConsumingServiceIndex); + } + + AuthnRequestImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) + { + init(); + } + + AuthnRequestImpl(const AuthnRequestImpl& src) : AbstractXMLObject(src), RequestAbstractTypeImpl(src) { + init(); + + ForceAuthn(m_ForceAuthn); + IsPassive(m_IsPassive); + setProtocolBinding(src.getProtocolBinding()); + setAssertionConsumerServiceIndex(m_AssertionConsumerServiceIndex); + setAssertionConsumerServiceURL(src.getAssertionConsumerServiceURL()); + setAttributeConsumingServiceIndex(m_AttributeConsumingServiceIndex); + setProviderName(src.getProviderName()); + + if (src.getSubject()) + setSubject(src.getSubject()->cloneSubject()); + if (src.getNameIDPolicy()) + setNameIDPolicy(src.getNameIDPolicy()->cloneNameIDPolicy()); + if (src.getConditions()) + setConditions(src.getConditions()->cloneConditions()); + if (src.getRequestedAuthnContext()) + setRequestedAuthnContext(src.getRequestedAuthnContext()->cloneRequestedAuthnContext()); + if (src.getScoping()) + setScoping(src.getScoping()->cloneScoping()); + } + + IMPL_XMLOBJECT_CLONE(AuthnRequest); + RequestAbstractType* cloneRequestAbstractType() const { + return cloneAuthnRequest(); + } + + IMPL_BOOLEAN_ATTRIB(ForceAuthn); + IMPL_BOOLEAN_ATTRIB(IsPassive); + IMPL_STRING_ATTRIB(ProtocolBinding); + IMPL_INTEGER_ATTRIB(AssertionConsumerServiceIndex); + IMPL_STRING_ATTRIB(AssertionConsumerServiceURL); + IMPL_INTEGER_ATTRIB(AttributeConsumingServiceIndex); + IMPL_STRING_ATTRIB(ProviderName); + + IMPL_TYPED_FOREIGN_CHILD(Subject,saml2); + IMPL_TYPED_CHILD(NameIDPolicy); + IMPL_TYPED_FOREIGN_CHILD(Conditions,saml2); + IMPL_TYPED_CHILD(RequestedAuthnContext); + IMPL_TYPED_CHILD(Scoping); + + protected: + void marshallAttributes(DOMElement* domElement) const { + MARSHALL_BOOLEAN_ATTRIB(ForceAuthn,FORCEAUTHN,NULL); + MARSHALL_BOOLEAN_ATTRIB(IsPassive,ISPASSIVE,NULL); + MARSHALL_STRING_ATTRIB(ProtocolBinding,PROTOCOLBINDING,NULL); + MARSHALL_INTEGER_ATTRIB(AssertionConsumerServiceIndex,ASSERTIONCONSUMERSERVICEINDEX,NULL); + MARSHALL_STRING_ATTRIB(AssertionConsumerServiceURL,ASSERTIONCONSUMERSERVICEURL,NULL); + MARSHALL_INTEGER_ATTRIB(AttributeConsumingServiceIndex,ATTRIBUTECONSUMINGSERVICEINDEX,NULL); + MARSHALL_STRING_ATTRIB(ProviderName,PROVIDERNAME,NULL); + RequestAbstractTypeImpl::marshallAttributes(domElement); + } + + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { + PROC_TYPED_FOREIGN_CHILD(Subject,saml2,SAMLConstants::SAML20_NS,false); + PROC_TYPED_CHILD(NameIDPolicy,SAMLConstants::SAML20P_NS,false); + PROC_TYPED_FOREIGN_CHILD(Conditions,saml2,SAMLConstants::SAML20_NS,false); + PROC_TYPED_CHILD(RequestedAuthnContext,SAMLConstants::SAML20P_NS,false); + PROC_TYPED_CHILD(Scoping,SAMLConstants::SAML20P_NS,false); + RequestAbstractTypeImpl::processChildElement(childXMLObject,root); + } + void processAttribute(const DOMAttr* attribute) { + PROC_BOOLEAN_ATTRIB(ForceAuthn,FORCEAUTHN,NULL); + PROC_BOOLEAN_ATTRIB(IsPassive,ISPASSIVE,NULL); + PROC_STRING_ATTRIB(ProtocolBinding,PROTOCOLBINDING,NULL); + PROC_INTEGER_ATTRIB(AssertionConsumerServiceIndex,ASSERTIONCONSUMERSERVICEINDEX,NULL); + PROC_STRING_ATTRIB(AssertionConsumerServiceURL,ASSERTIONCONSUMERSERVICEURL,NULL); + PROC_INTEGER_ATTRIB(AttributeConsumingServiceIndex,ATTRIBUTECONSUMINGSERVICEINDEX,NULL); + PROC_STRING_ATTRIB(ProviderName,PROVIDERNAME,NULL); + RequestAbstractTypeImpl::processAttribute(attribute); + } + }; + + class SAML_DLLLOCAL StatusResponseTypeImpl : public virtual StatusResponseType, + public AbstractComplexElement, + public AbstractDOMCachingXMLObject, + public AbstractXMLObjectMarshaller, + public AbstractXMLObjectUnmarshaller + { + void init() { + m_ID=NULL; + m_InResponseTo=NULL; + m_Version=NULL; + m_IssueInstant=NULL; + m_Destination=NULL; + m_Consent=NULL; + m_Issuer=NULL; + m_Signature=NULL; + m_Extensions=NULL; + m_Status=NULL; + m_children.push_back(NULL); + m_children.push_back(NULL); + m_children.push_back(NULL); + m_children.push_back(NULL); + m_pos_Issuer=m_children.begin(); + m_pos_Signature=m_pos_Issuer; + ++m_pos_Signature; + m_pos_Extensions=m_pos_Signature; + ++m_pos_Extensions; + m_pos_Status=m_pos_Extensions; + ++m_pos_Status; + } + protected: + StatusResponseTypeImpl() { + init(); + } + public: + virtual ~StatusResponseTypeImpl() { + XMLString::release(&m_ID); + XMLString::release(&m_InResponseTo); + XMLString::release(&m_Version); + XMLString::release(&m_Destination); + XMLString::release(&m_Consent); + delete m_IssueInstant; + } + + StatusResponseTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) + { + init(); + } + + StatusResponseTypeImpl(const StatusResponseTypeImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { + init(); + setID(src.getID()); + setInResponseTo(src.getInResponseTo()); + setVersion(src.getVersion()); + setIssueInstant(src.getIssueInstant()); + setDestination(src.getDestination()); + setConsent(src.getConsent()); + if (src.getIssuer()) + setIssuer(src.getIssuer()->cloneIssuer()); + if (src.getSignature()) + setSignature(src.getSignature()->cloneSignature()); + if (src.getExtensions()) + setExtensions(src.getExtensions()->cloneExtensions()); + if (src.getStatus()) + setStatus(src.getStatus()->cloneStatus()); + } + + //IMPL_TYPED_CHILD(Signature); + // Need customized setter. + protected: + Signature* m_Signature; + list::iterator m_pos_Signature; + public: + Signature* getSignature() const { + return m_Signature; + } + + void setSignature(Signature* sig) { + prepareForAssignment(m_Signature,sig); + *m_pos_Signature=m_Signature=sig; + // Sync content reference back up. + if (m_Signature) + m_Signature->setContentReference(new opensaml::ContentReference(*this)); + } + + IMPL_STRING_ATTRIB(Version); + IMPL_ID_ATTRIB(ID); + IMPL_STRING_ATTRIB(InResponseTo); + IMPL_DATETIME_ATTRIB(IssueInstant,0); + IMPL_STRING_ATTRIB(Destination); + IMPL_STRING_ATTRIB(Consent); + IMPL_TYPED_FOREIGN_CHILD(Issuer,saml2); + IMPL_TYPED_CHILD(Extensions); + IMPL_TYPED_CHILD(Status); + + protected: + void marshallAttributes(DOMElement* domElement) const { + if (!m_Version) + const_cast(this)->m_Version=XMLString::transcode("2.0"); + MARSHALL_STRING_ATTRIB(Version,VER,NULL); + if (!m_ID) + const_cast(this)->m_ID=SAMLConfig::getConfig().generateIdentifier(); + MARSHALL_ID_ATTRIB(ID,ID,NULL); + if (!m_IssueInstant) { + const_cast(this)->m_IssueInstantEpoch=time(NULL); + const_cast(this)->m_IssueInstant=new DateTime(m_IssueInstantEpoch); + } + MARSHALL_DATETIME_ATTRIB(IssueInstant,ISSUEINSTANT,NULL); + MARSHALL_STRING_ATTRIB(Destination,DESTINATION,NULL); + MARSHALL_STRING_ATTRIB(Consent,CONSENT,NULL); + MARSHALL_STRING_ATTRIB(InResponseTo,INRESPONSETO,NULL); + } + + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { + PROC_TYPED_FOREIGN_CHILD(Issuer,saml2,SAMLConstants::SAML20_NS,false); + PROC_TYPED_FOREIGN_CHILD(Signature,xmlsignature,XMLConstants::XMLSIG_NS,false); + PROC_TYPED_CHILD(Extensions,SAMLConstants::SAML20P_NS,false); + PROC_TYPED_CHILD(Status,SAMLConstants::SAML20P_NS,false); + AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); + } + + void processAttribute(const DOMAttr* attribute) { + PROC_ID_ATTRIB(ID,ID,NULL); + PROC_STRING_ATTRIB(Version,VER,NULL); + PROC_STRING_ATTRIB(InResponseTo,INRESPONSETO,NULL); + PROC_DATETIME_ATTRIB(IssueInstant,ISSUEINSTANT,NULL); + PROC_STRING_ATTRIB(Destination,DESTINATION,NULL); + PROC_STRING_ATTRIB(Consent,CONSENT,NULL); + AbstractXMLObjectUnmarshaller::processAttribute(attribute); + } + }; + + class SAML_DLLLOCAL ResponseImpl : public virtual Response, public StatusResponseTypeImpl + { + public: + virtual ~ResponseImpl() { } + + ResponseImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } + + ResponseImpl(const ResponseImpl& src) : AbstractXMLObject(src), StatusResponseTypeImpl(src) { + for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { + if (*i) { + Assertion* assertion=dynamic_cast(*i); + if (assertion) { + getAssertions().push_back(assertion->cloneAssertion()); + continue; + } + EncryptedAssertion* encAssertion=dynamic_cast(*i); + if (encAssertion) { + getEncryptedAssertions().push_back(encAssertion->cloneEncryptedAssertion()); + continue; + } + } + } + + } + + IMPL_XMLOBJECT_CLONE(Response); + StatusResponseType* cloneStatusResponseType() const { + return cloneResponse(); + } + + IMPL_TYPED_FOREIGN_CHILDREN(Assertion,saml2,m_children.end()); + IMPL_TYPED_FOREIGN_CHILDREN(EncryptedAssertion,saml2,m_children.end()); + + protected: + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { + PROC_TYPED_FOREIGN_CHILDREN(Assertion,saml2,SAMLConstants::SAML20_NS,false); + PROC_TYPED_FOREIGN_CHILDREN(EncryptedAssertion,saml2,SAMLConstants::SAML20_NS,false); + StatusResponseTypeImpl::processChildElement(childXMLObject,root); + } + }; + + class SAML_DLLLOCAL ArtifactResolveImpl : public virtual ArtifactResolve, public RequestAbstractTypeImpl + { + void init() { + m_Artifact=NULL; + m_children.push_back(NULL); + m_pos_Artifact=m_pos_Extensions; + ++m_pos_Artifact; + } + public: + virtual ~ArtifactResolveImpl() { } + + ArtifactResolveImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) + { + init(); + } + + ArtifactResolveImpl(const ArtifactResolveImpl& src) : AbstractXMLObject(src), RequestAbstractTypeImpl(src) { + init(); + if(src.getArtifact()) + setArtifact(src.getArtifact()->cloneArtifact()); + } + + IMPL_XMLOBJECT_CLONE(ArtifactResolve); + RequestAbstractType* cloneRequestAbstractType() const { + return cloneArtifactResolve(); + } + + IMPL_TYPED_CHILD(Artifact); + + protected: + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { + PROC_TYPED_CHILD(Artifact,SAMLConstants::SAML20P_NS,false); + RequestAbstractTypeImpl::processChildElement(childXMLObject,root); + } + }; + + class SAML_DLLLOCAL ArtifactResponseImpl : public virtual ArtifactResponse, public StatusResponseTypeImpl + { + void init() { + m_Payload=NULL; + m_children.push_back(NULL); + m_pos_Payload=m_pos_Status; + ++m_pos_Payload; + } + public: + virtual ~ArtifactResponseImpl() { } + + ArtifactResponseImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) + { + init(); + } + + ArtifactResponseImpl(const ArtifactResponseImpl& src) : AbstractXMLObject(src), StatusResponseTypeImpl(src) { + init(); + if (src.getPayload()) + setPayload(getPayload()->clone()); + + } + + IMPL_XMLOBJECT_CLONE(ArtifactResponse); + StatusResponseType* cloneStatusResponseType() const { + return cloneArtifactResponse(); + } + + IMPL_XMLOBJECT_CHILD(Payload); + + protected: + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { + // These are valid elements for the parent StatusResponseType, so don't process these. + // If not one of these, then it must be the payload. + if ( + ! XMLHelper::isNodeNamed(root,SAMLConstants::SAML20_NS,saml2::Issuer::LOCAL_NAME) && + ! XMLHelper::isNodeNamed(root,XMLConstants::XMLSIG_NS,xmlsignature::Signature::LOCAL_NAME) && + ! XMLHelper::isNodeNamed(root,SAMLConstants::SAML20P_NS,saml2p::Extensions::LOCAL_NAME) && + ! XMLHelper::isNodeNamed(root,SAMLConstants::SAML20P_NS,saml2p::Status::LOCAL_NAME) + ) + { + setPayload(childXMLObject); + return; + } + + StatusResponseTypeImpl::processChildElement(childXMLObject,root); + } + }; + + class SAML_DLLLOCAL NewEncryptedIDImpl : public virtual NewEncryptedID, + public AbstractComplexElement, + public AbstractDOMCachingXMLObject, + public AbstractXMLObjectMarshaller, + public AbstractXMLObjectUnmarshaller + { + void init() { + m_EncryptedData=NULL; + m_children.push_back(NULL); + m_pos_EncryptedData=m_children.begin(); + } + + protected: + NewEncryptedIDImpl() + { + init(); + } + + public: + virtual ~NewEncryptedIDImpl() {} + + NewEncryptedIDImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) + { + init(); + } + + NewEncryptedIDImpl(const NewEncryptedIDImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { + init(); + if (src.getEncryptedData()) + setEncryptedData(src.getEncryptedData()->cloneEncryptedData()); + VectorOf(xmlencryption::EncryptedKey) v=getEncryptedKeys(); + for (vector::const_iterator i=src.m_EncryptedKeys.begin(); i!=src.m_EncryptedKeys.end(); i++) { + if (*i) { + v.push_back((*i)->cloneEncryptedKey()); + } + } + } + + XMLObject* decrypt(KeyResolver* KEKresolver, const XMLCh* recipient) const + { + if (!m_EncryptedData) + throw DecryptionException("No encrypted data present."); + Decrypter decrypter(KEKresolver, new EncryptedKeyResolver(*this, recipient)); + DOMDocumentFragment* frag = decrypter.decryptData(m_EncryptedData); + if (frag->hasChildNodes() && frag->getFirstChild()==frag->getLastChild()) { + DOMNode* plaintext=frag->getFirstChild(); + if (plaintext->getNodeType()==DOMNode::ELEMENT_NODE) { + auto_ptr ret(XMLObjectBuilder::buildOneFromElement(static_cast(plaintext))); + ret->releaseThisAndChildrenDOM(); + return ret.release(); + } + } + frag->release(); + throw DecryptionException("Decryption did not result in a single element."); + } + + IMPL_XMLOBJECT_CLONE(NewEncryptedID); + EncryptedElementType* cloneEncryptedElementType() const { + return new NewEncryptedIDImpl(*this); + } + + IMPL_TYPED_FOREIGN_CHILD(EncryptedData,xmlencryption); + IMPL_TYPED_FOREIGN_CHILDREN(EncryptedKey,xmlencryption,m_children.end()); + + protected: + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { + PROC_TYPED_FOREIGN_CHILD(EncryptedData,xmlencryption,XMLConstants::XMLENC_NS,false); + PROC_TYPED_FOREIGN_CHILDREN(EncryptedKey,xmlencryption,XMLConstants::XMLENC_NS,false); + AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); + } + }; + + class SAML_DLLLOCAL TerminateImpl : public virtual Terminate, + public AbstractSimpleElement, + public AbstractDOMCachingXMLObject, + public AbstractXMLObjectMarshaller, + public AbstractXMLObjectUnmarshaller + { + public: + virtual ~TerminateImpl() { } + + TerminateImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } + + TerminateImpl(const TerminateImpl& src) + : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { + } + + IMPL_XMLOBJECT_CLONE(Terminate); + + protected: + // has no attributes or children + }; + + class SAML_DLLLOCAL ManageNameIDRequestImpl : public virtual ManageNameIDRequest, public RequestAbstractTypeImpl + { + void init() { + m_NameID=NULL; + m_EncryptedID=NULL; + m_NewID=NULL; + m_NewEncryptedID=NULL; + m_Terminate=NULL; + m_children.push_back(NULL); + m_children.push_back(NULL); + m_children.push_back(NULL); + m_children.push_back(NULL); + m_children.push_back(NULL); + m_pos_NameID=m_pos_Extensions; + ++m_pos_NameID; + m_pos_EncryptedID=m_pos_NameID; + ++m_pos_EncryptedID; + m_pos_NewID=m_pos_EncryptedID; + ++m_pos_NewID; + m_pos_NewEncryptedID=m_pos_NewID; + ++m_pos_NewEncryptedID; + m_pos_Terminate=m_pos_NewEncryptedID; + ++m_pos_Terminate; + + } + public: + virtual ~ManageNameIDRequestImpl() { } + + ManageNameIDRequestImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) + { + init(); + } + + ManageNameIDRequestImpl(const ManageNameIDRequestImpl& src) : AbstractXMLObject(src), RequestAbstractTypeImpl(src) { + init(); + + if (src.getNameID()) + setNameID(src.getNameID()->cloneNameID()); + if (src.getEncryptedID()) + setEncryptedID(src.getEncryptedID()->cloneEncryptedID()); + if (src.getNewID()) + setNewID(src.getNewID()->cloneNewID()); + if (src.getNewEncryptedID()) + setNewEncryptedID(src.getNewEncryptedID()->cloneNewEncryptedID()); + if (src.getTerminate()) + setTerminate(src.getTerminate()->cloneTerminate()); + + } + + IMPL_XMLOBJECT_CLONE(ManageNameIDRequest); + RequestAbstractType* cloneRequestAbstractType() const { + return cloneManageNameIDRequest(); + } + + IMPL_TYPED_FOREIGN_CHILD(NameID,saml2); + IMPL_TYPED_FOREIGN_CHILD(EncryptedID,saml2); + IMPL_TYPED_CHILD(NewID); + IMPL_TYPED_CHILD(NewEncryptedID); + IMPL_TYPED_CHILD(Terminate); + + protected: + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { + PROC_TYPED_FOREIGN_CHILD(NameID,saml2,SAMLConstants::SAML20_NS,false); + PROC_TYPED_FOREIGN_CHILD(EncryptedID,saml2,SAMLConstants::SAML20_NS,false); + PROC_TYPED_CHILD(NewID,SAMLConstants::SAML20P_NS,false); + PROC_TYPED_CHILD(NewEncryptedID,SAMLConstants::SAML20P_NS,false); + PROC_TYPED_CHILD(Terminate,SAMLConstants::SAML20P_NS,false); + RequestAbstractTypeImpl::processChildElement(childXMLObject,root); + } + }; + + class SAML_DLLLOCAL ManageNameIDResponseImpl : public virtual ManageNameIDResponse, public StatusResponseTypeImpl + { + public: + virtual ~ManageNameIDResponseImpl() { } + + ManageNameIDResponseImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } + + ManageNameIDResponseImpl(const ManageNameIDResponseImpl& src) : AbstractXMLObject(src), StatusResponseTypeImpl(src) { + } + + IMPL_XMLOBJECT_CLONE(ManageNameIDResponse); + StatusResponseType* cloneStatusResponseType() const { + return cloneManageNameIDResponse(); + } + }; + + class SAML_DLLLOCAL LogoutRequestImpl : public virtual LogoutRequest, public RequestAbstractTypeImpl + { + void init() { + m_Reason=NULL; + m_NotOnOrAfter=NULL; + + m_BaseID=NULL; + m_NameID=NULL; + m_EncryptedID=NULL; + m_children.push_back(NULL); + m_children.push_back(NULL); + m_children.push_back(NULL); + m_pos_BaseID=m_pos_Extensions; + ++m_pos_BaseID; + m_pos_NameID=m_pos_BaseID; + ++m_pos_NameID; + m_pos_EncryptedID=m_pos_NameID; + ++m_pos_EncryptedID; + + } + public: + virtual ~LogoutRequestImpl() { + XMLString::release(&m_Reason); + delete m_NotOnOrAfter; + } + + LogoutRequestImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) + { + init(); + } + + LogoutRequestImpl(const LogoutRequestImpl& src) : AbstractXMLObject(src), RequestAbstractTypeImpl(src) { + init(); + + setReason(src.getReason()); + setNotOnOrAfter(src.getNotOnOrAfter()); + + if (src.getBaseID()) + setBaseID(src.getBaseID()->cloneBaseID()); + if (src.getNameID()) + setNameID(src.getNameID()->cloneNameID()); + if (src.getEncryptedID()) + setEncryptedID(src.getEncryptedID()->cloneEncryptedID()); + + for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { + if (*i) { + SessionIndex* si = dynamic_cast(*i); + if (si) { + getSessionIndexs().push_back(si->cloneSessionIndex()); + continue; + } + } + } + } + + IMPL_XMLOBJECT_CLONE(LogoutRequest); + RequestAbstractType* cloneRequestAbstractType() const { + return cloneLogoutRequest(); + } + + IMPL_STRING_ATTRIB(Reason); + IMPL_DATETIME_ATTRIB(NotOnOrAfter,SAMLTIME_MAX); + IMPL_TYPED_FOREIGN_CHILD(BaseID,saml2); + IMPL_TYPED_FOREIGN_CHILD(NameID,saml2); + IMPL_TYPED_FOREIGN_CHILD(EncryptedID,saml2); + IMPL_TYPED_CHILDREN(SessionIndex,m_children.end()); + + protected: + void marshallAttributes(DOMElement* domElement) const { + MARSHALL_STRING_ATTRIB(Reason,REASON,NULL); + MARSHALL_DATETIME_ATTRIB(NotOnOrAfter,NOTONORAFTER,NULL); + RequestAbstractTypeImpl::marshallAttributes(domElement); + } + + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { + PROC_TYPED_FOREIGN_CHILD(BaseID,saml2,SAMLConstants::SAML20_NS,false); + PROC_TYPED_FOREIGN_CHILD(NameID,saml2,SAMLConstants::SAML20_NS,false); + PROC_TYPED_FOREIGN_CHILD(EncryptedID,saml2,SAMLConstants::SAML20_NS,false); + PROC_TYPED_CHILDREN(SessionIndex,SAMLConstants::SAML20P_NS,false); + RequestAbstractTypeImpl::processChildElement(childXMLObject,root); + } + void processAttribute(const DOMAttr* attribute) { + PROC_STRING_ATTRIB(Reason,REASON,NULL); + PROC_DATETIME_ATTRIB(NotOnOrAfter,NOTONORAFTER,NULL); + RequestAbstractTypeImpl::processAttribute(attribute); + } + }; + + class SAML_DLLLOCAL LogoutResponseImpl : public virtual LogoutResponse, public StatusResponseTypeImpl + { + public: + virtual ~LogoutResponseImpl() { } + + LogoutResponseImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } + + LogoutResponseImpl(const LogoutResponseImpl& src) : AbstractXMLObject(src), StatusResponseTypeImpl(src) { + } + + IMPL_XMLOBJECT_CLONE(LogoutResponse); + StatusResponseType* cloneStatusResponseType() const { + return cloneLogoutResponse(); + } + }; + + + class SAML_DLLLOCAL NameIDMappingRequestImpl : public virtual NameIDMappingRequest, public RequestAbstractTypeImpl + { + void init() { + m_BaseID=NULL; + m_NameID=NULL; + m_EncryptedID=NULL; + m_NameIDPolicy=NULL; + m_children.push_back(NULL); + m_children.push_back(NULL); + m_children.push_back(NULL); + m_children.push_back(NULL); + m_pos_BaseID=m_pos_Extensions; + ++m_pos_BaseID; + m_pos_NameID=m_pos_BaseID; + ++m_pos_NameID; + m_pos_EncryptedID=m_pos_NameID; + ++m_pos_EncryptedID; + m_pos_NameIDPolicy=m_pos_EncryptedID; + ++m_pos_NameIDPolicy; + + } + public: + virtual ~NameIDMappingRequestImpl() { } + + NameIDMappingRequestImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) + { + init(); + } + + NameIDMappingRequestImpl(const NameIDMappingRequestImpl& src) : AbstractXMLObject(src), RequestAbstractTypeImpl(src) { + init(); + + if (src.getBaseID()) + setBaseID(src.getBaseID()->cloneBaseID()); + if (src.getNameID()) + setNameID(src.getNameID()->cloneNameID()); + if (src.getEncryptedID()) + setEncryptedID(src.getEncryptedID()->cloneEncryptedID()); + if (src.getNameIDPolicy()) + setNameIDPolicy(src.getNameIDPolicy()->cloneNameIDPolicy()); + + } + + IMPL_XMLOBJECT_CLONE(NameIDMappingRequest); + RequestAbstractType* cloneRequestAbstractType() const { + return cloneNameIDMappingRequest(); + } + + IMPL_TYPED_FOREIGN_CHILD(BaseID,saml2); + IMPL_TYPED_FOREIGN_CHILD(NameID,saml2); + IMPL_TYPED_FOREIGN_CHILD(EncryptedID,saml2); + IMPL_TYPED_CHILD(NameIDPolicy); + + protected: + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { + PROC_TYPED_FOREIGN_CHILD(BaseID,saml2,SAMLConstants::SAML20_NS,false); + PROC_TYPED_FOREIGN_CHILD(NameID,saml2,SAMLConstants::SAML20_NS,false); + PROC_TYPED_FOREIGN_CHILD(EncryptedID,saml2,SAMLConstants::SAML20_NS,false); + PROC_TYPED_CHILD(NameIDPolicy,SAMLConstants::SAML20P_NS,false); + RequestAbstractTypeImpl::processChildElement(childXMLObject,root); + } + }; + + class SAML_DLLLOCAL NameIDMappingResponseImpl : public virtual NameIDMappingResponse, public StatusResponseTypeImpl + { + void init() { + m_NameID=NULL; + m_EncryptedID=NULL; + m_children.push_back(NULL); + m_children.push_back(NULL); + m_pos_NameID=m_pos_Status; + ++m_pos_NameID; + m_pos_EncryptedID=m_pos_NameID; + ++m_pos_EncryptedID; + } + public: + virtual ~NameIDMappingResponseImpl() { } + + NameIDMappingResponseImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) + { + init(); + } + + NameIDMappingResponseImpl(const NameIDMappingResponseImpl& src) : AbstractXMLObject(src), StatusResponseTypeImpl(src) { + init(); + + if (src.getNameID()) + setNameID(getNameID()->cloneNameID()); + if (src.getEncryptedID()) + setEncryptedID(getEncryptedID()->cloneEncryptedID()); + + } + + IMPL_XMLOBJECT_CLONE(NameIDMappingResponse); + StatusResponseType* cloneStatusResponseType() const { + return cloneNameIDMappingResponse(); + } + + IMPL_TYPED_FOREIGN_CHILD(NameID,saml2); + IMPL_TYPED_FOREIGN_CHILD(EncryptedID,saml2); + + protected: + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { + PROC_TYPED_FOREIGN_CHILD(NameID,saml2,SAMLConstants::SAML20_NS,false); + PROC_TYPED_FOREIGN_CHILD(EncryptedID,saml2,SAMLConstants::SAML20_NS,false); + StatusResponseTypeImpl::processChildElement(childXMLObject,root); + } + }; + }; +}; + +#if defined (_MSC_VER) + #pragma warning( pop ) +#endif + +// Builder Implementations +IMPL_XMLOBJECTBUILDER(Artifact); +IMPL_XMLOBJECTBUILDER(ArtifactResolve); +IMPL_XMLOBJECTBUILDER(ArtifactResponse); +IMPL_XMLOBJECTBUILDER(AssertionIDRequest); +IMPL_XMLOBJECTBUILDER(AttributeQuery); +IMPL_XMLOBJECTBUILDER(AuthnQuery); +IMPL_XMLOBJECTBUILDER(AuthnRequest); +IMPL_XMLOBJECTBUILDER(AuthzDecisionQuery); +IMPL_XMLOBJECTBUILDER(Extensions); +IMPL_XMLOBJECTBUILDER(GetComplete); +IMPL_XMLOBJECTBUILDER(IDPEntry); +IMPL_XMLOBJECTBUILDER(IDPList); +IMPL_XMLOBJECTBUILDER(LogoutRequest); +IMPL_XMLOBJECTBUILDER(LogoutResponse); +IMPL_XMLOBJECTBUILDER(ManageNameIDRequest); +IMPL_XMLOBJECTBUILDER(ManageNameIDResponse); +IMPL_XMLOBJECTBUILDER(NameIDMappingRequest); +IMPL_XMLOBJECTBUILDER(NameIDMappingResponse); +IMPL_XMLOBJECTBUILDER(NameIDPolicy); +IMPL_XMLOBJECTBUILDER(NewEncryptedID); +IMPL_XMLOBJECTBUILDER(NewID); +IMPL_XMLOBJECTBUILDER(RequestedAuthnContext); +IMPL_XMLOBJECTBUILDER(RequesterID); +IMPL_XMLOBJECTBUILDER(Response); +IMPL_XMLOBJECTBUILDER(Scoping); +IMPL_XMLOBJECTBUILDER(SessionIndex); +IMPL_XMLOBJECTBUILDER(Status); +IMPL_XMLOBJECTBUILDER(StatusCode); +IMPL_XMLOBJECTBUILDER(StatusDetail); +IMPL_XMLOBJECTBUILDER(StatusMessage); +IMPL_XMLOBJECTBUILDER(Terminate); + +IMPL_XMLOBJECTBUILDER(RespondTo); + +// Unicode literals +const XMLCh Artifact::LOCAL_NAME[] = UNICODE_LITERAL_8(A,r,t,i,f,a,c,t); +const XMLCh ArtifactResolve::LOCAL_NAME[] = UNICODE_LITERAL_15(A,r,t,i,f,a,c,t,R,e,s,o,l,v,e); +const XMLCh ArtifactResolve::TYPE_NAME[] = UNICODE_LITERAL_19(A,r,t,i,f,a,c,t,R,e,s,o,l,v,e,T,y,p,e); +const XMLCh ArtifactResponse::LOCAL_NAME[] = UNICODE_LITERAL_16(A,r,t,i,f,a,c,t,R,e,s,p,o,n,s,e); +const XMLCh ArtifactResponse::TYPE_NAME[] = UNICODE_LITERAL_20(A,r,t,i,f,a,c,t,R,e,s,p,o,n,s,e,T,y,p,e); +const XMLCh AssertionIDRequest::LOCAL_NAME[] = UNICODE_LITERAL_18(A,s,s,e,r,t,i,o,n,I,D,R,e,q,u,e,s,t); +const XMLCh AssertionIDRequest::TYPE_NAME[] = UNICODE_LITERAL_22(A,s,s,e,r,t,i,o,n,I,D,R,e,q,u,e,s,t,T,y,p,e); +const XMLCh AttributeQuery::LOCAL_NAME[] = UNICODE_LITERAL_14(A,t,t,r,i,b,u,t,e,Q,u,e,r,y); +const XMLCh AttributeQuery::TYPE_NAME[] = UNICODE_LITERAL_18(A,t,t,r,i,b,u,t,e,Q,u,e,r,y,T,y,p,e); +const XMLCh AuthnQuery::LOCAL_NAME[] = UNICODE_LITERAL_10(A,u,t,h,n,Q,u,e,r,y); +const XMLCh AuthnQuery::TYPE_NAME[] = UNICODE_LITERAL_14(A,u,t,h,n,Q,u,e,r,y,T,y,p,e); +const XMLCh AuthnQuery::SESSIONINDEX_ATTRIB_NAME[] = UNICODE_LITERAL_12(S,e,s,s,i,o,n,I,n,d,e,x); +const XMLCh AuthnRequest::LOCAL_NAME[] = UNICODE_LITERAL_12(A,u,t,h,n,R,e,q,u,e,s,t); +const XMLCh AuthnRequest::TYPE_NAME[] = UNICODE_LITERAL_16(A,u,t,h,n,R,e,q,u,e,s,t,T,y,p,e); +const XMLCh AuthnRequest::FORCEAUTHN_ATTRIB_NAME[] = UNICODE_LITERAL_10(F,o,r,c,e,A,u,t,h,n); +const XMLCh AuthnRequest::ISPASSIVE_ATTRIB_NAME[] = UNICODE_LITERAL_9(I,s,P,a,s,s,i,v,e); +const XMLCh AuthnRequest::PROTOCOLBINDING_ATTRIB_NAME[] = UNICODE_LITERAL_15(P,r,o,t,o,c,o,l,B,i,n,d,i,n,g); +const XMLCh AuthnRequest::ASSERTIONCONSUMERSERVICEINDEX_ATTRIB_NAME[] = UNICODE_LITERAL_29(A,s,s,e,r,t,i,o,n,C,o,n,s,u,m,e,r,S,e,r,v,i,c,e,I,n,d,e,x); +const XMLCh AuthnRequest::ASSERTIONCONSUMERSERVICEURL_ATTRIB_NAME[] = UNICODE_LITERAL_27(A,s,s,e,r,t,i,o,n,C,o,n,s,u,m,e,r,S,e,r,v,i,c,e,U,R,L); +const XMLCh AuthnRequest::ATTRIBUTECONSUMINGSERVICEINDEX_ATTRIB_NAME[] = UNICODE_LITERAL_30(A,t,t,r,i,b,u,t,e,C,o,n,s,u,m,i,n,g,S,e,r,v,i,c,e,I,n,d,e,x); +const XMLCh AuthnRequest::PROVIDERNAME_ATTRIB_NAME[] = UNICODE_LITERAL_12(P,r,o,v,i,d,e,r,N,a,m,e); +const XMLCh AuthzDecisionQuery::LOCAL_NAME[] = UNICODE_LITERAL_18(A,u,t,h,z,D,e,c,i,s,i,o,n,Q,u,e,r,y); +const XMLCh AuthzDecisionQuery::TYPE_NAME[] = UNICODE_LITERAL_22(A,u,t,h,z,D,e,c,i,s,i,o,n,Q,u,e,r,y,T,y,p,e); +const XMLCh AuthzDecisionQuery::RESOURCE_ATTRIB_NAME[] = UNICODE_LITERAL_8(R,e,s,o,u,r,c,e); +const XMLCh Extensions::LOCAL_NAME[] = UNICODE_LITERAL_10(E,x,t,e,n,s,i,o,n,s); +const XMLCh Extensions::TYPE_NAME[] = UNICODE_LITERAL_14(E,x,t,e,n,s,i,o,n,s,T,y,p,e); +const XMLCh GetComplete::LOCAL_NAME[] = UNICODE_LITERAL_11(G,e,t,C,o,m,p,l,e,t,e); +const XMLCh IDPEntry::LOCAL_NAME[] = UNICODE_LITERAL_8(I,D,P,E,n,t,r,y); +const XMLCh IDPEntry::TYPE_NAME[] = UNICODE_LITERAL_12(I,D,P,E,n,t,r,y,T,y,p,e); +const XMLCh IDPEntry::PROVIDERID_ATTRIB_NAME[] = UNICODE_LITERAL_10(P,r,o,v,i,d,e,r,I,D); +const XMLCh IDPEntry::NAME_ATTRIB_NAME[] = UNICODE_LITERAL_4(N,a,m,e); +const XMLCh IDPEntry::LOC_ATTRIB_NAME[] = UNICODE_LITERAL_3(L,o,c); +const XMLCh IDPList::LOCAL_NAME[] = UNICODE_LITERAL_7(I,D,P,L,i,s,t); +const XMLCh IDPList::TYPE_NAME[] = UNICODE_LITERAL_11(I,D,P,L,i,s,t,T,y,p,e); +const XMLCh LogoutRequest::LOCAL_NAME[] = UNICODE_LITERAL_13(L,o,g,o,u,t,R,e,q,u,e,s,t); +const XMLCh LogoutRequest::TYPE_NAME[] = UNICODE_LITERAL_17(L,o,g,o,u,t,R,e,q,u,e,s,t,T,y,p,e); +const XMLCh LogoutRequest::REASON_ATTRIB_NAME[] = UNICODE_LITERAL_6(R,e,a,s,o,n); +const XMLCh LogoutRequest::NOTONORAFTER_ATTRIB_NAME[] = UNICODE_LITERAL_12(N,o,t,O,n,O,r,A,f,t,e,r); +const XMLCh LogoutResponse::LOCAL_NAME[] = UNICODE_LITERAL_14(L,o,g,o,u,t,R,e,s,p,o,n,s,e); +const XMLCh ManageNameIDRequest::LOCAL_NAME[] = UNICODE_LITERAL_19(M,a,n,a,g,e,N,a,m,e,I,D,R,e,q,u,e,s,t); +const XMLCh ManageNameIDRequest::TYPE_NAME[] = UNICODE_LITERAL_23(M,a,n,a,g,e,N,a,m,e,I,D,R,e,q,u,e,s,t,T,y,p,e); +const XMLCh ManageNameIDResponse::LOCAL_NAME[] = UNICODE_LITERAL_20(M,a,n,a,g,e,N,a,m,e,I,D,R,e,s,p,o,n,s,e); +const XMLCh NameIDMappingRequest::LOCAL_NAME[] = UNICODE_LITERAL_20(N,a,m,e,I,D,M,a,p,p,i,n,g,R,e,q,u,e,s,t); +const XMLCh NameIDMappingRequest::TYPE_NAME[] = UNICODE_LITERAL_24(N,a,m,e,I,D,M,a,p,p,i,n,g,R,e,q,u,e,s,t,T,y,p,e); +const XMLCh NameIDMappingResponse::LOCAL_NAME[] = UNICODE_LITERAL_21(N,a,m,e,I,D,M,a,p,p,i,n,g,R,e,s,p,o,n,s,e); +const XMLCh NameIDMappingResponse::TYPE_NAME[] = UNICODE_LITERAL_25(N,a,m,e,I,D,M,a,p,p,i,n,g,R,e,s,p,o,n,s,e,T,y,p,e); +const XMLCh NameIDPolicy::LOCAL_NAME[] = UNICODE_LITERAL_12(N,a,m,e,I,D,P,o,l,i,c,y); +const XMLCh NameIDPolicy::TYPE_NAME[] = UNICODE_LITERAL_16(N,a,m,e,I,D,P,o,l,i,c,y,T,y,p,e); +const XMLCh NameIDPolicy::FORMAT_ATTRIB_NAME[] = UNICODE_LITERAL_6(F,o,r,m,a,t); +const XMLCh NameIDPolicy::SPNAMEQUALIFIER_ATTRIB_NAME[] = UNICODE_LITERAL_15(S,P,N,a,m,e,Q,u,a,l,i,f,i,e,r); +const XMLCh NameIDPolicy::ALLOWCREATE_ATTRIB_NAME[] = UNICODE_LITERAL_11(A,l,l,o,w,C,r,e,a,t,e); +const XMLCh NewEncryptedID::LOCAL_NAME[] = UNICODE_LITERAL_14(N,e,w,E,n,c,r,y,p,t,e,d,I,D); +const XMLCh NewID::LOCAL_NAME[] = UNICODE_LITERAL_5(N,e,w,I,D); +const XMLCh RequesterID::LOCAL_NAME[] = UNICODE_LITERAL_11(R,e,q,u,e,s,t,e,r,I,D); +const XMLCh RequestedAuthnContext::LOCAL_NAME[] = UNICODE_LITERAL_21(R,e,q,u,e,s,t,e,d,A,u,t,h,n,C,o,n,t,e,x,t); +const XMLCh RequestedAuthnContext::TYPE_NAME[] = UNICODE_LITERAL_25(R,e,q,u,e,s,t,e,d,A,u,t,h,n,C,o,n,t,e,x,t,T,y,p,e); +const XMLCh RequestedAuthnContext::COMPARISON_ATTRIB_NAME[] = UNICODE_LITERAL_10(C,o,m,p,a,r,i,s,o,n); +const XMLCh RequestedAuthnContext::COMPARISON_EXACT[] = UNICODE_LITERAL_5(e,x,a,c,t); +const XMLCh RequestedAuthnContext::COMPARISON_MINIMUM[] = UNICODE_LITERAL_7(m,i,n,i,m,u,m); +const XMLCh RequestedAuthnContext::COMPARISON_MAXIMUM[] = UNICODE_LITERAL_7(m,a,x,i,m,u,m); +const XMLCh RequestedAuthnContext::COMPARISON_BETTER[] = UNICODE_LITERAL_6(b,e,t,t,e,r); +const XMLCh RequestAbstractType::LOCAL_NAME[] = {chNull}; +const XMLCh RequestAbstractType::TYPE_NAME[] = UNICODE_LITERAL_19(R,e,q,u,e,s,t,A,b,s,t,r,a,c,t,T,y,p,e); +const XMLCh RequestAbstractType::ID_ATTRIB_NAME[] = UNICODE_LITERAL_2(I,D); +const XMLCh RequestAbstractType::VER_ATTRIB_NAME[] = UNICODE_LITERAL_7(V,e,r,s,i,o,n); +const XMLCh RequestAbstractType::ISSUEINSTANT_ATTRIB_NAME[] = UNICODE_LITERAL_12(I,s,s,u,e,I,n,s,t,a,n,t); +const XMLCh RequestAbstractType::DESTINATION_ATTRIB_NAME[] = UNICODE_LITERAL_11(D,e,s,t,i,n,a,t,i,o,n); +const XMLCh RequestAbstractType::CONSENT_ATTRIB_NAME[] = UNICODE_LITERAL_7(C,o,n,s,e,n,t); +const XMLCh RespondTo::LOCAL_NAME[] = UNICODE_LITERAL_9(R,e,s,p,o,n,d,T,o); +const XMLCh Response::LOCAL_NAME[] = UNICODE_LITERAL_8(R,e,s,p,o,n,s,e); +const XMLCh Response::TYPE_NAME[] = UNICODE_LITERAL_12(R,e,s,p,o,n,s,e,T,y,p,e); +const XMLCh Scoping::LOCAL_NAME[] = UNICODE_LITERAL_7(S,c,o,p,i,n,g); +const XMLCh Scoping::TYPE_NAME[] = UNICODE_LITERAL_11(S,c,o,p,i,n,g,T,y,p,e); +const XMLCh Scoping::PROXYCOUNT_ATTRIB_NAME[] = UNICODE_LITERAL_10(P,r,o,x,y,C,o,u,n,t); +const XMLCh SessionIndex::LOCAL_NAME[] = UNICODE_LITERAL_12(S,e,s,s,i,o,n,I,n,d,e,x); +const XMLCh Status::LOCAL_NAME[] = UNICODE_LITERAL_6(S,t,a,t,u,s); +const XMLCh Status::TYPE_NAME[] = UNICODE_LITERAL_10(S,t,a,t,u,s,T,y,p,e); +const XMLCh StatusCode::LOCAL_NAME[] = UNICODE_LITERAL_10(S,t,a,t,u,s,C,o,d,e); +const XMLCh StatusCode::TYPE_NAME[] = UNICODE_LITERAL_14(S,t,a,t,u,s,C,o,d,e,T,y,p,e); +const XMLCh StatusCode::VALUE_ATTRIB_NAME[] = UNICODE_LITERAL_5(V,a,l,u,e); +const XMLCh StatusDetail::LOCAL_NAME[] = UNICODE_LITERAL_12(S,t,a,t,u,s,D,e,t,a,i,l); +const XMLCh StatusDetail::TYPE_NAME[] = UNICODE_LITERAL_16(S,t,a,t,u,s,D,e,t,a,i,l,T,y,p,e); +const XMLCh StatusMessage::LOCAL_NAME[] = UNICODE_LITERAL_13(S,t,a,t,u,s,M,e,s,s,a,g,e); +const XMLCh StatusResponseType::LOCAL_NAME[] = {chNull}; +const XMLCh StatusResponseType::TYPE_NAME[] = UNICODE_LITERAL_18(S,t,a,t,u,s,R,e,s,p,o,n,s,e,T,y,p,e); +const XMLCh StatusResponseType::ID_ATTRIB_NAME[] = UNICODE_LITERAL_2(I,D); +const XMLCh StatusResponseType::INRESPONSETO_ATTRIB_NAME[] = UNICODE_LITERAL_12(I,n,R,e,s,p,o,n,s,e,T,o); +const XMLCh StatusResponseType::VER_ATTRIB_NAME[] = UNICODE_LITERAL_7(V,e,r,s,i,o,n); +const XMLCh StatusResponseType::ISSUEINSTANT_ATTRIB_NAME[] = UNICODE_LITERAL_12(I,s,s,u,e,I,n,s,t,a,n,t); +const XMLCh StatusResponseType::DESTINATION_ATTRIB_NAME[] = UNICODE_LITERAL_11(D,e,s,t,i,n,a,t,i,o,n); +const XMLCh StatusResponseType::CONSENT_ATTRIB_NAME[] = UNICODE_LITERAL_7(C,o,n,s,e,n,t); +const XMLCh SubjectQuery::LOCAL_NAME[] = UNICODE_LITERAL_12(S,u,b,j,e,c,t,Q,u,e,r,y); +const XMLCh SubjectQuery::TYPE_NAME[] = UNICODE_LITERAL_24(S,u,b,j,e,c,t,Q,u,e,r,y,A,b,s,t,r,a,c,t,T,y,p,e); +const XMLCh Terminate::LOCAL_NAME[] = UNICODE_LITERAL_9(T,e,r,m,i,n,a,t,e); +const XMLCh Terminate::TYPE_NAME[] = UNICODE_LITERAL_13(T,e,r,m,i,n,a,t,e,T,y,p,e); + +// Unicode literals: LogoutRequest element, Reason attribute +const XMLCh LogoutRequest::REASON_USER[] = // urn:oasis:names:tc:SAML:2.0:logout:user +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_l, chLatin_o, chLatin_g, chLatin_o, chLatin_u, chLatin_t, chColon, + chLatin_u, chLatin_s, chLatin_e, chLatin_r, chNull +}; + +const XMLCh LogoutRequest::REASON_ADMIN[] = // urn:oasis:names:tc:SAML:2.0:logout:admin +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_l, chLatin_o, chLatin_g, chLatin_o, chLatin_u, chLatin_t, chColon, + chLatin_a, chLatin_d, chLatin_m, chLatin_i, chLatin_n, chNull +}; + + +const XMLCh LogoutRequest::REASON_GLOBAL_TIMEOUT[] = // urn:oasis:names:tc:SAML:2.0:logout:global-timeout +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_l, chLatin_o, chLatin_g, chLatin_o, chLatin_u, chLatin_t, chColon, + chLatin_g, chLatin_l, chLatin_o, chLatin_b, chLatin_a, chLatin_l, + chDash, chLatin_t, chLatin_i, chLatin_m, chLatin_e, chLatin_o, chLatin_u, chLatin_t, chNull +}; + + +const XMLCh LogoutRequest::REASON_SP_TIMEOUT[] = // urn:oasis:names:tc:SAML:2.0:logout:sp-timeout +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_l, chLatin_o, chLatin_g, chLatin_o, chLatin_u, chLatin_t, chColon, + chLatin_s, chLatin_p, chDash, chLatin_t, chLatin_i, chLatin_m, chLatin_e, chLatin_o, chLatin_u, chLatin_t, chNull +}; + + +// Unicode literals, StatusCode Value +const XMLCh StatusCode::SUCCESS[] = // urn:oasis:names:tc:SAML:2.0:status:Success +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, + chLatin_S, chLatin_u, chLatin_c, chLatin_c, chLatin_e, chLatin_s, chLatin_s, chNull +}; + +const XMLCh StatusCode::REQUESTER[] = // urn:oasis:names:tc:SAML:2.0:status:Requester +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, + chLatin_R, chLatin_e, chLatin_q, chLatin_u, chLatin_e, chLatin_s, chLatin_t, chLatin_e, chLatin_r, chNull +}; + +const XMLCh StatusCode::RESPONDER[] = // urn:oasis:names:tc:SAML:2.0:status:Responder +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, + chLatin_R, chLatin_e, chLatin_s, chLatin_p, chLatin_o, chLatin_n, chLatin_d, chLatin_e, chLatin_r, chNull +}; + +const XMLCh StatusCode::VERSION_MISMATCH[] = // urn:oasis:names:tc:SAML:2.0:status:VersionMismatch +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, + chLatin_V, chLatin_e, chLatin_r, chLatin_s, chLatin_i, chLatin_o, chLatin_n, + chLatin_M, chLatin_i, chLatin_s, chLatin_m, chLatin_a, chLatin_t, chLatin_c, chLatin_h, chNull +}; + +const XMLCh StatusCode::AUTHN_FAILED[] = // urn:oasis:names:tc:SAML:2.0:status:AuthnFailed +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, + chLatin_A, chLatin_u, chLatin_t, chLatin_h, chLatin_n, + chLatin_F, chLatin_a, chLatin_i, chLatin_l, chLatin_e, chLatin_d, chNull +}; + +const XMLCh StatusCode::INVALID_ATTR_NAME_OR_VALUE[] = // urn:oasis:names:tc:SAML:2.0:status:InvalidAttrNameOrValue +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, + chLatin_I, chLatin_n, chLatin_v, chLatin_a, chLatin_l, chLatin_i, chLatin_d, + chLatin_A, chLatin_t, chLatin_t, chLatin_r, chLatin_N, chLatin_a, chLatin_m, chLatin_e, + chLatin_O, chLatin_r, chLatin_V, chLatin_a, chLatin_l, chLatin_u, chLatin_e, chNull +}; + +const XMLCh StatusCode::INVALID_NAMEID_POLICY[] = // urn:oasis:names:tc:SAML:2.0:status:InvalidNameIDPolicy +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, + chLatin_I, chLatin_n, chLatin_v, chLatin_a, chLatin_l, chLatin_i, chLatin_d, + chLatin_N, chLatin_a, chLatin_m, chLatin_e, chLatin_I, chLatin_D, + chLatin_P, chLatin_o, chLatin_l, chLatin_i, chLatin_c, chLatin_y, chNull +}; + +const XMLCh StatusCode::NO_AUTHN_CONTEXT[] = // urn:oasis:names:tc:SAML:2.0:status:NoAuthnContext +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, + chLatin_N, chLatin_o, chLatin_A, chLatin_u, chLatin_t, chLatin_h, chLatin_n, + chLatin_C, chLatin_o, chLatin_n, chLatin_t, chLatin_e, chLatin_x, chLatin_t, chNull +}; + +const XMLCh StatusCode::NO_AVAILABLE_IDP[] = // urn:oasis:names:tc:SAML:2.0:status:NoAvailableIDP +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, + chLatin_N, chLatin_o, chLatin_A, chLatin_v, chLatin_a, chLatin_i, chLatin_l, chLatin_a, chLatin_b, chLatin_l, chLatin_e, + chLatin_I, chLatin_D, chLatin_P, chNull +}; + +const XMLCh StatusCode::NO_PASSIVE[] = // urn:oasis:names:tc:SAML:2.0:status:NoPassive +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, + chLatin_N, chLatin_o, chLatin_P, chLatin_a, chLatin_s, chLatin_s, chLatin_i, chLatin_v, chLatin_e, chNull +}; + +const XMLCh StatusCode::NO_SUPPORTED_IDP[] = // urn:oasis:names:tc:SAML:2.0:status:NoSupportedIDP +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, + chLatin_N, chLatin_o, chLatin_S, chLatin_u, chLatin_p, chLatin_p, chLatin_o, chLatin_r, chLatin_t, chLatin_e, chLatin_d, + chLatin_I, chLatin_D, chLatin_P, chNull +}; + +const XMLCh StatusCode::PARTIAL_LOGOUT[] = // urn:oasis:names:tc:SAML:2.0:status:PartialLogout +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, + chLatin_P, chLatin_a, chLatin_r, chLatin_t, chLatin_i, chLatin_a, chLatin_l, + chLatin_L, chLatin_o, chLatin_g, chLatin_o, chLatin_u, chLatin_t, chNull +}; + +const XMLCh StatusCode::PROXY_COUNT_EXCEEDED[] = // urn:oasis:names:tc:SAML:2.0:status:ProxyCountExceeded +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, + chLatin_P, chLatin_r, chLatin_o, chLatin_x, chLatin_y, chLatin_C, chLatin_o, chLatin_u, chLatin_n, chLatin_t, + chLatin_E, chLatin_x, chLatin_c, chLatin_e, chLatin_e, chLatin_d, chLatin_e, chLatin_d, chNull +}; + +const XMLCh StatusCode::REQUEST_DENIED[] = // urn:oasis:names:tc:SAML:2.0:status:RequestDenied +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, + chLatin_R, chLatin_e, chLatin_q, chLatin_u, chLatin_e, chLatin_s, chLatin_t, + chLatin_D, chLatin_e, chLatin_n, chLatin_i, chLatin_e, chLatin_d, chNull +}; + +const XMLCh StatusCode::REQUEST_UNSUPPORTED[] = // urn:oasis:names:tc:SAML:2.0:status:RequestUnsupported +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, + chLatin_R, chLatin_e, chLatin_q, chLatin_u, chLatin_e, chLatin_s, chLatin_t, + chLatin_U, chLatin_n, chLatin_s, chLatin_u, chLatin_p, chLatin_p, chLatin_o, chLatin_r, chLatin_t, chLatin_e, chLatin_d, chNull +}; + +const XMLCh StatusCode::REQUEST_VERSION_DEPRECATED[] = // urn:oasis:names:tc:SAML:2.0:status:RequestVersionDeprecated +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, + chLatin_R, chLatin_e, chLatin_q, chLatin_u, chLatin_e, chLatin_s, chLatin_t, + chLatin_V, chLatin_e, chLatin_r, chLatin_s, chLatin_i, chLatin_o, chLatin_n, + chLatin_D, chLatin_e, chLatin_p, chLatin_r, chLatin_e, chLatin_c, chLatin_a, chLatin_t, chLatin_e, chLatin_d, chNull +}; + +const XMLCh StatusCode::REQUEST_VERSION_TOO_HIGH[] = // urn:oasis:names:tc:SAML:2.0:status:RequestVersionTooHigh +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, + chLatin_R, chLatin_e, chLatin_q, chLatin_u, chLatin_e, chLatin_s, chLatin_t, + chLatin_V, chLatin_e, chLatin_r, chLatin_s, chLatin_i, chLatin_o, chLatin_n, + chLatin_T, chLatin_o, chLatin_o, chLatin_H, chLatin_i, chLatin_g, chLatin_h, chNull +}; + +const XMLCh StatusCode::REQUEST_VERSION_TOO_LOW[] = // urn:oasis:names:tc:SAML:2.0:status:RequestVersionTooLow +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, + chLatin_R, chLatin_e, chLatin_q, chLatin_u, chLatin_e, chLatin_s, chLatin_t, + chLatin_V, chLatin_e, chLatin_r, chLatin_s, chLatin_i, chLatin_o, chLatin_n, + chLatin_T, chLatin_o, chLatin_o, chLatin_L, chLatin_o, chLatin_w, chNull +}; + +const XMLCh StatusCode::RESOURCE_NOT_RECOGNIZED[] = // urn:oasis:names:tc:SAML:2.0:status:ResourceNotRecognized +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, + chLatin_R, chLatin_e, chLatin_s, chLatin_o, chLatin_u, chLatin_r, chLatin_c, chLatin_e, + chLatin_N, chLatin_o, chLatin_t, + chLatin_R, chLatin_e, chLatin_c, chLatin_o, chLatin_g, chLatin_n, chLatin_i, chLatin_z, chLatin_e, chLatin_d, chNull +}; + +const XMLCh StatusCode::TOO_MANY_RESPONSES[] = // urn:oasis:names:tc:SAML:2.0:status:TooManyResponses +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, + chLatin_T, chLatin_o, chLatin_o, chLatin_M, chLatin_a, chLatin_n, chLatin_y, + chLatin_R, chLatin_e, chLatin_s, chLatin_p, chLatin_o, chLatin_n, chLatin_s, chLatin_e, chLatin_s, chNull +}; + +const XMLCh StatusCode::UNKNOWN_ATTR_PROFILE[] = // urn:oasis:names:tc:SAML:2.0:status:UnknownAttrProfile +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, + chLatin_U, chLatin_n, chLatin_k, chLatin_n, chLatin_o, chLatin_w, chLatin_n, + chLatin_A, chLatin_t, chLatin_t, chLatin_r, + chLatin_P, chLatin_r, chLatin_o, chLatin_f, chLatin_i, chLatin_l, chLatin_e, chNull +}; + +const XMLCh StatusCode::UNKNOWN_PRINCIPAL[] = // urn:oasis:names:tc:SAML:2.0:status:UnknownPrincipal +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, + chLatin_U, chLatin_n, chLatin_k, chLatin_n, chLatin_o, chLatin_w, chLatin_n, + chLatin_P, chLatin_r, chLatin_i, chLatin_n, chLatin_c, chLatin_i, chLatin_p, chLatin_a, chLatin_l, chNull +}; + +const XMLCh StatusCode::UNSUPPORTED_BINDING[] = // urn:oasis:names:tc:SAML:2.0:status:UnsupportedBinding +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_s, chLatin_t, chLatin_a, chLatin_t, chLatin_u, chLatin_s, chColon, + chLatin_U, chLatin_n, chLatin_s, chLatin_u, chLatin_p, chLatin_p, chLatin_o, chLatin_r, chLatin_t, chLatin_e, chLatin_d, + chLatin_B, chLatin_i, chLatin_n, chLatin_d, chLatin_i, chLatin_n, chLatin_g, chNull +}; + diff --git a/saml/saml2/metadata/ChainingMetadataProvider.h b/saml/saml2/metadata/ChainingMetadataProvider.h index d71a254..42b90e1 100644 --- a/saml/saml2/metadata/ChainingMetadataProvider.h +++ b/saml/saml2/metadata/ChainingMetadataProvider.h @@ -1,101 +1,101 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file saml/security/ChainingMetadataProvider.h - * - * MetadataProvider that uses multiple providers in sequence. - */ - -#ifndef __saml_chainmeta_h__ -#define __saml_chainmeta_h__ - -#include -#include - -namespace opensaml { - namespace saml2md { - - /** - * MetadataProvider that uses multiple providers in sequence. - */ - class SAML_API ChainingMetadataProvider - : public ObservableMetadataProvider, public ObservableMetadataProvider::Observer { - public: - /** - * Constructor. - * - * If a DOM is supplied, the following XML content is supported: - * - *

    - *
  • <MetadataProvider> elements with a type attribute - *
- * - * XML namespaces are ignored in the processing of this content. - * - * @param e DOM to supply configuration for provider - */ - ChainingMetadataProvider(const DOMElement* e=NULL); - - /** - * Destructor will delete any embedded engines. - */ - virtual ~ChainingMetadataProvider(); - - /** - * Adds a provider for future calls. The provider MUST be - * initialized before adding it. - * - * @param newProvider provider to add - */ - void addMetadataProvider(MetadataProvider* newProvider) { - m_providers.push_back(newProvider); - } - - /** - * Removes a provider. The caller must delete the provider if necessary. - * - * @param oldProvider provider to remove - * @return the old provider - */ - MetadataProvider* removeMetadataProvider(MetadataProvider* oldProvider) { - for (std::vector::iterator i=m_providers.begin(); i!=m_providers.end(); i++) { - if (oldProvider==(*i)) { - m_providers.erase(i); - return oldProvider; - } - } - return NULL; - } - - xmltooling::Lockable* lock(); - void unlock(); - void init(); - const xmlsignature::KeyResolver* getKeyResolver() const; - const xmltooling::XMLObject* getMetadata() const; - const EntitiesDescriptor* getEntitiesDescriptor(const char* name, bool requireValidMetadata=true) const; - const EntityDescriptor* getEntityDescriptor(const char* id, bool requireValidMetadata=true) const; - const EntityDescriptor* getEntityDescriptor(const SAMLArtifact* artifact) const; - void onEvent(MetadataProvider& provider); - - private: - xmltooling::ThreadKey* m_tlsKey; - std::vector m_providers; - }; - }; -}; - -#endif /* __saml_chainmeta_h__ */ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file saml/security/ChainingMetadataProvider.h + * + * MetadataProvider that uses multiple providers in sequence. + */ + +#ifndef __saml_chainmeta_h__ +#define __saml_chainmeta_h__ + +#include +#include + +namespace opensaml { + namespace saml2md { + + /** + * MetadataProvider that uses multiple providers in sequence. + */ + class SAML_API ChainingMetadataProvider + : public ObservableMetadataProvider, public ObservableMetadataProvider::Observer { + public: + /** + * Constructor. + * + * If a DOM is supplied, the following XML content is supported: + * + *
    + *
  • <MetadataProvider> elements with a type attribute + *
+ * + * XML namespaces are ignored in the processing of this content. + * + * @param e DOM to supply configuration for provider + */ + ChainingMetadataProvider(const DOMElement* e=NULL); + + /** + * Destructor will delete any embedded engines. + */ + virtual ~ChainingMetadataProvider(); + + /** + * Adds a provider for future calls. The provider MUST be + * initialized before adding it. + * + * @param newProvider provider to add + */ + void addMetadataProvider(MetadataProvider* newProvider) { + m_providers.push_back(newProvider); + } + + /** + * Removes a provider. The caller must delete the provider if necessary. + * + * @param oldProvider provider to remove + * @return the old provider + */ + MetadataProvider* removeMetadataProvider(MetadataProvider* oldProvider) { + for (std::vector::iterator i=m_providers.begin(); i!=m_providers.end(); i++) { + if (oldProvider==(*i)) { + m_providers.erase(i); + return oldProvider; + } + } + return NULL; + } + + xmltooling::Lockable* lock(); + void unlock(); + void init(); + const xmlsignature::KeyResolver* getKeyResolver() const; + const xmltooling::XMLObject* getMetadata() const; + const EntitiesDescriptor* getEntitiesDescriptor(const char* name, bool requireValidMetadata=true) const; + const EntityDescriptor* getEntityDescriptor(const char* id, bool requireValidMetadata=true) const; + const EntityDescriptor* getEntityDescriptor(const SAMLArtifact* artifact) const; + void onEvent(MetadataProvider& provider); + + private: + xmltooling::ThreadKey* m_tlsKey; + std::vector m_providers; + }; + }; +}; + +#endif /* __saml_chainmeta_h__ */ diff --git a/saml/saml2/metadata/impl/ChainingMetadataProvider.cpp b/saml/saml2/metadata/impl/ChainingMetadataProvider.cpp index 7f410d2..e110008 100644 --- a/saml/saml2/metadata/impl/ChainingMetadataProvider.cpp +++ b/saml/saml2/metadata/impl/ChainingMetadataProvider.cpp @@ -1,176 +1,176 @@ -/* - * Copyright 2001-2005 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * ChainingMetadataProvider.cpp - * - * MetadataProvider that uses multiple providers in sequence. - */ - -#include "internal.h" -#include "exceptions.h" -#include "saml2/metadata/ChainingMetadataProvider.h" - -#include -#include - -using namespace opensaml::saml2md; -using namespace opensaml; -using namespace xmlsignature; -using namespace xmltooling; -using namespace std; - -namespace opensaml { - namespace saml2md { - MetadataProvider* SAML_DLLLOCAL ChainingMetadataProviderFactory(const DOMElement* const & e) - { - return new ChainingMetadataProvider(e); - } - }; -}; - -static const XMLCh GenericMetadataProvider[] = UNICODE_LITERAL_16(M,e,t,a,d,a,t,a,P,r,o,v,i,d,e,r); -static const XMLCh type[] = UNICODE_LITERAL_4(t,y,p,e); - -ChainingMetadataProvider::ChainingMetadataProvider(const DOMElement* e) : ObservableMetadataProvider(e), m_tlsKey(NULL) -{ - try { - e = e ? xmltooling::XMLHelper::getFirstChildElement(e, GenericMetadataProvider) : NULL; - while (e) { - auto_ptr_char temp(e->getAttributeNS(NULL,type)); - if (temp.get()) { - auto_ptr provider( - SAMLConfig::getConfig().MetadataProviderManager.newPlugin(temp.get(), e) - ); - ObservableMetadataProvider* obs = dynamic_cast(provider.get()); - if (obs) - obs->addObserver(this); - m_providers.push_back(provider.get()); - provider.release(); - } - e = XMLHelper::getNextSiblingElement(e, GenericMetadataProvider); - } - } - catch (XMLToolingException&) { - for_each(m_providers.begin(), m_providers.end(), xmltooling::cleanup()); - throw; - } - m_tlsKey = ThreadKey::create(NULL); -} - -ChainingMetadataProvider::~ChainingMetadataProvider() -{ - delete m_tlsKey; - for_each(m_providers.begin(), m_providers.end(), xmltooling::cleanup()); -} - -void ChainingMetadataProvider::onEvent(MetadataProvider& provider) -{ - emitChangeEvent(); -} - -void ChainingMetadataProvider::init() -{ - for_each(m_providers.begin(), m_providers.end(), mem_fun(&MetadataProvider::init)); -} - -Lockable* ChainingMetadataProvider::lock() -{ - return this; // we're not lockable ourselves... -} - -void ChainingMetadataProvider::unlock() -{ - // Check for a locked provider. - void* ptr=m_tlsKey->getData(); - if (ptr) { - m_tlsKey->setData(NULL); - reinterpret_cast(ptr)->unlock(); - } -} - -const KeyResolver* ChainingMetadataProvider::getKeyResolver() const -{ - // Check for a locked provider. - void* ptr=m_tlsKey->getData(); - return ptr ? reinterpret_cast(ptr)->getKeyResolver() : NULL; - -} - -const XMLObject* ChainingMetadataProvider::getMetadata() const -{ - throw XMLToolingException("getMetadata operation not implemented on this provider."); -} - -const EntitiesDescriptor* ChainingMetadataProvider::getEntitiesDescriptor(const char* name, bool requireValidMetadata) const -{ - // Clear any existing lock. - const_cast(this)->unlock(); - - // Do a search. - const EntitiesDescriptor* ret=NULL; - for (vector::const_iterator i=m_providers.begin(); i!=m_providers.end(); ++i) { - (*i)->lock(); - if (ret=(*i)->getEntitiesDescriptor(name,requireValidMetadata)) { - // Save locked provider. - m_tlsKey->setData(*i); - return ret; - } - (*i)->unlock(); - } - - return NULL; -} - -const EntityDescriptor* ChainingMetadataProvider::getEntityDescriptor(const char* id, bool requireValidMetadata) const -{ - // Clear any existing lock. - const_cast(this)->unlock(); - - // Do a search. - const EntityDescriptor* ret=NULL; - for (vector::const_iterator i=m_providers.begin(); i!=m_providers.end(); ++i) { - (*i)->lock(); - if (ret=(*i)->getEntityDescriptor(id,requireValidMetadata)) { - // Save locked provider. - m_tlsKey->setData(*i); - return ret; - } - (*i)->unlock(); - } - - return NULL; -} - -const EntityDescriptor* ChainingMetadataProvider::getEntityDescriptor(const SAMLArtifact* artifact) const -{ - // Clear any existing lock. - const_cast(this)->unlock(); - - // Do a search. - const EntityDescriptor* ret=NULL; - for (vector::const_iterator i=m_providers.begin(); i!=m_providers.end(); ++i) { - (*i)->lock(); - if (ret=(*i)->getEntityDescriptor(artifact)) { - // Save locked provider. - m_tlsKey->setData(*i); - return ret; - } - (*i)->unlock(); - } - - return NULL; -} +/* + * Copyright 2001-2005 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * ChainingMetadataProvider.cpp + * + * MetadataProvider that uses multiple providers in sequence. + */ + +#include "internal.h" +#include "exceptions.h" +#include "saml2/metadata/ChainingMetadataProvider.h" + +#include +#include + +using namespace opensaml::saml2md; +using namespace opensaml; +using namespace xmlsignature; +using namespace xmltooling; +using namespace std; + +namespace opensaml { + namespace saml2md { + MetadataProvider* SAML_DLLLOCAL ChainingMetadataProviderFactory(const DOMElement* const & e) + { + return new ChainingMetadataProvider(e); + } + }; +}; + +static const XMLCh GenericMetadataProvider[] = UNICODE_LITERAL_16(M,e,t,a,d,a,t,a,P,r,o,v,i,d,e,r); +static const XMLCh type[] = UNICODE_LITERAL_4(t,y,p,e); + +ChainingMetadataProvider::ChainingMetadataProvider(const DOMElement* e) : ObservableMetadataProvider(e), m_tlsKey(NULL) +{ + try { + e = e ? xmltooling::XMLHelper::getFirstChildElement(e, GenericMetadataProvider) : NULL; + while (e) { + auto_ptr_char temp(e->getAttributeNS(NULL,type)); + if (temp.get()) { + auto_ptr provider( + SAMLConfig::getConfig().MetadataProviderManager.newPlugin(temp.get(), e) + ); + ObservableMetadataProvider* obs = dynamic_cast(provider.get()); + if (obs) + obs->addObserver(this); + m_providers.push_back(provider.get()); + provider.release(); + } + e = XMLHelper::getNextSiblingElement(e, GenericMetadataProvider); + } + } + catch (XMLToolingException&) { + for_each(m_providers.begin(), m_providers.end(), xmltooling::cleanup()); + throw; + } + m_tlsKey = ThreadKey::create(NULL); +} + +ChainingMetadataProvider::~ChainingMetadataProvider() +{ + delete m_tlsKey; + for_each(m_providers.begin(), m_providers.end(), xmltooling::cleanup()); +} + +void ChainingMetadataProvider::onEvent(MetadataProvider& provider) +{ + emitChangeEvent(); +} + +void ChainingMetadataProvider::init() +{ + for_each(m_providers.begin(), m_providers.end(), mem_fun(&MetadataProvider::init)); +} + +Lockable* ChainingMetadataProvider::lock() +{ + return this; // we're not lockable ourselves... +} + +void ChainingMetadataProvider::unlock() +{ + // Check for a locked provider. + void* ptr=m_tlsKey->getData(); + if (ptr) { + m_tlsKey->setData(NULL); + reinterpret_cast(ptr)->unlock(); + } +} + +const KeyResolver* ChainingMetadataProvider::getKeyResolver() const +{ + // Check for a locked provider. + void* ptr=m_tlsKey->getData(); + return ptr ? reinterpret_cast(ptr)->getKeyResolver() : NULL; + +} + +const XMLObject* ChainingMetadataProvider::getMetadata() const +{ + throw XMLToolingException("getMetadata operation not implemented on this provider."); +} + +const EntitiesDescriptor* ChainingMetadataProvider::getEntitiesDescriptor(const char* name, bool requireValidMetadata) const +{ + // Clear any existing lock. + const_cast(this)->unlock(); + + // Do a search. + const EntitiesDescriptor* ret=NULL; + for (vector::const_iterator i=m_providers.begin(); i!=m_providers.end(); ++i) { + (*i)->lock(); + if (ret=(*i)->getEntitiesDescriptor(name,requireValidMetadata)) { + // Save locked provider. + m_tlsKey->setData(*i); + return ret; + } + (*i)->unlock(); + } + + return NULL; +} + +const EntityDescriptor* ChainingMetadataProvider::getEntityDescriptor(const char* id, bool requireValidMetadata) const +{ + // Clear any existing lock. + const_cast(this)->unlock(); + + // Do a search. + const EntityDescriptor* ret=NULL; + for (vector::const_iterator i=m_providers.begin(); i!=m_providers.end(); ++i) { + (*i)->lock(); + if (ret=(*i)->getEntityDescriptor(id,requireValidMetadata)) { + // Save locked provider. + m_tlsKey->setData(*i); + return ret; + } + (*i)->unlock(); + } + + return NULL; +} + +const EntityDescriptor* ChainingMetadataProvider::getEntityDescriptor(const SAMLArtifact* artifact) const +{ + // Clear any existing lock. + const_cast(this)->unlock(); + + // Do a search. + const EntityDescriptor* ret=NULL; + for (vector::const_iterator i=m_providers.begin(); i!=m_providers.end(); ++i) { + (*i)->lock(); + if (ret=(*i)->getEntityDescriptor(artifact)) { + // Save locked provider. + m_tlsKey->setData(*i); + return ret; + } + (*i)->unlock(); + } + + return NULL; +} diff --git a/saml/security/AbstractPKIXTrustEngine.h b/saml/security/AbstractPKIXTrustEngine.h index 57fcab8..b73895e 100644 --- a/saml/security/AbstractPKIXTrustEngine.h +++ b/saml/security/AbstractPKIXTrustEngine.h @@ -1,147 +1,147 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file saml/security/AbstractPKIXTrustEngine.h - * - * A trust engine that uses X.509 trust anchors and CRLs associated with a role - * to perform PKIX validation of signatures and certificates. - */ - -#ifndef __saml_pkixtrust_h__ -#define __saml_pkixtrust_h__ - -#include -#include - -namespace opensaml { - - /** - * A trust engine that uses X.509 trust anchors and CRLs associated with a role - * to perform PKIX validation of signatures and certificates. - */ - class SAML_API AbstractPKIXTrustEngine : public X509TrustEngine - { - protected: - /** - * Constructor. - * - * If a DOM is supplied, the following XML content is supported: - * - *
    - *
  • <KeyResolver> elements with a type attribute - *
- * - * XML namespaces are ignored in the processing of this content. - * - * @param e DOM to supply configuration for provider - */ - AbstractPKIXTrustEngine(const DOMElement* e=NULL); - - /** - * Checks that either the ID for the entity with the given role or the key names - * for the given role match the subject or subject alternate names - * of the entity's certificate. - * - * @param certEE the credential for the entity to validate - * @param role the descriptor of the role the entity is supposed to be acting in - * - * @return true the name check succeeds, false if not - */ - bool checkEntityNames(XSECCryptoX509* certEE, const saml2md::RoleDescriptor& role) const; - - /** An inline KeyResolver for extracting certificates out of a signature. */ - xmlsignature::KeyResolver* m_inlineResolver; - - public: - virtual ~AbstractPKIXTrustEngine(); - - virtual bool validate( - xmlsignature::Signature& sig, - const saml2md::RoleDescriptor& role, - const xmlsignature::KeyResolver* keyResolver=NULL - ) const; - - virtual bool validate( - XSECCryptoX509* certEE, - const std::vector& certChain, - const saml2md::RoleDescriptor& role, - bool checkName=true, - const xmlsignature::KeyResolver* keyResolver=NULL - ) const; - - /** - * Stateful interface that supplies PKIX validation data to the trust engine. - * Applications can adapt this TrustEngine to their environment by returning - * implementations of this interface from the getPKIXValidationInfoIterator - * method. - */ - class SAML_API PKIXValidationInfoIterator { - MAKE_NONCOPYABLE(PKIXValidationInfoIterator); - protected: - PKIXValidationInfoIterator() {} - public: - virtual ~PKIXValidationInfoIterator() {} - - /** - * Advances to the next set of information, if any. - * - * @return true iff another set of information is available - */ - virtual bool next()=0; - - /** - * Returns the allowable trust chain verification depth for the - * validation data in the current position. - * - * @return allowable trust chain verification depth - */ - virtual int getVerificationDepth() const=0; - - /** - * Returns the set of trust anchors for the validation data in the - * current position. Keeping the certificates beyond the lifetime - * of the iterator or after advancing to the next position requires - * copying them. - * - * @return set of trust anchors - */ - virtual const std::vector& getTrustAnchors() const=0; - - /** - * Returns the set of CRLs for the validation data in the - * current position. Keeping the CRLs beyond the lifetime - * of the iterator or after advancing to the next position requires - * copying them. - * - * @return set of CRLs - */ - virtual const std::vector& getCRLs() const=0; - }; - - /** - * Provides access to the information necessary, for the given role, for - * PKIX validation of credentials. Each set of validation information returned - * will be tried, in turn, until one succeeds or no more remain. - * The caller must free the returned interface when finished with it. - * - * @return interface for obtaining validation data - */ - virtual PKIXValidationInfoIterator* getPKIXValidationInfoIterator(const saml2md::RoleDescriptor& role) const=0; - }; -}; - -#endif /* __saml_pkixtrust_h__ */ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file saml/security/AbstractPKIXTrustEngine.h + * + * A trust engine that uses X.509 trust anchors and CRLs associated with a role + * to perform PKIX validation of signatures and certificates. + */ + +#ifndef __saml_pkixtrust_h__ +#define __saml_pkixtrust_h__ + +#include +#include + +namespace opensaml { + + /** + * A trust engine that uses X.509 trust anchors and CRLs associated with a role + * to perform PKIX validation of signatures and certificates. + */ + class SAML_API AbstractPKIXTrustEngine : public X509TrustEngine + { + protected: + /** + * Constructor. + * + * If a DOM is supplied, the following XML content is supported: + * + *
    + *
  • <KeyResolver> elements with a type attribute + *
+ * + * XML namespaces are ignored in the processing of this content. + * + * @param e DOM to supply configuration for provider + */ + AbstractPKIXTrustEngine(const DOMElement* e=NULL); + + /** + * Checks that either the ID for the entity with the given role or the key names + * for the given role match the subject or subject alternate names + * of the entity's certificate. + * + * @param certEE the credential for the entity to validate + * @param role the descriptor of the role the entity is supposed to be acting in + * + * @return true the name check succeeds, false if not + */ + bool checkEntityNames(XSECCryptoX509* certEE, const saml2md::RoleDescriptor& role) const; + + /** An inline KeyResolver for extracting certificates out of a signature. */ + xmlsignature::KeyResolver* m_inlineResolver; + + public: + virtual ~AbstractPKIXTrustEngine(); + + virtual bool validate( + xmlsignature::Signature& sig, + const saml2md::RoleDescriptor& role, + const xmlsignature::KeyResolver* keyResolver=NULL + ) const; + + virtual bool validate( + XSECCryptoX509* certEE, + const std::vector& certChain, + const saml2md::RoleDescriptor& role, + bool checkName=true, + const xmlsignature::KeyResolver* keyResolver=NULL + ) const; + + /** + * Stateful interface that supplies PKIX validation data to the trust engine. + * Applications can adapt this TrustEngine to their environment by returning + * implementations of this interface from the getPKIXValidationInfoIterator + * method. + */ + class SAML_API PKIXValidationInfoIterator { + MAKE_NONCOPYABLE(PKIXValidationInfoIterator); + protected: + PKIXValidationInfoIterator() {} + public: + virtual ~PKIXValidationInfoIterator() {} + + /** + * Advances to the next set of information, if any. + * + * @return true iff another set of information is available + */ + virtual bool next()=0; + + /** + * Returns the allowable trust chain verification depth for the + * validation data in the current position. + * + * @return allowable trust chain verification depth + */ + virtual int getVerificationDepth() const=0; + + /** + * Returns the set of trust anchors for the validation data in the + * current position. Keeping the certificates beyond the lifetime + * of the iterator or after advancing to the next position requires + * copying them. + * + * @return set of trust anchors + */ + virtual const std::vector& getTrustAnchors() const=0; + + /** + * Returns the set of CRLs for the validation data in the + * current position. Keeping the CRLs beyond the lifetime + * of the iterator or after advancing to the next position requires + * copying them. + * + * @return set of CRLs + */ + virtual const std::vector& getCRLs() const=0; + }; + + /** + * Provides access to the information necessary, for the given role, for + * PKIX validation of credentials. Each set of validation information returned + * will be tried, in turn, until one succeeds or no more remain. + * The caller must free the returned interface when finished with it. + * + * @return interface for obtaining validation data + */ + virtual PKIXValidationInfoIterator* getPKIXValidationInfoIterator(const saml2md::RoleDescriptor& role) const=0; + }; +}; + +#endif /* __saml_pkixtrust_h__ */ diff --git a/saml/security/ChainingTrustEngine.h b/saml/security/ChainingTrustEngine.h index ed24c53..4551841 100644 --- a/saml/security/ChainingTrustEngine.h +++ b/saml/security/ChainingTrustEngine.h @@ -1,99 +1,99 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file saml/security/ChainingTrustEngine.h - * - * X509TrustEngine that uses multiple engines in sequence. - */ - -#ifndef __saml_chaintrust_h__ -#define __saml_chaintrust_h__ - -#include - -namespace opensaml { - - /** - * X509TrustEngine that uses multiple engines in sequence. - */ - class SAML_API ChainingTrustEngine : public X509TrustEngine { - public: - /** - * Constructor. - * - * If a DOM is supplied, the following XML content is supported: - * - *
    - *
  • <TrustEngine> elements with a type attribute - *
- * - * XML namespaces are ignored in the processing of this content. - * - * @param e DOM to supply configuration for provider - */ - ChainingTrustEngine(const DOMElement* e=NULL); - - /** - * Destructor will delete any embedded engines. - */ - virtual ~ChainingTrustEngine(); - - /** - * Adds a trust engine for future calls. - * - * @param newEngine trust engine to add - */ - void addTrustEngine(X509TrustEngine* newEngine) { - m_engines.push_back(newEngine); - } - - /** - * Removes a trust engine. The caller must delete the engine if necessary. - * - * @param oldEngine trust engine to remove - * @return the old engine - */ - X509TrustEngine* removeTrustEngine(X509TrustEngine* 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; - } - - virtual bool validate( - xmlsignature::Signature& sig, - const saml2md::RoleDescriptor& role, - const xmlsignature::KeyResolver* keyResolver=NULL - ) const; - virtual bool validate( - XSECCryptoX509* certEE, - const std::vector& certChain, - const saml2md::RoleDescriptor& role, - bool checkName=true, - const xmlsignature::KeyResolver* keyResolver=NULL - ) const; - - private: - std::vector m_engines; - }; - -}; - -#endif /* __saml_chaintrust_h__ */ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file saml/security/ChainingTrustEngine.h + * + * X509TrustEngine that uses multiple engines in sequence. + */ + +#ifndef __saml_chaintrust_h__ +#define __saml_chaintrust_h__ + +#include + +namespace opensaml { + + /** + * X509TrustEngine that uses multiple engines in sequence. + */ + class SAML_API ChainingTrustEngine : public X509TrustEngine { + public: + /** + * Constructor. + * + * If a DOM is supplied, the following XML content is supported: + * + *
    + *
  • <TrustEngine> elements with a type attribute + *
+ * + * XML namespaces are ignored in the processing of this content. + * + * @param e DOM to supply configuration for provider + */ + ChainingTrustEngine(const DOMElement* e=NULL); + + /** + * Destructor will delete any embedded engines. + */ + virtual ~ChainingTrustEngine(); + + /** + * Adds a trust engine for future calls. + * + * @param newEngine trust engine to add + */ + void addTrustEngine(X509TrustEngine* newEngine) { + m_engines.push_back(newEngine); + } + + /** + * Removes a trust engine. The caller must delete the engine if necessary. + * + * @param oldEngine trust engine to remove + * @return the old engine + */ + X509TrustEngine* removeTrustEngine(X509TrustEngine* 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; + } + + virtual bool validate( + xmlsignature::Signature& sig, + const saml2md::RoleDescriptor& role, + const xmlsignature::KeyResolver* keyResolver=NULL + ) const; + virtual bool validate( + XSECCryptoX509* certEE, + const std::vector& certChain, + const saml2md::RoleDescriptor& role, + bool checkName=true, + const xmlsignature::KeyResolver* keyResolver=NULL + ) const; + + private: + std::vector m_engines; + }; + +}; + +#endif /* __saml_chaintrust_h__ */ diff --git a/saml/security/MetadataKeyInfoIterator.h b/saml/security/MetadataKeyInfoIterator.h index 6d408d5..98125c6 100644 --- a/saml/security/MetadataKeyInfoIterator.h +++ b/saml/security/MetadataKeyInfoIterator.h @@ -1,80 +1,80 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * MetadataKeyInfoIterator.h - * - * Adapter between SAML metadata and TrustEngine KeyInfoIterator interface. - */ - -#ifndef __saml_keyiter_h__ -#define __saml_keyiter_h__ - -#include - -#include - -namespace opensaml { - - /** - * Adapter between SAML metadata and TrustEngine KeyInfoIterator interface. - */ - class SAML_API MetadataKeyInfoIterator : public xmltooling::TrustEngine::KeyInfoIterator - { - const std::vector& m_keys; - std::vector::const_iterator m_iter; - - void advance() { - while (hasNext()) { - const XMLCh* use=(*m_iter)->getUse(); - if ((!use || !*use || XMLString::equals(use,saml2md::KeyDescriptor::KEYTYPE_SIGNING)) && (*m_iter)->getKeyInfo()) - return; - m_iter++; - } - } - - public: - MetadataKeyInfoIterator(const saml2md::RoleDescriptor& role) : m_keys(role.getKeyDescriptors()) { - m_iter=m_keys.begin(); - advance(); - } - - virtual ~MetadataKeyInfoIterator() {} - - /** - * Indicates whether additional KeyInfo objects are available. - * - * @return true iff another KeyInfo object can be fetched - */ - virtual bool hasNext() const { - return m_iter!=m_keys.end(); - } - - /** - * Returns the next KeyInfo object available. - * - * @return the next KeyInfo object, or NULL if none are left - */ - virtual const xmlsignature::KeyInfo* next() { - xmlsignature::KeyInfo* ret = (*m_iter)->getKeyInfo(); - m_iter++; - advance(); - return ret; - } - }; -}; - -#endif /* __saml_keyiter_h__ */ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * MetadataKeyInfoIterator.h + * + * Adapter between SAML metadata and TrustEngine KeyInfoIterator interface. + */ + +#ifndef __saml_keyiter_h__ +#define __saml_keyiter_h__ + +#include + +#include + +namespace opensaml { + + /** + * Adapter between SAML metadata and TrustEngine KeyInfoIterator interface. + */ + class SAML_API MetadataKeyInfoIterator : public xmltooling::TrustEngine::KeyInfoIterator + { + const std::vector& m_keys; + std::vector::const_iterator m_iter; + + void advance() { + while (hasNext()) { + const XMLCh* use=(*m_iter)->getUse(); + if ((!use || !*use || XMLString::equals(use,saml2md::KeyDescriptor::KEYTYPE_SIGNING)) && (*m_iter)->getKeyInfo()) + return; + m_iter++; + } + } + + public: + MetadataKeyInfoIterator(const saml2md::RoleDescriptor& role) : m_keys(role.getKeyDescriptors()) { + m_iter=m_keys.begin(); + advance(); + } + + virtual ~MetadataKeyInfoIterator() {} + + /** + * Indicates whether additional KeyInfo objects are available. + * + * @return true iff another KeyInfo object can be fetched + */ + virtual bool hasNext() const { + return m_iter!=m_keys.end(); + } + + /** + * Returns the next KeyInfo object available. + * + * @return the next KeyInfo object, or NULL if none are left + */ + virtual const xmlsignature::KeyInfo* next() { + xmlsignature::KeyInfo* ret = (*m_iter)->getKeyInfo(); + m_iter++; + advance(); + return ret; + } + }; +}; + +#endif /* __saml_keyiter_h__ */ diff --git a/saml/security/TrustEngine.h b/saml/security/TrustEngine.h index 69ebe26..3ca02b4 100644 --- a/saml/security/TrustEngine.h +++ b/saml/security/TrustEngine.h @@ -1,89 +1,89 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file saml/security/TrustEngine.h - * - * SAML-specific TrustEngine API - */ - -#ifndef __saml_trust_h__ -#define __saml_trust_h__ - -#include -#include -#include - -namespace opensaml { - - /** - * Adapts SAML metadata as a source of KeyInfo for a TrustEngine - * and adds SAML-specific signature validation. - */ - class SAML_API TrustEngine { - MAKE_NONCOPYABLE(TrustEngine); - protected: - /** - * Constructor. - * - * If a DOM is supplied, the following XML content is supported: - * - *
    - *
  • <KeyResolver> elements with a type attribute - *
- * - * XML namespaces are ignored in the processing of this content. - * - * @param e DOM to supply configuration for provider - */ - TrustEngine(const DOMElement* e=NULL) {} - - public: - virtual ~TrustEngine() {} - - /** - * Determines whether a signed SAML object is correct and valid with respect - * to the information known about the issuer. - * - * A custom KeyResolver can be supplied from outside the TrustEngine. - * Alternatively, one may be specified to the plugin constructor. - * A non-caching, inline resolver will be used as a fallback. - * - * @param sig reference to a signature object to validate - * @param role metadata role supplying key information - * @param keyResolver optional externally supplied KeyResolver, or NULL - */ - virtual bool validate( - xmlsignature::Signature& sig, - const saml2md::RoleDescriptor& role, - const xmlsignature::KeyResolver* keyResolver=NULL - ) const=0; - }; - - - /** - * Registers TrustEngine classes into the runtime. - */ - void SAML_API registerTrustEngines(); - - /** TrustEngine based on explicit key information resolved from metadata. */ - #define EXPLICIT_KEY_SAMLTRUSTENGINE "org.opensaml.security.ExplicitKeyTrustEngine" - - /** TrustEngine that tries multiple engines in sequence. */ - #define CHAINING_SAMLTRUSTENGINE "org.opensaml.security.ChainingTrustEngine" -}; - -#endif /* __saml_trust_h__ */ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file saml/security/TrustEngine.h + * + * SAML-specific TrustEngine API + */ + +#ifndef __saml_trust_h__ +#define __saml_trust_h__ + +#include +#include +#include + +namespace opensaml { + + /** + * Adapts SAML metadata as a source of KeyInfo for a TrustEngine + * and adds SAML-specific signature validation. + */ + class SAML_API TrustEngine { + MAKE_NONCOPYABLE(TrustEngine); + protected: + /** + * Constructor. + * + * If a DOM is supplied, the following XML content is supported: + * + *
    + *
  • <KeyResolver> elements with a type attribute + *
+ * + * XML namespaces are ignored in the processing of this content. + * + * @param e DOM to supply configuration for provider + */ + TrustEngine(const DOMElement* e=NULL) {} + + public: + virtual ~TrustEngine() {} + + /** + * Determines whether a signed SAML object is correct and valid with respect + * to the information known about the issuer. + * + * A custom KeyResolver can be supplied from outside the TrustEngine. + * Alternatively, one may be specified to the plugin constructor. + * A non-caching, inline resolver will be used as a fallback. + * + * @param sig reference to a signature object to validate + * @param role metadata role supplying key information + * @param keyResolver optional externally supplied KeyResolver, or NULL + */ + virtual bool validate( + xmlsignature::Signature& sig, + const saml2md::RoleDescriptor& role, + const xmlsignature::KeyResolver* keyResolver=NULL + ) const=0; + }; + + + /** + * Registers TrustEngine classes into the runtime. + */ + void SAML_API registerTrustEngines(); + + /** TrustEngine based on explicit key information resolved from metadata. */ + #define EXPLICIT_KEY_SAMLTRUSTENGINE "org.opensaml.security.ExplicitKeyTrustEngine" + + /** TrustEngine that tries multiple engines in sequence. */ + #define CHAINING_SAMLTRUSTENGINE "org.opensaml.security.ChainingTrustEngine" +}; + +#endif /* __saml_trust_h__ */ diff --git a/saml/security/X509TrustEngine.h b/saml/security/X509TrustEngine.h index 478e86e..848e97f 100644 --- a/saml/security/X509TrustEngine.h +++ b/saml/security/X509TrustEngine.h @@ -1,78 +1,78 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file saml/security/X509TrustEngine.h - * - * Extended TrustEngine interface that adds validation of X.509 credentials. - */ - -#ifndef __saml_x509trust_h__ -#define __saml_x509trust_h__ - -#include - -namespace opensaml { - - /** - * Extended TrustEngine interface that adds validation of X.509 credentials. - */ - class SAML_API X509TrustEngine : public TrustEngine { - protected: - /** - * Constructor. - * - * If a DOM is supplied, the following XML content is supported: - * - *
    - *
  • <KeyResolver> elements with a type attribute - *
- * - * XML namespaces are ignored in the processing of this content. - * - * @param e DOM to supply configuration for provider - */ - X509TrustEngine(const DOMElement* e=NULL) : TrustEngine(e) {} - - public: - virtual ~X509TrustEngine() {} - - /** - * Determines whether an X.509 credential is valid with respect - * to the information known about the peer. - * - * A custom KeyResolver can be supplied from outside the TrustEngine. - * Alternatively, one may be specified to the plugin constructor. - * A non-caching, inline resolver will be used as a fallback. - * - * @param certEE end-entity certificate to validate - * @param certChain the complete set of certificates presented for validation (includes certEE) - * @param role metadata role supplying key information - * @param checkName true iff certificate subject/name checking has NOT already occurred - * @param keyResolver optional externally supplied KeyResolver, or NULL - */ - virtual bool validate( - XSECCryptoX509* certEE, - const std::vector& certChain, - const saml2md::RoleDescriptor& role, - bool checkName=true, - const xmlsignature::KeyResolver* keyResolver=NULL - ) const=0; - }; - -}; - -#endif /* __saml_x509trust_h__ */ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file saml/security/X509TrustEngine.h + * + * Extended TrustEngine interface that adds validation of X.509 credentials. + */ + +#ifndef __saml_x509trust_h__ +#define __saml_x509trust_h__ + +#include + +namespace opensaml { + + /** + * Extended TrustEngine interface that adds validation of X.509 credentials. + */ + class SAML_API X509TrustEngine : public TrustEngine { + protected: + /** + * Constructor. + * + * If a DOM is supplied, the following XML content is supported: + * + *
    + *
  • <KeyResolver> elements with a type attribute + *
+ * + * XML namespaces are ignored in the processing of this content. + * + * @param e DOM to supply configuration for provider + */ + X509TrustEngine(const DOMElement* e=NULL) : TrustEngine(e) {} + + public: + virtual ~X509TrustEngine() {} + + /** + * Determines whether an X.509 credential is valid with respect + * to the information known about the peer. + * + * A custom KeyResolver can be supplied from outside the TrustEngine. + * Alternatively, one may be specified to the plugin constructor. + * A non-caching, inline resolver will be used as a fallback. + * + * @param certEE end-entity certificate to validate + * @param certChain the complete set of certificates presented for validation (includes certEE) + * @param role metadata role supplying key information + * @param checkName true iff certificate subject/name checking has NOT already occurred + * @param keyResolver optional externally supplied KeyResolver, or NULL + */ + virtual bool validate( + XSECCryptoX509* certEE, + const std::vector& certChain, + const saml2md::RoleDescriptor& role, + bool checkName=true, + const xmlsignature::KeyResolver* keyResolver=NULL + ) const=0; + }; + +}; + +#endif /* __saml_x509trust_h__ */ diff --git a/saml/security/impl/AbstractPKIXTrustEngine.cpp b/saml/security/impl/AbstractPKIXTrustEngine.cpp index 629faf5..f7f1fbc 100644 --- a/saml/security/impl/AbstractPKIXTrustEngine.cpp +++ b/saml/security/impl/AbstractPKIXTrustEngine.cpp @@ -1,372 +1,372 @@ -/* - * Copyright 2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * AbstractPKIXTrustEngine.cpp - * - * A trust engine that uses X.509 trust anchors and CRLs associated with a role - * to perform PKIX validation of signatures and certificates. - */ - -#include "internal.h" -#include "security/AbstractPKIXTrustEngine.h" -#include "signature/SignatureProfileValidator.h" - -#include -#include -#include -#include -#include -#include -#include - -using namespace opensaml::saml2md; -using namespace opensaml; -using namespace xmlsignature; -using namespace xmltooling; -using namespace log4cpp; -using namespace std; - -AbstractPKIXTrustEngine::AbstractPKIXTrustEngine(const DOMElement* e) : X509TrustEngine(e), m_inlineResolver(NULL) -{ - m_inlineResolver = XMLToolingConfig::getConfig().KeyResolverManager.newPlugin(INLINE_KEY_RESOLVER,NULL); -} - -AbstractPKIXTrustEngine::~AbstractPKIXTrustEngine() -{ - delete m_inlineResolver; -} - -namespace { - static int SAML_DLLLOCAL error_callback(int ok, X509_STORE_CTX* ctx) - { - if (!ok) - Category::getInstance("OpenSSL").error("path validation failure: %s", X509_verify_cert_error_string(ctx->error)); - return ok; - } - - static bool SAML_DLLLOCAL validate( - X509* EE, STACK_OF(X509)* untrusted, AbstractPKIXTrustEngine::PKIXValidationInfoIterator* pkixInfo - ) - { - Category& log=Category::getInstance(SAML_LOGCAT".TrustEngine"); - - // First we build a stack of CA certs. These objects are all referenced in place. - log.debug("building CA list from PKIX Validation information"); - - // We need this for CRL support. - X509_STORE* store=X509_STORE_new(); - if (!store) { - log_openssl(); - return false; - } - #if (OPENSSL_VERSION_NUMBER >= 0x00907000L) - X509_STORE_set_flags(store,X509_V_FLAG_CRL_CHECK_ALL); - #endif - - STACK_OF(X509)* CAstack = sk_X509_new_null(); - - // This contains the state of the validate operation. - X509_STORE_CTX ctx; - - const vector& CAcerts = pkixInfo->getTrustAnchors(); - for (vector::const_iterator i=CAcerts.begin(); i!=CAcerts.end(); ++i) { - if ((*i)->getProviderName()==DSIGConstants::s_unicodeStrPROVOpenSSL) { - sk_X509_push(CAstack,static_cast(*i)->getOpenSSLX509()); - } - } - - const vector& crls = pkixInfo->getCRLs(); - for (vector::const_iterator j=crls.begin(); j!=crls.end(); ++j) { - if ((*j)->getProviderName()==DSIGConstants::s_unicodeStrPROVOpenSSL) { - // owned by store - X509_STORE_add_crl( - store, - X509_CRL_dup(static_cast(*j)->getOpenSSLX509CRL()) - ); - } - } - - // AFAICT, EE and untrusted are passed in but not owned by the ctx. - #if (OPENSSL_VERSION_NUMBER >= 0x00907000L) - if (X509_STORE_CTX_init(&ctx,store,EE,untrusted)!=1) { - log_openssl(); - log.error("unable to initialize X509_STORE_CTX"); - sk_X509_free(CAstack); - X509_STORE_free(store); - return false; - } - #else - X509_STORE_CTX_init(&ctx,store,EE,untrusted); - #endif - - // Seems to be most efficient to just pass in the CA stack. - X509_STORE_CTX_trusted_stack(&ctx,CAstack); - X509_STORE_CTX_set_depth(&ctx,100); // we check the depth down below - X509_STORE_CTX_set_verify_cb(&ctx,error_callback); - - int ret=X509_verify_cert(&ctx); - if (ret==1) { - // Now see if the depth was acceptable by counting the number of intermediates. - int depth=sk_X509_num(ctx.chain)-2; - if (pkixInfo->getVerificationDepth() < depth) { - log.error( - "certificate chain was too long (%d intermediates, only %d allowed)", - (depth==-1) ? 0 : depth, - pkixInfo->getVerificationDepth() - ); - ret=0; - } - } - - // Clean up... - X509_STORE_CTX_cleanup(&ctx); - X509_STORE_free(store); - sk_X509_free(CAstack); - - if (ret==1) { - log.info("successfully validated certificate chain"); - return true; - } - - return false; - } -}; - -bool AbstractPKIXTrustEngine::checkEntityNames(XSECCryptoX509* certEE, const RoleDescriptor& role) const -{ - Category& log=Category::getInstance(SAML_LOGCAT".TrustEngine"); - - // Build a list of acceptable names. Transcode the possible key "names" to UTF-8. - // For some simple cases, this should handle UTF-8 encoded DNs in certificates. - vector keynames; - const vector& keydescs=role.getKeyDescriptors(); - for (vector::const_iterator kd_i=keydescs.begin(); kd_i!=keydescs.end(); ++kd_i) { - const XMLCh* use=(*kd_i)->getUse(); - const KeyInfo* keyInfo = (*kd_i)->getKeyInfo(); - if (keyInfo && use && XMLString::equals(use,KeyDescriptor::KEYTYPE_ENCRYPTION)) - continue; - const vector& knames=keyInfo->getKeyNames(); - for (vector::const_iterator kn_i=knames.begin(); kn_i!=knames.end(); ++kn_i) { - const XMLCh* n=(*kn_i)->getName(); - if (n && *n) { - char* kn=toUTF8(n); - keynames.push_back(kn); - delete[] kn; - } - } - } - - EntityDescriptor* parent=dynamic_cast(role.getParent()); - if (parent) { - const XMLCh* eid=parent->getEntityID(); - if (eid && *eid) { - char* kn=toUTF8(eid); - keynames.push_back(kn); - delete[] kn; - } - } - - char buf[256]; - X509* x=static_cast(certEE)->getOpenSSLX509(); - X509_NAME* subject=X509_get_subject_name(x); - if (subject) { - // One way is a direct match to the subject DN. - // Seems that the way to do the compare is to write the X509_NAME into a BIO. - BIO* b = BIO_new(BIO_s_mem()); - BIO* b2 = BIO_new(BIO_s_mem()); - BIO_set_mem_eof_return(b, 0); - BIO_set_mem_eof_return(b2, 0); - // The flags give us LDAP order instead of X.500, with a comma separator. - int len=X509_NAME_print_ex(b,subject,0,XN_FLAG_RFC2253); - string subjectstr,subjectstr2; - BIO_flush(b); - while ((len = BIO_read(b, buf, 255)) > 0) { - buf[len] = '\0'; - subjectstr+=buf; - } - log.infoStream() << "certificate subject: " << subjectstr << CategoryStream::ENDLINE; - // The flags give us LDAP order instead of X.500, with a comma plus space separator. - len=X509_NAME_print_ex(b2,subject,0,XN_FLAG_RFC2253 + XN_FLAG_SEP_CPLUS_SPC - XN_FLAG_SEP_COMMA_PLUS); - BIO_flush(b2); - while ((len = BIO_read(b2, buf, 255)) > 0) { - buf[len] = '\0'; - subjectstr2+=buf; - } - - // Check each keyname. - for (vector::const_iterator n=keynames.begin(); n!=keynames.end(); n++) { -#ifdef HAVE_STRCASECMP - if (!strcasecmp(n->c_str(),subjectstr.c_str()) || !strcasecmp(n->c_str(),subjectstr2.c_str())) { -#else - if (!stricmp(n->c_str(),subjectstr.c_str()) || !stricmp(n->c_str(),subjectstr2.c_str())) { -#endif - log.info("matched full subject DN to a key name (%s)", n->c_str()); - BIO_free(b); - BIO_free(b2); - return true; - } - } - BIO_free(b); - BIO_free(b2); - - log.debug("unable to match DN, trying TLS subjectAltName match"); - STACK_OF(GENERAL_NAME)* altnames=(STACK_OF(GENERAL_NAME)*)X509_get_ext_d2i(x, NID_subject_alt_name, NULL, NULL); - if (altnames) { - int numalts = sk_GENERAL_NAME_num(altnames); - for (int an=0; antype==GEN_DNS || check->type==GEN_URI) { - const char* altptr = (char*)ASN1_STRING_data(check->d.ia5); - const int altlen = ASN1_STRING_length(check->d.ia5); - - for (vector::const_iterator n=keynames.begin(); n!=keynames.end(); n++) { -#ifdef HAVE_STRCASECMP - if ((check->type==GEN_DNS && !strncasecmp(altptr,n->c_str(),altlen)) -#else - if ((check->type==GEN_DNS && !strnicmp(altptr,n->c_str(),altlen)) -#endif - || (check->type==GEN_URI && !strncmp(altptr,n->c_str(),altlen))) { - log.info("matched DNS/URI subjectAltName to a key name (%s)", n->c_str()); - GENERAL_NAMES_free(altnames); - return true; - } - } - } - } - } - GENERAL_NAMES_free(altnames); - - log.debug("unable to match subjectAltName, trying TLS CN match"); - memset(buf,0,sizeof(buf)); - if (X509_NAME_get_text_by_NID(subject,NID_commonName,buf,255)>0) { - for (vector::const_iterator n=keynames.begin(); n!=keynames.end(); n++) { -#ifdef HAVE_STRCASECMP - if (!strcasecmp(buf,n->c_str())) { -#else - if (!stricmp(buf,n->c_str())) { -#endif - log.info("matched subject CN to a key name (%s)", n->c_str()); - return true; - } - } - } - else - log.warn("no common name in certificate subject"); - } - else - log.error("certificate has no subject?!"); - - return false; -} - -bool AbstractPKIXTrustEngine::validate( - XSECCryptoX509* certEE, - const vector& certChain, - const RoleDescriptor& role, - bool checkName, - const KeyResolver* keyResolver - ) const -{ -#ifdef _DEBUG - NDC ndc("validate"); -#endif - Category& log=Category::getInstance(SAML_LOGCAT".TrustEngine"); - - if (!certEE) { - log.error("X.509 credential was NULL, unable to perform validation"); - return false; - } - - if (checkName) { - log.debug("checking that the entity certificate name is acceptable"); - if (!checkEntityNames(certEE,role)) { - log.error("entity certificate name was not acceptable"); - return false; - } - } - - log.debug("performing certificate path validation..."); - - STACK_OF(X509)* untrusted=sk_X509_new_null(); - for (vector::const_iterator i=certChain.begin(); i!=certChain.end(); ++i) { - sk_X509_push(untrusted,static_cast(*i)->getOpenSSLX509()); - } - - auto_ptr pkix(getPKIXValidationInfoIterator(role)); - while (pkix->next()) { - if (::validate(static_cast(certEE)->getOpenSSLX509(),untrusted,pkix.get())) { - sk_X509_free(untrusted); - return true; - } - } - - sk_X509_free(untrusted); - log.error("failed to validate certificate chain using supplied PKIX information"); - return false; -} - -bool AbstractPKIXTrustEngine::validate(Signature& sig, const RoleDescriptor& role, const KeyResolver* keyResolver) const -{ -#ifdef _DEBUG - NDC ndc("validate"); -#endif - Category& log=Category::getInstance(SAML_LOGCAT".TrustEngine"); - - log.debug("attempting to validate signature profile"); - SignatureProfileValidator sigValidator; - try { - sigValidator.validate(&sig); - log.debug("signature profile validated"); - } - catch (ValidationException& e) { - if (log.isDebugEnabled()) { - log.debug("signature profile failed to validate: %s", e.what()); - } - return false; - } - - // Pull the certificate chain out of the signature using an inline KeyResolver. - KeyResolver::ResolvedCertificates certs; - if (0==m_inlineResolver->resolveCertificates(&sig, certs)) { - log.error("unable to perform PKIX validation, signature does not contain any certificates"); - return false; - } - - log.debug("validating signature using certificate from within the signature"); - - // Find and save off a pointer to the certificate that unlocks the object. - // Most of the time, this will be the first one anyway. - XSECCryptoX509* certEE=NULL; - SignatureValidator keyValidator; - for (vector::const_iterator i=certs.v().begin(); !certEE && i!=certs.v().end(); ++i) { - try { - keyValidator.setKey((*i)->clonePublicKey()); - keyValidator.validate(&sig); - log.info("signature verified with key inside signature, attempting certificate validation..."); - certEE=(*i); - } - catch (ValidationException&) { - // trap failures - } - } - - if (certEE) - return validate(certEE,certs.v(),role,true,keyResolver); - - log.error("failed to verify signature with embedded certificates"); - return false; -} +/* + * Copyright 2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * AbstractPKIXTrustEngine.cpp + * + * A trust engine that uses X.509 trust anchors and CRLs associated with a role + * to perform PKIX validation of signatures and certificates. + */ + +#include "internal.h" +#include "security/AbstractPKIXTrustEngine.h" +#include "signature/SignatureProfileValidator.h" + +#include +#include +#include +#include +#include +#include +#include + +using namespace opensaml::saml2md; +using namespace opensaml; +using namespace xmlsignature; +using namespace xmltooling; +using namespace log4cpp; +using namespace std; + +AbstractPKIXTrustEngine::AbstractPKIXTrustEngine(const DOMElement* e) : X509TrustEngine(e), m_inlineResolver(NULL) +{ + m_inlineResolver = XMLToolingConfig::getConfig().KeyResolverManager.newPlugin(INLINE_KEY_RESOLVER,NULL); +} + +AbstractPKIXTrustEngine::~AbstractPKIXTrustEngine() +{ + delete m_inlineResolver; +} + +namespace { + static int SAML_DLLLOCAL error_callback(int ok, X509_STORE_CTX* ctx) + { + if (!ok) + Category::getInstance("OpenSSL").error("path validation failure: %s", X509_verify_cert_error_string(ctx->error)); + return ok; + } + + static bool SAML_DLLLOCAL validate( + X509* EE, STACK_OF(X509)* untrusted, AbstractPKIXTrustEngine::PKIXValidationInfoIterator* pkixInfo + ) + { + Category& log=Category::getInstance(SAML_LOGCAT".TrustEngine"); + + // First we build a stack of CA certs. These objects are all referenced in place. + log.debug("building CA list from PKIX Validation information"); + + // We need this for CRL support. + X509_STORE* store=X509_STORE_new(); + if (!store) { + log_openssl(); + return false; + } + #if (OPENSSL_VERSION_NUMBER >= 0x00907000L) + X509_STORE_set_flags(store,X509_V_FLAG_CRL_CHECK_ALL); + #endif + + STACK_OF(X509)* CAstack = sk_X509_new_null(); + + // This contains the state of the validate operation. + X509_STORE_CTX ctx; + + const vector& CAcerts = pkixInfo->getTrustAnchors(); + for (vector::const_iterator i=CAcerts.begin(); i!=CAcerts.end(); ++i) { + if ((*i)->getProviderName()==DSIGConstants::s_unicodeStrPROVOpenSSL) { + sk_X509_push(CAstack,static_cast(*i)->getOpenSSLX509()); + } + } + + const vector& crls = pkixInfo->getCRLs(); + for (vector::const_iterator j=crls.begin(); j!=crls.end(); ++j) { + if ((*j)->getProviderName()==DSIGConstants::s_unicodeStrPROVOpenSSL) { + // owned by store + X509_STORE_add_crl( + store, + X509_CRL_dup(static_cast(*j)->getOpenSSLX509CRL()) + ); + } + } + + // AFAICT, EE and untrusted are passed in but not owned by the ctx. + #if (OPENSSL_VERSION_NUMBER >= 0x00907000L) + if (X509_STORE_CTX_init(&ctx,store,EE,untrusted)!=1) { + log_openssl(); + log.error("unable to initialize X509_STORE_CTX"); + sk_X509_free(CAstack); + X509_STORE_free(store); + return false; + } + #else + X509_STORE_CTX_init(&ctx,store,EE,untrusted); + #endif + + // Seems to be most efficient to just pass in the CA stack. + X509_STORE_CTX_trusted_stack(&ctx,CAstack); + X509_STORE_CTX_set_depth(&ctx,100); // we check the depth down below + X509_STORE_CTX_set_verify_cb(&ctx,error_callback); + + int ret=X509_verify_cert(&ctx); + if (ret==1) { + // Now see if the depth was acceptable by counting the number of intermediates. + int depth=sk_X509_num(ctx.chain)-2; + if (pkixInfo->getVerificationDepth() < depth) { + log.error( + "certificate chain was too long (%d intermediates, only %d allowed)", + (depth==-1) ? 0 : depth, + pkixInfo->getVerificationDepth() + ); + ret=0; + } + } + + // Clean up... + X509_STORE_CTX_cleanup(&ctx); + X509_STORE_free(store); + sk_X509_free(CAstack); + + if (ret==1) { + log.info("successfully validated certificate chain"); + return true; + } + + return false; + } +}; + +bool AbstractPKIXTrustEngine::checkEntityNames(XSECCryptoX509* certEE, const RoleDescriptor& role) const +{ + Category& log=Category::getInstance(SAML_LOGCAT".TrustEngine"); + + // Build a list of acceptable names. Transcode the possible key "names" to UTF-8. + // For some simple cases, this should handle UTF-8 encoded DNs in certificates. + vector keynames; + const vector& keydescs=role.getKeyDescriptors(); + for (vector::const_iterator kd_i=keydescs.begin(); kd_i!=keydescs.end(); ++kd_i) { + const XMLCh* use=(*kd_i)->getUse(); + const KeyInfo* keyInfo = (*kd_i)->getKeyInfo(); + if (keyInfo && use && XMLString::equals(use,KeyDescriptor::KEYTYPE_ENCRYPTION)) + continue; + const vector& knames=keyInfo->getKeyNames(); + for (vector::const_iterator kn_i=knames.begin(); kn_i!=knames.end(); ++kn_i) { + const XMLCh* n=(*kn_i)->getName(); + if (n && *n) { + char* kn=toUTF8(n); + keynames.push_back(kn); + delete[] kn; + } + } + } + + EntityDescriptor* parent=dynamic_cast(role.getParent()); + if (parent) { + const XMLCh* eid=parent->getEntityID(); + if (eid && *eid) { + char* kn=toUTF8(eid); + keynames.push_back(kn); + delete[] kn; + } + } + + char buf[256]; + X509* x=static_cast(certEE)->getOpenSSLX509(); + X509_NAME* subject=X509_get_subject_name(x); + if (subject) { + // One way is a direct match to the subject DN. + // Seems that the way to do the compare is to write the X509_NAME into a BIO. + BIO* b = BIO_new(BIO_s_mem()); + BIO* b2 = BIO_new(BIO_s_mem()); + BIO_set_mem_eof_return(b, 0); + BIO_set_mem_eof_return(b2, 0); + // The flags give us LDAP order instead of X.500, with a comma separator. + int len=X509_NAME_print_ex(b,subject,0,XN_FLAG_RFC2253); + string subjectstr,subjectstr2; + BIO_flush(b); + while ((len = BIO_read(b, buf, 255)) > 0) { + buf[len] = '\0'; + subjectstr+=buf; + } + log.infoStream() << "certificate subject: " << subjectstr << CategoryStream::ENDLINE; + // The flags give us LDAP order instead of X.500, with a comma plus space separator. + len=X509_NAME_print_ex(b2,subject,0,XN_FLAG_RFC2253 + XN_FLAG_SEP_CPLUS_SPC - XN_FLAG_SEP_COMMA_PLUS); + BIO_flush(b2); + while ((len = BIO_read(b2, buf, 255)) > 0) { + buf[len] = '\0'; + subjectstr2+=buf; + } + + // Check each keyname. + for (vector::const_iterator n=keynames.begin(); n!=keynames.end(); n++) { +#ifdef HAVE_STRCASECMP + if (!strcasecmp(n->c_str(),subjectstr.c_str()) || !strcasecmp(n->c_str(),subjectstr2.c_str())) { +#else + if (!stricmp(n->c_str(),subjectstr.c_str()) || !stricmp(n->c_str(),subjectstr2.c_str())) { +#endif + log.info("matched full subject DN to a key name (%s)", n->c_str()); + BIO_free(b); + BIO_free(b2); + return true; + } + } + BIO_free(b); + BIO_free(b2); + + log.debug("unable to match DN, trying TLS subjectAltName match"); + STACK_OF(GENERAL_NAME)* altnames=(STACK_OF(GENERAL_NAME)*)X509_get_ext_d2i(x, NID_subject_alt_name, NULL, NULL); + if (altnames) { + int numalts = sk_GENERAL_NAME_num(altnames); + for (int an=0; antype==GEN_DNS || check->type==GEN_URI) { + const char* altptr = (char*)ASN1_STRING_data(check->d.ia5); + const int altlen = ASN1_STRING_length(check->d.ia5); + + for (vector::const_iterator n=keynames.begin(); n!=keynames.end(); n++) { +#ifdef HAVE_STRCASECMP + if ((check->type==GEN_DNS && !strncasecmp(altptr,n->c_str(),altlen)) +#else + if ((check->type==GEN_DNS && !strnicmp(altptr,n->c_str(),altlen)) +#endif + || (check->type==GEN_URI && !strncmp(altptr,n->c_str(),altlen))) { + log.info("matched DNS/URI subjectAltName to a key name (%s)", n->c_str()); + GENERAL_NAMES_free(altnames); + return true; + } + } + } + } + } + GENERAL_NAMES_free(altnames); + + log.debug("unable to match subjectAltName, trying TLS CN match"); + memset(buf,0,sizeof(buf)); + if (X509_NAME_get_text_by_NID(subject,NID_commonName,buf,255)>0) { + for (vector::const_iterator n=keynames.begin(); n!=keynames.end(); n++) { +#ifdef HAVE_STRCASECMP + if (!strcasecmp(buf,n->c_str())) { +#else + if (!stricmp(buf,n->c_str())) { +#endif + log.info("matched subject CN to a key name (%s)", n->c_str()); + return true; + } + } + } + else + log.warn("no common name in certificate subject"); + } + else + log.error("certificate has no subject?!"); + + return false; +} + +bool AbstractPKIXTrustEngine::validate( + XSECCryptoX509* certEE, + const vector& certChain, + const RoleDescriptor& role, + bool checkName, + const KeyResolver* keyResolver + ) const +{ +#ifdef _DEBUG + NDC ndc("validate"); +#endif + Category& log=Category::getInstance(SAML_LOGCAT".TrustEngine"); + + if (!certEE) { + log.error("X.509 credential was NULL, unable to perform validation"); + return false; + } + + if (checkName) { + log.debug("checking that the entity certificate name is acceptable"); + if (!checkEntityNames(certEE,role)) { + log.error("entity certificate name was not acceptable"); + return false; + } + } + + log.debug("performing certificate path validation..."); + + STACK_OF(X509)* untrusted=sk_X509_new_null(); + for (vector::const_iterator i=certChain.begin(); i!=certChain.end(); ++i) { + sk_X509_push(untrusted,static_cast(*i)->getOpenSSLX509()); + } + + auto_ptr pkix(getPKIXValidationInfoIterator(role)); + while (pkix->next()) { + if (::validate(static_cast(certEE)->getOpenSSLX509(),untrusted,pkix.get())) { + sk_X509_free(untrusted); + return true; + } + } + + sk_X509_free(untrusted); + log.error("failed to validate certificate chain using supplied PKIX information"); + return false; +} + +bool AbstractPKIXTrustEngine::validate(Signature& sig, const RoleDescriptor& role, const KeyResolver* keyResolver) const +{ +#ifdef _DEBUG + NDC ndc("validate"); +#endif + Category& log=Category::getInstance(SAML_LOGCAT".TrustEngine"); + + log.debug("attempting to validate signature profile"); + SignatureProfileValidator sigValidator; + try { + sigValidator.validate(&sig); + log.debug("signature profile validated"); + } + catch (ValidationException& e) { + if (log.isDebugEnabled()) { + log.debug("signature profile failed to validate: %s", e.what()); + } + return false; + } + + // Pull the certificate chain out of the signature using an inline KeyResolver. + KeyResolver::ResolvedCertificates certs; + if (0==m_inlineResolver->resolveCertificates(&sig, certs)) { + log.error("unable to perform PKIX validation, signature does not contain any certificates"); + return false; + } + + log.debug("validating signature using certificate from within the signature"); + + // Find and save off a pointer to the certificate that unlocks the object. + // Most of the time, this will be the first one anyway. + XSECCryptoX509* certEE=NULL; + SignatureValidator keyValidator; + for (vector::const_iterator i=certs.v().begin(); !certEE && i!=certs.v().end(); ++i) { + try { + keyValidator.setKey((*i)->clonePublicKey()); + keyValidator.validate(&sig); + log.info("signature verified with key inside signature, attempting certificate validation..."); + certEE=(*i); + } + catch (ValidationException&) { + // trap failures + } + } + + if (certEE) + return validate(certEE,certs.v(),role,true,keyResolver); + + log.error("failed to verify signature with embedded certificates"); + return false; +} diff --git a/saml/security/impl/ChainingTrustEngine.cpp b/saml/security/impl/ChainingTrustEngine.cpp index f85335d..f6b95cb 100644 --- a/saml/security/impl/ChainingTrustEngine.cpp +++ b/saml/security/impl/ChainingTrustEngine.cpp @@ -1,99 +1,99 @@ -/* - * Copyright 2001-2005 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * ChainingTrustEngine.cpp - * - * TrustEngine that uses multiple engines in sequence. - */ - -#include "internal.h" -#include "exceptions.h" -#include "security/ChainingTrustEngine.h" - -using namespace opensaml::saml2md; -using namespace opensaml; -using namespace xmlsignature; -using namespace std; - -namespace opensaml { - TrustEngine* SAML_DLLLOCAL ChainingTrustEngineFactory(const DOMElement* const & e) - { - return new ChainingTrustEngine(e); - } -}; - -static const XMLCh GenericTrustEngine[] = UNICODE_LITERAL_11(T,r,u,s,t,E,n,g,i,n,e); -static const XMLCh type[] = UNICODE_LITERAL_4(t,y,p,e); - -ChainingTrustEngine::ChainingTrustEngine(const DOMElement* e) { - try { - e = e ? xmltooling::XMLHelper::getFirstChildElement(e, GenericTrustEngine) : NULL; - while (e) { - xmltooling::auto_ptr_char temp(e->getAttributeNS(NULL,type)); - if (temp.get()) { - auto_ptr engine( - SAMLConfig::getConfig().TrustEngineManager.newPlugin(temp.get(), e) - ); - X509TrustEngine* x509 = dynamic_cast(engine.get()); - if (x509) { - m_engines.push_back(x509); - engine.release(); - } - else { - throw xmltooling::UnknownExtensionException("Embedded trust engine does not support required interface."); - } - } - e = xmltooling::XMLHelper::getNextSiblingElement(e, GenericTrustEngine); - } - } - catch (xmltooling::XMLToolingException&) { - for_each(m_engines.begin(), m_engines.end(), xmltooling::cleanup()); - throw; - } -} - -ChainingTrustEngine::~ChainingTrustEngine() { - for_each(m_engines.begin(), m_engines.end(), xmltooling::cleanup()); -} - -bool ChainingTrustEngine::validate( - Signature& sig, - const RoleDescriptor& role, - const KeyResolver* keyResolver - ) const -{ - for (vector::const_iterator i=m_engines.begin(); i!=m_engines.end(); ++i) { - if (static_cast(*i)->validate(sig,role,keyResolver)) - return true; - } - return false; -} - -bool ChainingTrustEngine::validate( - XSECCryptoX509* certEE, - const vector& certChain, - const RoleDescriptor& role, - bool checkName, - const KeyResolver* keyResolver - ) const -{ - for (vector::const_iterator i=m_engines.begin(); i!=m_engines.end(); ++i) { - if ((*i)->validate(certEE,certChain,role,checkName,keyResolver)) - return true; - } - return false; -} +/* + * Copyright 2001-2005 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * ChainingTrustEngine.cpp + * + * TrustEngine that uses multiple engines in sequence. + */ + +#include "internal.h" +#include "exceptions.h" +#include "security/ChainingTrustEngine.h" + +using namespace opensaml::saml2md; +using namespace opensaml; +using namespace xmlsignature; +using namespace std; + +namespace opensaml { + TrustEngine* SAML_DLLLOCAL ChainingTrustEngineFactory(const DOMElement* const & e) + { + return new ChainingTrustEngine(e); + } +}; + +static const XMLCh GenericTrustEngine[] = UNICODE_LITERAL_11(T,r,u,s,t,E,n,g,i,n,e); +static const XMLCh type[] = UNICODE_LITERAL_4(t,y,p,e); + +ChainingTrustEngine::ChainingTrustEngine(const DOMElement* e) { + try { + e = e ? xmltooling::XMLHelper::getFirstChildElement(e, GenericTrustEngine) : NULL; + while (e) { + xmltooling::auto_ptr_char temp(e->getAttributeNS(NULL,type)); + if (temp.get()) { + auto_ptr engine( + SAMLConfig::getConfig().TrustEngineManager.newPlugin(temp.get(), e) + ); + X509TrustEngine* x509 = dynamic_cast(engine.get()); + if (x509) { + m_engines.push_back(x509); + engine.release(); + } + else { + throw xmltooling::UnknownExtensionException("Embedded trust engine does not support required interface."); + } + } + e = xmltooling::XMLHelper::getNextSiblingElement(e, GenericTrustEngine); + } + } + catch (xmltooling::XMLToolingException&) { + for_each(m_engines.begin(), m_engines.end(), xmltooling::cleanup()); + throw; + } +} + +ChainingTrustEngine::~ChainingTrustEngine() { + for_each(m_engines.begin(), m_engines.end(), xmltooling::cleanup()); +} + +bool ChainingTrustEngine::validate( + Signature& sig, + const RoleDescriptor& role, + const KeyResolver* keyResolver + ) const +{ + for (vector::const_iterator i=m_engines.begin(); i!=m_engines.end(); ++i) { + if (static_cast(*i)->validate(sig,role,keyResolver)) + return true; + } + return false; +} + +bool ChainingTrustEngine::validate( + XSECCryptoX509* certEE, + const vector& certChain, + const RoleDescriptor& role, + bool checkName, + const KeyResolver* keyResolver + ) const +{ + for (vector::const_iterator i=m_engines.begin(); i!=m_engines.end(); ++i) { + if ((*i)->validate(certEE,certChain,role,checkName,keyResolver)) + return true; + } + return false; +} diff --git a/saml/security/impl/ExplicitKeyTrustEngine.cpp b/saml/security/impl/ExplicitKeyTrustEngine.cpp index 3ab759f..7249ee9 100644 --- a/saml/security/impl/ExplicitKeyTrustEngine.cpp +++ b/saml/security/impl/ExplicitKeyTrustEngine.cpp @@ -1,118 +1,118 @@ -/* - * Copyright 2001-2005 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * ExplicitKeyTrustEngine.cpp - * - * TrustEngine based on explicit knowledge of peer key information. - */ - -#include "internal.h" -#include "exceptions.h" -#include "security/MetadataKeyInfoIterator.h" -#include "security/X509TrustEngine.h" -#include "signature/SignatureProfileValidator.h" - -#include -#include -#include - -using namespace opensaml::saml2md; -using namespace opensaml; -using namespace xmlsignature; -using namespace log4cpp; -using namespace std; - -namespace opensaml { - class SAML_DLLLOCAL ExplicitKeyTrustEngine : public X509TrustEngine - { - public: - ExplicitKeyTrustEngine(const DOMElement* e) : X509TrustEngine(e), m_engine(NULL) { - auto_ptr engine( - xmltooling::XMLToolingConfig::getConfig().TrustEngineManager.newPlugin(EXPLICIT_KEY_TRUSTENGINE, e) - ); - if (m_engine=dynamic_cast(engine.get())) - engine.release(); - else - throw xmltooling::UnknownExtensionException("Embedded trust engine does not support required interface."); - } - - virtual ~ExplicitKeyTrustEngine() { - delete m_engine; - } - - virtual bool validate( - Signature& sig, - const RoleDescriptor& role, - const KeyResolver* keyResolver=NULL - ) const; - virtual bool validate( - XSECCryptoX509* certEE, - const vector& certChain, - const RoleDescriptor& role, - bool checkName=true, - const KeyResolver* keyResolver=NULL - ) const; - - private: - xmltooling::X509TrustEngine* m_engine; - }; - - TrustEngine* SAML_DLLLOCAL ExplicitKeyTrustEngineFactory(const DOMElement* const & e) - { - return new ExplicitKeyTrustEngine(e); - } -}; - -bool ExplicitKeyTrustEngine::validate( - Signature& sig, - const RoleDescriptor& role, - const KeyResolver* keyResolver - ) const -{ -#ifdef _DEBUG - xmltooling::NDC ndc("validate"); -#endif - Category& log=Category::getInstance(SAML_LOGCAT".TrustEngine"); - - log.debug("attempting to validate signature profile"); - SignatureProfileValidator sigValidator; - try { - sigValidator.validate(&sig); - log.debug("signature profile validated"); - } - catch (xmltooling::ValidationException& e) { - if (log.isDebugEnabled()) { - log.debug("signature profile failed to validate: %s", e.what()); - } - return false; - } - - MetadataKeyInfoIterator keys(role); - return static_cast(m_engine)->validate(sig,keys,keyResolver); -} - -bool ExplicitKeyTrustEngine::validate( - XSECCryptoX509* certEE, - const vector& certChain, - const RoleDescriptor& role, - bool checkName, - const KeyResolver* keyResolver - ) const -{ - MetadataKeyInfoIterator keys(role); - return m_engine->validate(certEE,certChain,keys,checkName,keyResolver); -} +/* + * Copyright 2001-2005 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * ExplicitKeyTrustEngine.cpp + * + * TrustEngine based on explicit knowledge of peer key information. + */ + +#include "internal.h" +#include "exceptions.h" +#include "security/MetadataKeyInfoIterator.h" +#include "security/X509TrustEngine.h" +#include "signature/SignatureProfileValidator.h" + +#include +#include +#include + +using namespace opensaml::saml2md; +using namespace opensaml; +using namespace xmlsignature; +using namespace log4cpp; +using namespace std; + +namespace opensaml { + class SAML_DLLLOCAL ExplicitKeyTrustEngine : public X509TrustEngine + { + public: + ExplicitKeyTrustEngine(const DOMElement* e) : X509TrustEngine(e), m_engine(NULL) { + auto_ptr engine( + xmltooling::XMLToolingConfig::getConfig().TrustEngineManager.newPlugin(EXPLICIT_KEY_TRUSTENGINE, e) + ); + if (m_engine=dynamic_cast(engine.get())) + engine.release(); + else + throw xmltooling::UnknownExtensionException("Embedded trust engine does not support required interface."); + } + + virtual ~ExplicitKeyTrustEngine() { + delete m_engine; + } + + virtual bool validate( + Signature& sig, + const RoleDescriptor& role, + const KeyResolver* keyResolver=NULL + ) const; + virtual bool validate( + XSECCryptoX509* certEE, + const vector& certChain, + const RoleDescriptor& role, + bool checkName=true, + const KeyResolver* keyResolver=NULL + ) const; + + private: + xmltooling::X509TrustEngine* m_engine; + }; + + TrustEngine* SAML_DLLLOCAL ExplicitKeyTrustEngineFactory(const DOMElement* const & e) + { + return new ExplicitKeyTrustEngine(e); + } +}; + +bool ExplicitKeyTrustEngine::validate( + Signature& sig, + const RoleDescriptor& role, + const KeyResolver* keyResolver + ) const +{ +#ifdef _DEBUG + xmltooling::NDC ndc("validate"); +#endif + Category& log=Category::getInstance(SAML_LOGCAT".TrustEngine"); + + log.debug("attempting to validate signature profile"); + SignatureProfileValidator sigValidator; + try { + sigValidator.validate(&sig); + log.debug("signature profile validated"); + } + catch (xmltooling::ValidationException& e) { + if (log.isDebugEnabled()) { + log.debug("signature profile failed to validate: %s", e.what()); + } + return false; + } + + MetadataKeyInfoIterator keys(role); + return static_cast(m_engine)->validate(sig,keys,keyResolver); +} + +bool ExplicitKeyTrustEngine::validate( + XSECCryptoX509* certEE, + const vector& certChain, + const RoleDescriptor& role, + bool checkName, + const KeyResolver* keyResolver + ) const +{ + MetadataKeyInfoIterator keys(role); + return m_engine->validate(certEE,certChain,keys,checkName,keyResolver); +} diff --git a/saml/signature/ContentReference.cpp b/saml/signature/ContentReference.cpp index b63e3de..121d8bc 100644 --- a/saml/signature/ContentReference.cpp +++ b/saml/signature/ContentReference.cpp @@ -1,68 +1,68 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * ContentReference.cpp - * - * SAML-specific signature reference profile - */ - -#include "internal.h" -#include "signature/ContentReference.h" -#include "signature/SignableObject.h" - -#include -#include -#include -#include - -using namespace opensaml; -using namespace std; - -class _addprefix : public binary_function { -public: - void operator()(DSIGTransformC14n* t, const string& s) const { - if (s.empty()) - t->addInclusiveNamespace("#default"); - else - t->addInclusiveNamespace(s.c_str()); - } -}; - -void ContentReference::createReferences(DSIGSignature* sig) -{ - DSIGReference* ref=NULL; - const XMLCh* id=m_signableObject.getXMLID(); - if (!id || !*id) - ref=sig->createReference(&chNull); // whole doc reference - else { - XMLCh* buf=new XMLCh[XMLString::stringLen(id) + 2]; - buf[0]=chPound; - buf[1]=chNull; - XMLString::catString(buf,id); - try { - ref=sig->createReference(buf); - delete[] buf; - } - catch(...) { - delete[] buf; - throw; - } - } - ref->appendEnvelopedSignatureTransform(); - DSIGTransformC14n* c14n=ref->appendCanonicalizationTransform(CANON_C14NE_NOC); - for_each(m_prefixes.begin(), m_prefixes.end(), bind1st(_addprefix(),c14n)); -} +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * ContentReference.cpp + * + * SAML-specific signature reference profile + */ + +#include "internal.h" +#include "signature/ContentReference.h" +#include "signature/SignableObject.h" + +#include +#include +#include +#include + +using namespace opensaml; +using namespace std; + +class _addprefix : public binary_function { +public: + void operator()(DSIGTransformC14n* t, const string& s) const { + if (s.empty()) + t->addInclusiveNamespace("#default"); + else + t->addInclusiveNamespace(s.c_str()); + } +}; + +void ContentReference::createReferences(DSIGSignature* sig) +{ + DSIGReference* ref=NULL; + const XMLCh* id=m_signableObject.getXMLID(); + if (!id || !*id) + ref=sig->createReference(&chNull); // whole doc reference + else { + XMLCh* buf=new XMLCh[XMLString::stringLen(id) + 2]; + buf[0]=chPound; + buf[1]=chNull; + XMLString::catString(buf,id); + try { + ref=sig->createReference(buf); + delete[] buf; + } + catch(...) { + delete[] buf; + throw; + } + } + ref->appendEnvelopedSignatureTransform(); + DSIGTransformC14n* c14n=ref->appendCanonicalizationTransform(CANON_C14NE_NOC); + for_each(m_prefixes.begin(), m_prefixes.end(), bind1st(_addprefix(),c14n)); +} diff --git a/saml/signature/ContentReference.h b/saml/signature/ContentReference.h index 9bc9973..dbf4d95 100644 --- a/saml/signature/ContentReference.h +++ b/saml/signature/ContentReference.h @@ -1,80 +1,80 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file saml/signature/ContentReference.h - * - * SAML-specific signature reference profile - */ - -#ifndef __saml_sigref_h__ -#define __saml_sigref_h__ - -#include -#include - -#include - -namespace opensaml { - - class SAML_API SignableObject; - - /** - * SAML-specific signature reference profile. - */ - class SAML_API ContentReference : public virtual xmlsignature::ContentReference - { - public: - /** - * Constructor. - * - * @param signableObject reference to object being signed - */ - ContentReference(const SignableObject& signableObject) : m_signableObject(signableObject) { - } - - virtual ~ContentReference() {} - - /** - * Given a "blank" native signature, creates signature reference - * appropriate for the SAML object being signed. - * - * @param sig native signature interface - */ - virtual void createReferences(DSIGSignature* sig); - - /** - * Adds a namespace prefix for "inclusive" processing by the - * Exclusive C14N Transform applied to the object. - * An empty string will be transformed into "#default". - * - * @param prefix the prefix to add - */ - void addInclusivePrefix(const char* prefix) { - m_prefixes.push_back(prefix); - } - - protected: - /** Reference to object to sign. */ - const SignableObject& m_signableObject; - - /** Inclusive prefixes. */ - std::vector m_prefixes; - }; - -}; - -#endif /* __saml_sigref_h__ */ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file saml/signature/ContentReference.h + * + * SAML-specific signature reference profile + */ + +#ifndef __saml_sigref_h__ +#define __saml_sigref_h__ + +#include +#include + +#include + +namespace opensaml { + + class SAML_API SignableObject; + + /** + * SAML-specific signature reference profile. + */ + class SAML_API ContentReference : public virtual xmlsignature::ContentReference + { + public: + /** + * Constructor. + * + * @param signableObject reference to object being signed + */ + ContentReference(const SignableObject& signableObject) : m_signableObject(signableObject) { + } + + virtual ~ContentReference() {} + + /** + * Given a "blank" native signature, creates signature reference + * appropriate for the SAML object being signed. + * + * @param sig native signature interface + */ + virtual void createReferences(DSIGSignature* sig); + + /** + * Adds a namespace prefix for "inclusive" processing by the + * Exclusive C14N Transform applied to the object. + * An empty string will be transformed into "#default". + * + * @param prefix the prefix to add + */ + void addInclusivePrefix(const char* prefix) { + m_prefixes.push_back(prefix); + } + + protected: + /** Reference to object to sign. */ + const SignableObject& m_signableObject; + + /** Inclusive prefixes. */ + std::vector m_prefixes; + }; + +}; + +#endif /* __saml_sigref_h__ */ diff --git a/saml/signature/SignableObject.h b/saml/signature/SignableObject.h index 90ebcaa..a1d6521 100644 --- a/saml/signature/SignableObject.h +++ b/saml/signature/SignableObject.h @@ -1,57 +1,57 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file saml/signature/SignableObject.h - * - * Base class for SAML objects that can be signed. - */ - -#ifndef __saml_signable_h__ -#define __saml_signable_h__ - -#include -#include -#include - -namespace opensaml { - - /** - * Base class for SAML objects that can be signed. - */ - class SAML_API SignableObject : public virtual xmltooling::XMLObject - { - public: - virtual ~SignableObject() {} - - /** - * Gets a new ContentReference object bound to this object. - * It's lifetime must not outlast this object, so it should - * generally be set into a Signature owned by the object. - * - * @return a new ContentReference - */ - virtual ContentReference* getContentReference() const { - return new ContentReference(*this); - } - - protected: - SignableObject() {} - }; - -}; - -#endif /* __saml_signable_h__ */ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file saml/signature/SignableObject.h + * + * Base class for SAML objects that can be signed. + */ + +#ifndef __saml_signable_h__ +#define __saml_signable_h__ + +#include +#include +#include + +namespace opensaml { + + /** + * Base class for SAML objects that can be signed. + */ + class SAML_API SignableObject : public virtual xmltooling::XMLObject + { + public: + virtual ~SignableObject() {} + + /** + * Gets a new ContentReference object bound to this object. + * It's lifetime must not outlast this object, so it should + * generally be set into a Signature owned by the object. + * + * @return a new ContentReference + */ + virtual ContentReference* getContentReference() const { + return new ContentReference(*this); + } + + protected: + SignableObject() {} + }; + +}; + +#endif /* __saml_signable_h__ */ diff --git a/saml/signature/SignatureProfileValidator.cpp b/saml/signature/SignatureProfileValidator.cpp index ada4481..a00e966 100644 --- a/saml/signature/SignatureProfileValidator.cpp +++ b/saml/signature/SignatureProfileValidator.cpp @@ -1,76 +1,76 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * SignatureProfileValidator.cpp - * - * SAML-specific signature verification - */ - -#include "internal.h" -#include "exceptions.h" -#include "signature/SignatureProfileValidator.h" - -#include - -#include -#include -#include -#include - -using namespace opensaml; -using namespace xmlsignature; -using namespace xmltooling; -using namespace std; - -void SignatureProfileValidator::validate(const XMLObject* xmlObject) const -{ - const Signature* sigObj=dynamic_cast(xmlObject); - if (!sigObj) - throw ValidationException("Validator only applies to Signature objects."); - DSIGSignature* sig=sigObj->getXMLSignature(); - if (!sig) - throw ValidationException("Signature does not exist yet."); - - const SignableObject* signableObj=dynamic_cast(sigObj->getParent()); - if (!signableObj) - throw ValidationException("Signature is not a child of a signable SAML object."); - - bool valid=false; - DSIGReferenceList* refs=sig->getReferenceList(); - if (refs && refs->getSize()==1) { - DSIGReference* ref=refs->item(0); - if (ref) { - const XMLCh* URI=ref->getURI(); - const XMLCh* ID=signableObj->getXMLID(); - if (URI==NULL || *URI==0 || (*URI==chPound && ID && !XMLString::compareString(URI+1,ID))) { - DSIGTransformList* tlist=ref->getTransforms(); - for (unsigned int i=0; tlist && igetSize(); i++) { - if (tlist->item(i)->getTransformType()==TRANSFORM_ENVELOPED_SIGNATURE) - valid=true; - else if (tlist->item(i)->getTransformType()!=TRANSFORM_EXC_C14N && - tlist->item(i)->getTransformType()!=TRANSFORM_C14N) { - valid=false; - break; - } - } - } - } - } - - if (!valid) - throw ValidationException("Invalid signature profile for SAML object."); -} +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * SignatureProfileValidator.cpp + * + * SAML-specific signature verification + */ + +#include "internal.h" +#include "exceptions.h" +#include "signature/SignatureProfileValidator.h" + +#include + +#include +#include +#include +#include + +using namespace opensaml; +using namespace xmlsignature; +using namespace xmltooling; +using namespace std; + +void SignatureProfileValidator::validate(const XMLObject* xmlObject) const +{ + const Signature* sigObj=dynamic_cast(xmlObject); + if (!sigObj) + throw ValidationException("Validator only applies to Signature objects."); + DSIGSignature* sig=sigObj->getXMLSignature(); + if (!sig) + throw ValidationException("Signature does not exist yet."); + + const SignableObject* signableObj=dynamic_cast(sigObj->getParent()); + if (!signableObj) + throw ValidationException("Signature is not a child of a signable SAML object."); + + bool valid=false; + DSIGReferenceList* refs=sig->getReferenceList(); + if (refs && refs->getSize()==1) { + DSIGReference* ref=refs->item(0); + if (ref) { + const XMLCh* URI=ref->getURI(); + const XMLCh* ID=signableObj->getXMLID(); + if (URI==NULL || *URI==0 || (*URI==chPound && ID && !XMLString::compareString(URI+1,ID))) { + DSIGTransformList* tlist=ref->getTransforms(); + for (unsigned int i=0; tlist && igetSize(); i++) { + if (tlist->item(i)->getTransformType()==TRANSFORM_ENVELOPED_SIGNATURE) + valid=true; + else if (tlist->item(i)->getTransformType()!=TRANSFORM_EXC_C14N && + tlist->item(i)->getTransformType()!=TRANSFORM_C14N) { + valid=false; + break; + } + } + } + } + } + + if (!valid) + throw ValidationException("Invalid signature profile for SAML object."); +} diff --git a/saml/signature/SignatureProfileValidator.h b/saml/signature/SignatureProfileValidator.h index 615ced5..3fd2695 100644 --- a/saml/signature/SignatureProfileValidator.h +++ b/saml/signature/SignatureProfileValidator.h @@ -1,46 +1,46 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file saml/signature/SignatureProfileValidator.h - * - * SAML-specific signature profile validator - */ - -#ifndef __saml_sigval_h__ -#define __saml_sigval_h__ - -#include -#include -#include - -namespace opensaml { - - /** - * SAML-specific signature profile validator. - */ - class SAML_API SignatureProfileValidator : public virtual xmltooling::Validator - { - public: - SignatureProfileValidator() {} - virtual ~SignatureProfileValidator() {} - - void validate(const xmltooling::XMLObject* xmlObject) const; - }; - -}; - -#endif /* __saml_sigval_h__ */ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file saml/signature/SignatureProfileValidator.h + * + * SAML-specific signature profile validator + */ + +#ifndef __saml_sigval_h__ +#define __saml_sigval_h__ + +#include +#include +#include + +namespace opensaml { + + /** + * SAML-specific signature profile validator. + */ + class SAML_API SignatureProfileValidator : public virtual xmltooling::Validator + { + public: + SignatureProfileValidator() {} + virtual ~SignatureProfileValidator() {} + + void validate(const xmltooling::XMLObject* xmlObject) const; + }; + +}; + +#endif /* __saml_sigval_h__ */ diff --git a/saml/util/SAMLConstants.cpp b/saml/util/SAMLConstants.cpp index 13b3a6c..7fcdc2c 100644 --- a/saml/util/SAMLConstants.cpp +++ b/saml/util/SAMLConstants.cpp @@ -1,178 +1,178 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * SAMLConstants.cpp - * - * SAML XML namespace constants - */ - - -#include "internal.h" -#include "util/SAMLConstants.h" -#include - -using namespace xercesc; -using namespace opensaml; - -const XMLCh SAMLConstants::PAOS_NS[] = // urn:liberty:paos:2003-08 -{ chLatin_u, chLatin_r, chLatin_n, chColon, - chLatin_l, chLatin_i, chLatin_b, chLatin_e, chLatin_r, chLatin_t, chLatin_y, chColon, - chLatin_p, chLatin_a, chLatin_o, chLatin_s, chColon, - chDigit_2, chDigit_0, chDigit_0, chDigit_3, chDash, chDigit_0, chDigit_8, chNull -}; - -const XMLCh SAMLConstants::PAOS_PREFIX[] = UNICODE_LITERAL_4(p,a,o,s); - -const XMLCh SAMLConstants::SAML1_NS[] = // urn:oasis:names:tc:SAML:1.0:assertion -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_1, chPeriod, chDigit_0, chColon, - chLatin_a, chLatin_s, chLatin_s, chLatin_e, chLatin_r, chLatin_t, chLatin_i, chLatin_o, chLatin_n, chNull -}; - -const XMLCh SAMLConstants::SAML1P_NS[] = // urn:oasis:names:tc:SAML:1.0:protocol -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_1, chPeriod, chDigit_0, chColon, - chLatin_p, chLatin_r, chLatin_o, chLatin_t, chLatin_o, chLatin_c, chLatin_o, chLatin_l, chNull -}; - -const XMLCh SAMLConstants::SAML1_PREFIX[] = UNICODE_LITERAL_4(s,a,m,l); - -const XMLCh SAMLConstants::SAML1P_PREFIX[] = UNICODE_LITERAL_5(s,a,m,l,p); - -const XMLCh SAMLConstants::SAML20_VERSION[] = // 2.0 -{ chDigit_2, chPeriod, chDigit_0, chNull -}; - -const XMLCh SAMLConstants::SAML20_NS[] = // urn:oasis:names:tc:SAML:2.0:assertion -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_a, chLatin_s, chLatin_s, chLatin_e, chLatin_r, chLatin_t, chLatin_i, chLatin_o, chLatin_n, chNull -}; - -const XMLCh SAMLConstants::SAML20P_NS[] = // urn:oasis:names:tc:SAML:2.0:protocol -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_p, chLatin_r, chLatin_o, chLatin_t, chLatin_o, chLatin_c, chLatin_o, chLatin_l, chNull -}; - -const XMLCh SAMLConstants::SAML20MD_NS[] = // urn:oasis:names:tc:SAML:2.0:metadata -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_m, chLatin_e, chLatin_t, chLatin_a, chLatin_d, chLatin_a, chLatin_t, chLatin_a, chNull -}; - -const XMLCh SAMLConstants::SAML20AC_NS[] = // urn:oasis:names:tc:SAML:2.0:ac -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_a, chLatin_c, chNull -}; - -const XMLCh SAMLConstants::SAML20_PREFIX[] = UNICODE_LITERAL_4(s,a,m,l); - -const XMLCh SAMLConstants::SAML20P_PREFIX[] = UNICODE_LITERAL_5(s,a,m,l,p); - -const XMLCh SAMLConstants::SAML20MD_PREFIX[] = UNICODE_LITERAL_2(m,d); - -const XMLCh SAMLConstants::SAML20AC_PREFIX[] = UNICODE_LITERAL_2(a,c); - -const XMLCh SAMLConstants::SAML20ECP_NS[] = // urn:oasis:names:tc:SAML:2.0:profiles:SSO:ecp -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_p, chLatin_r, chLatin_o, chLatin_f, chLatin_i, chLatin_l, chLatin_e, chLatin_s, chColon, - chLatin_S, chLatin_S, chLatin_O, chColon, chLatin_e, chLatin_c, chLatin_p, chNull -}; - -const XMLCh SAMLConstants::SAML20ECP_PREFIX[] = UNICODE_LITERAL_3(e,c,p); - -const XMLCh SAMLConstants::SAML20DCE_NS[] = // urn:oasis:names:tc:SAML:2.0:profiles:attribute:DCE -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_p, chLatin_r, chLatin_o, chLatin_f, chLatin_i, chLatin_l, chLatin_e, chLatin_s, chColon, - chLatin_a, chLatin_t, chLatin_t, chLatin_r, chLatin_i, chLatin_b, chLatin_u, chLatin_t, chLatin_e, chColon, - chLatin_D, chLatin_C, chLatin_E, chNull -}; - -const XMLCh SAMLConstants::SAML20DCE_PREFIX[] = UNICODE_LITERAL_3(D,C,E); - -const XMLCh SAMLConstants::SAML20X500_NS[] = // urn:oasis:names:tc:SAML:2.0:profiles:attribute:X500 -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_p, chLatin_r, chLatin_o, chLatin_f, chLatin_i, chLatin_l, chLatin_e, chLatin_s, chColon, - chLatin_a, chLatin_t, chLatin_t, chLatin_r, chLatin_i, chLatin_b, chLatin_u, chLatin_t, chLatin_e, chColon, - chLatin_X, chDigit_5, chDigit_0, chDigit_0, chNull -}; - -const XMLCh SAMLConstants::SAML20X500_PREFIX[] = { chLatin_x, chDigit_5, chDigit_0, chDigit_0 }; - -const XMLCh SAMLConstants::SAML20XACML_NS[] = // urn:oasis:names:tc:SAML:2.0:profiles:attribute:XACML -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, - chLatin_p, chLatin_r, chLatin_o, chLatin_f, chLatin_i, chLatin_l, chLatin_e, chLatin_s, chColon, - chLatin_a, chLatin_t, chLatin_t, chLatin_r, chLatin_i, chLatin_b, chLatin_u, chLatin_t, chLatin_e, chColon, - chLatin_X, chLatin_A, chLatin_C, chLatin_M, chLatin_L, chNull -}; - -const XMLCh SAMLConstants::SAML20XACML_PREFIX[] = UNICODE_LITERAL_9(x,a,c,m,l,p,r,o,f); - -const XMLCh SAMLConstants::SAML1MD_NS[] = // urn:oasis:names:tc:SAML:profiles:v1metadata -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, - chLatin_p, chLatin_r, chLatin_o, chLatin_f, chLatin_i, chLatin_l, chLatin_e, chLatin_s, chColon, - chLatin_v, chDigit_1, chLatin_m, chLatin_e, chLatin_t, chLatin_a, chLatin_d, chLatin_a, chLatin_t, chLatin_a, chNull -}; - -const XMLCh SAMLConstants::SAML1MD_PREFIX[] = -{ chLatin_s, chLatin_a, chLatin_m, chLatin_l, chDigit_1, chLatin_m, chLatin_d, chNull }; - -const XMLCh SAMLConstants::SAML11_PROTOCOL_ENUM[] = // urn:oasis:names:tc:SAML:1.1:protocol -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_1, chPeriod, chDigit_1, chColon, - chLatin_p, chLatin_r, chLatin_o, chLatin_t, chLatin_o, chLatin_c, chLatin_o, chLatin_l, chNull -}; - -const XMLCh SAMLConstants::SAML20MD_QUERY_EXT_NS[] = // urn:oasis:names:tc:SAML:metadata:ext:query -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, - chLatin_m, chLatin_e, chLatin_t, chLatin_a, chLatin_d, chLatin_a, chLatin_t, chLatin_a, chColon, - chLatin_e, chLatin_x, chLatin_t, chColon, chLatin_q, chLatin_u, chLatin_e, chLatin_r, chLatin_y, chNull -}; - -const XMLCh SAMLConstants::SAML20MD_QUERY_EXT_PREFIX[] = UNICODE_LITERAL_5(q,u,e,r,y); - -const XMLCh SAMLConstants::SAML20P_THIRDPARTY_EXT_NS[] = // urn:oasis:names:tc:SAML:protocol:ext:third-party -{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, - chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, - chLatin_p, chLatin_r, chLatin_o, chLatin_t, chLatin_o, chLatin_c, chLatin_o, chLatin_l, chColon, - chLatin_e, chLatin_x, chLatin_t, chColon, - chLatin_t, chLatin_h, chLatin_i, chLatin_r, chLatin_d, chDash, chLatin_p, chLatin_a, chLatin_r, chLatin_t, chLatin_y, chNull -}; - -const XMLCh SAMLConstants::SAML20P_THIRDPARTY_EXT_PREFIX[] = UNICODE_LITERAL_6(t,h,r,p,t,y); +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * SAMLConstants.cpp + * + * SAML XML namespace constants + */ + + +#include "internal.h" +#include "util/SAMLConstants.h" +#include + +using namespace xercesc; +using namespace opensaml; + +const XMLCh SAMLConstants::PAOS_NS[] = // urn:liberty:paos:2003-08 +{ chLatin_u, chLatin_r, chLatin_n, chColon, + chLatin_l, chLatin_i, chLatin_b, chLatin_e, chLatin_r, chLatin_t, chLatin_y, chColon, + chLatin_p, chLatin_a, chLatin_o, chLatin_s, chColon, + chDigit_2, chDigit_0, chDigit_0, chDigit_3, chDash, chDigit_0, chDigit_8, chNull +}; + +const XMLCh SAMLConstants::PAOS_PREFIX[] = UNICODE_LITERAL_4(p,a,o,s); + +const XMLCh SAMLConstants::SAML1_NS[] = // urn:oasis:names:tc:SAML:1.0:assertion +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_1, chPeriod, chDigit_0, chColon, + chLatin_a, chLatin_s, chLatin_s, chLatin_e, chLatin_r, chLatin_t, chLatin_i, chLatin_o, chLatin_n, chNull +}; + +const XMLCh SAMLConstants::SAML1P_NS[] = // urn:oasis:names:tc:SAML:1.0:protocol +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_1, chPeriod, chDigit_0, chColon, + chLatin_p, chLatin_r, chLatin_o, chLatin_t, chLatin_o, chLatin_c, chLatin_o, chLatin_l, chNull +}; + +const XMLCh SAMLConstants::SAML1_PREFIX[] = UNICODE_LITERAL_4(s,a,m,l); + +const XMLCh SAMLConstants::SAML1P_PREFIX[] = UNICODE_LITERAL_5(s,a,m,l,p); + +const XMLCh SAMLConstants::SAML20_VERSION[] = // 2.0 +{ chDigit_2, chPeriod, chDigit_0, chNull +}; + +const XMLCh SAMLConstants::SAML20_NS[] = // urn:oasis:names:tc:SAML:2.0:assertion +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_a, chLatin_s, chLatin_s, chLatin_e, chLatin_r, chLatin_t, chLatin_i, chLatin_o, chLatin_n, chNull +}; + +const XMLCh SAMLConstants::SAML20P_NS[] = // urn:oasis:names:tc:SAML:2.0:protocol +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_p, chLatin_r, chLatin_o, chLatin_t, chLatin_o, chLatin_c, chLatin_o, chLatin_l, chNull +}; + +const XMLCh SAMLConstants::SAML20MD_NS[] = // urn:oasis:names:tc:SAML:2.0:metadata +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_m, chLatin_e, chLatin_t, chLatin_a, chLatin_d, chLatin_a, chLatin_t, chLatin_a, chNull +}; + +const XMLCh SAMLConstants::SAML20AC_NS[] = // urn:oasis:names:tc:SAML:2.0:ac +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_a, chLatin_c, chNull +}; + +const XMLCh SAMLConstants::SAML20_PREFIX[] = UNICODE_LITERAL_4(s,a,m,l); + +const XMLCh SAMLConstants::SAML20P_PREFIX[] = UNICODE_LITERAL_5(s,a,m,l,p); + +const XMLCh SAMLConstants::SAML20MD_PREFIX[] = UNICODE_LITERAL_2(m,d); + +const XMLCh SAMLConstants::SAML20AC_PREFIX[] = UNICODE_LITERAL_2(a,c); + +const XMLCh SAMLConstants::SAML20ECP_NS[] = // urn:oasis:names:tc:SAML:2.0:profiles:SSO:ecp +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_p, chLatin_r, chLatin_o, chLatin_f, chLatin_i, chLatin_l, chLatin_e, chLatin_s, chColon, + chLatin_S, chLatin_S, chLatin_O, chColon, chLatin_e, chLatin_c, chLatin_p, chNull +}; + +const XMLCh SAMLConstants::SAML20ECP_PREFIX[] = UNICODE_LITERAL_3(e,c,p); + +const XMLCh SAMLConstants::SAML20DCE_NS[] = // urn:oasis:names:tc:SAML:2.0:profiles:attribute:DCE +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_p, chLatin_r, chLatin_o, chLatin_f, chLatin_i, chLatin_l, chLatin_e, chLatin_s, chColon, + chLatin_a, chLatin_t, chLatin_t, chLatin_r, chLatin_i, chLatin_b, chLatin_u, chLatin_t, chLatin_e, chColon, + chLatin_D, chLatin_C, chLatin_E, chNull +}; + +const XMLCh SAMLConstants::SAML20DCE_PREFIX[] = UNICODE_LITERAL_3(D,C,E); + +const XMLCh SAMLConstants::SAML20X500_NS[] = // urn:oasis:names:tc:SAML:2.0:profiles:attribute:X500 +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_p, chLatin_r, chLatin_o, chLatin_f, chLatin_i, chLatin_l, chLatin_e, chLatin_s, chColon, + chLatin_a, chLatin_t, chLatin_t, chLatin_r, chLatin_i, chLatin_b, chLatin_u, chLatin_t, chLatin_e, chColon, + chLatin_X, chDigit_5, chDigit_0, chDigit_0, chNull +}; + +const XMLCh SAMLConstants::SAML20X500_PREFIX[] = { chLatin_x, chDigit_5, chDigit_0, chDigit_0 }; + +const XMLCh SAMLConstants::SAML20XACML_NS[] = // urn:oasis:names:tc:SAML:2.0:profiles:attribute:XACML +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon, + chLatin_p, chLatin_r, chLatin_o, chLatin_f, chLatin_i, chLatin_l, chLatin_e, chLatin_s, chColon, + chLatin_a, chLatin_t, chLatin_t, chLatin_r, chLatin_i, chLatin_b, chLatin_u, chLatin_t, chLatin_e, chColon, + chLatin_X, chLatin_A, chLatin_C, chLatin_M, chLatin_L, chNull +}; + +const XMLCh SAMLConstants::SAML20XACML_PREFIX[] = UNICODE_LITERAL_9(x,a,c,m,l,p,r,o,f); + +const XMLCh SAMLConstants::SAML1MD_NS[] = // urn:oasis:names:tc:SAML:profiles:v1metadata +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, + chLatin_p, chLatin_r, chLatin_o, chLatin_f, chLatin_i, chLatin_l, chLatin_e, chLatin_s, chColon, + chLatin_v, chDigit_1, chLatin_m, chLatin_e, chLatin_t, chLatin_a, chLatin_d, chLatin_a, chLatin_t, chLatin_a, chNull +}; + +const XMLCh SAMLConstants::SAML1MD_PREFIX[] = +{ chLatin_s, chLatin_a, chLatin_m, chLatin_l, chDigit_1, chLatin_m, chLatin_d, chNull }; + +const XMLCh SAMLConstants::SAML11_PROTOCOL_ENUM[] = // urn:oasis:names:tc:SAML:1.1:protocol +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_1, chPeriod, chDigit_1, chColon, + chLatin_p, chLatin_r, chLatin_o, chLatin_t, chLatin_o, chLatin_c, chLatin_o, chLatin_l, chNull +}; + +const XMLCh SAMLConstants::SAML20MD_QUERY_EXT_NS[] = // urn:oasis:names:tc:SAML:metadata:ext:query +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, + chLatin_m, chLatin_e, chLatin_t, chLatin_a, chLatin_d, chLatin_a, chLatin_t, chLatin_a, chColon, + chLatin_e, chLatin_x, chLatin_t, chColon, chLatin_q, chLatin_u, chLatin_e, chLatin_r, chLatin_y, chNull +}; + +const XMLCh SAMLConstants::SAML20MD_QUERY_EXT_PREFIX[] = UNICODE_LITERAL_5(q,u,e,r,y); + +const XMLCh SAMLConstants::SAML20P_THIRDPARTY_EXT_NS[] = // urn:oasis:names:tc:SAML:protocol:ext:third-party +{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon, + chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon, + chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, + chLatin_p, chLatin_r, chLatin_o, chLatin_t, chLatin_o, chLatin_c, chLatin_o, chLatin_l, chColon, + chLatin_e, chLatin_x, chLatin_t, chColon, + chLatin_t, chLatin_h, chLatin_i, chLatin_r, chLatin_d, chDash, chLatin_p, chLatin_a, chLatin_r, chLatin_t, chLatin_y, chNull +}; + +const XMLCh SAMLConstants::SAML20P_THIRDPARTY_EXT_PREFIX[] = UNICODE_LITERAL_6(t,h,r,p,t,y); diff --git a/saml/util/SAMLConstants.h b/saml/util/SAMLConstants.h index e5ce12e..deb2d08 100644 --- a/saml/util/SAMLConstants.h +++ b/saml/util/SAMLConstants.h @@ -1,131 +1,131 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file saml/util/SAMLConstants.h - * - * SAML XML namespace constants - */ - -#ifndef __saml_xmlconstants_h__ -#define __saml_xmlconstants_h__ - -#include - -namespace opensaml { - - /** - * SAML related constants. - */ - struct SAML_API SAMLConstants : public xmltooling::XMLConstants - { - /** Liberty PAOS XML Namespace ("urn:liberty:paos:2003-08") */ - static const XMLCh PAOS_NS[]; - - /** Liberty PAOS QName prefix ("paos") */ - static const XMLCh PAOS_PREFIX[]; - - /** SAML 1.X Assertion XML namespace ("urn:oasis:names:tc:SAML:1.0:assertion") */ - static const XMLCh SAML1_NS[]; - - /** SAML 1.X Protocol XML namespace ("urn:oasis:names:tc:SAML:1.0:protocol") */ - static const XMLCh SAML1P_NS[]; - - /** SAML 1.X Assertion QName prefix ("saml") */ - static const XMLCh SAML1_PREFIX[]; - - /** SAML 1.X Protocol QName prefix ("samlp") */ - static const XMLCh SAML1P_PREFIX[]; - - /** SAML 2.0 Version ("2.0") */ - static const XMLCh SAML20_VERSION[]; - - /** SAML 2.0 Assertion XML namespace ("urn:oasis:names:tc:SAML:2.0:assertion") */ - static const XMLCh SAML20_NS[]; - - /** SAML 2.0 Protocol XML namespace ("urn:oasis:names:tc:SAML:2.0:protocol") */ - static const XMLCh SAML20P_NS[]; - - /** SAML 2.0 Metadata XML namespace ("urn:oasis:names:tc:SAML:2.0:metadata") */ - static const XMLCh SAML20MD_NS[]; - - /** SAML 2.0 AuthnContext XML namespace ("urn:oasis:names:tc:SAML:2.0:ac") */ - static const XMLCh SAML20AC_NS[]; - - /** SAML 2.0 Assertion QName prefix ("saml") */ - static const XMLCh SAML20_PREFIX[]; - - /** SAML 2.0 Protocol QName prefix ("samlp") */ - static const XMLCh SAML20P_PREFIX[]; - - /** SAML 2.0 Metadata QName prefix ("md") */ - static const XMLCh SAML20MD_PREFIX[]; - - /** SAML 2.0 AuthnContext QName prefix ("ac") */ - static const XMLCh SAML20AC_PREFIX[]; - - /** SAML 2.0 Enhanced Client/Proxy SSO Profile XML Namespace ("urn:oasis:names:tc:SAML:2.0:profiles:SSO:ecp") */ - static const XMLCh SAML20ECP_NS[]; - - /** SAML 2.0 Enhanced Client/Proxy SSO Profile QName prefix ("ecp") */ - static const XMLCh SAML20ECP_PREFIX[]; - - /** SAML 2.0 DCE PAC Attribute Profile XML Namespace ("urn:oasis:names:tc:SAML:2.0:profiles:attribute:DCE") */ - static const XMLCh SAML20DCE_NS[]; - - /** SAML 2.0 DCE PAC Attribute Profile QName prefix ("DCE") */ - static const XMLCh SAML20DCE_PREFIX[]; - - /** SAML 2.0 X.500 Attribute Profile XML Namespace ("urn:oasis:names:tc:SAML:2.0:profiles:attribute:X500") */ - static const XMLCh SAML20X500_NS[]; - - /** SAML 2.0 X.500 Attribute Profile QName prefix ("x500") */ - static const XMLCh SAML20X500_PREFIX[]; - - /** SAML 2.0 XACML Attribute Profile XML Namespace ("urn:oasis:names:tc:SAML:2.0:profiles:attribute:XACML") */ - static const XMLCh SAML20XACML_NS[]; - - /** SAML 2.0 XACML Attribute Profile QName prefix ("xacmlprof") */ - static const XMLCh SAML20XACML_PREFIX[]; - - /** SAML 1.x Metadata Profile XML Namespace ("urn:oasis:names:tc:SAML:profiles:v1metadata") */ - static const XMLCh SAML1MD_NS[]; - - /** SAML 1.x Metadata Profile QName prefix ("saml1md") */ - static const XMLCh SAML1MD_PREFIX[]; - - /** SAML 1.0 Protocol Enumeration constant ("urn:oasis:names:tc:SAML:1.0:protocol") */ - #define SAML10_PROTOCOL_ENUM SAML1P_NS - - /** SAML 1.1 Protocol Enumeration constant ("urn:oasis:names:tc:SAML:1.1:protocol") */ - static const XMLCh SAML11_PROTOCOL_ENUM[]; - - /** SAML Query Requester Metadata Extension XML Namespace ("urn:oasis:names:tc:SAML:metadata:ext:query") */ - static const XMLCh SAML20MD_QUERY_EXT_NS[]; - - /** SAML Query Requester Metadata Extension QName prefix ("query") */ - static const XMLCh SAML20MD_QUERY_EXT_PREFIX[]; - - /** SAML Third-Party Request Protocol Extension XML Namespace ("urn:oasis:names:tc:SAML:protocol:ext:third-party") */ - static const XMLCh SAML20P_THIRDPARTY_EXT_NS[]; - - /** SAML Third-Party Request Protocol Extension QName prefix ("query") */ - static const XMLCh SAML20P_THIRDPARTY_EXT_PREFIX[]; - }; - -}; - -#endif /* __saml_xmlconstants_h__ */ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file saml/util/SAMLConstants.h + * + * SAML XML namespace constants + */ + +#ifndef __saml_xmlconstants_h__ +#define __saml_xmlconstants_h__ + +#include + +namespace opensaml { + + /** + * SAML related constants. + */ + struct SAML_API SAMLConstants : public xmltooling::XMLConstants + { + /** Liberty PAOS XML Namespace ("urn:liberty:paos:2003-08") */ + static const XMLCh PAOS_NS[]; + + /** Liberty PAOS QName prefix ("paos") */ + static const XMLCh PAOS_PREFIX[]; + + /** SAML 1.X Assertion XML namespace ("urn:oasis:names:tc:SAML:1.0:assertion") */ + static const XMLCh SAML1_NS[]; + + /** SAML 1.X Protocol XML namespace ("urn:oasis:names:tc:SAML:1.0:protocol") */ + static const XMLCh SAML1P_NS[]; + + /** SAML 1.X Assertion QName prefix ("saml") */ + static const XMLCh SAML1_PREFIX[]; + + /** SAML 1.X Protocol QName prefix ("samlp") */ + static const XMLCh SAML1P_PREFIX[]; + + /** SAML 2.0 Version ("2.0") */ + static const XMLCh SAML20_VERSION[]; + + /** SAML 2.0 Assertion XML namespace ("urn:oasis:names:tc:SAML:2.0:assertion") */ + static const XMLCh SAML20_NS[]; + + /** SAML 2.0 Protocol XML namespace ("urn:oasis:names:tc:SAML:2.0:protocol") */ + static const XMLCh SAML20P_NS[]; + + /** SAML 2.0 Metadata XML namespace ("urn:oasis:names:tc:SAML:2.0:metadata") */ + static const XMLCh SAML20MD_NS[]; + + /** SAML 2.0 AuthnContext XML namespace ("urn:oasis:names:tc:SAML:2.0:ac") */ + static const XMLCh SAML20AC_NS[]; + + /** SAML 2.0 Assertion QName prefix ("saml") */ + static const XMLCh SAML20_PREFIX[]; + + /** SAML 2.0 Protocol QName prefix ("samlp") */ + static const XMLCh SAML20P_PREFIX[]; + + /** SAML 2.0 Metadata QName prefix ("md") */ + static const XMLCh SAML20MD_PREFIX[]; + + /** SAML 2.0 AuthnContext QName prefix ("ac") */ + static const XMLCh SAML20AC_PREFIX[]; + + /** SAML 2.0 Enhanced Client/Proxy SSO Profile XML Namespace ("urn:oasis:names:tc:SAML:2.0:profiles:SSO:ecp") */ + static const XMLCh SAML20ECP_NS[]; + + /** SAML 2.0 Enhanced Client/Proxy SSO Profile QName prefix ("ecp") */ + static const XMLCh SAML20ECP_PREFIX[]; + + /** SAML 2.0 DCE PAC Attribute Profile XML Namespace ("urn:oasis:names:tc:SAML:2.0:profiles:attribute:DCE") */ + static const XMLCh SAML20DCE_NS[]; + + /** SAML 2.0 DCE PAC Attribute Profile QName prefix ("DCE") */ + static const XMLCh SAML20DCE_PREFIX[]; + + /** SAML 2.0 X.500 Attribute Profile XML Namespace ("urn:oasis:names:tc:SAML:2.0:profiles:attribute:X500") */ + static const XMLCh SAML20X500_NS[]; + + /** SAML 2.0 X.500 Attribute Profile QName prefix ("x500") */ + static const XMLCh SAML20X500_PREFIX[]; + + /** SAML 2.0 XACML Attribute Profile XML Namespace ("urn:oasis:names:tc:SAML:2.0:profiles:attribute:XACML") */ + static const XMLCh SAML20XACML_NS[]; + + /** SAML 2.0 XACML Attribute Profile QName prefix ("xacmlprof") */ + static const XMLCh SAML20XACML_PREFIX[]; + + /** SAML 1.x Metadata Profile XML Namespace ("urn:oasis:names:tc:SAML:profiles:v1metadata") */ + static const XMLCh SAML1MD_NS[]; + + /** SAML 1.x Metadata Profile QName prefix ("saml1md") */ + static const XMLCh SAML1MD_PREFIX[]; + + /** SAML 1.0 Protocol Enumeration constant ("urn:oasis:names:tc:SAML:1.0:protocol") */ + #define SAML10_PROTOCOL_ENUM SAML1P_NS + + /** SAML 1.1 Protocol Enumeration constant ("urn:oasis:names:tc:SAML:1.1:protocol") */ + static const XMLCh SAML11_PROTOCOL_ENUM[]; + + /** SAML Query Requester Metadata Extension XML Namespace ("urn:oasis:names:tc:SAML:metadata:ext:query") */ + static const XMLCh SAML20MD_QUERY_EXT_NS[]; + + /** SAML Query Requester Metadata Extension QName prefix ("query") */ + static const XMLCh SAML20MD_QUERY_EXT_PREFIX[]; + + /** SAML Third-Party Request Protocol Extension XML Namespace ("urn:oasis:names:tc:SAML:protocol:ext:third-party") */ + static const XMLCh SAML20P_THIRDPARTY_EXT_NS[]; + + /** SAML Third-Party Request Protocol Extension QName prefix ("query") */ + static const XMLCh SAML20P_THIRDPARTY_EXT_PREFIX[]; + }; + +}; + +#endif /* __saml_xmlconstants_h__ */ diff --git a/saml/version.h b/saml/version.h index c7bd3f8..d355b4d 100644 --- a/saml/version.h +++ b/saml/version.h @@ -1,74 +1,74 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * version.h - * - * Library version macros and constants - */ - -#ifndef __saml_version_h__ -#define __saml_version_h__ - -// This is all based on Xerces, on the theory it might be useful to -// support this kind of stuff in the future. If they ever yank some -// of this stuff, it can be copied into here. - -#include - -// --------------------------------------------------------------------------- -// V E R S I O N S P E C I F I C A T I O N - -/** - * MODIFY THESE NUMERIC VALUES TO COINCIDE WITH OPENSAML VERSION - * AND DO NOT MODIFY ANYTHING ELSE IN THIS VERSION HEADER FILE - */ - -#define OPENSAML_VERSION_MAJOR 1 -#define OPENSAML_VERSION_MINOR 0 -#define OPENSAML_VERSION_REVISION 0 - -/** DO NOT MODIFY BELOW THIS LINE */ - -/** - * MAGIC THAT AUTOMATICALLY GENERATES THE FOLLOWING: - * - * gOpenSAMLVersionStr, gOpenSAMLFullVersionStr, gOpenSAMLMajVersion, gOpenSAMLMinVersion, gOpenSAMLRevision - */ - -// --------------------------------------------------------------------------- -// V E R S I O N I N F O R M A T I O N - -// OpenSAML version strings; these particular macros cannot be used for -// conditional compilation as they are not numeric constants - -#define OPENSAML_FULLVERSIONSTR INVK_CAT3_SEP_UNDERSCORE(OPENSAML_VERSION_MAJOR,OPENSAML_VERSION_MINOR,OPENSAML_VERSION_REVISION) -#define OPENSAML_FULLVERSIONDOT INVK_CAT3_SEP_PERIOD(OPENSAML_VERSION_MAJOR,OPENSAML_VERSION_MINOR,OPENSAML_VERSION_REVISION) -#define OPENSAML_FULLVERSIONNUM INVK_CAT3_SEP_NIL(OPENSAML_VERSION_MAJOR,OPENSAML_VERSION_MINOR,OPENSAML_VERSION_REVISION) -#define OPENSAML_VERSIONSTR INVK_CAT2_SEP_UNDERSCORE(OPENSAML_VERSION_MAJOR,OPENSAML_VERSION_MINOR) - -const char* const gOpenSAMLVersionStr = OPENSAML_VERSIONSTR; -const char* const gOpenSAMLFullVersionStr = OPENSAML_FULLVERSIONSTR; -const unsigned int gOpenSAMLMajVersion = OPENSAML_VERSION_MAJOR; -const unsigned int gOpenSAMLMinVersion = OPENSAML_VERSION_MINOR; -const unsigned int gOpenSAMLRevision = OPENSAML_VERSION_REVISION; - -// OpenSAML version numeric constants that can be used for conditional -// compilation purposes. - -#define _OPENSAML_VERSION CALC_EXPANDED_FORM (OPENSAML_VERSION_MAJOR,OPENSAML_VERSION_MINOR,OPENSAML_VERSION_REVISION) - -#endif /* __saml_version_h__ */ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * version.h + * + * Library version macros and constants + */ + +#ifndef __saml_version_h__ +#define __saml_version_h__ + +// This is all based on Xerces, on the theory it might be useful to +// support this kind of stuff in the future. If they ever yank some +// of this stuff, it can be copied into here. + +#include + +// --------------------------------------------------------------------------- +// V E R S I O N S P E C I F I C A T I O N + +/** + * MODIFY THESE NUMERIC VALUES TO COINCIDE WITH OPENSAML VERSION + * AND DO NOT MODIFY ANYTHING ELSE IN THIS VERSION HEADER FILE + */ + +#define OPENSAML_VERSION_MAJOR 1 +#define OPENSAML_VERSION_MINOR 0 +#define OPENSAML_VERSION_REVISION 0 + +/** DO NOT MODIFY BELOW THIS LINE */ + +/** + * MAGIC THAT AUTOMATICALLY GENERATES THE FOLLOWING: + * + * gOpenSAMLVersionStr, gOpenSAMLFullVersionStr, gOpenSAMLMajVersion, gOpenSAMLMinVersion, gOpenSAMLRevision + */ + +// --------------------------------------------------------------------------- +// V E R S I O N I N F O R M A T I O N + +// OpenSAML version strings; these particular macros cannot be used for +// conditional compilation as they are not numeric constants + +#define OPENSAML_FULLVERSIONSTR INVK_CAT3_SEP_UNDERSCORE(OPENSAML_VERSION_MAJOR,OPENSAML_VERSION_MINOR,OPENSAML_VERSION_REVISION) +#define OPENSAML_FULLVERSIONDOT INVK_CAT3_SEP_PERIOD(OPENSAML_VERSION_MAJOR,OPENSAML_VERSION_MINOR,OPENSAML_VERSION_REVISION) +#define OPENSAML_FULLVERSIONNUM INVK_CAT3_SEP_NIL(OPENSAML_VERSION_MAJOR,OPENSAML_VERSION_MINOR,OPENSAML_VERSION_REVISION) +#define OPENSAML_VERSIONSTR INVK_CAT2_SEP_UNDERSCORE(OPENSAML_VERSION_MAJOR,OPENSAML_VERSION_MINOR) + +const char* const gOpenSAMLVersionStr = OPENSAML_VERSIONSTR; +const char* const gOpenSAMLFullVersionStr = OPENSAML_FULLVERSIONSTR; +const unsigned int gOpenSAMLMajVersion = OPENSAML_VERSION_MAJOR; +const unsigned int gOpenSAMLMinVersion = OPENSAML_VERSION_MINOR; +const unsigned int gOpenSAMLRevision = OPENSAML_VERSION_REVISION; + +// OpenSAML version numeric constants that can be used for conditional +// compilation purposes. + +#define _OPENSAML_VERSION CALC_EXPANDED_FORM (OPENSAML_VERSION_MAJOR,OPENSAML_VERSION_MINOR,OPENSAML_VERSION_REVISION) + +#endif /* __saml_version_h__ */ diff --git a/samltest/ArtifactMapTest.h b/samltest/ArtifactMapTest.h index 8f2aa30..507a495 100644 --- a/samltest/ArtifactMapTest.h +++ b/samltest/ArtifactMapTest.h @@ -1,53 +1,53 @@ -/* - * Copyright 2001-2005 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include "saml/binding/ArtifactMap.h" -#include -#include - -using namespace opensaml::saml2p; -using namespace opensaml; -using namespace std; - -class ArtifactMapTest : public CxxTest::TestSuite -{ -public: - string providerIdStr; - string handle; - void setUp() { - if (handle.empty()) { - providerIdStr = "https://idp.org/SAML"; - SAMLConfig::getConfig().generateRandomBytes(handle,SAML2ArtifactType0004::HANDLE_LENGTH); - } - } - void tearDown() { - } - void testArtifactMap(void) { - auto_ptr response(ResponseBuilder::buildResponse()); - - SAML2ArtifactType0004 artifact(SAMLConfig::getConfig().hashSHA1(providerIdStr.c_str()),666,handle); - - ArtifactMap* artifactMap = SAMLConfig::getConfig().getArtifactMap(); - artifactMap->storeContent(response.get(), &artifact, providerIdStr.c_str()); - response.release(); - - auto_ptr xmlObject(artifactMap->retrieveContent(&artifact, providerIdStr.c_str())); - TSM_ASSERT_THROWS("Artifact resolution improperly succeeded.", artifactMap->retrieveContent(&artifact), BindingException); - TSM_ASSERT("Mapped content was not a Response.", dynamic_cast(xmlObject.get())!=NULL); - } -}; +/* + * Copyright 2001-2005 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include "saml/binding/ArtifactMap.h" +#include +#include + +using namespace opensaml::saml2p; +using namespace opensaml; +using namespace std; + +class ArtifactMapTest : public CxxTest::TestSuite +{ +public: + string providerIdStr; + string handle; + void setUp() { + if (handle.empty()) { + providerIdStr = "https://idp.org/SAML"; + SAMLConfig::getConfig().generateRandomBytes(handle,SAML2ArtifactType0004::HANDLE_LENGTH); + } + } + void tearDown() { + } + void testArtifactMap(void) { + auto_ptr response(ResponseBuilder::buildResponse()); + + SAML2ArtifactType0004 artifact(SAMLConfig::getConfig().hashSHA1(providerIdStr.c_str()),666,handle); + + ArtifactMap* artifactMap = SAMLConfig::getConfig().getArtifactMap(); + artifactMap->storeContent(response.get(), &artifact, providerIdStr.c_str()); + response.release(); + + auto_ptr xmlObject(artifactMap->retrieveContent(&artifact, providerIdStr.c_str())); + TSM_ASSERT_THROWS("Artifact resolution improperly succeeded.", artifactMap->retrieveContent(&artifact), BindingException); + TSM_ASSERT("Mapped content was not a Response.", dynamic_cast(xmlObject.get())!=NULL); + } +}; diff --git a/samltest/SAMLArtifactCreationTest.h b/samltest/SAMLArtifactCreationTest.h index 4190dfc..205d43b 100644 --- a/samltest/SAMLArtifactCreationTest.h +++ b/samltest/SAMLArtifactCreationTest.h @@ -1,85 +1,85 @@ -/* - * Copyright 2001-2005 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include -#include -#include - -using namespace opensaml::saml1p; -using namespace opensaml::saml2p; -using namespace opensaml; -using namespace std; - -class SAMLArtifactCreationTest : public CxxTest::TestSuite -{ -public: - string providerIdStr; - string handle; - void setUp() { - if (handle.empty()) { - providerIdStr = "https://idp.org/SAML"; - SAMLConfig::getConfig().generateRandomBytes(handle,SAMLArtifactType0001::HANDLE_LENGTH); - } - } - void testSAMLArtifactType0001(void) { - SAMLConfig& conf=SAMLConfig::getConfig(); - string sourceId; - conf.generateRandomBytes(sourceId,SAMLArtifactType0001::SOURCEID_LENGTH); - SAMLArtifactType0001 artifact1(sourceId,handle); - //printResults(artifact1); - - SAMLArtifactType0001 artifact2(conf.hashSHA1(providerIdStr.c_str()),handle); - //printResults(artifact2,providerIdStr.c_str()); - } - - void testSAMLArtifactType0002(void) { - SAMLArtifactType0002 artifact(providerIdStr,handle); - //printResults(artifact,providerIdStr.c_str()); - } - - void testSAMLArtifactType0004(void) { - SAML2ArtifactType0004 artifact(SAMLConfig::getConfig().hashSHA1(providerIdStr.c_str()),666,handle); - //printResults(artifact,providerIdStr.c_str()); - } - - void printResults(SAMLArtifact& artifact, const char* str=NULL) { - // print heading: - cout << "Artifact Type " << SAMLArtifact::toHex(artifact.getTypeCode()); - cout << " (size = " << artifact.getBytes().size() << ")" << endl; - - // print URI: - if (str) { - cout << "URI: " << str << endl; - } - else { - cout << "URI: NONE" << endl; - } - - // print hex-encoded artifact: - cout << "Hex: " << SAMLArtifact::toHex(artifact.getBytes()) << endl; - - // print base64-encoded artifact: - cout << "Base64: " << artifact.encode() << endl; - - // print ruler: - cout << " ----------------------------------------------------------------------" << endl; - cout << " 1234567890123456789012345678901234567890123456789012345678901234567890" << endl; - cout << " 1 2 3 4 5 6 7" << endl; - cout << " ----------------------------------------------------------------------" << endl; - } -}; +/* + * Copyright 2001-2005 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include +#include +#include + +using namespace opensaml::saml1p; +using namespace opensaml::saml2p; +using namespace opensaml; +using namespace std; + +class SAMLArtifactCreationTest : public CxxTest::TestSuite +{ +public: + string providerIdStr; + string handle; + void setUp() { + if (handle.empty()) { + providerIdStr = "https://idp.org/SAML"; + SAMLConfig::getConfig().generateRandomBytes(handle,SAMLArtifactType0001::HANDLE_LENGTH); + } + } + void testSAMLArtifactType0001(void) { + SAMLConfig& conf=SAMLConfig::getConfig(); + string sourceId; + conf.generateRandomBytes(sourceId,SAMLArtifactType0001::SOURCEID_LENGTH); + SAMLArtifactType0001 artifact1(sourceId,handle); + //printResults(artifact1); + + SAMLArtifactType0001 artifact2(conf.hashSHA1(providerIdStr.c_str()),handle); + //printResults(artifact2,providerIdStr.c_str()); + } + + void testSAMLArtifactType0002(void) { + SAMLArtifactType0002 artifact(providerIdStr,handle); + //printResults(artifact,providerIdStr.c_str()); + } + + void testSAMLArtifactType0004(void) { + SAML2ArtifactType0004 artifact(SAMLConfig::getConfig().hashSHA1(providerIdStr.c_str()),666,handle); + //printResults(artifact,providerIdStr.c_str()); + } + + void printResults(SAMLArtifact& artifact, const char* str=NULL) { + // print heading: + cout << "Artifact Type " << SAMLArtifact::toHex(artifact.getTypeCode()); + cout << " (size = " << artifact.getBytes().size() << ")" << endl; + + // print URI: + if (str) { + cout << "URI: " << str << endl; + } + else { + cout << "URI: NONE" << endl; + } + + // print hex-encoded artifact: + cout << "Hex: " << SAMLArtifact::toHex(artifact.getBytes()) << endl; + + // print base64-encoded artifact: + cout << "Base64: " << artifact.encode() << endl; + + // print ruler: + cout << " ----------------------------------------------------------------------" << endl; + cout << " 1234567890123456789012345678901234567890123456789012345678901234567890" << endl; + cout << " 1 2 3 4 5 6 7" << endl; + cout << " ----------------------------------------------------------------------" << endl; + } +}; diff --git a/samltest/SAMLArtifactType0001Test.h b/samltest/SAMLArtifactType0001Test.h index 8cdd9fb..0aebb54 100644 --- a/samltest/SAMLArtifactType0001Test.h +++ b/samltest/SAMLArtifactType0001Test.h @@ -1,45 +1,45 @@ -/* - * Copyright 2001-2005 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml1p; -using namespace opensaml; -using namespace std; - -class SAMLArtifactType0001Test : public CxxTest::TestSuite -{ -public: - string providerIdStr; - - void setUp() { - providerIdStr = "https://idp.org/SAML"; - } - - void testSAMLArtifactType0001(void) { - string sourceId = SAMLConfig::getConfig().hashSHA1(providerIdStr.c_str()); - auto_ptr artifact(new SAMLArtifactType0001(sourceId)); - auto_ptr tempArtifact(SAMLArtifact::parse(artifact->encode().c_str())); - - TS_ASSERT_EQUALS(artifact->getSource(),tempArtifact->getSource()); - TS_ASSERT_EQUALS(artifact->getMessageHandle(),tempArtifact->getMessageHandle()); - - TS_ASSERT_THROWS(auto_ptr bogus1(new SAMLArtifactType0001(sourceId + sourceId)), ArtifactException); - TS_ASSERT_THROWS(auto_ptr bogus2(new SAMLArtifactType0001(sourceId, artifact->getMessageHandle() + artifact->getMessageHandle())), ArtifactException); - } -}; +/* + * Copyright 2001-2005 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml1p; +using namespace opensaml; +using namespace std; + +class SAMLArtifactType0001Test : public CxxTest::TestSuite +{ +public: + string providerIdStr; + + void setUp() { + providerIdStr = "https://idp.org/SAML"; + } + + void testSAMLArtifactType0001(void) { + string sourceId = SAMLConfig::getConfig().hashSHA1(providerIdStr.c_str()); + auto_ptr artifact(new SAMLArtifactType0001(sourceId)); + auto_ptr tempArtifact(SAMLArtifact::parse(artifact->encode().c_str())); + + TS_ASSERT_EQUALS(artifact->getSource(),tempArtifact->getSource()); + TS_ASSERT_EQUALS(artifact->getMessageHandle(),tempArtifact->getMessageHandle()); + + TS_ASSERT_THROWS(auto_ptr bogus1(new SAMLArtifactType0001(sourceId + sourceId)), ArtifactException); + TS_ASSERT_THROWS(auto_ptr bogus2(new SAMLArtifactType0001(sourceId, artifact->getMessageHandle() + artifact->getMessageHandle())), ArtifactException); + } +}; diff --git a/samltest/SAMLArtifactType0002Test.h b/samltest/SAMLArtifactType0002Test.h index 2a9ce99..fb07778 100644 --- a/samltest/SAMLArtifactType0002Test.h +++ b/samltest/SAMLArtifactType0002Test.h @@ -1,43 +1,43 @@ -/* - * Copyright 2001-2005 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml1p; -using namespace opensaml; -using namespace std; - -class SAMLArtifactType0002Test : public CxxTest::TestSuite -{ -public: - string providerIdStr; - - void setUp() { - providerIdStr = "https://idp.org/SAML"; - } - - void testSAMLArtifactType0002(void) { - auto_ptr artifact(new SAMLArtifactType0002(providerIdStr)); - auto_ptr tempArtifact(SAMLArtifact::parse(artifact->encode().c_str())); - - TS_ASSERT_EQUALS(artifact->getSource(),tempArtifact->getSource()); - TS_ASSERT_EQUALS(artifact->getMessageHandle(),tempArtifact->getMessageHandle()); - - TS_ASSERT_THROWS(auto_ptr bogus1(new SAMLArtifactType0002(providerIdStr, artifact->getMessageHandle() + artifact->getMessageHandle())), ArtifactException); - } -}; +/* + * Copyright 2001-2005 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml1p; +using namespace opensaml; +using namespace std; + +class SAMLArtifactType0002Test : public CxxTest::TestSuite +{ +public: + string providerIdStr; + + void setUp() { + providerIdStr = "https://idp.org/SAML"; + } + + void testSAMLArtifactType0002(void) { + auto_ptr artifact(new SAMLArtifactType0002(providerIdStr)); + auto_ptr tempArtifact(SAMLArtifact::parse(artifact->encode().c_str())); + + TS_ASSERT_EQUALS(artifact->getSource(),tempArtifact->getSource()); + TS_ASSERT_EQUALS(artifact->getMessageHandle(),tempArtifact->getMessageHandle()); + + TS_ASSERT_THROWS(auto_ptr bogus1(new SAMLArtifactType0002(providerIdStr, artifact->getMessageHandle() + artifact->getMessageHandle())), ArtifactException); + } +}; diff --git a/samltest/SAMLArtifactType0004Test.h b/samltest/SAMLArtifactType0004Test.h index ff8a569..09c5cfb 100644 --- a/samltest/SAMLArtifactType0004Test.h +++ b/samltest/SAMLArtifactType0004Test.h @@ -1,46 +1,46 @@ -/* - * Copyright 2001-2005 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2p; -using namespace opensaml; -using namespace std; - -class SAMLArtifactType0004Test : public CxxTest::TestSuite -{ -public: - string providerIdStr; - - void setUp() { - providerIdStr = "https://idp.org/SAML"; - } - - void testSAMLArtifactType0004(void) { - string sourceId = SAMLConfig::getConfig().hashSHA1(providerIdStr.c_str()); - auto_ptr artifact(new SAML2ArtifactType0004(sourceId,666)); - auto_ptr tempArtifact(dynamic_cast(SAMLArtifact::parse(artifact->encode().c_str()))); - - TS_ASSERT_EQUALS(artifact->getSource(),tempArtifact->getSource()); - TS_ASSERT_EQUALS(artifact->getEndpointIndex(),tempArtifact->getEndpointIndex()); - TS_ASSERT_EQUALS(artifact->getMessageHandle(),tempArtifact->getMessageHandle()); - - TS_ASSERT_THROWS(auto_ptr bogus1(new SAML2ArtifactType0004(sourceId, 100000)), ArtifactException); - TS_ASSERT_THROWS(auto_ptr bogus2(new SAML2ArtifactType0004(sourceId, 666, artifact->getMessageHandle() + artifact->getMessageHandle())), ArtifactException); - } -}; +/* + * Copyright 2001-2005 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2p; +using namespace opensaml; +using namespace std; + +class SAMLArtifactType0004Test : public CxxTest::TestSuite +{ +public: + string providerIdStr; + + void setUp() { + providerIdStr = "https://idp.org/SAML"; + } + + void testSAMLArtifactType0004(void) { + string sourceId = SAMLConfig::getConfig().hashSHA1(providerIdStr.c_str()); + auto_ptr artifact(new SAML2ArtifactType0004(sourceId,666)); + auto_ptr tempArtifact(dynamic_cast(SAMLArtifact::parse(artifact->encode().c_str()))); + + TS_ASSERT_EQUALS(artifact->getSource(),tempArtifact->getSource()); + TS_ASSERT_EQUALS(artifact->getEndpointIndex(),tempArtifact->getEndpointIndex()); + TS_ASSERT_EQUALS(artifact->getMessageHandle(),tempArtifact->getMessageHandle()); + + TS_ASSERT_THROWS(auto_ptr bogus1(new SAML2ArtifactType0004(sourceId, 100000)), ArtifactException); + TS_ASSERT_THROWS(auto_ptr bogus2(new SAML2ArtifactType0004(sourceId, 666, artifact->getMessageHandle() + artifact->getMessageHandle())), ArtifactException); + } +}; diff --git a/samltest/saml1/binding/SAML1ArtifactTest.h b/samltest/saml1/binding/SAML1ArtifactTest.h index f6abaa7..8413815 100644 --- a/samltest/saml1/binding/SAML1ArtifactTest.h +++ b/samltest/saml1/binding/SAML1ArtifactTest.h @@ -1,144 +1,144 @@ -/* - * Copyright 2001-2005 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "binding.h" - -#include -#include -#include -#include -#include - -using namespace opensaml::saml1p; -using namespace opensaml::saml1; - -class SAML1ArtifactTest : public CxxTest::TestSuite, - public SAMLBindingBaseTestCase, public MessageEncoder::ArtifactGenerator, public MessageDecoder::ArtifactResolver { -public: - void setUp() { - m_fields.clear(); - SAMLBindingBaseTestCase::setUp(); - } - - void tearDown() { - m_fields.clear(); - SAMLBindingBaseTestCase::tearDown(); - } - - void testSAML1Artifact() { - try { - // Read message to use from file. - string path = data_path + "saml1/binding/SAML1Assertion.xml"; - ifstream in(path.c_str()); - DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); - XercesJanitor janitor(doc); - auto_ptr toSend( - dynamic_cast(XMLObjectBuilder::buildOneFromElement(doc->getDocumentElement(),true)) - ); - janitor.release(); - - // Encode message. - auto_ptr encoder(SAMLConfig::getConfig().MessageEncoderManager.newPlugin(SAML1_ARTIFACT_ENCODER, NULL)); - encoder->setArtifactGenerator(this); - encoder->encode(m_fields,toSend.get(),"https://sp.example.org/","state",m_creds); - toSend.release(); - - // Decode message. - string relayState; - const RoleDescriptor* issuer=NULL; - bool trusted=false; - QName idprole(SAMLConstants::SAML20MD_NS, IDPSSODescriptor::LOCAL_NAME); - auto_ptr decoder(SAMLConfig::getConfig().MessageDecoderManager.newPlugin(SAML1_ARTIFACT_DECODER, NULL)); - decoder->setArtifactResolver(this); - Locker locker(m_metadata); - auto_ptr response( - dynamic_cast( - decoder->decode(relayState,issuer,trusted,*this,m_metadata,&idprole,m_trust) - ) - ); - - // Test the results. - TSM_ASSERT_EQUALS("TARGET was not the expected result.", relayState, "state"); - TSM_ASSERT("SAML Response not decoded successfully.", response.get()); - TSM_ASSERT("Message was not verified.", issuer && trusted); - auto_ptr_char entityID(dynamic_cast(issuer->getParent())->getEntityID()); - TSM_ASSERT("Issuer was not expected.", !strcmp(entityID.get(),"https://idp.example.org/")); - TSM_ASSERT_EQUALS("Assertion count was not correct.", response->getAssertions().size(), 1); - - // Trigger a replay. - TSM_ASSERT_THROWS("Did not catch the replay.", - decoder->decode(relayState,issuer,trusted,*this,m_metadata,&idprole,m_trust), - BindingException); - } - catch (XMLToolingException& ex) { - TS_TRACE(ex.what()); - throw; - } - } - - const char* getMethod() const { - return "GET"; - } - - const char* getRequestURL() const { - return "https://sp.example.org/SAML/Artifact"; - } - - const char* getQueryString() const { - return NULL; - } - - SAMLArtifact* generateSAML1Artifact(const char* relyingParty) const { - return new SAMLArtifactType0001(SAMLConfig::getConfig().hashSHA1("https://idp.example.org/")); - } - - saml2p::SAML2Artifact* generateSAML2Artifact(const char* relyingParty) const { - throw BindingException("Not implemented."); - } - - Response* resolve( - bool& authenticated, - const vector& artifacts, - const IDPSSODescriptor& idpDescriptor, - const X509TrustEngine* trustEngine=NULL - ) const { - TSM_ASSERT_EQUALS("Too many artifacts.", artifacts.size(), 1); - XMLObject* xmlObject = - SAMLConfig::getConfig().getArtifactMap()->retrieveContent(artifacts.front(), "https://sp.example.org/"); - Assertion* assertion = dynamic_cast(xmlObject); - TSM_ASSERT("Not an assertion.", assertion!=NULL); - auto_ptr response(ResponseBuilder::buildResponse()); - response->getAssertions().push_back(assertion); - Status* status = StatusBuilder::buildStatus(); - response->setStatus(status); - StatusCode* sc = StatusCodeBuilder::buildStatusCode(); - status->setStatusCode(sc); - sc->setValue(&StatusCode::SUCCESS); - response->marshall(); - SchemaValidators.validate(response.get()); - authenticated = true; - return response.release(); - } - - saml2p::ArtifactResponse* resolve( - bool& authenticated, - const saml2p::SAML2Artifact& artifact, - const SSODescriptorType& ssoDescriptor, - const X509TrustEngine* trustEngine=NULL - ) const { - throw BindingException("Not implemented."); - } -}; +/* + * Copyright 2001-2005 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "binding.h" + +#include +#include +#include +#include +#include + +using namespace opensaml::saml1p; +using namespace opensaml::saml1; + +class SAML1ArtifactTest : public CxxTest::TestSuite, + public SAMLBindingBaseTestCase, public MessageEncoder::ArtifactGenerator, public MessageDecoder::ArtifactResolver { +public: + void setUp() { + m_fields.clear(); + SAMLBindingBaseTestCase::setUp(); + } + + void tearDown() { + m_fields.clear(); + SAMLBindingBaseTestCase::tearDown(); + } + + void testSAML1Artifact() { + try { + // Read message to use from file. + string path = data_path + "saml1/binding/SAML1Assertion.xml"; + ifstream in(path.c_str()); + DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); + XercesJanitor janitor(doc); + auto_ptr toSend( + dynamic_cast(XMLObjectBuilder::buildOneFromElement(doc->getDocumentElement(),true)) + ); + janitor.release(); + + // Encode message. + auto_ptr encoder(SAMLConfig::getConfig().MessageEncoderManager.newPlugin(SAML1_ARTIFACT_ENCODER, NULL)); + encoder->setArtifactGenerator(this); + encoder->encode(m_fields,toSend.get(),"https://sp.example.org/","state",m_creds); + toSend.release(); + + // Decode message. + string relayState; + const RoleDescriptor* issuer=NULL; + bool trusted=false; + QName idprole(SAMLConstants::SAML20MD_NS, IDPSSODescriptor::LOCAL_NAME); + auto_ptr decoder(SAMLConfig::getConfig().MessageDecoderManager.newPlugin(SAML1_ARTIFACT_DECODER, NULL)); + decoder->setArtifactResolver(this); + Locker locker(m_metadata); + auto_ptr response( + dynamic_cast( + decoder->decode(relayState,issuer,trusted,*this,m_metadata,&idprole,m_trust) + ) + ); + + // Test the results. + TSM_ASSERT_EQUALS("TARGET was not the expected result.", relayState, "state"); + TSM_ASSERT("SAML Response not decoded successfully.", response.get()); + TSM_ASSERT("Message was not verified.", issuer && trusted); + auto_ptr_char entityID(dynamic_cast(issuer->getParent())->getEntityID()); + TSM_ASSERT("Issuer was not expected.", !strcmp(entityID.get(),"https://idp.example.org/")); + TSM_ASSERT_EQUALS("Assertion count was not correct.", response->getAssertions().size(), 1); + + // Trigger a replay. + TSM_ASSERT_THROWS("Did not catch the replay.", + decoder->decode(relayState,issuer,trusted,*this,m_metadata,&idprole,m_trust), + BindingException); + } + catch (XMLToolingException& ex) { + TS_TRACE(ex.what()); + throw; + } + } + + const char* getMethod() const { + return "GET"; + } + + const char* getRequestURL() const { + return "https://sp.example.org/SAML/Artifact"; + } + + const char* getQueryString() const { + return NULL; + } + + SAMLArtifact* generateSAML1Artifact(const char* relyingParty) const { + return new SAMLArtifactType0001(SAMLConfig::getConfig().hashSHA1("https://idp.example.org/")); + } + + saml2p::SAML2Artifact* generateSAML2Artifact(const char* relyingParty) const { + throw BindingException("Not implemented."); + } + + Response* resolve( + bool& authenticated, + const vector& artifacts, + const IDPSSODescriptor& idpDescriptor, + const X509TrustEngine* trustEngine=NULL + ) const { + TSM_ASSERT_EQUALS("Too many artifacts.", artifacts.size(), 1); + XMLObject* xmlObject = + SAMLConfig::getConfig().getArtifactMap()->retrieveContent(artifacts.front(), "https://sp.example.org/"); + Assertion* assertion = dynamic_cast(xmlObject); + TSM_ASSERT("Not an assertion.", assertion!=NULL); + auto_ptr response(ResponseBuilder::buildResponse()); + response->getAssertions().push_back(assertion); + Status* status = StatusBuilder::buildStatus(); + response->setStatus(status); + StatusCode* sc = StatusCodeBuilder::buildStatusCode(); + status->setStatusCode(sc); + sc->setValue(&StatusCode::SUCCESS); + response->marshall(); + SchemaValidators.validate(response.get()); + authenticated = true; + return response.release(); + } + + saml2p::ArtifactResponse* resolve( + bool& authenticated, + const saml2p::SAML2Artifact& artifact, + const SSODescriptorType& ssoDescriptor, + const X509TrustEngine* trustEngine=NULL + ) const { + throw BindingException("Not implemented."); + } +}; diff --git a/samltest/saml1/binding/SAML1POSTTest.h b/samltest/saml1/binding/SAML1POSTTest.h index 27e96ee..6872867 100644 --- a/samltest/saml1/binding/SAML1POSTTest.h +++ b/samltest/saml1/binding/SAML1POSTTest.h @@ -1,147 +1,147 @@ -/* - * Copyright 2001-2005 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "binding.h" - -#include - -using namespace opensaml::saml1p; -using namespace opensaml::saml1; - -class SAML1POSTTest : public CxxTest::TestSuite, public SAMLBindingBaseTestCase { -public: - void setUp() { - m_fields.clear(); - SAMLBindingBaseTestCase::setUp(); - } - - void tearDown() { - m_fields.clear(); - SAMLBindingBaseTestCase::tearDown(); - } - - void testSAML1POSTTrusted() { - try { - // Read message to use from file. - string path = data_path + "saml1/binding/SAML1Response.xml"; - ifstream in(path.c_str()); - DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); - XercesJanitor janitor(doc); - auto_ptr toSend( - dynamic_cast(XMLObjectBuilder::buildOneFromElement(doc->getDocumentElement(),true)) - ); - janitor.release(); - - // Freshen timestamp. - toSend->setIssueInstant(time(NULL)); - - // Encode message. - auto_ptr encoder(SAMLConfig::getConfig().MessageEncoderManager.newPlugin(SAML1_POST_ENCODER, NULL)); - encoder->encode(m_fields,toSend.get(),"https://sp.example.org/","state",m_creds); - toSend.release(); - - // Decode message. - string relayState; - const RoleDescriptor* issuer=NULL; - bool trusted=false; - QName idprole(SAMLConstants::SAML20MD_NS, IDPSSODescriptor::LOCAL_NAME); - auto_ptr decoder(SAMLConfig::getConfig().MessageDecoderManager.newPlugin(SAML1_POST_DECODER, NULL)); - Locker locker(m_metadata); - auto_ptr response( - dynamic_cast( - decoder->decode(relayState,issuer,trusted,*this,m_metadata,&idprole,m_trust) - ) - ); - - // Test the results. - TSM_ASSERT_EQUALS("TARGET was not the expected result.", relayState, "state"); - TSM_ASSERT("SAML Response not decoded successfully.", response.get()); - TSM_ASSERT("Message was not verified.", issuer && trusted); - auto_ptr_char entityID(dynamic_cast(issuer->getParent())->getEntityID()); - TSM_ASSERT("Issuer was not expected.", !strcmp(entityID.get(),"https://idp.example.org/")); - TSM_ASSERT_EQUALS("Assertion count was not correct.", response->getAssertions().size(), 1); - } - catch (XMLToolingException& ex) { - TS_TRACE(ex.what()); - throw; - } - } - - void testSAML1POSTUntrusted() { - try { - // Read message to use from file. - string path = data_path + "saml1/binding/SAML1Response.xml"; - ifstream in(path.c_str()); - DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); - XercesJanitor janitor(doc); - auto_ptr toSend( - dynamic_cast(XMLObjectBuilder::buildOneFromElement(doc->getDocumentElement(),true)) - ); - janitor.release(); - - // Freshen timestamp and clear ID. - toSend->setIssueInstant(time(NULL)); - toSend->setResponseID(NULL); - - // Encode message. - auto_ptr encoder(SAMLConfig::getConfig().MessageEncoderManager.newPlugin(SAML1_POST_ENCODER, NULL)); - encoder->encode(m_fields,toSend.get(),"https://sp.example.org/","state"); - toSend.release(); - - // Decode message. - string relayState; - const RoleDescriptor* issuer=NULL; - bool trusted=false; - QName idprole(SAMLConstants::SAML20MD_NS, IDPSSODescriptor::LOCAL_NAME); - auto_ptr decoder(SAMLConfig::getConfig().MessageDecoderManager.newPlugin(SAML1_POST_DECODER, NULL)); - Locker locker(m_metadata); - auto_ptr response( - dynamic_cast( - decoder->decode(relayState,issuer,trusted,*this,m_metadata,&idprole) - ) - ); - - // Test the results. - TSM_ASSERT_EQUALS("TARGET was not the expected result.", relayState, "state"); - TSM_ASSERT("SAML Response not decoded successfully.", response.get()); - TSM_ASSERT("Message was verified.", issuer && !trusted); - auto_ptr_char entityID(dynamic_cast(issuer->getParent())->getEntityID()); - TSM_ASSERT("Issuer was not expected.", !strcmp(entityID.get(),"https://idp.example.org/")); - TSM_ASSERT_EQUALS("Assertion count was not correct.", response->getAssertions().size(), 1); - - // Trigger a replay. - TSM_ASSERT_THROWS("Did not catch the replay.", - decoder->decode(relayState,issuer,trusted,*this,m_metadata,&idprole,m_trust), - BindingException); - } - catch (XMLToolingException& ex) { - TS_TRACE(ex.what()); - throw; - } - } - - const char* getMethod() const { - return "POST"; - } - - const char* getRequestURL() const { - return "https://sp.example.org/SAML/POST"; - } - - const char* getQueryString() const { - return NULL; - } -}; +/* + * Copyright 2001-2005 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "binding.h" + +#include + +using namespace opensaml::saml1p; +using namespace opensaml::saml1; + +class SAML1POSTTest : public CxxTest::TestSuite, public SAMLBindingBaseTestCase { +public: + void setUp() { + m_fields.clear(); + SAMLBindingBaseTestCase::setUp(); + } + + void tearDown() { + m_fields.clear(); + SAMLBindingBaseTestCase::tearDown(); + } + + void testSAML1POSTTrusted() { + try { + // Read message to use from file. + string path = data_path + "saml1/binding/SAML1Response.xml"; + ifstream in(path.c_str()); + DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); + XercesJanitor janitor(doc); + auto_ptr toSend( + dynamic_cast(XMLObjectBuilder::buildOneFromElement(doc->getDocumentElement(),true)) + ); + janitor.release(); + + // Freshen timestamp. + toSend->setIssueInstant(time(NULL)); + + // Encode message. + auto_ptr encoder(SAMLConfig::getConfig().MessageEncoderManager.newPlugin(SAML1_POST_ENCODER, NULL)); + encoder->encode(m_fields,toSend.get(),"https://sp.example.org/","state",m_creds); + toSend.release(); + + // Decode message. + string relayState; + const RoleDescriptor* issuer=NULL; + bool trusted=false; + QName idprole(SAMLConstants::SAML20MD_NS, IDPSSODescriptor::LOCAL_NAME); + auto_ptr decoder(SAMLConfig::getConfig().MessageDecoderManager.newPlugin(SAML1_POST_DECODER, NULL)); + Locker locker(m_metadata); + auto_ptr response( + dynamic_cast( + decoder->decode(relayState,issuer,trusted,*this,m_metadata,&idprole,m_trust) + ) + ); + + // Test the results. + TSM_ASSERT_EQUALS("TARGET was not the expected result.", relayState, "state"); + TSM_ASSERT("SAML Response not decoded successfully.", response.get()); + TSM_ASSERT("Message was not verified.", issuer && trusted); + auto_ptr_char entityID(dynamic_cast(issuer->getParent())->getEntityID()); + TSM_ASSERT("Issuer was not expected.", !strcmp(entityID.get(),"https://idp.example.org/")); + TSM_ASSERT_EQUALS("Assertion count was not correct.", response->getAssertions().size(), 1); + } + catch (XMLToolingException& ex) { + TS_TRACE(ex.what()); + throw; + } + } + + void testSAML1POSTUntrusted() { + try { + // Read message to use from file. + string path = data_path + "saml1/binding/SAML1Response.xml"; + ifstream in(path.c_str()); + DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); + XercesJanitor janitor(doc); + auto_ptr toSend( + dynamic_cast(XMLObjectBuilder::buildOneFromElement(doc->getDocumentElement(),true)) + ); + janitor.release(); + + // Freshen timestamp and clear ID. + toSend->setIssueInstant(time(NULL)); + toSend->setResponseID(NULL); + + // Encode message. + auto_ptr encoder(SAMLConfig::getConfig().MessageEncoderManager.newPlugin(SAML1_POST_ENCODER, NULL)); + encoder->encode(m_fields,toSend.get(),"https://sp.example.org/","state"); + toSend.release(); + + // Decode message. + string relayState; + const RoleDescriptor* issuer=NULL; + bool trusted=false; + QName idprole(SAMLConstants::SAML20MD_NS, IDPSSODescriptor::LOCAL_NAME); + auto_ptr decoder(SAMLConfig::getConfig().MessageDecoderManager.newPlugin(SAML1_POST_DECODER, NULL)); + Locker locker(m_metadata); + auto_ptr response( + dynamic_cast( + decoder->decode(relayState,issuer,trusted,*this,m_metadata,&idprole) + ) + ); + + // Test the results. + TSM_ASSERT_EQUALS("TARGET was not the expected result.", relayState, "state"); + TSM_ASSERT("SAML Response not decoded successfully.", response.get()); + TSM_ASSERT("Message was verified.", issuer && !trusted); + auto_ptr_char entityID(dynamic_cast(issuer->getParent())->getEntityID()); + TSM_ASSERT("Issuer was not expected.", !strcmp(entityID.get(),"https://idp.example.org/")); + TSM_ASSERT_EQUALS("Assertion count was not correct.", response->getAssertions().size(), 1); + + // Trigger a replay. + TSM_ASSERT_THROWS("Did not catch the replay.", + decoder->decode(relayState,issuer,trusted,*this,m_metadata,&idprole,m_trust), + BindingException); + } + catch (XMLToolingException& ex) { + TS_TRACE(ex.what()); + throw; + } + } + + const char* getMethod() const { + return "POST"; + } + + const char* getRequestURL() const { + return "https://sp.example.org/SAML/POST"; + } + + const char* getQueryString() const { + return NULL; + } +}; diff --git a/samltest/saml1/core/impl/ActionTest.h b/samltest/saml1/core/impl/ActionTest.h index 643adf2..f484f13 100644 --- a/samltest/saml1/core/impl/ActionTest.h +++ b/samltest/saml1/core/impl/ActionTest.h @@ -1,67 +1,67 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include - -using namespace opensaml::saml1; - -class ActionTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* expectedContents; - XMLCh* expectedNamespace; - -public: - void setUp() { - singleElementFile = data_path + "saml1/core/impl/singleAction.xml"; - singleElementOptionalAttributesFile = data_path + "saml1/core/impl/singleActionAttributes.xml"; - expectedContents = XMLString::transcode("Action Contents"); - expectedNamespace = XMLString::transcode("namespace"); - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&expectedContents); - XMLString::release(&expectedNamespace); - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - Action* action = dynamic_cast(xo.get()); - TS_ASSERT(action!=NULL); - TSM_ASSERT("namespace attribute present", action->getNamespace()==NULL); - TSM_ASSERT("Contents present", action->getAction()==NULL); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - Action* action = dynamic_cast(xo.get()); - assertEquals("namespace attribute ", expectedNamespace, action->getNamespace()); - assertEquals("Contents ", expectedContents, action->getAction()); - } - - void testSingleElementMarshall() { - assertEquals(expectedDOM, ActionBuilder::buildAction()); - } - - void testSingleElementOptionalAttributesMarshall() { - Action* action=ActionBuilder::buildAction(); - action->setNamespace(expectedNamespace); - action->setAction(expectedContents); - assertEquals(expectedOptionalAttributesDOM, action); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include + +using namespace opensaml::saml1; + +class ActionTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedContents; + XMLCh* expectedNamespace; + +public: + void setUp() { + singleElementFile = data_path + "saml1/core/impl/singleAction.xml"; + singleElementOptionalAttributesFile = data_path + "saml1/core/impl/singleActionAttributes.xml"; + expectedContents = XMLString::transcode("Action Contents"); + expectedNamespace = XMLString::transcode("namespace"); + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedContents); + XMLString::release(&expectedNamespace); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + Action* action = dynamic_cast(xo.get()); + TS_ASSERT(action!=NULL); + TSM_ASSERT("namespace attribute present", action->getNamespace()==NULL); + TSM_ASSERT("Contents present", action->getAction()==NULL); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + Action* action = dynamic_cast(xo.get()); + assertEquals("namespace attribute ", expectedNamespace, action->getNamespace()); + assertEquals("Contents ", expectedContents, action->getAction()); + } + + void testSingleElementMarshall() { + assertEquals(expectedDOM, ActionBuilder::buildAction()); + } + + void testSingleElementOptionalAttributesMarshall() { + Action* action=ActionBuilder::buildAction(); + action->setNamespace(expectedNamespace); + action->setAction(expectedContents); + assertEquals(expectedOptionalAttributesDOM, action); + } + +}; diff --git a/samltest/saml1/core/impl/AdviceTest.h b/samltest/saml1/core/impl/AdviceTest.h index 50d5eed..648aa61 100644 --- a/samltest/saml1/core/impl/AdviceTest.h +++ b/samltest/saml1/core/impl/AdviceTest.h @@ -1,73 +1,73 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include - -using namespace opensaml::saml1; - -class AdviceTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* AssertionID; - XMLCh* IssueInstant; - -public: - void setUp() { - AssertionID=XMLString::transcode("_123456789"); - IssueInstant=XMLString::transcode("1971-03-19T13:23:00Z"); - singleElementFile = data_path + "saml1/core/impl/singleAdvice.xml"; - childElementsFile = data_path + "saml1/core/impl/AdviceWithChildren.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&AssertionID); - XMLString::release(&IssueInstant); - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - Advice* advice = dynamic_cast(xo.get()); - TS_ASSERT(advice!=NULL); - TSM_ASSERT_EQUALS("Number of child AssertIDReference elements", 0, advice->getAssertionIDReferences().size()); - TSM_ASSERT_EQUALS("Number of child Assertion elements", 0, advice->getAssertions().size()); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - Advice* advice = dynamic_cast(xo.get()); - TSM_ASSERT_EQUALS("Number of child AssertIDReference elements", 2, advice->getAssertionIDReferences().size()); - TSM_ASSERT_EQUALS("Number of child Assertion elements", 1, advice->getAssertions().size()); - } - - void testSingleElementMarshall() { - assertEquals(expectedDOM, AdviceBuilder::buildAdvice()); - } - - void testChildElementsMarshall() { - Advice* advice=AdviceBuilder::buildAdvice(); - - advice->getAssertionIDReferences().push_back(AssertionIDReferenceBuilder::buildAssertionIDReference()); - Assertion* assertion=AssertionBuilder::buildAssertion(); - assertion->setAssertionID(AssertionID); - assertion->setIssueInstant(IssueInstant); - advice->getAssertions().push_back(assertion); - advice->getAssertionIDReferences().push_back(AssertionIDReferenceBuilder::buildAssertionIDReference()); - - assertEquals(expectedChildElementsDOM, advice); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include + +using namespace opensaml::saml1; + +class AdviceTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* AssertionID; + XMLCh* IssueInstant; + +public: + void setUp() { + AssertionID=XMLString::transcode("_123456789"); + IssueInstant=XMLString::transcode("1971-03-19T13:23:00Z"); + singleElementFile = data_path + "saml1/core/impl/singleAdvice.xml"; + childElementsFile = data_path + "saml1/core/impl/AdviceWithChildren.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&AssertionID); + XMLString::release(&IssueInstant); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + Advice* advice = dynamic_cast(xo.get()); + TS_ASSERT(advice!=NULL); + TSM_ASSERT_EQUALS("Number of child AssertIDReference elements", 0, advice->getAssertionIDReferences().size()); + TSM_ASSERT_EQUALS("Number of child Assertion elements", 0, advice->getAssertions().size()); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + Advice* advice = dynamic_cast(xo.get()); + TSM_ASSERT_EQUALS("Number of child AssertIDReference elements", 2, advice->getAssertionIDReferences().size()); + TSM_ASSERT_EQUALS("Number of child Assertion elements", 1, advice->getAssertions().size()); + } + + void testSingleElementMarshall() { + assertEquals(expectedDOM, AdviceBuilder::buildAdvice()); + } + + void testChildElementsMarshall() { + Advice* advice=AdviceBuilder::buildAdvice(); + + advice->getAssertionIDReferences().push_back(AssertionIDReferenceBuilder::buildAssertionIDReference()); + Assertion* assertion=AssertionBuilder::buildAssertion(); + assertion->setAssertionID(AssertionID); + assertion->setIssueInstant(IssueInstant); + advice->getAssertions().push_back(assertion); + advice->getAssertionIDReferences().push_back(AssertionIDReferenceBuilder::buildAssertionIDReference()); + + assertEquals(expectedChildElementsDOM, advice); + } + +}; diff --git a/samltest/saml1/core/impl/AssertionIDReferenceTest.h b/samltest/saml1/core/impl/AssertionIDReferenceTest.h index 3cd2f92..82293b3 100644 --- a/samltest/saml1/core/impl/AssertionIDReferenceTest.h +++ b/samltest/saml1/core/impl/AssertionIDReferenceTest.h @@ -1,61 +1,61 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include - -using namespace opensaml::saml1; - -class AssertionIDReferenceTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* expectedNCName; - -public: - void setUp() { - singleElementFile = data_path + "saml1/core/impl/singleAssertionIDReference.xml"; - singleElementOptionalAttributesFile = data_path + "saml1/core/impl/singleAssertionIDReferenceContents.xml"; - expectedNCName = XMLString::transcode("NibbleAHappyWarthog"); - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&expectedNCName); - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - AssertionIDReference* assertionIDReference = dynamic_cast(xo.get()); - TS_ASSERT(assertionIDReference!=NULL); - TSM_ASSERT("NCName present", assertionIDReference->getAssertionID()==NULL); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - AssertionIDReference* assertionIDReference = dynamic_cast(xo.get()); - assertEquals("NCName ", expectedNCName, assertionIDReference->getAssertionID()); - } - - void testSingleElementMarshall() { - assertEquals(expectedDOM, AssertionIDReferenceBuilder::buildAssertionIDReference()); - } - - void testSingleElementOptionalAttributesMarshall() { - AssertionIDReference* assertionIDReference=AssertionIDReferenceBuilder::buildAssertionIDReference(); - assertionIDReference->setAssertionID(expectedNCName); - assertEquals(expectedOptionalAttributesDOM, assertionIDReference); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include + +using namespace opensaml::saml1; + +class AssertionIDReferenceTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedNCName; + +public: + void setUp() { + singleElementFile = data_path + "saml1/core/impl/singleAssertionIDReference.xml"; + singleElementOptionalAttributesFile = data_path + "saml1/core/impl/singleAssertionIDReferenceContents.xml"; + expectedNCName = XMLString::transcode("NibbleAHappyWarthog"); + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedNCName); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + AssertionIDReference* assertionIDReference = dynamic_cast(xo.get()); + TS_ASSERT(assertionIDReference!=NULL); + TSM_ASSERT("NCName present", assertionIDReference->getAssertionID()==NULL); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + AssertionIDReference* assertionIDReference = dynamic_cast(xo.get()); + assertEquals("NCName ", expectedNCName, assertionIDReference->getAssertionID()); + } + + void testSingleElementMarshall() { + assertEquals(expectedDOM, AssertionIDReferenceBuilder::buildAssertionIDReference()); + } + + void testSingleElementOptionalAttributesMarshall() { + AssertionIDReference* assertionIDReference=AssertionIDReferenceBuilder::buildAssertionIDReference(); + assertionIDReference->setAssertionID(expectedNCName); + assertEquals(expectedOptionalAttributesDOM, assertionIDReference); + } + +}; diff --git a/samltest/saml1/core/impl/AssertionTest.h b/samltest/saml1/core/impl/AssertionTest.h index 94ba0ac..7b0ed6b 100644 --- a/samltest/saml1/core/impl/AssertionTest.h +++ b/samltest/saml1/core/impl/AssertionTest.h @@ -1,148 +1,148 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include - -using namespace opensaml::saml1; - -class AssertionTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - int expectedMinorVersion; - XMLCh* expectedIssuer; - DateTime* expectedIssueInstant; - XMLCh* expectedID; - -public: - void setUp() { - expectedID=XMLString::transcode("ident"); - expectedMinorVersion=1; - expectedIssueInstant=new DateTime(XMLString::transcode("1970-01-02T01:01:02.100Z")); - expectedIssueInstant->parseDateTime(); - expectedIssuer=XMLString::transcode("issuer"); - singleElementFile = data_path + "saml1/core/impl/singleAssertion.xml"; - singleElementOptionalAttributesFile = data_path + "saml1/core/impl/singleAssertionAttributes.xml"; - childElementsFile = data_path + "saml1/core/impl/AssertionWithChildren.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&expectedID); - XMLString::release(&expectedIssuer); - delete expectedIssueInstant; - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - Assertion& assertion = dynamic_cast(*xo.get()); - TSM_ASSERT("Issuer attribute", assertion.getIssuer()==NULL); - TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), assertion.getIssueInstant()->getEpoch()); - assertEquals("ID attribute", expectedID, assertion.getAssertionID()); - - TSM_ASSERT("Conditions element", assertion.getConditions()==NULL); - TSM_ASSERT("Advice element", assertion.getAdvice()==NULL); - - TSM_ASSERT_EQUALS("Statement element count", 0, assertion.getStatements().size()); - TSM_ASSERT_EQUALS("SubjectStatements element count", 0, assertion.getSubjectStatements().size()); - TSM_ASSERT_EQUALS("AttributeStatements element count", 0, assertion.getAttributeStatements().size()); - TSM_ASSERT_EQUALS("AuthenticationStatements element count", 0, assertion.getAuthenticationStatements().size()); - TSM_ASSERT_EQUALS("AuthorizationDecisionStatements element count", 0, assertion.getAuthorizationDecisionStatements().size()); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - Assertion& assertion = dynamic_cast(*xo.get()); - - assertEquals("Issuer attribute", expectedIssuer, assertion.getIssuer()); - TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), assertion.getIssueInstant()->getEpoch()); - assertEquals("ID attribute", expectedID, assertion.getAssertionID()); - TSM_ASSERT_EQUALS("Issuer expectedMinorVersion", expectedMinorVersion, assertion.getMinorVersion().second); - - TSM_ASSERT("Conditions element", assertion.getConditions()==NULL); - TSM_ASSERT("Advice element", assertion.getAdvice()==NULL); - - TSM_ASSERT_EQUALS("Statement element count", 0, assertion.getStatements().size()); - TSM_ASSERT_EQUALS("SubjectStatements element count", 0, assertion.getSubjectStatements().size()); - TSM_ASSERT_EQUALS("AttributeStatements element count", 0, assertion.getAttributeStatements().size()); - TSM_ASSERT_EQUALS("AuthenticationStatements element count", 0, assertion.getAuthenticationStatements().size()); - TSM_ASSERT_EQUALS("AuthorizationDecisionStatements element count", 0, assertion.getAuthorizationDecisionStatements().size()); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - Assertion& assertion = dynamic_cast(*xo.get()); - - TSM_ASSERT("Issuer attribute", assertion.getIssuer()==NULL); - TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), assertion.getIssueInstant()->getEpoch()); - assertEquals("ID attribute", expectedID, assertion.getAssertionID()); - - TSM_ASSERT("Conditions element null", assertion.getConditions()!=NULL); - TSM_ASSERT("Advice element null", assertion.getAdvice()!=NULL); - - TSM_ASSERT_EQUALS("AuthenticationStatements element count", 2, assertion.getAuthenticationStatements().size()); - TSM_ASSERT_EQUALS("AttributeStatements element count", 3, assertion.getAttributeStatements().size()); - TSM_ASSERT_EQUALS("AuthorizationDecisionStatements element count", 3, assertion.getAuthorizationDecisionStatements().size()); - } - - void testSingleElementMarshall() { - Assertion* assertion=AssertionBuilder::buildAssertion(); - assertion->setAssertionID(expectedID); - assertion->setIssueInstant(expectedIssueInstant); - assertEquals(expectedDOM, assertion); - } - - void testSingleElementOptionalAttributesMarshall() { - Assertion* assertion=AssertionBuilder::buildAssertion(); - assertion->setIssueInstant(expectedIssueInstant); - assertion->setAssertionID(expectedID); - assertion->setIssuer(expectedIssuer); - assertEquals(expectedOptionalAttributesDOM, assertion); - } - - void testChildElementsMarshall() { - Assertion* assertion=AssertionBuilder::buildAssertion(); - assertion->setIssueInstant(expectedIssueInstant); - assertion->setAssertionID(expectedID); - assertion->setConditions(ConditionsBuilder::buildConditions()); - assertion->setAdvice(AdviceBuilder::buildAdvice()); - assertion->getAuthenticationStatements().push_back( - AuthenticationStatementBuilder::buildAuthenticationStatement() - ); - assertion->getAuthorizationDecisionStatements().push_back( - AuthorizationDecisionStatementBuilder::buildAuthorizationDecisionStatement() - ); - assertion->getAttributeStatements().push_back( - AttributeStatementBuilder::buildAttributeStatement() - ); - assertion->getAuthenticationStatements().push_back( - AuthenticationStatementBuilder::buildAuthenticationStatement() - ); - assertion->getAuthorizationDecisionStatements().push_back( - AuthorizationDecisionStatementBuilder::buildAuthorizationDecisionStatement() - ); - assertion->getAttributeStatements().push_back( - AttributeStatementBuilder::buildAttributeStatement() - ); - assertion->getAuthorizationDecisionStatements().push_back( - AuthorizationDecisionStatementBuilder::buildAuthorizationDecisionStatement() - ); - assertion->getAttributeStatements().push_back( - AttributeStatementBuilder::buildAttributeStatement() - ); - assertEquals(expectedChildElementsDOM, assertion); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include + +using namespace opensaml::saml1; + +class AssertionTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + int expectedMinorVersion; + XMLCh* expectedIssuer; + DateTime* expectedIssueInstant; + XMLCh* expectedID; + +public: + void setUp() { + expectedID=XMLString::transcode("ident"); + expectedMinorVersion=1; + expectedIssueInstant=new DateTime(XMLString::transcode("1970-01-02T01:01:02.100Z")); + expectedIssueInstant->parseDateTime(); + expectedIssuer=XMLString::transcode("issuer"); + singleElementFile = data_path + "saml1/core/impl/singleAssertion.xml"; + singleElementOptionalAttributesFile = data_path + "saml1/core/impl/singleAssertionAttributes.xml"; + childElementsFile = data_path + "saml1/core/impl/AssertionWithChildren.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedID); + XMLString::release(&expectedIssuer); + delete expectedIssueInstant; + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + Assertion& assertion = dynamic_cast(*xo.get()); + TSM_ASSERT("Issuer attribute", assertion.getIssuer()==NULL); + TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), assertion.getIssueInstant()->getEpoch()); + assertEquals("ID attribute", expectedID, assertion.getAssertionID()); + + TSM_ASSERT("Conditions element", assertion.getConditions()==NULL); + TSM_ASSERT("Advice element", assertion.getAdvice()==NULL); + + TSM_ASSERT_EQUALS("Statement element count", 0, assertion.getStatements().size()); + TSM_ASSERT_EQUALS("SubjectStatements element count", 0, assertion.getSubjectStatements().size()); + TSM_ASSERT_EQUALS("AttributeStatements element count", 0, assertion.getAttributeStatements().size()); + TSM_ASSERT_EQUALS("AuthenticationStatements element count", 0, assertion.getAuthenticationStatements().size()); + TSM_ASSERT_EQUALS("AuthorizationDecisionStatements element count", 0, assertion.getAuthorizationDecisionStatements().size()); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + Assertion& assertion = dynamic_cast(*xo.get()); + + assertEquals("Issuer attribute", expectedIssuer, assertion.getIssuer()); + TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), assertion.getIssueInstant()->getEpoch()); + assertEquals("ID attribute", expectedID, assertion.getAssertionID()); + TSM_ASSERT_EQUALS("Issuer expectedMinorVersion", expectedMinorVersion, assertion.getMinorVersion().second); + + TSM_ASSERT("Conditions element", assertion.getConditions()==NULL); + TSM_ASSERT("Advice element", assertion.getAdvice()==NULL); + + TSM_ASSERT_EQUALS("Statement element count", 0, assertion.getStatements().size()); + TSM_ASSERT_EQUALS("SubjectStatements element count", 0, assertion.getSubjectStatements().size()); + TSM_ASSERT_EQUALS("AttributeStatements element count", 0, assertion.getAttributeStatements().size()); + TSM_ASSERT_EQUALS("AuthenticationStatements element count", 0, assertion.getAuthenticationStatements().size()); + TSM_ASSERT_EQUALS("AuthorizationDecisionStatements element count", 0, assertion.getAuthorizationDecisionStatements().size()); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + Assertion& assertion = dynamic_cast(*xo.get()); + + TSM_ASSERT("Issuer attribute", assertion.getIssuer()==NULL); + TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), assertion.getIssueInstant()->getEpoch()); + assertEquals("ID attribute", expectedID, assertion.getAssertionID()); + + TSM_ASSERT("Conditions element null", assertion.getConditions()!=NULL); + TSM_ASSERT("Advice element null", assertion.getAdvice()!=NULL); + + TSM_ASSERT_EQUALS("AuthenticationStatements element count", 2, assertion.getAuthenticationStatements().size()); + TSM_ASSERT_EQUALS("AttributeStatements element count", 3, assertion.getAttributeStatements().size()); + TSM_ASSERT_EQUALS("AuthorizationDecisionStatements element count", 3, assertion.getAuthorizationDecisionStatements().size()); + } + + void testSingleElementMarshall() { + Assertion* assertion=AssertionBuilder::buildAssertion(); + assertion->setAssertionID(expectedID); + assertion->setIssueInstant(expectedIssueInstant); + assertEquals(expectedDOM, assertion); + } + + void testSingleElementOptionalAttributesMarshall() { + Assertion* assertion=AssertionBuilder::buildAssertion(); + assertion->setIssueInstant(expectedIssueInstant); + assertion->setAssertionID(expectedID); + assertion->setIssuer(expectedIssuer); + assertEquals(expectedOptionalAttributesDOM, assertion); + } + + void testChildElementsMarshall() { + Assertion* assertion=AssertionBuilder::buildAssertion(); + assertion->setIssueInstant(expectedIssueInstant); + assertion->setAssertionID(expectedID); + assertion->setConditions(ConditionsBuilder::buildConditions()); + assertion->setAdvice(AdviceBuilder::buildAdvice()); + assertion->getAuthenticationStatements().push_back( + AuthenticationStatementBuilder::buildAuthenticationStatement() + ); + assertion->getAuthorizationDecisionStatements().push_back( + AuthorizationDecisionStatementBuilder::buildAuthorizationDecisionStatement() + ); + assertion->getAttributeStatements().push_back( + AttributeStatementBuilder::buildAttributeStatement() + ); + assertion->getAuthenticationStatements().push_back( + AuthenticationStatementBuilder::buildAuthenticationStatement() + ); + assertion->getAuthorizationDecisionStatements().push_back( + AuthorizationDecisionStatementBuilder::buildAuthorizationDecisionStatement() + ); + assertion->getAttributeStatements().push_back( + AttributeStatementBuilder::buildAttributeStatement() + ); + assertion->getAuthorizationDecisionStatements().push_back( + AuthorizationDecisionStatementBuilder::buildAuthorizationDecisionStatement() + ); + assertion->getAttributeStatements().push_back( + AttributeStatementBuilder::buildAttributeStatement() + ); + assertEquals(expectedChildElementsDOM, assertion); + } + +}; diff --git a/samltest/saml1/core/impl/AttributeDesignatorTest.h b/samltest/saml1/core/impl/AttributeDesignatorTest.h index 9f09fc2..839bb2b 100644 --- a/samltest/saml1/core/impl/AttributeDesignatorTest.h +++ b/samltest/saml1/core/impl/AttributeDesignatorTest.h @@ -1,66 +1,66 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include - -using namespace opensaml::saml1; - -class AttributeDesignatorTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* expectedAttributeName; - XMLCh* expectedAttributeNamespace; - -public: - void setUp() { - expectedAttributeName=XMLString::transcode("AttributeName"); - expectedAttributeNamespace=XMLString::transcode("namespace"); - singleElementFile = data_path + "saml1/core/impl/singleAttributeDesignator.xml"; - singleElementOptionalAttributesFile = data_path + "saml1/core/impl/singleAttributeDesignatorAttributes.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&expectedAttributeName); - XMLString::release(&expectedAttributeNamespace); - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - AttributeDesignator& ad = dynamic_cast(*xo.get()); - TSM_ASSERT("AttributeName", ad.getAttributeName()==NULL); - TSM_ASSERT("AttributeNamespace", ad.getAttributeNamespace()==NULL); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - AttributeDesignator& ad = dynamic_cast(*xo.get()); - assertEquals("AttributeName", expectedAttributeName, ad.getAttributeName()); - assertEquals("AttributeNamespace", expectedAttributeNamespace, ad.getAttributeNamespace()); - } - - void testSingleElementMarshall() { - assertEquals(expectedDOM, AttributeDesignatorBuilder::buildAttributeDesignator()); - } - - void testSingleElementOptionalAttributesMarshall() { - AttributeDesignator* ad=AttributeDesignatorBuilder::buildAttributeDesignator(); - ad->setAttributeName(expectedAttributeName); - ad->setAttributeNamespace(expectedAttributeNamespace); - assertEquals(expectedOptionalAttributesDOM, ad); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include + +using namespace opensaml::saml1; + +class AttributeDesignatorTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedAttributeName; + XMLCh* expectedAttributeNamespace; + +public: + void setUp() { + expectedAttributeName=XMLString::transcode("AttributeName"); + expectedAttributeNamespace=XMLString::transcode("namespace"); + singleElementFile = data_path + "saml1/core/impl/singleAttributeDesignator.xml"; + singleElementOptionalAttributesFile = data_path + "saml1/core/impl/singleAttributeDesignatorAttributes.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedAttributeName); + XMLString::release(&expectedAttributeNamespace); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + AttributeDesignator& ad = dynamic_cast(*xo.get()); + TSM_ASSERT("AttributeName", ad.getAttributeName()==NULL); + TSM_ASSERT("AttributeNamespace", ad.getAttributeNamespace()==NULL); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + AttributeDesignator& ad = dynamic_cast(*xo.get()); + assertEquals("AttributeName", expectedAttributeName, ad.getAttributeName()); + assertEquals("AttributeNamespace", expectedAttributeNamespace, ad.getAttributeNamespace()); + } + + void testSingleElementMarshall() { + assertEquals(expectedDOM, AttributeDesignatorBuilder::buildAttributeDesignator()); + } + + void testSingleElementOptionalAttributesMarshall() { + AttributeDesignator* ad=AttributeDesignatorBuilder::buildAttributeDesignator(); + ad->setAttributeName(expectedAttributeName); + ad->setAttributeNamespace(expectedAttributeNamespace); + assertEquals(expectedOptionalAttributesDOM, ad); + } + +}; diff --git a/samltest/saml1/core/impl/AttributeStatementTest.h b/samltest/saml1/core/impl/AttributeStatementTest.h index 3b6c054..79be1ca 100644 --- a/samltest/saml1/core/impl/AttributeStatementTest.h +++ b/samltest/saml1/core/impl/AttributeStatementTest.h @@ -1,69 +1,69 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include - -using namespace opensaml::saml1; - -class AttributeStatementTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { -public: - void setUp() { - singleElementFile = data_path + "saml1/core/impl/singleAttributeStatement.xml"; - childElementsFile = data_path + "saml1/core/impl/AttributeStatementWithChildren.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - AttributeStatement& as = dynamic_cast(*xo.get()); - TSM_ASSERT(" element present", as.getSubject()==NULL); - TSM_ASSERT_EQUALS("Non zero count of elements", 0, as.getAttributes().size()); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - AttributeStatement& as = dynamic_cast(*xo.get()); - TSM_ASSERT(" element not present", as.getSubject()!=NULL); - TSM_ASSERT_EQUALS("count of elements", 5, as.getAttributes().size()); - - as.getAttributes().erase(as.getAttributes().begin()); - TSM_ASSERT_EQUALS("count of elements after single remove", 4, as.getAttributes().size()); - - as.getAttributes().erase(as.getAttributes().begin()); - as.getAttributes().erase(as.getAttributes().begin()+1); - TSM_ASSERT_EQUALS("count of elements after double remove", 2, as.getAttributes().size()); - } - - void testSingleElementMarshall() { - assertEquals(expectedDOM, AttributeStatementBuilder::buildAttributeStatement()); - } - - void testChildElementsMarshall() { - AttributeStatement* as=AttributeStatementBuilder::buildAttributeStatement(); - as->setSubject(SubjectBuilder::buildSubject()); - for (int i = 0; i < 5; i++) { - as->getAttributes().push_back(AttributeBuilder::buildAttribute()); - } - - assertEquals(expectedChildElementsDOM, as); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include + +using namespace opensaml::saml1; + +class AttributeStatementTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { +public: + void setUp() { + singleElementFile = data_path + "saml1/core/impl/singleAttributeStatement.xml"; + childElementsFile = data_path + "saml1/core/impl/AttributeStatementWithChildren.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + AttributeStatement& as = dynamic_cast(*xo.get()); + TSM_ASSERT(" element present", as.getSubject()==NULL); + TSM_ASSERT_EQUALS("Non zero count of elements", 0, as.getAttributes().size()); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + AttributeStatement& as = dynamic_cast(*xo.get()); + TSM_ASSERT(" element not present", as.getSubject()!=NULL); + TSM_ASSERT_EQUALS("count of elements", 5, as.getAttributes().size()); + + as.getAttributes().erase(as.getAttributes().begin()); + TSM_ASSERT_EQUALS("count of elements after single remove", 4, as.getAttributes().size()); + + as.getAttributes().erase(as.getAttributes().begin()); + as.getAttributes().erase(as.getAttributes().begin()+1); + TSM_ASSERT_EQUALS("count of elements after double remove", 2, as.getAttributes().size()); + } + + void testSingleElementMarshall() { + assertEquals(expectedDOM, AttributeStatementBuilder::buildAttributeStatement()); + } + + void testChildElementsMarshall() { + AttributeStatement* as=AttributeStatementBuilder::buildAttributeStatement(); + as->setSubject(SubjectBuilder::buildSubject()); + for (int i = 0; i < 5; i++) { + as->getAttributes().push_back(AttributeBuilder::buildAttribute()); + } + + assertEquals(expectedChildElementsDOM, as); + } + +}; diff --git a/samltest/saml1/core/impl/AttributeTest.h b/samltest/saml1/core/impl/AttributeTest.h index 8a99211..1047d83 100644 --- a/samltest/saml1/core/impl/AttributeTest.h +++ b/samltest/saml1/core/impl/AttributeTest.h @@ -1,87 +1,87 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include - -using namespace opensaml::saml1; - -class AttributeTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* expectedAttributeName; - XMLCh* expectedAttributeNamespace; - -public: - void setUp() { - expectedAttributeName=XMLString::transcode("AttributeName"); - expectedAttributeNamespace=XMLString::transcode("namespace"); - singleElementFile = data_path + "saml1/core/impl/singleAttribute.xml"; - singleElementOptionalAttributesFile = data_path + "saml1/core/impl/singleAttributeAttributes.xml"; - childElementsFile = data_path + "saml1/core/impl/AttributeWithChildren.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&expectedAttributeName); - XMLString::release(&expectedAttributeNamespace); - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - Attribute& a = dynamic_cast(*xo.get()); - TSM_ASSERT("AttributeName", a.getAttributeName()==NULL); - TSM_ASSERT("AttributeNamespace", a.getAttributeNamespace()==NULL); - TSM_ASSERT_EQUALS(" subelement found", 0, a.getAttributeValues().size()); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - Attribute& a = dynamic_cast(*xo.get()); - assertEquals("AttributeName", expectedAttributeName, a.getAttributeName()); - assertEquals("AttributeNamespace", expectedAttributeNamespace, a.getAttributeNamespace()); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - Attribute& a = dynamic_cast(*xo.get()); - TSM_ASSERT_EQUALS("Number of subelements", 4, a.getAttributeValues().size()); - } - - void testSingleElementMarshall() { - assertEquals(expectedDOM, AttributeBuilder::buildAttribute()); - } - - void testSingleElementOptionalAttributesMarshall() { - Attribute* a=AttributeBuilder::buildAttribute(); - a->setAttributeName(expectedAttributeName); - a->setAttributeNamespace(expectedAttributeNamespace); - assertEquals(expectedOptionalAttributesDOM, a); - } - - void testChildElementsMarshall(){ - Attribute* a=AttributeBuilder::buildAttribute(); - - const XMLCh xsdstring[] = UNICODE_LITERAL_6(s,t,r,i,n,g); - - const XMLObjectBuilder* builder=XMLObjectBuilder::getBuilder(QName(SAMLConstants::SAML1_NS,AttributeValue::LOCAL_NAME)); - TS_ASSERT(builder!=NULL); - QName xsitype(XMLConstants::XSD_NS,xsdstring,XMLConstants::XSD_PREFIX); - for (int i=0; i<4; i++) - a->getAttributeValues().push_back(builder->buildObject(SAMLConstants::SAML1_NS, AttributeValue::LOCAL_NAME, SAMLConstants::SAML1_PREFIX, &xsitype)); - - assertEquals(expectedChildElementsDOM, a); - } -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include + +using namespace opensaml::saml1; + +class AttributeTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedAttributeName; + XMLCh* expectedAttributeNamespace; + +public: + void setUp() { + expectedAttributeName=XMLString::transcode("AttributeName"); + expectedAttributeNamespace=XMLString::transcode("namespace"); + singleElementFile = data_path + "saml1/core/impl/singleAttribute.xml"; + singleElementOptionalAttributesFile = data_path + "saml1/core/impl/singleAttributeAttributes.xml"; + childElementsFile = data_path + "saml1/core/impl/AttributeWithChildren.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedAttributeName); + XMLString::release(&expectedAttributeNamespace); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + Attribute& a = dynamic_cast(*xo.get()); + TSM_ASSERT("AttributeName", a.getAttributeName()==NULL); + TSM_ASSERT("AttributeNamespace", a.getAttributeNamespace()==NULL); + TSM_ASSERT_EQUALS(" subelement found", 0, a.getAttributeValues().size()); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + Attribute& a = dynamic_cast(*xo.get()); + assertEquals("AttributeName", expectedAttributeName, a.getAttributeName()); + assertEquals("AttributeNamespace", expectedAttributeNamespace, a.getAttributeNamespace()); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + Attribute& a = dynamic_cast(*xo.get()); + TSM_ASSERT_EQUALS("Number of subelements", 4, a.getAttributeValues().size()); + } + + void testSingleElementMarshall() { + assertEquals(expectedDOM, AttributeBuilder::buildAttribute()); + } + + void testSingleElementOptionalAttributesMarshall() { + Attribute* a=AttributeBuilder::buildAttribute(); + a->setAttributeName(expectedAttributeName); + a->setAttributeNamespace(expectedAttributeNamespace); + assertEquals(expectedOptionalAttributesDOM, a); + } + + void testChildElementsMarshall(){ + Attribute* a=AttributeBuilder::buildAttribute(); + + const XMLCh xsdstring[] = UNICODE_LITERAL_6(s,t,r,i,n,g); + + const XMLObjectBuilder* builder=XMLObjectBuilder::getBuilder(QName(SAMLConstants::SAML1_NS,AttributeValue::LOCAL_NAME)); + TS_ASSERT(builder!=NULL); + QName xsitype(XMLConstants::XSD_NS,xsdstring,XMLConstants::XSD_PREFIX); + for (int i=0; i<4; i++) + a->getAttributeValues().push_back(builder->buildObject(SAMLConstants::SAML1_NS, AttributeValue::LOCAL_NAME, SAMLConstants::SAML1_PREFIX, &xsitype)); + + assertEquals(expectedChildElementsDOM, a); + } +}; diff --git a/samltest/saml1/core/impl/AudienceRestrictionConditionTest.h b/samltest/saml1/core/impl/AudienceRestrictionConditionTest.h index afacde3..8278ebc 100644 --- a/samltest/saml1/core/impl/AudienceRestrictionConditionTest.h +++ b/samltest/saml1/core/impl/AudienceRestrictionConditionTest.h @@ -1,56 +1,56 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include - -using namespace opensaml::saml1; - -class AudienceRestrictionConditionTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { -public: - void setUp() { - singleElementFile = data_path + "saml1/core/impl/singleAudienceRestrictionCondition.xml"; - childElementsFile = data_path + "saml1/core/impl/AudienceRestrictionConditionWithChildren.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - AudienceRestrictionCondition& a = dynamic_cast(*xo.get()); - TSM_ASSERT_EQUALS("Count of child Audience elements !=0", 0, a.getAudiences().size()); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - AudienceRestrictionCondition& a = dynamic_cast(*xo.get()); - TSM_ASSERT_EQUALS("Count of child Audience elements", 2, a.getAudiences().size()); - } - - void testSingleElementMarshall() { - assertEquals(expectedDOM, AudienceRestrictionConditionBuilder::buildAudienceRestrictionCondition()); - } - - void testChildElementsMarshall(){ - AudienceRestrictionCondition* a=AudienceRestrictionConditionBuilder::buildAudienceRestrictionCondition(); - a->getAudiences().push_back(AudienceBuilder::buildAudience()); - a->getAudiences().push_back(AudienceBuilder::buildAudience()); - assertEquals(expectedChildElementsDOM, a); - } -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include + +using namespace opensaml::saml1; + +class AudienceRestrictionConditionTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { +public: + void setUp() { + singleElementFile = data_path + "saml1/core/impl/singleAudienceRestrictionCondition.xml"; + childElementsFile = data_path + "saml1/core/impl/AudienceRestrictionConditionWithChildren.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + AudienceRestrictionCondition& a = dynamic_cast(*xo.get()); + TSM_ASSERT_EQUALS("Count of child Audience elements !=0", 0, a.getAudiences().size()); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + AudienceRestrictionCondition& a = dynamic_cast(*xo.get()); + TSM_ASSERT_EQUALS("Count of child Audience elements", 2, a.getAudiences().size()); + } + + void testSingleElementMarshall() { + assertEquals(expectedDOM, AudienceRestrictionConditionBuilder::buildAudienceRestrictionCondition()); + } + + void testChildElementsMarshall(){ + AudienceRestrictionCondition* a=AudienceRestrictionConditionBuilder::buildAudienceRestrictionCondition(); + a->getAudiences().push_back(AudienceBuilder::buildAudience()); + a->getAudiences().push_back(AudienceBuilder::buildAudience()); + assertEquals(expectedChildElementsDOM, a); + } +}; diff --git a/samltest/saml1/core/impl/AudienceTest.h b/samltest/saml1/core/impl/AudienceTest.h index 1a95e35..ca58c18 100644 --- a/samltest/saml1/core/impl/AudienceTest.h +++ b/samltest/saml1/core/impl/AudienceTest.h @@ -1,60 +1,60 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include - -using namespace opensaml::saml1; - -class AudienceTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* expectedUri; - -public: - void setUp() { - expectedUri=XMLString::transcode("urn:oasis:names:tc:SAML:1.0:assertion"); - singleElementFile = data_path + "saml1/core/impl/singleAudience.xml"; - singleElementOptionalAttributesFile = data_path + "saml1/core/impl/singleAudienceAttributes.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&expectedUri); - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - Audience& a = dynamic_cast(*xo.get()); - TSM_ASSERT("Uri is non-null", a.getAudienceURI()==NULL); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - Audience& a = dynamic_cast(*xo.get()); - assertEquals("Uri", expectedUri, a.getAudienceURI()); - } - - void testSingleElementMarshall() { - assertEquals(expectedDOM, AudienceBuilder::buildAudience()); - } - - void testSingleElementOptionalAttributesMarshall() { - Audience* a=AudienceBuilder::buildAudience(); - a->setAudienceURI(expectedUri); - assertEquals(expectedOptionalAttributesDOM, a); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include + +using namespace opensaml::saml1; + +class AudienceTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedUri; + +public: + void setUp() { + expectedUri=XMLString::transcode("urn:oasis:names:tc:SAML:1.0:assertion"); + singleElementFile = data_path + "saml1/core/impl/singleAudience.xml"; + singleElementOptionalAttributesFile = data_path + "saml1/core/impl/singleAudienceAttributes.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedUri); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + Audience& a = dynamic_cast(*xo.get()); + TSM_ASSERT("Uri is non-null", a.getAudienceURI()==NULL); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + Audience& a = dynamic_cast(*xo.get()); + assertEquals("Uri", expectedUri, a.getAudienceURI()); + } + + void testSingleElementMarshall() { + assertEquals(expectedDOM, AudienceBuilder::buildAudience()); + } + + void testSingleElementOptionalAttributesMarshall() { + Audience* a=AudienceBuilder::buildAudience(); + a->setAudienceURI(expectedUri); + assertEquals(expectedOptionalAttributesDOM, a); + } + +}; diff --git a/samltest/saml1/core/impl/AuthenticationStatementTest.h b/samltest/saml1/core/impl/AuthenticationStatementTest.h index 0bf3df1..e7689c7 100644 --- a/samltest/saml1/core/impl/AuthenticationStatementTest.h +++ b/samltest/saml1/core/impl/AuthenticationStatementTest.h @@ -1,96 +1,96 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include - -using namespace opensaml::saml1; - -class AuthenticationStatementTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* expectedAuthenticationMethod; - XMLCh* expectedAuthenticationInstant; - -public: - void setUp() { - expectedAuthenticationInstant=XMLString::transcode("1970-01-02T01:01:02.123Z"); - expectedAuthenticationMethod=XMLString::transcode("trustme"); - singleElementFile = data_path + "saml1/core/impl/singleAuthenticationStatement.xml"; - singleElementOptionalAttributesFile = data_path + "saml1/core/impl/singleAuthenticationStatementAttributes.xml"; - childElementsFile = data_path + "saml1/core/impl/AuthenticationStatementWithChildren.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&expectedAuthenticationInstant); - XMLString::release(&expectedAuthenticationMethod); - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - AuthenticationStatement& as = dynamic_cast(*xo.get()); - TSM_ASSERT("AuthenticationMethod attribute present", as.getAuthenticationMethod()==NULL); - TSM_ASSERT("AuthenticationInstant attribute present", as.getAuthenticationInstant()==NULL); - - TSM_ASSERT("Subject element", as.getSubject()==NULL); - TSM_ASSERT("SubjectLocality element", as.getSubjectLocality()==NULL); - TSM_ASSERT_EQUALS("AuthorityBinding element count", 0, as.getAuthorityBindings().size()); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - AuthenticationStatement& as = dynamic_cast(*xo.get()); - - assertEquals("AuthenticationMethod attribute", expectedAuthenticationMethod, as.getAuthenticationMethod()); - assertEquals("AuthenticationInstant attribute", expectedAuthenticationInstant, as.getAuthenticationInstant()->getRawData()); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - AuthenticationStatement& as1 = dynamic_cast(*xo.get()); - as1.releaseThisAndChildrenDOM(); - auto_ptr as2(as1.cloneAuthenticationStatement()); - AuthenticationStatement& as=*as2.get(); - - TSM_ASSERT("Subject element", as.getSubject()!=NULL); - TSM_ASSERT("SubjectLocality element", as.getSubjectLocality()!=NULL); - - TSM_ASSERT_EQUALS("AuthorityBinding element count", 2, as.getAuthorityBindings().size()); - as.getAuthorityBindings().erase(as.getAuthorityBindings().begin()); - TSM_ASSERT_EQUALS("AuthorityBinding element count", 1, as.getAuthorityBindings().size()); - } - - void testSingleElementMarshall() { - assertEquals(expectedDOM, AuthenticationStatementBuilder::buildAuthenticationStatement()); - } - - void testSingleElementOptionalAttributesMarshall() { - AuthenticationStatement* as=AuthenticationStatementBuilder::buildAuthenticationStatement(); - as->setAuthenticationInstant(expectedAuthenticationInstant); - as->setAuthenticationMethod(expectedAuthenticationMethod); - assertEquals(expectedOptionalAttributesDOM, as); - } - - void testChildElementsMarshall() { - AuthenticationStatement* as=AuthenticationStatementBuilder::buildAuthenticationStatement(); - as->setSubject(SubjectBuilder::buildSubject()); - as->setSubjectLocality(SubjectLocalityBuilder::buildSubjectLocality()); - as->getAuthorityBindings().push_back(AuthorityBindingBuilder::buildAuthorityBinding()); - as->getAuthorityBindings().push_back(AuthorityBindingBuilder::buildAuthorityBinding()); - assertEquals(expectedChildElementsDOM, as); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include + +using namespace opensaml::saml1; + +class AuthenticationStatementTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedAuthenticationMethod; + XMLCh* expectedAuthenticationInstant; + +public: + void setUp() { + expectedAuthenticationInstant=XMLString::transcode("1970-01-02T01:01:02.123Z"); + expectedAuthenticationMethod=XMLString::transcode("trustme"); + singleElementFile = data_path + "saml1/core/impl/singleAuthenticationStatement.xml"; + singleElementOptionalAttributesFile = data_path + "saml1/core/impl/singleAuthenticationStatementAttributes.xml"; + childElementsFile = data_path + "saml1/core/impl/AuthenticationStatementWithChildren.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedAuthenticationInstant); + XMLString::release(&expectedAuthenticationMethod); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + AuthenticationStatement& as = dynamic_cast(*xo.get()); + TSM_ASSERT("AuthenticationMethod attribute present", as.getAuthenticationMethod()==NULL); + TSM_ASSERT("AuthenticationInstant attribute present", as.getAuthenticationInstant()==NULL); + + TSM_ASSERT("Subject element", as.getSubject()==NULL); + TSM_ASSERT("SubjectLocality element", as.getSubjectLocality()==NULL); + TSM_ASSERT_EQUALS("AuthorityBinding element count", 0, as.getAuthorityBindings().size()); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + AuthenticationStatement& as = dynamic_cast(*xo.get()); + + assertEquals("AuthenticationMethod attribute", expectedAuthenticationMethod, as.getAuthenticationMethod()); + assertEquals("AuthenticationInstant attribute", expectedAuthenticationInstant, as.getAuthenticationInstant()->getRawData()); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + AuthenticationStatement& as1 = dynamic_cast(*xo.get()); + as1.releaseThisAndChildrenDOM(); + auto_ptr as2(as1.cloneAuthenticationStatement()); + AuthenticationStatement& as=*as2.get(); + + TSM_ASSERT("Subject element", as.getSubject()!=NULL); + TSM_ASSERT("SubjectLocality element", as.getSubjectLocality()!=NULL); + + TSM_ASSERT_EQUALS("AuthorityBinding element count", 2, as.getAuthorityBindings().size()); + as.getAuthorityBindings().erase(as.getAuthorityBindings().begin()); + TSM_ASSERT_EQUALS("AuthorityBinding element count", 1, as.getAuthorityBindings().size()); + } + + void testSingleElementMarshall() { + assertEquals(expectedDOM, AuthenticationStatementBuilder::buildAuthenticationStatement()); + } + + void testSingleElementOptionalAttributesMarshall() { + AuthenticationStatement* as=AuthenticationStatementBuilder::buildAuthenticationStatement(); + as->setAuthenticationInstant(expectedAuthenticationInstant); + as->setAuthenticationMethod(expectedAuthenticationMethod); + assertEquals(expectedOptionalAttributesDOM, as); + } + + void testChildElementsMarshall() { + AuthenticationStatement* as=AuthenticationStatementBuilder::buildAuthenticationStatement(); + as->setSubject(SubjectBuilder::buildSubject()); + as->setSubjectLocality(SubjectLocalityBuilder::buildSubjectLocality()); + as->getAuthorityBindings().push_back(AuthorityBindingBuilder::buildAuthorityBinding()); + as->getAuthorityBindings().push_back(AuthorityBindingBuilder::buildAuthorityBinding()); + assertEquals(expectedChildElementsDOM, as); + } + +}; diff --git a/samltest/saml2/binding/SAML2ArtifactTest.h b/samltest/saml2/binding/SAML2ArtifactTest.h index 1d08453..ea5717f 100644 --- a/samltest/saml2/binding/SAML2ArtifactTest.h +++ b/samltest/saml2/binding/SAML2ArtifactTest.h @@ -1,145 +1,145 @@ -/* - * Copyright 2001-2005 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "binding.h" - -#include -#include -#include -#include - -using namespace opensaml::saml2p; -using namespace opensaml::saml2; - -class SAML2ArtifactTest : public CxxTest::TestSuite, - public SAMLBindingBaseTestCase, public MessageEncoder::ArtifactGenerator, public MessageDecoder::ArtifactResolver { -public: - void setUp() { - m_fields.clear(); - SAMLBindingBaseTestCase::setUp(); - } - - void tearDown() { - m_fields.clear(); - SAMLBindingBaseTestCase::tearDown(); - } - - void testSAML2Artifact() { - try { - // Read message to use from file. - string path = data_path + "saml2/binding/SAML2Response.xml"; - ifstream in(path.c_str()); - DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); - XercesJanitor janitor(doc); - auto_ptr toSend( - dynamic_cast(XMLObjectBuilder::buildOneFromElement(doc->getDocumentElement(),true)) - ); - janitor.release(); - - // Freshen timestamp. - toSend->setIssueInstant(time(NULL)); - - // Encode message. - auto_ptr encoder(SAMLConfig::getConfig().MessageEncoderManager.newPlugin(SAML2_ARTIFACT_ENCODER, NULL)); - encoder->setArtifactGenerator(this); - encoder->encode(m_fields,toSend.get(),"https://sp.example.org/","state",m_creds); - toSend.release(); - - // Decode message. - string relayState; - const RoleDescriptor* issuer=NULL; - bool trusted=false; - QName idprole(SAMLConstants::SAML20MD_NS, IDPSSODescriptor::LOCAL_NAME); - auto_ptr decoder(SAMLConfig::getConfig().MessageDecoderManager.newPlugin(SAML2_ARTIFACT_DECODER, NULL)); - decoder->setArtifactResolver(this); - Locker locker(m_metadata); - auto_ptr response( - dynamic_cast( - decoder->decode(relayState,issuer,trusted,*this,m_metadata,&idprole,m_trust) - ) - ); - - // Test the results. - TSM_ASSERT_EQUALS("RelayState was not the expected result.", relayState, "state"); - TSM_ASSERT("SAML Response not decoded successfully.", response.get()); - TSM_ASSERT("Message was not verified.", issuer && trusted); - auto_ptr_char entityID(dynamic_cast(issuer->getParent())->getEntityID()); - TSM_ASSERT("Issuer was not expected.", !strcmp(entityID.get(),"https://idp.example.org/")); - TSM_ASSERT_EQUALS("Assertion count was not correct.", response->getAssertions().size(), 1); - - // Trigger a replay. - TSM_ASSERT_THROWS("Did not catch the replay.", - decoder->decode(relayState,issuer,trusted,*this,m_metadata,&idprole,m_trust), - BindingException); - } - catch (XMLToolingException& ex) { - TS_TRACE(ex.what()); - throw; - } - } - - const char* getMethod() const { - return "GET"; - } - - const char* getRequestURL() const { - return "https://sp.example.org/SAML/Artifact"; - } - - const char* getQueryString() const { - return NULL; - } - - SAMLArtifact* generateSAML1Artifact(const char* relyingParty) const { - throw BindingException("Not implemented."); - } - - saml2p::SAML2Artifact* generateSAML2Artifact(const char* relyingParty) const { - return new SAML2ArtifactType0004(SAMLConfig::getConfig().hashSHA1("https://idp.example.org/"),1); - } - - saml1p::Response* resolve( - bool& authenticated, - const vector& artifacts, - const IDPSSODescriptor& idpDescriptor, - const X509TrustEngine* trustEngine=NULL - ) const { - throw BindingException("Not implemented."); - } - - ArtifactResponse* resolve( - bool& authenticated, - const SAML2Artifact& artifact, - const SSODescriptorType& ssoDescriptor, - const X509TrustEngine* trustEngine=NULL - ) const { - XMLObject* xmlObject = - SAMLConfig::getConfig().getArtifactMap()->retrieveContent(&artifact, "https://sp.example.org/"); - Response* payload = dynamic_cast(xmlObject); - TSM_ASSERT("Not a response.", payload!=NULL); - auto_ptr response(ArtifactResponseBuilder::buildArtifactResponse()); - response->setPayload(payload); - Status* status = StatusBuilder::buildStatus(); - response->setStatus(status); - StatusCode* sc = StatusCodeBuilder::buildStatusCode(); - status->setStatusCode(sc); - sc->setValue(StatusCode::SUCCESS); - response->marshall(); - SchemaValidators.validate(response.get()); - authenticated = true; - return response.release(); - } -}; +/* + * Copyright 2001-2005 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "binding.h" + +#include +#include +#include +#include + +using namespace opensaml::saml2p; +using namespace opensaml::saml2; + +class SAML2ArtifactTest : public CxxTest::TestSuite, + public SAMLBindingBaseTestCase, public MessageEncoder::ArtifactGenerator, public MessageDecoder::ArtifactResolver { +public: + void setUp() { + m_fields.clear(); + SAMLBindingBaseTestCase::setUp(); + } + + void tearDown() { + m_fields.clear(); + SAMLBindingBaseTestCase::tearDown(); + } + + void testSAML2Artifact() { + try { + // Read message to use from file. + string path = data_path + "saml2/binding/SAML2Response.xml"; + ifstream in(path.c_str()); + DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); + XercesJanitor janitor(doc); + auto_ptr toSend( + dynamic_cast(XMLObjectBuilder::buildOneFromElement(doc->getDocumentElement(),true)) + ); + janitor.release(); + + // Freshen timestamp. + toSend->setIssueInstant(time(NULL)); + + // Encode message. + auto_ptr encoder(SAMLConfig::getConfig().MessageEncoderManager.newPlugin(SAML2_ARTIFACT_ENCODER, NULL)); + encoder->setArtifactGenerator(this); + encoder->encode(m_fields,toSend.get(),"https://sp.example.org/","state",m_creds); + toSend.release(); + + // Decode message. + string relayState; + const RoleDescriptor* issuer=NULL; + bool trusted=false; + QName idprole(SAMLConstants::SAML20MD_NS, IDPSSODescriptor::LOCAL_NAME); + auto_ptr decoder(SAMLConfig::getConfig().MessageDecoderManager.newPlugin(SAML2_ARTIFACT_DECODER, NULL)); + decoder->setArtifactResolver(this); + Locker locker(m_metadata); + auto_ptr response( + dynamic_cast( + decoder->decode(relayState,issuer,trusted,*this,m_metadata,&idprole,m_trust) + ) + ); + + // Test the results. + TSM_ASSERT_EQUALS("RelayState was not the expected result.", relayState, "state"); + TSM_ASSERT("SAML Response not decoded successfully.", response.get()); + TSM_ASSERT("Message was not verified.", issuer && trusted); + auto_ptr_char entityID(dynamic_cast(issuer->getParent())->getEntityID()); + TSM_ASSERT("Issuer was not expected.", !strcmp(entityID.get(),"https://idp.example.org/")); + TSM_ASSERT_EQUALS("Assertion count was not correct.", response->getAssertions().size(), 1); + + // Trigger a replay. + TSM_ASSERT_THROWS("Did not catch the replay.", + decoder->decode(relayState,issuer,trusted,*this,m_metadata,&idprole,m_trust), + BindingException); + } + catch (XMLToolingException& ex) { + TS_TRACE(ex.what()); + throw; + } + } + + const char* getMethod() const { + return "GET"; + } + + const char* getRequestURL() const { + return "https://sp.example.org/SAML/Artifact"; + } + + const char* getQueryString() const { + return NULL; + } + + SAMLArtifact* generateSAML1Artifact(const char* relyingParty) const { + throw BindingException("Not implemented."); + } + + saml2p::SAML2Artifact* generateSAML2Artifact(const char* relyingParty) const { + return new SAML2ArtifactType0004(SAMLConfig::getConfig().hashSHA1("https://idp.example.org/"),1); + } + + saml1p::Response* resolve( + bool& authenticated, + const vector& artifacts, + const IDPSSODescriptor& idpDescriptor, + const X509TrustEngine* trustEngine=NULL + ) const { + throw BindingException("Not implemented."); + } + + ArtifactResponse* resolve( + bool& authenticated, + const SAML2Artifact& artifact, + const SSODescriptorType& ssoDescriptor, + const X509TrustEngine* trustEngine=NULL + ) const { + XMLObject* xmlObject = + SAMLConfig::getConfig().getArtifactMap()->retrieveContent(&artifact, "https://sp.example.org/"); + Response* payload = dynamic_cast(xmlObject); + TSM_ASSERT("Not a response.", payload!=NULL); + auto_ptr response(ArtifactResponseBuilder::buildArtifactResponse()); + response->setPayload(payload); + Status* status = StatusBuilder::buildStatus(); + response->setStatus(status); + StatusCode* sc = StatusCodeBuilder::buildStatusCode(); + status->setStatusCode(sc); + sc->setValue(StatusCode::SUCCESS); + response->marshall(); + SchemaValidators.validate(response.get()); + authenticated = true; + return response.release(); + } +}; diff --git a/samltest/saml2/binding/SAML2POSTTest.h b/samltest/saml2/binding/SAML2POSTTest.h index 4e2ed8e..c4addc7 100644 --- a/samltest/saml2/binding/SAML2POSTTest.h +++ b/samltest/saml2/binding/SAML2POSTTest.h @@ -1,147 +1,147 @@ -/* - * Copyright 2001-2005 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "binding.h" - -#include - -using namespace opensaml::saml2p; -using namespace opensaml::saml2; - -class SAML2POSTTest : public CxxTest::TestSuite, public SAMLBindingBaseTestCase { -public: - void setUp() { - m_fields.clear(); - SAMLBindingBaseTestCase::setUp(); - } - - void tearDown() { - m_fields.clear(); - SAMLBindingBaseTestCase::tearDown(); - } - - void testSAML2POSTTrusted() { - try { - // Read message to use from file. - string path = data_path + "saml2/binding/SAML2Response.xml"; - ifstream in(path.c_str()); - DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); - XercesJanitor janitor(doc); - auto_ptr toSend( - dynamic_cast(XMLObjectBuilder::buildOneFromElement(doc->getDocumentElement(),true)) - ); - janitor.release(); - - // Freshen timestamp. - toSend->setIssueInstant(time(NULL)); - - // Encode message. - auto_ptr encoder(SAMLConfig::getConfig().MessageEncoderManager.newPlugin(SAML2_POST_ENCODER, NULL)); - encoder->encode(m_fields,toSend.get(),"https://sp.example.org/","state",m_creds); - toSend.release(); - - // Decode message. - string relayState; - const RoleDescriptor* issuer=NULL; - bool trusted=false; - QName idprole(SAMLConstants::SAML20MD_NS, IDPSSODescriptor::LOCAL_NAME); - auto_ptr decoder(SAMLConfig::getConfig().MessageDecoderManager.newPlugin(SAML2_POST_DECODER, NULL)); - Locker locker(m_metadata); - auto_ptr response( - dynamic_cast( - decoder->decode(relayState,issuer,trusted,*this,m_metadata,&idprole,m_trust) - ) - ); - - // Test the results. - TSM_ASSERT_EQUALS("RelayState was not the expected result.", relayState, "state"); - TSM_ASSERT("SAML Response not decoded successfully.", response.get()); - TSM_ASSERT("Message was not verified.", issuer && trusted); - auto_ptr_char entityID(dynamic_cast(issuer->getParent())->getEntityID()); - TSM_ASSERT("Issuer was not expected.", !strcmp(entityID.get(),"https://idp.example.org/")); - TSM_ASSERT_EQUALS("Assertion count was not correct.", response->getAssertions().size(), 1); - } - catch (XMLToolingException& ex) { - TS_TRACE(ex.what()); - throw; - } - } - - void testSAML2POSTUntrusted() { - try { - // Read message to use from file. - string path = data_path + "saml2/binding/SAML2Response.xml"; - ifstream in(path.c_str()); - DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); - XercesJanitor janitor(doc); - auto_ptr toSend( - dynamic_cast(XMLObjectBuilder::buildOneFromElement(doc->getDocumentElement(),true)) - ); - janitor.release(); - - // Freshen timestamp and clear ID. - toSend->setIssueInstant(time(NULL)); - toSend->setID(NULL); - - // Encode message. - auto_ptr encoder(SAMLConfig::getConfig().MessageEncoderManager.newPlugin(SAML2_POST_ENCODER, NULL)); - encoder->encode(m_fields,toSend.get(),"https://sp.example.org/","state"); - toSend.release(); - - // Decode message. - string relayState; - const RoleDescriptor* issuer=NULL; - bool trusted=false; - QName idprole(SAMLConstants::SAML20MD_NS, IDPSSODescriptor::LOCAL_NAME); - auto_ptr decoder(SAMLConfig::getConfig().MessageDecoderManager.newPlugin(SAML2_POST_DECODER, NULL)); - Locker locker(m_metadata); - auto_ptr response( - dynamic_cast( - decoder->decode(relayState,issuer,trusted,*this,m_metadata,&idprole) - ) - ); - - // Test the results. - TSM_ASSERT_EQUALS("RelayState was not the expected result.", relayState, "state"); - TSM_ASSERT("SAML Response not decoded successfully.", response.get()); - TSM_ASSERT("Message was verified.", issuer && !trusted); - auto_ptr_char entityID(dynamic_cast(issuer->getParent())->getEntityID()); - TSM_ASSERT("Issuer was not expected.", !strcmp(entityID.get(),"https://idp.example.org/")); - TSM_ASSERT_EQUALS("Assertion count was not correct.", response->getAssertions().size(), 1); - - // Trigger a replay. - TSM_ASSERT_THROWS("Did not catch the replay.", - decoder->decode(relayState,issuer,trusted,*this,m_metadata,&idprole,m_trust), - BindingException); - } - catch (XMLToolingException& ex) { - TS_TRACE(ex.what()); - throw; - } - } - - const char* getMethod() const { - return "POST"; - } - - const char* getRequestURL() const { - return "https://sp.example.org/SAML/POST"; - } - - const char* getQueryString() const { - return NULL; - } -}; +/* + * Copyright 2001-2005 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "binding.h" + +#include + +using namespace opensaml::saml2p; +using namespace opensaml::saml2; + +class SAML2POSTTest : public CxxTest::TestSuite, public SAMLBindingBaseTestCase { +public: + void setUp() { + m_fields.clear(); + SAMLBindingBaseTestCase::setUp(); + } + + void tearDown() { + m_fields.clear(); + SAMLBindingBaseTestCase::tearDown(); + } + + void testSAML2POSTTrusted() { + try { + // Read message to use from file. + string path = data_path + "saml2/binding/SAML2Response.xml"; + ifstream in(path.c_str()); + DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); + XercesJanitor janitor(doc); + auto_ptr toSend( + dynamic_cast(XMLObjectBuilder::buildOneFromElement(doc->getDocumentElement(),true)) + ); + janitor.release(); + + // Freshen timestamp. + toSend->setIssueInstant(time(NULL)); + + // Encode message. + auto_ptr encoder(SAMLConfig::getConfig().MessageEncoderManager.newPlugin(SAML2_POST_ENCODER, NULL)); + encoder->encode(m_fields,toSend.get(),"https://sp.example.org/","state",m_creds); + toSend.release(); + + // Decode message. + string relayState; + const RoleDescriptor* issuer=NULL; + bool trusted=false; + QName idprole(SAMLConstants::SAML20MD_NS, IDPSSODescriptor::LOCAL_NAME); + auto_ptr decoder(SAMLConfig::getConfig().MessageDecoderManager.newPlugin(SAML2_POST_DECODER, NULL)); + Locker locker(m_metadata); + auto_ptr response( + dynamic_cast( + decoder->decode(relayState,issuer,trusted,*this,m_metadata,&idprole,m_trust) + ) + ); + + // Test the results. + TSM_ASSERT_EQUALS("RelayState was not the expected result.", relayState, "state"); + TSM_ASSERT("SAML Response not decoded successfully.", response.get()); + TSM_ASSERT("Message was not verified.", issuer && trusted); + auto_ptr_char entityID(dynamic_cast(issuer->getParent())->getEntityID()); + TSM_ASSERT("Issuer was not expected.", !strcmp(entityID.get(),"https://idp.example.org/")); + TSM_ASSERT_EQUALS("Assertion count was not correct.", response->getAssertions().size(), 1); + } + catch (XMLToolingException& ex) { + TS_TRACE(ex.what()); + throw; + } + } + + void testSAML2POSTUntrusted() { + try { + // Read message to use from file. + string path = data_path + "saml2/binding/SAML2Response.xml"; + ifstream in(path.c_str()); + DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); + XercesJanitor janitor(doc); + auto_ptr toSend( + dynamic_cast(XMLObjectBuilder::buildOneFromElement(doc->getDocumentElement(),true)) + ); + janitor.release(); + + // Freshen timestamp and clear ID. + toSend->setIssueInstant(time(NULL)); + toSend->setID(NULL); + + // Encode message. + auto_ptr encoder(SAMLConfig::getConfig().MessageEncoderManager.newPlugin(SAML2_POST_ENCODER, NULL)); + encoder->encode(m_fields,toSend.get(),"https://sp.example.org/","state"); + toSend.release(); + + // Decode message. + string relayState; + const RoleDescriptor* issuer=NULL; + bool trusted=false; + QName idprole(SAMLConstants::SAML20MD_NS, IDPSSODescriptor::LOCAL_NAME); + auto_ptr decoder(SAMLConfig::getConfig().MessageDecoderManager.newPlugin(SAML2_POST_DECODER, NULL)); + Locker locker(m_metadata); + auto_ptr response( + dynamic_cast( + decoder->decode(relayState,issuer,trusted,*this,m_metadata,&idprole) + ) + ); + + // Test the results. + TSM_ASSERT_EQUALS("RelayState was not the expected result.", relayState, "state"); + TSM_ASSERT("SAML Response not decoded successfully.", response.get()); + TSM_ASSERT("Message was verified.", issuer && !trusted); + auto_ptr_char entityID(dynamic_cast(issuer->getParent())->getEntityID()); + TSM_ASSERT("Issuer was not expected.", !strcmp(entityID.get(),"https://idp.example.org/")); + TSM_ASSERT_EQUALS("Assertion count was not correct.", response->getAssertions().size(), 1); + + // Trigger a replay. + TSM_ASSERT_THROWS("Did not catch the replay.", + decoder->decode(relayState,issuer,trusted,*this,m_metadata,&idprole,m_trust), + BindingException); + } + catch (XMLToolingException& ex) { + TS_TRACE(ex.what()); + throw; + } + } + + const char* getMethod() const { + return "POST"; + } + + const char* getRequestURL() const { + return "https://sp.example.org/SAML/POST"; + } + + const char* getQueryString() const { + return NULL; + } +}; diff --git a/samltest/saml2/core/impl/Action20Test.h b/samltest/saml2/core/impl/Action20Test.h index 910a990..c40d980 100644 --- a/samltest/saml2/core/impl/Action20Test.h +++ b/samltest/saml2/core/impl/Action20Test.h @@ -1,61 +1,61 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2; - -class Action20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* expectedNamespace; - XMLCh* expectedContent; - -public: - void setUp() { - expectedNamespace = XMLString::transcode("urn:string:namespace"); - expectedContent = XMLString::transcode("someActionName"); - - singleElementFile = data_path + "saml2/core/impl/Action.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&expectedNamespace); - XMLString::release(&expectedContent); - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - Action* action = dynamic_cast(xo.get()); - TS_ASSERT(action!=NULL); - - assertEquals("Element content", expectedContent, action->getAction()); - assertEquals("Namespace attribute", expectedNamespace, action->getNamespace()); - } - - - void testSingleElementMarshall() { - Action* action = ActionBuilder::buildAction(); - TS_ASSERT(action!=NULL); - - action->setAction(expectedContent); - action->setNamespace(expectedNamespace); - assertEquals(expectedDOM, action); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +class Action20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedNamespace; + XMLCh* expectedContent; + +public: + void setUp() { + expectedNamespace = XMLString::transcode("urn:string:namespace"); + expectedContent = XMLString::transcode("someActionName"); + + singleElementFile = data_path + "saml2/core/impl/Action.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedNamespace); + XMLString::release(&expectedContent); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + Action* action = dynamic_cast(xo.get()); + TS_ASSERT(action!=NULL); + + assertEquals("Element content", expectedContent, action->getAction()); + assertEquals("Namespace attribute", expectedNamespace, action->getNamespace()); + } + + + void testSingleElementMarshall() { + Action* action = ActionBuilder::buildAction(); + TS_ASSERT(action!=NULL); + + action->setAction(expectedContent); + action->setNamespace(expectedNamespace); + assertEquals(expectedDOM, action); + } + +}; diff --git a/samltest/saml2/core/impl/Advice20Test.h b/samltest/saml2/core/impl/Advice20Test.h index 66e0c41..8aed1a2 100644 --- a/samltest/saml2/core/impl/Advice20Test.h +++ b/samltest/saml2/core/impl/Advice20Test.h @@ -1,89 +1,89 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2; - -class Advice20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - -//TODO test with some non-SAML Other children - -public: - void setUp() { - singleElementFile = data_path + "saml2/core/impl/Advice.xml"; - childElementsFile = data_path + "saml2/core/impl/AdviceChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - Advice* advice = dynamic_cast(xo.get()); - TS_ASSERT(advice!=NULL); - - TSM_ASSERT_EQUALS("# of AssertionIDRef child elements", 0, advice->getAssertionIDRefs().size()); - TSM_ASSERT_EQUALS("# of AssertionURIRef child elements", 0, advice->getAssertionURIRefs().size()); - TSM_ASSERT_EQUALS("# of Assertion child elements", 0, advice->getAssertions().size()); - TSM_ASSERT_EQUALS("# of EncryptedAssertion child elements", 0, advice->getEncryptedAssertions().size()); - TSM_ASSERT_EQUALS("# of Other child elements", 0, advice->getOthers().size()); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - Advice* advice= dynamic_cast(xo.get()); - TS_ASSERT(advice!=NULL); - - TSM_ASSERT_EQUALS("# of AssertionIDRef child elements", 3, advice->getAssertionIDRefs().size()); - TSM_ASSERT_EQUALS("# of AssertionURIRef child elements", 2, advice->getAssertionURIRefs().size()); - TSM_ASSERT_EQUALS("# of Assertion child elements", 2, advice->getAssertions().size()); - TSM_ASSERT_EQUALS("# of EncryptedAssertion child elements", 1, advice->getEncryptedAssertions().size()); - TSM_ASSERT_EQUALS("# of Other child elements", 0, advice->getOthers().size()); - } - - void testSingleElementMarshall() { - Advice* advice=AdviceBuilder::buildAdvice(); - assertEquals(expectedDOM, advice); - } - - void testChildElementsMarshall() { - Advice* advice=AdviceBuilder::buildAdvice(); - - Assertion* assertion1 = AssertionBuilder::buildAssertion(); - assertion1->setID(XMLString::transcode("abc123")); - assertion1->setIssueInstant(new DateTime(XMLString::transcode("2006-07-21T22:27:19Z"))); - - Assertion* assertion2 = AssertionBuilder::buildAssertion(); - assertion2->setID(XMLString::transcode("def456")); - assertion2->setIssueInstant(new DateTime(XMLString::transcode("2006-07-21T22:27:19Z"))); - - advice->getAssertionIDRefs().push_back(AssertionIDRefBuilder::buildAssertionIDRef()); - advice->getAssertionIDRefs().push_back(AssertionIDRefBuilder::buildAssertionIDRef()); - advice->getAssertionURIRefs().push_back(AssertionURIRefBuilder::buildAssertionURIRef()); - advice->getAssertionIDRefs().push_back(AssertionIDRefBuilder::buildAssertionIDRef()); - advice->getAssertionURIRefs().push_back(AssertionURIRefBuilder::buildAssertionURIRef()); - advice->getAssertions().push_back(assertion1); - advice->getEncryptedAssertions().push_back(EncryptedAssertionBuilder::buildEncryptedAssertion()); - advice->getAssertions().push_back(assertion2); - assertEquals(expectedChildElementsDOM, advice); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +class Advice20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + +//TODO test with some non-SAML Other children + +public: + void setUp() { + singleElementFile = data_path + "saml2/core/impl/Advice.xml"; + childElementsFile = data_path + "saml2/core/impl/AdviceChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + Advice* advice = dynamic_cast(xo.get()); + TS_ASSERT(advice!=NULL); + + TSM_ASSERT_EQUALS("# of AssertionIDRef child elements", 0, advice->getAssertionIDRefs().size()); + TSM_ASSERT_EQUALS("# of AssertionURIRef child elements", 0, advice->getAssertionURIRefs().size()); + TSM_ASSERT_EQUALS("# of Assertion child elements", 0, advice->getAssertions().size()); + TSM_ASSERT_EQUALS("# of EncryptedAssertion child elements", 0, advice->getEncryptedAssertions().size()); + TSM_ASSERT_EQUALS("# of Other child elements", 0, advice->getOthers().size()); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + Advice* advice= dynamic_cast(xo.get()); + TS_ASSERT(advice!=NULL); + + TSM_ASSERT_EQUALS("# of AssertionIDRef child elements", 3, advice->getAssertionIDRefs().size()); + TSM_ASSERT_EQUALS("# of AssertionURIRef child elements", 2, advice->getAssertionURIRefs().size()); + TSM_ASSERT_EQUALS("# of Assertion child elements", 2, advice->getAssertions().size()); + TSM_ASSERT_EQUALS("# of EncryptedAssertion child elements", 1, advice->getEncryptedAssertions().size()); + TSM_ASSERT_EQUALS("# of Other child elements", 0, advice->getOthers().size()); + } + + void testSingleElementMarshall() { + Advice* advice=AdviceBuilder::buildAdvice(); + assertEquals(expectedDOM, advice); + } + + void testChildElementsMarshall() { + Advice* advice=AdviceBuilder::buildAdvice(); + + Assertion* assertion1 = AssertionBuilder::buildAssertion(); + assertion1->setID(XMLString::transcode("abc123")); + assertion1->setIssueInstant(new DateTime(XMLString::transcode("2006-07-21T22:27:19Z"))); + + Assertion* assertion2 = AssertionBuilder::buildAssertion(); + assertion2->setID(XMLString::transcode("def456")); + assertion2->setIssueInstant(new DateTime(XMLString::transcode("2006-07-21T22:27:19Z"))); + + advice->getAssertionIDRefs().push_back(AssertionIDRefBuilder::buildAssertionIDRef()); + advice->getAssertionIDRefs().push_back(AssertionIDRefBuilder::buildAssertionIDRef()); + advice->getAssertionURIRefs().push_back(AssertionURIRefBuilder::buildAssertionURIRef()); + advice->getAssertionIDRefs().push_back(AssertionIDRefBuilder::buildAssertionIDRef()); + advice->getAssertionURIRefs().push_back(AssertionURIRefBuilder::buildAssertionURIRef()); + advice->getAssertions().push_back(assertion1); + advice->getEncryptedAssertions().push_back(EncryptedAssertionBuilder::buildEncryptedAssertion()); + advice->getAssertions().push_back(assertion2); + assertEquals(expectedChildElementsDOM, advice); + } + +}; diff --git a/samltest/saml2/core/impl/ArtifactResolve20Test.h b/samltest/saml2/core/impl/ArtifactResolve20Test.h index 670bdf2..25f6977 100644 --- a/samltest/saml2/core/impl/ArtifactResolve20Test.h +++ b/samltest/saml2/core/impl/ArtifactResolve20Test.h @@ -1,123 +1,123 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2p; -using namespace opensaml::saml2; - -class ArtifactResolve20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* expectedID; - XMLCh* expectedVersion; - XMLCh* expectedConsent; - XMLCh* expectedDestination; - DateTime* expectedIssueInstant; - -public: - void setUp() { - expectedID = XMLString::transcode("abc123");; - expectedVersion = XMLString::transcode("2.0"); - expectedConsent = XMLString::transcode("urn:string:consent"); - expectedDestination = XMLString::transcode("http://idp.example.org/endpoint"); - expectedIssueInstant = new DateTime(XMLString::transcode("2006-02-21T16:40:00.000Z")); - expectedIssueInstant->parseDateTime(); - - singleElementFile = data_path + "saml2/core/impl/ArtifactResolve.xml"; - singleElementOptionalAttributesFile = data_path + "saml2/core/impl/ArtifactResolveOptionalAttributes.xml"; - childElementsFile = data_path + "saml2/core/impl/ArtifactResolveChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&expectedID); - XMLString::release(&expectedVersion); - XMLString::release(&expectedConsent); - XMLString::release(&expectedDestination); - delete expectedIssueInstant; - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - ArtifactResolve* request = dynamic_cast(xo.get()); - TS_ASSERT(request!=NULL); - assertEquals("ID attribute", expectedID, request->getID()); - assertEquals("Version attribute", expectedVersion, request->getVersion()); - TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), request->getIssueInstant()->getEpoch()); - - TS_ASSERT(request->getIssuer()==NULL); - TS_ASSERT(request->getSignature()==NULL); - TS_ASSERT(request->getExtensions()==NULL); - TS_ASSERT(request->getArtifact()==NULL); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - ArtifactResolve* request = dynamic_cast(xo.get()); - TS_ASSERT(request!=NULL); - assertEquals("Consent attribute", expectedConsent, request->getConsent()); - assertEquals("Destination attribute", expectedDestination, request->getDestination()); - - TS_ASSERT(request->getIssuer()==NULL); - TS_ASSERT(request->getSignature()==NULL); - TS_ASSERT(request->getExtensions()==NULL); - TS_ASSERT(request->getArtifact()==NULL); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - ArtifactResolve* request= dynamic_cast(xo.get()); - TS_ASSERT(request!=NULL); - TS_ASSERT(request->getIssuer()!=NULL); - TS_ASSERT(request->getSignature()==NULL); - TS_ASSERT(request->getExtensions()==NULL); - TS_ASSERT(request->getArtifact()!=NULL); - } - - void testSingleElementMarshall() { - ArtifactResolve* request=ArtifactResolveBuilder::buildArtifactResolve(); - request->setID(expectedID); - request->setIssueInstant(expectedIssueInstant); - //request->setVersion(expectedVersion); - assertEquals(expectedDOM, request); - } - - void testSingleElementOptionalAttributesMarshall() { - ArtifactResolve* request=ArtifactResolveBuilder::buildArtifactResolve(); - request->setID(expectedID); - request->setIssueInstant(expectedIssueInstant); - //request->setVersion(expectedVersion); - request->setConsent(expectedConsent); - request->setDestination(expectedDestination); - assertEquals(expectedOptionalAttributesDOM, request); - } - - void testChildElementsMarshall() { - ArtifactResolve* request=ArtifactResolveBuilder::buildArtifactResolve(); - request->setID(expectedID); - request->setIssueInstant(expectedIssueInstant); - // Do this just so don't have to redeclare the saml namespace prefix on every child element in the control XML file - Namespace* ns = new Namespace(opensaml::SAMLConstants::SAML20_NS, opensaml::SAMLConstants::SAML20_PREFIX); - request->addNamespace(*ns); - request->setIssuer(IssuerBuilder::buildIssuer()); - request->setArtifact(ArtifactBuilder::buildArtifact()); - assertEquals(expectedChildElementsDOM, request); - delete ns; - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2p; +using namespace opensaml::saml2; + +class ArtifactResolve20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedID; + XMLCh* expectedVersion; + XMLCh* expectedConsent; + XMLCh* expectedDestination; + DateTime* expectedIssueInstant; + +public: + void setUp() { + expectedID = XMLString::transcode("abc123");; + expectedVersion = XMLString::transcode("2.0"); + expectedConsent = XMLString::transcode("urn:string:consent"); + expectedDestination = XMLString::transcode("http://idp.example.org/endpoint"); + expectedIssueInstant = new DateTime(XMLString::transcode("2006-02-21T16:40:00.000Z")); + expectedIssueInstant->parseDateTime(); + + singleElementFile = data_path + "saml2/core/impl/ArtifactResolve.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/ArtifactResolveOptionalAttributes.xml"; + childElementsFile = data_path + "saml2/core/impl/ArtifactResolveChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedID); + XMLString::release(&expectedVersion); + XMLString::release(&expectedConsent); + XMLString::release(&expectedDestination); + delete expectedIssueInstant; + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + ArtifactResolve* request = dynamic_cast(xo.get()); + TS_ASSERT(request!=NULL); + assertEquals("ID attribute", expectedID, request->getID()); + assertEquals("Version attribute", expectedVersion, request->getVersion()); + TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), request->getIssueInstant()->getEpoch()); + + TS_ASSERT(request->getIssuer()==NULL); + TS_ASSERT(request->getSignature()==NULL); + TS_ASSERT(request->getExtensions()==NULL); + TS_ASSERT(request->getArtifact()==NULL); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + ArtifactResolve* request = dynamic_cast(xo.get()); + TS_ASSERT(request!=NULL); + assertEquals("Consent attribute", expectedConsent, request->getConsent()); + assertEquals("Destination attribute", expectedDestination, request->getDestination()); + + TS_ASSERT(request->getIssuer()==NULL); + TS_ASSERT(request->getSignature()==NULL); + TS_ASSERT(request->getExtensions()==NULL); + TS_ASSERT(request->getArtifact()==NULL); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + ArtifactResolve* request= dynamic_cast(xo.get()); + TS_ASSERT(request!=NULL); + TS_ASSERT(request->getIssuer()!=NULL); + TS_ASSERT(request->getSignature()==NULL); + TS_ASSERT(request->getExtensions()==NULL); + TS_ASSERT(request->getArtifact()!=NULL); + } + + void testSingleElementMarshall() { + ArtifactResolve* request=ArtifactResolveBuilder::buildArtifactResolve(); + request->setID(expectedID); + request->setIssueInstant(expectedIssueInstant); + //request->setVersion(expectedVersion); + assertEquals(expectedDOM, request); + } + + void testSingleElementOptionalAttributesMarshall() { + ArtifactResolve* request=ArtifactResolveBuilder::buildArtifactResolve(); + request->setID(expectedID); + request->setIssueInstant(expectedIssueInstant); + //request->setVersion(expectedVersion); + request->setConsent(expectedConsent); + request->setDestination(expectedDestination); + assertEquals(expectedOptionalAttributesDOM, request); + } + + void testChildElementsMarshall() { + ArtifactResolve* request=ArtifactResolveBuilder::buildArtifactResolve(); + request->setID(expectedID); + request->setIssueInstant(expectedIssueInstant); + // Do this just so don't have to redeclare the saml namespace prefix on every child element in the control XML file + Namespace* ns = new Namespace(opensaml::SAMLConstants::SAML20_NS, opensaml::SAMLConstants::SAML20_PREFIX); + request->addNamespace(*ns); + request->setIssuer(IssuerBuilder::buildIssuer()); + request->setArtifact(ArtifactBuilder::buildArtifact()); + assertEquals(expectedChildElementsDOM, request); + delete ns; + } + +}; diff --git a/samltest/saml2/core/impl/ArtifactResponse20Test.h b/samltest/saml2/core/impl/ArtifactResponse20Test.h index 2e46e21..23a0017 100644 --- a/samltest/saml2/core/impl/ArtifactResponse20Test.h +++ b/samltest/saml2/core/impl/ArtifactResponse20Test.h @@ -1,155 +1,155 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2p; -using namespace opensaml::saml2; - -class ArtifactResponse20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* expectedID; - XMLCh* expectedInResponseTo; - XMLCh* expectedVersion; - XMLCh* expectedConsent; - XMLCh* expectedDestination; - DateTime* expectedIssueInstant; - - // The payload will be an AuthnRequest in this test. - // AuthnRequest marshaller autogenerates ID, Version and IssueInstant if they are NULL, - // so have to agree on something to put in the control XML - XMLCh* authnRequestID; - -public: - void setUp() { - expectedID = XMLString::transcode("def456"); - expectedInResponseTo = XMLString::transcode("abc123"); - expectedVersion = XMLString::transcode("2.0"); - expectedConsent = XMLString::transcode("urn:string:consent"); - expectedDestination = XMLString::transcode("http://sp.example.org/endpoint"); - expectedIssueInstant = new DateTime(XMLString::transcode("2006-02-21T16:40:00.000Z")); - expectedIssueInstant->parseDateTime(); - - authnRequestID = XMLString::transcode("test1"); - - singleElementFile = data_path + "saml2/core/impl/ArtifactResponse.xml"; - singleElementOptionalAttributesFile = data_path + "saml2/core/impl/ArtifactResponseOptionalAttributes.xml"; - childElementsFile = data_path + "saml2/core/impl/ArtifactResponseChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&expectedID); - XMLString::release(&expectedInResponseTo); - XMLString::release(&expectedVersion); - XMLString::release(&expectedConsent); - XMLString::release(&expectedDestination); - XMLString::release(&authnRequestID); - delete expectedIssueInstant; - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - ArtifactResponse* response = dynamic_cast(xo.get()); - TS_ASSERT(response!=NULL); - - assertEquals("ID attribute", expectedID, response->getID()); - assertEquals("Version attribute", expectedVersion, response->getVersion()); - TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), response->getIssueInstant()->getEpoch()); - - TS_ASSERT(response->getIssuer()==NULL); - TS_ASSERT(response->getSignature()==NULL); - TS_ASSERT(response->getExtensions()==NULL); - TS_ASSERT(response->getStatus()==NULL); - TS_ASSERT(response->getPayload()==NULL); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - ArtifactResponse* response = dynamic_cast(xo.get()); - TS_ASSERT(response!=NULL); - - assertEquals("Consent attribute", expectedConsent, response->getConsent()); - assertEquals("Destination attribute", expectedDestination, response->getDestination()); - assertEquals("InResponseTo attribute", expectedInResponseTo, response->getInResponseTo()); - - TS_ASSERT(response->getIssuer()==NULL); - TS_ASSERT(response->getSignature()==NULL); - TS_ASSERT(response->getExtensions()==NULL); - TS_ASSERT(response->getStatus()==NULL); - TS_ASSERT(response->getPayload()==NULL); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - ArtifactResponse* response= dynamic_cast(xo.get()); - TS_ASSERT(response!=NULL); - - TS_ASSERT(response->getIssuer()!=NULL); - TS_ASSERT(response->getSignature()==NULL); - TS_ASSERT(response->getExtensions()==NULL); - TS_ASSERT(response->getStatus()!=NULL); - TS_ASSERT(response->getPayload()!=NULL); - } - - void testSingleElementMarshall() { - ArtifactResponse* response = ArtifactResponseBuilder::buildArtifactResponse(); - TS_ASSERT(response!=NULL); - - response->setID(expectedID); - response->setIssueInstant(expectedIssueInstant); - //response->setVersion(expectedVersion); - assertEquals(expectedDOM, response); - } - - void testSingleElementOptionalAttributesMarshall() { - ArtifactResponse* response = ArtifactResponseBuilder::buildArtifactResponse(); - TS_ASSERT(response!=NULL); - - response->setID(expectedID); - response->setInResponseTo(expectedInResponseTo); - response->setIssueInstant(expectedIssueInstant); - //response->setVersion(expectedVersion); - response->setConsent(expectedConsent); - response->setDestination(expectedDestination); - response->setInResponseTo(expectedInResponseTo); - assertEquals(expectedOptionalAttributesDOM, response); - } - - void testChildElementsMarshall() { - ArtifactResponse* response = ArtifactResponseBuilder::buildArtifactResponse(); - TS_ASSERT(response!=NULL); - - response->setID(expectedID); - response->setIssueInstant(expectedIssueInstant); - // Do this just so don't have to redeclare the saml namespace prefix on every child element in the control XML file - Namespace* ns = new Namespace(opensaml::SAMLConstants::SAML20_NS, opensaml::SAMLConstants::SAML20_PREFIX); - response->addNamespace(*ns); - response->setIssuer(IssuerBuilder::buildIssuer()); - response->setStatus(StatusBuilder::buildStatus()); - - AuthnRequest* authnRequest = AuthnRequestBuilder::buildAuthnRequest(); - authnRequest->setIssueInstant(expectedIssueInstant); - authnRequest->setID(authnRequestID); - response->setPayload(authnRequest); - - assertEquals(expectedChildElementsDOM, response); - delete ns; - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2p; +using namespace opensaml::saml2; + +class ArtifactResponse20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedID; + XMLCh* expectedInResponseTo; + XMLCh* expectedVersion; + XMLCh* expectedConsent; + XMLCh* expectedDestination; + DateTime* expectedIssueInstant; + + // The payload will be an AuthnRequest in this test. + // AuthnRequest marshaller autogenerates ID, Version and IssueInstant if they are NULL, + // so have to agree on something to put in the control XML + XMLCh* authnRequestID; + +public: + void setUp() { + expectedID = XMLString::transcode("def456"); + expectedInResponseTo = XMLString::transcode("abc123"); + expectedVersion = XMLString::transcode("2.0"); + expectedConsent = XMLString::transcode("urn:string:consent"); + expectedDestination = XMLString::transcode("http://sp.example.org/endpoint"); + expectedIssueInstant = new DateTime(XMLString::transcode("2006-02-21T16:40:00.000Z")); + expectedIssueInstant->parseDateTime(); + + authnRequestID = XMLString::transcode("test1"); + + singleElementFile = data_path + "saml2/core/impl/ArtifactResponse.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/ArtifactResponseOptionalAttributes.xml"; + childElementsFile = data_path + "saml2/core/impl/ArtifactResponseChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedID); + XMLString::release(&expectedInResponseTo); + XMLString::release(&expectedVersion); + XMLString::release(&expectedConsent); + XMLString::release(&expectedDestination); + XMLString::release(&authnRequestID); + delete expectedIssueInstant; + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + ArtifactResponse* response = dynamic_cast(xo.get()); + TS_ASSERT(response!=NULL); + + assertEquals("ID attribute", expectedID, response->getID()); + assertEquals("Version attribute", expectedVersion, response->getVersion()); + TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), response->getIssueInstant()->getEpoch()); + + TS_ASSERT(response->getIssuer()==NULL); + TS_ASSERT(response->getSignature()==NULL); + TS_ASSERT(response->getExtensions()==NULL); + TS_ASSERT(response->getStatus()==NULL); + TS_ASSERT(response->getPayload()==NULL); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + ArtifactResponse* response = dynamic_cast(xo.get()); + TS_ASSERT(response!=NULL); + + assertEquals("Consent attribute", expectedConsent, response->getConsent()); + assertEquals("Destination attribute", expectedDestination, response->getDestination()); + assertEquals("InResponseTo attribute", expectedInResponseTo, response->getInResponseTo()); + + TS_ASSERT(response->getIssuer()==NULL); + TS_ASSERT(response->getSignature()==NULL); + TS_ASSERT(response->getExtensions()==NULL); + TS_ASSERT(response->getStatus()==NULL); + TS_ASSERT(response->getPayload()==NULL); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + ArtifactResponse* response= dynamic_cast(xo.get()); + TS_ASSERT(response!=NULL); + + TS_ASSERT(response->getIssuer()!=NULL); + TS_ASSERT(response->getSignature()==NULL); + TS_ASSERT(response->getExtensions()==NULL); + TS_ASSERT(response->getStatus()!=NULL); + TS_ASSERT(response->getPayload()!=NULL); + } + + void testSingleElementMarshall() { + ArtifactResponse* response = ArtifactResponseBuilder::buildArtifactResponse(); + TS_ASSERT(response!=NULL); + + response->setID(expectedID); + response->setIssueInstant(expectedIssueInstant); + //response->setVersion(expectedVersion); + assertEquals(expectedDOM, response); + } + + void testSingleElementOptionalAttributesMarshall() { + ArtifactResponse* response = ArtifactResponseBuilder::buildArtifactResponse(); + TS_ASSERT(response!=NULL); + + response->setID(expectedID); + response->setInResponseTo(expectedInResponseTo); + response->setIssueInstant(expectedIssueInstant); + //response->setVersion(expectedVersion); + response->setConsent(expectedConsent); + response->setDestination(expectedDestination); + response->setInResponseTo(expectedInResponseTo); + assertEquals(expectedOptionalAttributesDOM, response); + } + + void testChildElementsMarshall() { + ArtifactResponse* response = ArtifactResponseBuilder::buildArtifactResponse(); + TS_ASSERT(response!=NULL); + + response->setID(expectedID); + response->setIssueInstant(expectedIssueInstant); + // Do this just so don't have to redeclare the saml namespace prefix on every child element in the control XML file + Namespace* ns = new Namespace(opensaml::SAMLConstants::SAML20_NS, opensaml::SAMLConstants::SAML20_PREFIX); + response->addNamespace(*ns); + response->setIssuer(IssuerBuilder::buildIssuer()); + response->setStatus(StatusBuilder::buildStatus()); + + AuthnRequest* authnRequest = AuthnRequestBuilder::buildAuthnRequest(); + authnRequest->setIssueInstant(expectedIssueInstant); + authnRequest->setID(authnRequestID); + response->setPayload(authnRequest); + + assertEquals(expectedChildElementsDOM, response); + delete ns; + } + +}; diff --git a/samltest/saml2/core/impl/Assertion20Test.h b/samltest/saml2/core/impl/Assertion20Test.h index 4bd3ddb..0f28e4d 100644 --- a/samltest/saml2/core/impl/Assertion20Test.h +++ b/samltest/saml2/core/impl/Assertion20Test.h @@ -1,135 +1,135 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2; - -class Assertion20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - const XMLCh* expectedVersion; - XMLCh* expectedID; - DateTime* expectedIssueInstant; - -public: - void setUp() { - expectedVersion = SAMLConstants::SAML20_VERSION; - expectedID = XMLString::transcode("abc123"); - expectedIssueInstant = new DateTime(XMLString::transcode("1984-08-26T10:01:30.043Z")); - expectedIssueInstant->parseDateTime(); - - - singleElementFile = data_path + "saml2/core/impl/Assertion.xml"; - singleElementOptionalAttributesFile = data_path + "saml2/core/impl/AssertionOptionalAttributes.xml"; - childElementsFile = data_path + "saml2/core/impl/AssertionChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - delete expectedIssueInstant; - XMLString::release(&expectedID); - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - Assertion* assertion = dynamic_cast(xo.get()); - TS_ASSERT(assertion!=NULL); - - assertEquals("ID attribute", expectedID, assertion->getID()); - assertEquals("Version attribute", expectedVersion, assertion->getVersion()); - TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), assertion->getIssueInstant()->getEpoch()); - - TS_ASSERT(assertion->getIssuer()==NULL); - TS_ASSERT(assertion->getSignature()==NULL); - TS_ASSERT(assertion->getSubject()==NULL); - TS_ASSERT(assertion->getConditions()==NULL); - TS_ASSERT(assertion->getAdvice()==NULL); - - TSM_ASSERT_EQUALS("# of Statement child elements", 0, assertion->getStatements().size()); - TSM_ASSERT_EQUALS("# of AuthnStatement child elements", 0, assertion->getAuthnStatements().size()); - TSM_ASSERT_EQUALS("# of AttributeStatement child elements", 0, assertion->getAttributeStatements().size()); - TSM_ASSERT_EQUALS("# of AuthzDecisionStatement child elements", 0, assertion->getAuthzDecisionStatements().size()); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - Assertion* assertion= dynamic_cast(xo.get()); - TS_ASSERT(assertion!=NULL); - - assertEquals("ID attribute", expectedID, assertion->getID()); - assertEquals("Version attribute", expectedVersion, assertion->getVersion()); - TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), assertion->getIssueInstant()->getEpoch()); - - TS_ASSERT(assertion->getIssuer()!=NULL); - TS_ASSERT(assertion->getSignature()==NULL); - TS_ASSERT(assertion->getSubject()!=NULL); - TS_ASSERT(assertion->getConditions()!=NULL); - TS_ASSERT(assertion->getAdvice()!=NULL); - - TSM_ASSERT_EQUALS("# of Statement child elements", 0, assertion->getStatements().size()); - TSM_ASSERT_EQUALS("# of AuthnStatement child elements", 1, assertion->getAuthnStatements().size()); - TSM_ASSERT_EQUALS("# of AttributeStatement child elements", 3, assertion->getAttributeStatements().size()); - TSM_ASSERT_EQUALS("# of AuthzDecisionStatement child elements", 2, assertion->getAuthzDecisionStatements().size()); - } - - void testSingleElementMarshall() { - Assertion* assertion=AssertionBuilder::buildAssertion(); - assertion->setID(expectedID); - assertion->setIssueInstant(expectedIssueInstant); - assertEquals(expectedDOM, assertion); - } - - void testChildElementsMarshall() { - Assertion* assertion=AssertionBuilder::buildAssertion(); - assertion->setID(expectedID); - assertion->setIssueInstant(expectedIssueInstant); - assertion->setIssuer(IssuerBuilder::buildIssuer()); - assertion->setSubject(SubjectBuilder::buildSubject()); - assertion->setConditions(ConditionsBuilder::buildConditions()); - assertion->setAdvice(AdviceBuilder::buildAdvice()); - - //Test storing children as their direct type - assertion->getAuthnStatements().push_back(AuthnStatementBuilder::buildAuthnStatement()); - assertion->getAttributeStatements().push_back(AttributeStatementBuilder::buildAttributeStatement()); - assertion->getAttributeStatements().push_back(AttributeStatementBuilder::buildAttributeStatement()); - assertion->getAuthzDecisionStatements().push_back(AuthzDecisionStatementBuilder::buildAuthzDecisionStatement()); - assertion->getAuthzDecisionStatements().push_back(AuthzDecisionStatementBuilder::buildAuthzDecisionStatement()); - assertion->getAttributeStatements().push_back(AttributeStatementBuilder::buildAttributeStatement()); - assertEquals(expectedChildElementsDOM, assertion); - - // Note: assertEquals() above has already 'delete'-ed the XMLObject* it was passed - assertion=NULL; - assertion=AssertionBuilder::buildAssertion(); - assertion->setID(expectedID); - assertion->setIssueInstant(expectedIssueInstant); - assertion->setIssuer(IssuerBuilder::buildIssuer()); - assertion->setSubject(SubjectBuilder::buildSubject()); - assertion->setConditions(ConditionsBuilder::buildConditions()); - assertion->setAdvice(AdviceBuilder::buildAdvice()); - - //Test storing children as a Statement (each is a derived type of StatementAbstractType) - assertion->getStatements().push_back(AuthnStatementBuilder::buildAuthnStatement()); - assertion->getStatements().push_back(AttributeStatementBuilder::buildAttributeStatement()); - assertion->getStatements().push_back(AttributeStatementBuilder::buildAttributeStatement()); - assertion->getStatements().push_back(AuthzDecisionStatementBuilder::buildAuthzDecisionStatement()); - assertion->getStatements().push_back(AuthzDecisionStatementBuilder::buildAuthzDecisionStatement()); - assertion->getStatements().push_back(AttributeStatementBuilder::buildAttributeStatement()); - assertEquals(expectedChildElementsDOM, assertion); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +class Assertion20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + const XMLCh* expectedVersion; + XMLCh* expectedID; + DateTime* expectedIssueInstant; + +public: + void setUp() { + expectedVersion = SAMLConstants::SAML20_VERSION; + expectedID = XMLString::transcode("abc123"); + expectedIssueInstant = new DateTime(XMLString::transcode("1984-08-26T10:01:30.043Z")); + expectedIssueInstant->parseDateTime(); + + + singleElementFile = data_path + "saml2/core/impl/Assertion.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/AssertionOptionalAttributes.xml"; + childElementsFile = data_path + "saml2/core/impl/AssertionChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + delete expectedIssueInstant; + XMLString::release(&expectedID); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + Assertion* assertion = dynamic_cast(xo.get()); + TS_ASSERT(assertion!=NULL); + + assertEquals("ID attribute", expectedID, assertion->getID()); + assertEquals("Version attribute", expectedVersion, assertion->getVersion()); + TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), assertion->getIssueInstant()->getEpoch()); + + TS_ASSERT(assertion->getIssuer()==NULL); + TS_ASSERT(assertion->getSignature()==NULL); + TS_ASSERT(assertion->getSubject()==NULL); + TS_ASSERT(assertion->getConditions()==NULL); + TS_ASSERT(assertion->getAdvice()==NULL); + + TSM_ASSERT_EQUALS("# of Statement child elements", 0, assertion->getStatements().size()); + TSM_ASSERT_EQUALS("# of AuthnStatement child elements", 0, assertion->getAuthnStatements().size()); + TSM_ASSERT_EQUALS("# of AttributeStatement child elements", 0, assertion->getAttributeStatements().size()); + TSM_ASSERT_EQUALS("# of AuthzDecisionStatement child elements", 0, assertion->getAuthzDecisionStatements().size()); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + Assertion* assertion= dynamic_cast(xo.get()); + TS_ASSERT(assertion!=NULL); + + assertEquals("ID attribute", expectedID, assertion->getID()); + assertEquals("Version attribute", expectedVersion, assertion->getVersion()); + TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), assertion->getIssueInstant()->getEpoch()); + + TS_ASSERT(assertion->getIssuer()!=NULL); + TS_ASSERT(assertion->getSignature()==NULL); + TS_ASSERT(assertion->getSubject()!=NULL); + TS_ASSERT(assertion->getConditions()!=NULL); + TS_ASSERT(assertion->getAdvice()!=NULL); + + TSM_ASSERT_EQUALS("# of Statement child elements", 0, assertion->getStatements().size()); + TSM_ASSERT_EQUALS("# of AuthnStatement child elements", 1, assertion->getAuthnStatements().size()); + TSM_ASSERT_EQUALS("# of AttributeStatement child elements", 3, assertion->getAttributeStatements().size()); + TSM_ASSERT_EQUALS("# of AuthzDecisionStatement child elements", 2, assertion->getAuthzDecisionStatements().size()); + } + + void testSingleElementMarshall() { + Assertion* assertion=AssertionBuilder::buildAssertion(); + assertion->setID(expectedID); + assertion->setIssueInstant(expectedIssueInstant); + assertEquals(expectedDOM, assertion); + } + + void testChildElementsMarshall() { + Assertion* assertion=AssertionBuilder::buildAssertion(); + assertion->setID(expectedID); + assertion->setIssueInstant(expectedIssueInstant); + assertion->setIssuer(IssuerBuilder::buildIssuer()); + assertion->setSubject(SubjectBuilder::buildSubject()); + assertion->setConditions(ConditionsBuilder::buildConditions()); + assertion->setAdvice(AdviceBuilder::buildAdvice()); + + //Test storing children as their direct type + assertion->getAuthnStatements().push_back(AuthnStatementBuilder::buildAuthnStatement()); + assertion->getAttributeStatements().push_back(AttributeStatementBuilder::buildAttributeStatement()); + assertion->getAttributeStatements().push_back(AttributeStatementBuilder::buildAttributeStatement()); + assertion->getAuthzDecisionStatements().push_back(AuthzDecisionStatementBuilder::buildAuthzDecisionStatement()); + assertion->getAuthzDecisionStatements().push_back(AuthzDecisionStatementBuilder::buildAuthzDecisionStatement()); + assertion->getAttributeStatements().push_back(AttributeStatementBuilder::buildAttributeStatement()); + assertEquals(expectedChildElementsDOM, assertion); + + // Note: assertEquals() above has already 'delete'-ed the XMLObject* it was passed + assertion=NULL; + assertion=AssertionBuilder::buildAssertion(); + assertion->setID(expectedID); + assertion->setIssueInstant(expectedIssueInstant); + assertion->setIssuer(IssuerBuilder::buildIssuer()); + assertion->setSubject(SubjectBuilder::buildSubject()); + assertion->setConditions(ConditionsBuilder::buildConditions()); + assertion->setAdvice(AdviceBuilder::buildAdvice()); + + //Test storing children as a Statement (each is a derived type of StatementAbstractType) + assertion->getStatements().push_back(AuthnStatementBuilder::buildAuthnStatement()); + assertion->getStatements().push_back(AttributeStatementBuilder::buildAttributeStatement()); + assertion->getStatements().push_back(AttributeStatementBuilder::buildAttributeStatement()); + assertion->getStatements().push_back(AuthzDecisionStatementBuilder::buildAuthzDecisionStatement()); + assertion->getStatements().push_back(AuthzDecisionStatementBuilder::buildAuthzDecisionStatement()); + assertion->getStatements().push_back(AttributeStatementBuilder::buildAttributeStatement()); + assertEquals(expectedChildElementsDOM, assertion); + } + +}; diff --git a/samltest/saml2/core/impl/AssertionIDRequest20Test.h b/samltest/saml2/core/impl/AssertionIDRequest20Test.h index 8488000..6ec4172 100644 --- a/samltest/saml2/core/impl/AssertionIDRequest20Test.h +++ b/samltest/saml2/core/impl/AssertionIDRequest20Test.h @@ -1,125 +1,125 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2p; -using namespace opensaml::saml2; - -class AssertionIDRequest20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* expectedID; - XMLCh* expectedVersion; - XMLCh* expectedConsent; - XMLCh* expectedDestination; - DateTime* expectedIssueInstant; - -public: - void setUp() { - expectedID = XMLString::transcode("abc123");; - expectedVersion = XMLString::transcode("2.0"); - expectedConsent = XMLString::transcode("urn:string:consent"); - expectedDestination = XMLString::transcode("http://idp.example.org/endpoint"); - expectedIssueInstant = new DateTime(XMLString::transcode("2006-02-21T16:40:00.000Z")); - expectedIssueInstant->parseDateTime(); - - singleElementFile = data_path + "saml2/core/impl/AssertionIDRequest.xml"; - singleElementOptionalAttributesFile = data_path + "saml2/core/impl/AssertionIDRequestOptionalAttributes.xml"; - childElementsFile = data_path + "saml2/core/impl/AssertionIDRequestChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&expectedID); - XMLString::release(&expectedVersion); - XMLString::release(&expectedConsent); - XMLString::release(&expectedDestination); - delete expectedIssueInstant; - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - AssertionIDRequest* request = dynamic_cast(xo.get()); - TS_ASSERT(request!=NULL); - assertEquals("ID attribute", expectedID, request->getID()); - assertEquals("Version attribute", expectedVersion, request->getVersion()); - TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), request->getIssueInstant()->getEpoch()); - - TS_ASSERT(request->getIssuer()==NULL); - TS_ASSERT(request->getSignature()==NULL); - TS_ASSERT(request->getExtensions()==NULL); - TSM_ASSERT_EQUALS("# of AssertionIDRef child elements", 0, request->getAssertionIDRefs().size()); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - AssertionIDRequest* request = dynamic_cast(xo.get()); - TS_ASSERT(request!=NULL); - assertEquals("Consent attribute", expectedConsent, request->getConsent()); - assertEquals("Destination attribute", expectedDestination, request->getDestination()); - - TS_ASSERT(request->getIssuer()==NULL); - TS_ASSERT(request->getSignature()==NULL); - TS_ASSERT(request->getExtensions()==NULL); - TSM_ASSERT_EQUALS("# of AssertionIDRef child elements", 0, request->getAssertionIDRefs().size()); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - AssertionIDRequest* request= dynamic_cast(xo.get()); - TS_ASSERT(request!=NULL); - TS_ASSERT(request->getIssuer()!=NULL); - TS_ASSERT(request->getSignature()==NULL); - TS_ASSERT(request->getExtensions()==NULL); - TSM_ASSERT_EQUALS("# of AssertionIDRef child elements", 3, request->getAssertionIDRefs().size()); - } - - void testSingleElementMarshall() { - AssertionIDRequest* request=AssertionIDRequestBuilder::buildAssertionIDRequest(); - request->setID(expectedID); - request->setIssueInstant(expectedIssueInstant); - //request->setVersion(expectedVersion); - assertEquals(expectedDOM, request); - } - - void testSingleElementOptionalAttributesMarshall() { - AssertionIDRequest* request=AssertionIDRequestBuilder::buildAssertionIDRequest(); - request->setID(expectedID); - request->setIssueInstant(expectedIssueInstant); - //request->setVersion(expectedVersion); - request->setConsent(expectedConsent); - request->setDestination(expectedDestination); - assertEquals(expectedOptionalAttributesDOM, request); - } - - void testChildElementsMarshall() { - AssertionIDRequest* request=AssertionIDRequestBuilder::buildAssertionIDRequest(); - request->setID(expectedID); - request->setIssueInstant(expectedIssueInstant); - // Do this just so don't have to redeclare the saml namespace prefix on every child element in the control XML file - Namespace* ns = new Namespace(opensaml::SAMLConstants::SAML20_NS, opensaml::SAMLConstants::SAML20_PREFIX); - request->addNamespace(*ns); - request->setIssuer(IssuerBuilder::buildIssuer()); - request->getAssertionIDRefs().push_back(AssertionIDRefBuilder::buildAssertionIDRef()); - request->getAssertionIDRefs().push_back(AssertionIDRefBuilder::buildAssertionIDRef()); - request->getAssertionIDRefs().push_back(AssertionIDRefBuilder::buildAssertionIDRef()); - assertEquals(expectedChildElementsDOM, request); - delete ns; - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2p; +using namespace opensaml::saml2; + +class AssertionIDRequest20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedID; + XMLCh* expectedVersion; + XMLCh* expectedConsent; + XMLCh* expectedDestination; + DateTime* expectedIssueInstant; + +public: + void setUp() { + expectedID = XMLString::transcode("abc123");; + expectedVersion = XMLString::transcode("2.0"); + expectedConsent = XMLString::transcode("urn:string:consent"); + expectedDestination = XMLString::transcode("http://idp.example.org/endpoint"); + expectedIssueInstant = new DateTime(XMLString::transcode("2006-02-21T16:40:00.000Z")); + expectedIssueInstant->parseDateTime(); + + singleElementFile = data_path + "saml2/core/impl/AssertionIDRequest.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/AssertionIDRequestOptionalAttributes.xml"; + childElementsFile = data_path + "saml2/core/impl/AssertionIDRequestChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedID); + XMLString::release(&expectedVersion); + XMLString::release(&expectedConsent); + XMLString::release(&expectedDestination); + delete expectedIssueInstant; + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + AssertionIDRequest* request = dynamic_cast(xo.get()); + TS_ASSERT(request!=NULL); + assertEquals("ID attribute", expectedID, request->getID()); + assertEquals("Version attribute", expectedVersion, request->getVersion()); + TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), request->getIssueInstant()->getEpoch()); + + TS_ASSERT(request->getIssuer()==NULL); + TS_ASSERT(request->getSignature()==NULL); + TS_ASSERT(request->getExtensions()==NULL); + TSM_ASSERT_EQUALS("# of AssertionIDRef child elements", 0, request->getAssertionIDRefs().size()); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + AssertionIDRequest* request = dynamic_cast(xo.get()); + TS_ASSERT(request!=NULL); + assertEquals("Consent attribute", expectedConsent, request->getConsent()); + assertEquals("Destination attribute", expectedDestination, request->getDestination()); + + TS_ASSERT(request->getIssuer()==NULL); + TS_ASSERT(request->getSignature()==NULL); + TS_ASSERT(request->getExtensions()==NULL); + TSM_ASSERT_EQUALS("# of AssertionIDRef child elements", 0, request->getAssertionIDRefs().size()); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + AssertionIDRequest* request= dynamic_cast(xo.get()); + TS_ASSERT(request!=NULL); + TS_ASSERT(request->getIssuer()!=NULL); + TS_ASSERT(request->getSignature()==NULL); + TS_ASSERT(request->getExtensions()==NULL); + TSM_ASSERT_EQUALS("# of AssertionIDRef child elements", 3, request->getAssertionIDRefs().size()); + } + + void testSingleElementMarshall() { + AssertionIDRequest* request=AssertionIDRequestBuilder::buildAssertionIDRequest(); + request->setID(expectedID); + request->setIssueInstant(expectedIssueInstant); + //request->setVersion(expectedVersion); + assertEquals(expectedDOM, request); + } + + void testSingleElementOptionalAttributesMarshall() { + AssertionIDRequest* request=AssertionIDRequestBuilder::buildAssertionIDRequest(); + request->setID(expectedID); + request->setIssueInstant(expectedIssueInstant); + //request->setVersion(expectedVersion); + request->setConsent(expectedConsent); + request->setDestination(expectedDestination); + assertEquals(expectedOptionalAttributesDOM, request); + } + + void testChildElementsMarshall() { + AssertionIDRequest* request=AssertionIDRequestBuilder::buildAssertionIDRequest(); + request->setID(expectedID); + request->setIssueInstant(expectedIssueInstant); + // Do this just so don't have to redeclare the saml namespace prefix on every child element in the control XML file + Namespace* ns = new Namespace(opensaml::SAMLConstants::SAML20_NS, opensaml::SAMLConstants::SAML20_PREFIX); + request->addNamespace(*ns); + request->setIssuer(IssuerBuilder::buildIssuer()); + request->getAssertionIDRefs().push_back(AssertionIDRefBuilder::buildAssertionIDRef()); + request->getAssertionIDRefs().push_back(AssertionIDRefBuilder::buildAssertionIDRef()); + request->getAssertionIDRefs().push_back(AssertionIDRefBuilder::buildAssertionIDRef()); + assertEquals(expectedChildElementsDOM, request); + delete ns; + } + +}; diff --git a/samltest/saml2/core/impl/Attribute20Test.h b/samltest/saml2/core/impl/Attribute20Test.h index 18e37c6..d6d1d8b 100644 --- a/samltest/saml2/core/impl/Attribute20Test.h +++ b/samltest/saml2/core/impl/Attribute20Test.h @@ -1,107 +1,107 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2; - -class Attribute20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* expectedName; - XMLCh* expectedNameFormat; - XMLCh* expectedFriendlyName; - -public: - void setUp() { - expectedName = XMLString::transcode("attribName"); - expectedNameFormat = XMLString::transcode("urn:string:format"); - expectedFriendlyName = XMLString::transcode("Attribute Name"); - - singleElementFile = data_path + "saml2/core/impl/Attribute.xml"; - singleElementOptionalAttributesFile = data_path + "saml2/core/impl/AttributeOptionalAttributes.xml"; - childElementsFile = data_path + "saml2/core/impl/AttributeChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&expectedName); - XMLString::release(&expectedNameFormat); - XMLString::release(&expectedFriendlyName); - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - Attribute* attribute = dynamic_cast(xo.get()); - TS_ASSERT(attribute!=NULL); - - assertEquals("Name attribute", expectedName, attribute->getName()); - TS_ASSERT(attribute->getNameFormat()==NULL); - TS_ASSERT(attribute->getFriendlyName()==NULL); - - TSM_ASSERT_EQUALS("# of AttributeValue child elements", 0, attribute->getAttributeValues().size()); - - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - Attribute* attribute = dynamic_cast(xo.get()); - TS_ASSERT(attribute!=NULL); - - assertEquals("Name attribute", expectedName, attribute->getName()); - assertEquals("NameFormat attribute", expectedNameFormat, attribute->getNameFormat()); - assertEquals("FriendlyName attribute", expectedFriendlyName, attribute->getFriendlyName()); - - TSM_ASSERT_EQUALS("# of AttributeValue child elements", 0, attribute->getAttributeValues().size()); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - Attribute* attribute= dynamic_cast(xo.get()); - TS_ASSERT(attribute!=NULL); - - TS_ASSERT(attribute->getName()==NULL); - TS_ASSERT(attribute->getNameFormat()==NULL); - TS_ASSERT(attribute->getFriendlyName()==NULL); - - TSM_ASSERT_EQUALS("# of AttributeValue child elements", 3, attribute->getAttributeValues().size()); - - } - - void testSingleElementMarshall() { - Attribute* attribute=AttributeBuilder::buildAttribute(); - attribute->setName(expectedName); - assertEquals(expectedDOM, attribute); - } - - void testSingleElementOptionalAttributesMarshall() { - Attribute* attribute=AttributeBuilder::buildAttribute(); - attribute->setName(expectedName); - attribute->setNameFormat(expectedNameFormat); - attribute->setFriendlyName(expectedFriendlyName); - assertEquals(expectedOptionalAttributesDOM, attribute); - } - - void testChildElementsMarshall() { - Attribute* attribute=AttributeBuilder::buildAttribute(); - attribute->getAttributeValues().push_back(AttributeValueBuilder::buildAttributeValue()); - attribute->getAttributeValues().push_back(AttributeValueBuilder::buildAttributeValue()); - attribute->getAttributeValues().push_back(AttributeValueBuilder::buildAttributeValue()); - assertEquals(expectedChildElementsDOM, attribute); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +class Attribute20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedName; + XMLCh* expectedNameFormat; + XMLCh* expectedFriendlyName; + +public: + void setUp() { + expectedName = XMLString::transcode("attribName"); + expectedNameFormat = XMLString::transcode("urn:string:format"); + expectedFriendlyName = XMLString::transcode("Attribute Name"); + + singleElementFile = data_path + "saml2/core/impl/Attribute.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/AttributeOptionalAttributes.xml"; + childElementsFile = data_path + "saml2/core/impl/AttributeChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedName); + XMLString::release(&expectedNameFormat); + XMLString::release(&expectedFriendlyName); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + Attribute* attribute = dynamic_cast(xo.get()); + TS_ASSERT(attribute!=NULL); + + assertEquals("Name attribute", expectedName, attribute->getName()); + TS_ASSERT(attribute->getNameFormat()==NULL); + TS_ASSERT(attribute->getFriendlyName()==NULL); + + TSM_ASSERT_EQUALS("# of AttributeValue child elements", 0, attribute->getAttributeValues().size()); + + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + Attribute* attribute = dynamic_cast(xo.get()); + TS_ASSERT(attribute!=NULL); + + assertEquals("Name attribute", expectedName, attribute->getName()); + assertEquals("NameFormat attribute", expectedNameFormat, attribute->getNameFormat()); + assertEquals("FriendlyName attribute", expectedFriendlyName, attribute->getFriendlyName()); + + TSM_ASSERT_EQUALS("# of AttributeValue child elements", 0, attribute->getAttributeValues().size()); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + Attribute* attribute= dynamic_cast(xo.get()); + TS_ASSERT(attribute!=NULL); + + TS_ASSERT(attribute->getName()==NULL); + TS_ASSERT(attribute->getNameFormat()==NULL); + TS_ASSERT(attribute->getFriendlyName()==NULL); + + TSM_ASSERT_EQUALS("# of AttributeValue child elements", 3, attribute->getAttributeValues().size()); + + } + + void testSingleElementMarshall() { + Attribute* attribute=AttributeBuilder::buildAttribute(); + attribute->setName(expectedName); + assertEquals(expectedDOM, attribute); + } + + void testSingleElementOptionalAttributesMarshall() { + Attribute* attribute=AttributeBuilder::buildAttribute(); + attribute->setName(expectedName); + attribute->setNameFormat(expectedNameFormat); + attribute->setFriendlyName(expectedFriendlyName); + assertEquals(expectedOptionalAttributesDOM, attribute); + } + + void testChildElementsMarshall() { + Attribute* attribute=AttributeBuilder::buildAttribute(); + attribute->getAttributeValues().push_back(AttributeValueBuilder::buildAttributeValue()); + attribute->getAttributeValues().push_back(AttributeValueBuilder::buildAttributeValue()); + attribute->getAttributeValues().push_back(AttributeValueBuilder::buildAttributeValue()); + assertEquals(expectedChildElementsDOM, attribute); + } + +}; diff --git a/samltest/saml2/core/impl/AttributeQuery20Test.h b/samltest/saml2/core/impl/AttributeQuery20Test.h index 1b1fc9d..4d2645e 100644 --- a/samltest/saml2/core/impl/AttributeQuery20Test.h +++ b/samltest/saml2/core/impl/AttributeQuery20Test.h @@ -1,128 +1,128 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2p; -using namespace opensaml::saml2; - -class AttributeQuery20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* expectedID; - XMLCh* expectedVersion; - XMLCh* expectedConsent; - XMLCh* expectedDestination; - DateTime* expectedIssueInstant; - -public: - void setUp() { - expectedID = XMLString::transcode("abc123");; - expectedVersion = XMLString::transcode("2.0"); - expectedConsent = XMLString::transcode("urn:string:consent"); - expectedDestination = XMLString::transcode("http://idp.example.org/endpoint"); - expectedIssueInstant = new DateTime(XMLString::transcode("2006-02-21T16:40:00.000Z")); - expectedIssueInstant->parseDateTime(); - - singleElementFile = data_path + "saml2/core/impl/AttributeQuery.xml"; - singleElementOptionalAttributesFile = data_path + "saml2/core/impl/AttributeQueryOptionalAttributes.xml"; - childElementsFile = data_path + "saml2/core/impl/AttributeQueryChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&expectedID); - XMLString::release(&expectedVersion); - XMLString::release(&expectedConsent); - XMLString::release(&expectedDestination); - delete expectedIssueInstant; - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - AttributeQuery* query = dynamic_cast(xo.get()); - TS_ASSERT(query!=NULL); - assertEquals("ID attribute", expectedID, query->getID()); - assertEquals("Version attribute", expectedVersion, query->getVersion()); - TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), query->getIssueInstant()->getEpoch()); - - TS_ASSERT(query->getIssuer()==NULL); - TS_ASSERT(query->getSignature()==NULL); - TS_ASSERT(query->getExtensions()==NULL); - TS_ASSERT(query->getSubject()==NULL); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - AttributeQuery* query = dynamic_cast(xo.get()); - TS_ASSERT(query!=NULL); - assertEquals("Consent attribute", expectedConsent, query->getConsent()); - assertEquals("Destination attribute", expectedDestination, query->getDestination()); - - TS_ASSERT(query->getIssuer()==NULL); - TS_ASSERT(query->getSignature()==NULL); - TS_ASSERT(query->getExtensions()==NULL); - TS_ASSERT(query->getSubject()==NULL); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - AttributeQuery* query= dynamic_cast(xo.get()); - TS_ASSERT(query!=NULL); - TS_ASSERT(query->getIssuer()!=NULL); - TS_ASSERT(query->getSignature()==NULL); - TS_ASSERT(query->getExtensions()==NULL); - TS_ASSERT(query->getSubject()!=NULL); - TSM_ASSERT_EQUALS("# of Attribute child elements", 4, query->getAttributes().size()); - } - - void testSingleElementMarshall() { - AttributeQuery* query=AttributeQueryBuilder::buildAttributeQuery(); - query->setID(expectedID); - query->setIssueInstant(expectedIssueInstant); - //query->setVersion(expectedVersion); - assertEquals(expectedDOM, query); - } - - void testSingleElementOptionalAttributesMarshall() { - AttributeQuery* query=AttributeQueryBuilder::buildAttributeQuery(); - query->setID(expectedID); - query->setIssueInstant(expectedIssueInstant); - //query->setVersion(expectedVersion); - query->setConsent(expectedConsent); - query->setDestination(expectedDestination); - assertEquals(expectedOptionalAttributesDOM, query); - } - - void testChildElementsMarshall() { - AttributeQuery* query=AttributeQueryBuilder::buildAttributeQuery(); - query->setID(expectedID); - query->setIssueInstant(expectedIssueInstant); - // Do this just so don't have to redeclare the saml namespace prefix on every child element in the control XML file - Namespace* ns = new Namespace(opensaml::SAMLConstants::SAML20_NS, opensaml::SAMLConstants::SAML20_PREFIX); - query->addNamespace(*ns); - query->setIssuer(IssuerBuilder::buildIssuer()); - query->setSubject(SubjectBuilder::buildSubject()); - query->getAttributes().push_back(AttributeBuilder::buildAttribute()); - query->getAttributes().push_back(AttributeBuilder::buildAttribute()); - query->getAttributes().push_back(AttributeBuilder::buildAttribute()); - query->getAttributes().push_back(AttributeBuilder::buildAttribute()); - assertEquals(expectedChildElementsDOM, query); - delete ns; - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2p; +using namespace opensaml::saml2; + +class AttributeQuery20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedID; + XMLCh* expectedVersion; + XMLCh* expectedConsent; + XMLCh* expectedDestination; + DateTime* expectedIssueInstant; + +public: + void setUp() { + expectedID = XMLString::transcode("abc123");; + expectedVersion = XMLString::transcode("2.0"); + expectedConsent = XMLString::transcode("urn:string:consent"); + expectedDestination = XMLString::transcode("http://idp.example.org/endpoint"); + expectedIssueInstant = new DateTime(XMLString::transcode("2006-02-21T16:40:00.000Z")); + expectedIssueInstant->parseDateTime(); + + singleElementFile = data_path + "saml2/core/impl/AttributeQuery.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/AttributeQueryOptionalAttributes.xml"; + childElementsFile = data_path + "saml2/core/impl/AttributeQueryChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedID); + XMLString::release(&expectedVersion); + XMLString::release(&expectedConsent); + XMLString::release(&expectedDestination); + delete expectedIssueInstant; + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + AttributeQuery* query = dynamic_cast(xo.get()); + TS_ASSERT(query!=NULL); + assertEquals("ID attribute", expectedID, query->getID()); + assertEquals("Version attribute", expectedVersion, query->getVersion()); + TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), query->getIssueInstant()->getEpoch()); + + TS_ASSERT(query->getIssuer()==NULL); + TS_ASSERT(query->getSignature()==NULL); + TS_ASSERT(query->getExtensions()==NULL); + TS_ASSERT(query->getSubject()==NULL); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + AttributeQuery* query = dynamic_cast(xo.get()); + TS_ASSERT(query!=NULL); + assertEquals("Consent attribute", expectedConsent, query->getConsent()); + assertEquals("Destination attribute", expectedDestination, query->getDestination()); + + TS_ASSERT(query->getIssuer()==NULL); + TS_ASSERT(query->getSignature()==NULL); + TS_ASSERT(query->getExtensions()==NULL); + TS_ASSERT(query->getSubject()==NULL); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + AttributeQuery* query= dynamic_cast(xo.get()); + TS_ASSERT(query!=NULL); + TS_ASSERT(query->getIssuer()!=NULL); + TS_ASSERT(query->getSignature()==NULL); + TS_ASSERT(query->getExtensions()==NULL); + TS_ASSERT(query->getSubject()!=NULL); + TSM_ASSERT_EQUALS("# of Attribute child elements", 4, query->getAttributes().size()); + } + + void testSingleElementMarshall() { + AttributeQuery* query=AttributeQueryBuilder::buildAttributeQuery(); + query->setID(expectedID); + query->setIssueInstant(expectedIssueInstant); + //query->setVersion(expectedVersion); + assertEquals(expectedDOM, query); + } + + void testSingleElementOptionalAttributesMarshall() { + AttributeQuery* query=AttributeQueryBuilder::buildAttributeQuery(); + query->setID(expectedID); + query->setIssueInstant(expectedIssueInstant); + //query->setVersion(expectedVersion); + query->setConsent(expectedConsent); + query->setDestination(expectedDestination); + assertEquals(expectedOptionalAttributesDOM, query); + } + + void testChildElementsMarshall() { + AttributeQuery* query=AttributeQueryBuilder::buildAttributeQuery(); + query->setID(expectedID); + query->setIssueInstant(expectedIssueInstant); + // Do this just so don't have to redeclare the saml namespace prefix on every child element in the control XML file + Namespace* ns = new Namespace(opensaml::SAMLConstants::SAML20_NS, opensaml::SAMLConstants::SAML20_PREFIX); + query->addNamespace(*ns); + query->setIssuer(IssuerBuilder::buildIssuer()); + query->setSubject(SubjectBuilder::buildSubject()); + query->getAttributes().push_back(AttributeBuilder::buildAttribute()); + query->getAttributes().push_back(AttributeBuilder::buildAttribute()); + query->getAttributes().push_back(AttributeBuilder::buildAttribute()); + query->getAttributes().push_back(AttributeBuilder::buildAttribute()); + assertEquals(expectedChildElementsDOM, query); + delete ns; + } + +}; diff --git a/samltest/saml2/core/impl/AttributeStatement20Test.h b/samltest/saml2/core/impl/AttributeStatement20Test.h index 830d557..4bf9b8b 100644 --- a/samltest/saml2/core/impl/AttributeStatement20Test.h +++ b/samltest/saml2/core/impl/AttributeStatement20Test.h @@ -1,69 +1,69 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2; - -class AttributeStatement20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - -public: - void setUp() { - singleElementFile = data_path + "saml2/core/impl/AttributeStatement.xml"; - childElementsFile = data_path + "saml2/core/impl/AttributeStatementChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - AttributeStatement* statement = dynamic_cast(xo.get()); - TS_ASSERT(statement!=NULL); - - TSM_ASSERT_EQUALS("# of Attribute child elements", 0, statement->getAttributes().size()); - TSM_ASSERT_EQUALS("# of EncryptedAttribute child elements", 0, statement->getEncryptedAttributes().size()); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - AttributeStatement* statement= dynamic_cast(xo.get()); - TS_ASSERT(statement!=NULL); - - TSM_ASSERT_EQUALS("# of Attribute child elements", 3, statement->getAttributes().size()); - TSM_ASSERT_EQUALS("# of EncryptedAttribute child elements", 1, statement->getEncryptedAttributes().size()); - } - - void testSingleElementMarshall() { - AttributeStatement* statement=AttributeStatementBuilder::buildAttributeStatement(); - assertEquals(expectedDOM, statement); - } - - void testChildElementsMarshall() { - AttributeStatement* statement=AttributeStatementBuilder::buildAttributeStatement(); - - statement->getAttributes().push_back(AttributeBuilder::buildAttribute()); - statement->getAttributes().push_back(AttributeBuilder::buildAttribute()); - statement->getEncryptedAttributes().push_back(EncryptedAttributeBuilder::buildEncryptedAttribute()); - statement->getAttributes().push_back(AttributeBuilder::buildAttribute()); - assertEquals(expectedChildElementsDOM, statement); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +class AttributeStatement20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + +public: + void setUp() { + singleElementFile = data_path + "saml2/core/impl/AttributeStatement.xml"; + childElementsFile = data_path + "saml2/core/impl/AttributeStatementChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + AttributeStatement* statement = dynamic_cast(xo.get()); + TS_ASSERT(statement!=NULL); + + TSM_ASSERT_EQUALS("# of Attribute child elements", 0, statement->getAttributes().size()); + TSM_ASSERT_EQUALS("# of EncryptedAttribute child elements", 0, statement->getEncryptedAttributes().size()); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + AttributeStatement* statement= dynamic_cast(xo.get()); + TS_ASSERT(statement!=NULL); + + TSM_ASSERT_EQUALS("# of Attribute child elements", 3, statement->getAttributes().size()); + TSM_ASSERT_EQUALS("# of EncryptedAttribute child elements", 1, statement->getEncryptedAttributes().size()); + } + + void testSingleElementMarshall() { + AttributeStatement* statement=AttributeStatementBuilder::buildAttributeStatement(); + assertEquals(expectedDOM, statement); + } + + void testChildElementsMarshall() { + AttributeStatement* statement=AttributeStatementBuilder::buildAttributeStatement(); + + statement->getAttributes().push_back(AttributeBuilder::buildAttribute()); + statement->getAttributes().push_back(AttributeBuilder::buildAttribute()); + statement->getEncryptedAttributes().push_back(EncryptedAttributeBuilder::buildEncryptedAttribute()); + statement->getAttributes().push_back(AttributeBuilder::buildAttribute()); + assertEquals(expectedChildElementsDOM, statement); + } + +}; diff --git a/samltest/saml2/core/impl/AudienceRestriction20Test.h b/samltest/saml2/core/impl/AudienceRestriction20Test.h index dedd2e5..4526205 100644 --- a/samltest/saml2/core/impl/AudienceRestriction20Test.h +++ b/samltest/saml2/core/impl/AudienceRestriction20Test.h @@ -1,64 +1,64 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2; - -class AudienceRestriction20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - -public: - void setUp() { - singleElementFile = data_path + "saml2/core/impl/AudienceRestriction.xml"; - childElementsFile = data_path + "saml2/core/impl/AudienceRestrictionChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - AudienceRestriction* ar = dynamic_cast(xo.get()); - TS_ASSERT(ar!=NULL); - - TSM_ASSERT_EQUALS("# of Audience child elements", 0, ar->getAudiences().size()); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - AudienceRestriction* ar= dynamic_cast(xo.get()); - TS_ASSERT(ar!=NULL); - - TSM_ASSERT_EQUALS("# of Audience child elements", 2, ar->getAudiences().size()); - } - - void testSingleElementMarshall() { - AudienceRestriction* ar=AudienceRestrictionBuilder::buildAudienceRestriction(); - assertEquals(expectedDOM, ar); - } - - void testChildElementsMarshall() { - AudienceRestriction* ar=AudienceRestrictionBuilder::buildAudienceRestriction(); - ar->getAudiences().push_back(AudienceBuilder::buildAudience()); - ar->getAudiences().push_back(AudienceBuilder::buildAudience()); - assertEquals(expectedChildElementsDOM, ar); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +class AudienceRestriction20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + +public: + void setUp() { + singleElementFile = data_path + "saml2/core/impl/AudienceRestriction.xml"; + childElementsFile = data_path + "saml2/core/impl/AudienceRestrictionChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + AudienceRestriction* ar = dynamic_cast(xo.get()); + TS_ASSERT(ar!=NULL); + + TSM_ASSERT_EQUALS("# of Audience child elements", 0, ar->getAudiences().size()); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + AudienceRestriction* ar= dynamic_cast(xo.get()); + TS_ASSERT(ar!=NULL); + + TSM_ASSERT_EQUALS("# of Audience child elements", 2, ar->getAudiences().size()); + } + + void testSingleElementMarshall() { + AudienceRestriction* ar=AudienceRestrictionBuilder::buildAudienceRestriction(); + assertEquals(expectedDOM, ar); + } + + void testChildElementsMarshall() { + AudienceRestriction* ar=AudienceRestrictionBuilder::buildAudienceRestriction(); + ar->getAudiences().push_back(AudienceBuilder::buildAudience()); + ar->getAudiences().push_back(AudienceBuilder::buildAudience()); + assertEquals(expectedChildElementsDOM, ar); + } + +}; diff --git a/samltest/saml2/core/impl/AuthnContext20Test.h b/samltest/saml2/core/impl/AuthnContext20Test.h index 360d144..32384d1 100644 --- a/samltest/saml2/core/impl/AuthnContext20Test.h +++ b/samltest/saml2/core/impl/AuthnContext20Test.h @@ -1,72 +1,72 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2; - -class AuthnContext20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - -public: - void setUp() { - singleElementFile = data_path + "saml2/core/impl/AuthnContext.xml"; - childElementsFile = data_path + "saml2/core/impl/AuthnContextChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - AuthnContext* ac = dynamic_cast(xo.get()); - TS_ASSERT(ac!=NULL); - - TS_ASSERT(ac->getAuthnContextClassRef()==NULL); - TS_ASSERT(ac->getAuthnContextDecl()==NULL); - TS_ASSERT(ac->getAuthnContextDeclRef()==NULL); - TSM_ASSERT_EQUALS("# of AuthenticatingAuthority child elements", 0, ac->getAuthenticatingAuthoritys().size()); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - AuthnContext* ac= dynamic_cast(xo.get()); - TS_ASSERT(ac!=NULL); - - TS_ASSERT(ac->getAuthnContextClassRef()!=NULL); - TS_ASSERT(ac->getAuthnContextDecl()==NULL); - TS_ASSERT(ac->getAuthnContextDeclRef()!=NULL); - TSM_ASSERT_EQUALS("# of AuthenticatingAuthority child elements", 2, ac->getAuthenticatingAuthoritys().size()); - } - - void testSingleElementMarshall() { - AuthnContext* ac=AuthnContextBuilder::buildAuthnContext(); - assertEquals(expectedDOM, ac); - } - - void testChildElementsMarshall() { - AuthnContext* ac=AuthnContextBuilder::buildAuthnContext(); - ac->setAuthnContextClassRef(AuthnContextClassRefBuilder::buildAuthnContextClassRef()); - ac->setAuthnContextDeclRef(AuthnContextDeclRefBuilder::buildAuthnContextDeclRef()); - ac->getAuthenticatingAuthoritys().push_back(AuthenticatingAuthorityBuilder::buildAuthenticatingAuthority()); - ac->getAuthenticatingAuthoritys().push_back(AuthenticatingAuthorityBuilder::buildAuthenticatingAuthority()); - assertEquals(expectedChildElementsDOM, ac); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +class AuthnContext20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + +public: + void setUp() { + singleElementFile = data_path + "saml2/core/impl/AuthnContext.xml"; + childElementsFile = data_path + "saml2/core/impl/AuthnContextChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + AuthnContext* ac = dynamic_cast(xo.get()); + TS_ASSERT(ac!=NULL); + + TS_ASSERT(ac->getAuthnContextClassRef()==NULL); + TS_ASSERT(ac->getAuthnContextDecl()==NULL); + TS_ASSERT(ac->getAuthnContextDeclRef()==NULL); + TSM_ASSERT_EQUALS("# of AuthenticatingAuthority child elements", 0, ac->getAuthenticatingAuthoritys().size()); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + AuthnContext* ac= dynamic_cast(xo.get()); + TS_ASSERT(ac!=NULL); + + TS_ASSERT(ac->getAuthnContextClassRef()!=NULL); + TS_ASSERT(ac->getAuthnContextDecl()==NULL); + TS_ASSERT(ac->getAuthnContextDeclRef()!=NULL); + TSM_ASSERT_EQUALS("# of AuthenticatingAuthority child elements", 2, ac->getAuthenticatingAuthoritys().size()); + } + + void testSingleElementMarshall() { + AuthnContext* ac=AuthnContextBuilder::buildAuthnContext(); + assertEquals(expectedDOM, ac); + } + + void testChildElementsMarshall() { + AuthnContext* ac=AuthnContextBuilder::buildAuthnContext(); + ac->setAuthnContextClassRef(AuthnContextClassRefBuilder::buildAuthnContextClassRef()); + ac->setAuthnContextDeclRef(AuthnContextDeclRefBuilder::buildAuthnContextDeclRef()); + ac->getAuthenticatingAuthoritys().push_back(AuthenticatingAuthorityBuilder::buildAuthenticatingAuthority()); + ac->getAuthenticatingAuthoritys().push_back(AuthenticatingAuthorityBuilder::buildAuthenticatingAuthority()); + assertEquals(expectedChildElementsDOM, ac); + } + +}; diff --git a/samltest/saml2/core/impl/AuthnQuery20Test.h b/samltest/saml2/core/impl/AuthnQuery20Test.h index 5610d0d..400de42 100644 --- a/samltest/saml2/core/impl/AuthnQuery20Test.h +++ b/samltest/saml2/core/impl/AuthnQuery20Test.h @@ -1,132 +1,132 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2p; -using namespace opensaml::saml2; - -class AuthnQuery20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* expectedID; - XMLCh* expectedVersion; - XMLCh* expectedConsent; - XMLCh* expectedDestination; - DateTime* expectedIssueInstant; - XMLCh* expectedSessionIndex; - -public: - void setUp() { - expectedID = XMLString::transcode("abc123");; - expectedVersion = XMLString::transcode("2.0"); - expectedConsent = XMLString::transcode("urn:string:consent"); - expectedDestination = XMLString::transcode("http://idp.example.org/endpoint"); - expectedIssueInstant = new DateTime(XMLString::transcode("2006-02-21T16:40:00.000Z")); - expectedIssueInstant->parseDateTime(); - expectedSessionIndex = XMLString::transcode("session12345"); - - singleElementFile = data_path + "saml2/core/impl/AuthnQuery.xml"; - singleElementOptionalAttributesFile = data_path + "saml2/core/impl/AuthnQueryOptionalAttributes.xml"; - childElementsFile = data_path + "saml2/core/impl/AuthnQueryChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&expectedID); - XMLString::release(&expectedVersion); - XMLString::release(&expectedConsent); - XMLString::release(&expectedDestination); - XMLString::release(&expectedSessionIndex); - delete expectedIssueInstant; - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - AuthnQuery* query = dynamic_cast(xo.get()); - TS_ASSERT(query!=NULL); - assertEquals("ID attribute", expectedID, query->getID()); - assertEquals("Version attribute", expectedVersion, query->getVersion()); - TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), query->getIssueInstant()->getEpoch()); - - TS_ASSERT(query->getIssuer()==NULL); - TS_ASSERT(query->getSignature()==NULL); - TS_ASSERT(query->getExtensions()==NULL); - TS_ASSERT(query->getSubject()==NULL); - TS_ASSERT(query->getRequestedAuthnContext()==NULL); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - AuthnQuery* query = dynamic_cast(xo.get()); - TS_ASSERT(query!=NULL); - assertEquals("Consent attribute", expectedConsent, query->getConsent()); - assertEquals("Destination attribute", expectedDestination, query->getDestination()); - assertEquals("SessionIndex attribute", expectedSessionIndex, query->getSessionIndex()); - - TS_ASSERT(query->getIssuer()==NULL); - TS_ASSERT(query->getSignature()==NULL); - TS_ASSERT(query->getExtensions()==NULL); - TS_ASSERT(query->getSubject()==NULL); - TS_ASSERT(query->getRequestedAuthnContext()==NULL); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - AuthnQuery* query= dynamic_cast(xo.get()); - TS_ASSERT(query!=NULL); - TS_ASSERT(query->getIssuer()!=NULL); - TS_ASSERT(query->getSignature()==NULL); - TS_ASSERT(query->getExtensions()==NULL); - TS_ASSERT(query->getSubject()!=NULL); - TS_ASSERT(query->getRequestedAuthnContext()!=NULL); - } - - void testSingleElementMarshall() { - AuthnQuery* query=AuthnQueryBuilder::buildAuthnQuery(); - query->setID(expectedID); - query->setIssueInstant(expectedIssueInstant); - //query->setVersion(expectedVersion); - assertEquals(expectedDOM, query); - } - - void testSingleElementOptionalAttributesMarshall() { - AuthnQuery* query=AuthnQueryBuilder::buildAuthnQuery(); - query->setID(expectedID); - query->setIssueInstant(expectedIssueInstant); - //query->setVersion(expectedVersion); - query->setConsent(expectedConsent); - query->setDestination(expectedDestination); - query->setSessionIndex(expectedSessionIndex); - assertEquals(expectedOptionalAttributesDOM, query); - } - - void testChildElementsMarshall() { - AuthnQuery* query=AuthnQueryBuilder::buildAuthnQuery(); - query->setID(expectedID); - query->setIssueInstant(expectedIssueInstant); - // Do this just so don't have to redeclare the saml namespace prefix on every child element in the control XML file - Namespace* ns = new Namespace(opensaml::SAMLConstants::SAML20_NS, opensaml::SAMLConstants::SAML20_PREFIX); - query->addNamespace(*ns); - query->setIssuer(IssuerBuilder::buildIssuer()); - query->setSubject(SubjectBuilder::buildSubject()); - query->setRequestedAuthnContext(RequestedAuthnContextBuilder::buildRequestedAuthnContext()); - assertEquals(expectedChildElementsDOM, query); - delete ns; - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2p; +using namespace opensaml::saml2; + +class AuthnQuery20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedID; + XMLCh* expectedVersion; + XMLCh* expectedConsent; + XMLCh* expectedDestination; + DateTime* expectedIssueInstant; + XMLCh* expectedSessionIndex; + +public: + void setUp() { + expectedID = XMLString::transcode("abc123");; + expectedVersion = XMLString::transcode("2.0"); + expectedConsent = XMLString::transcode("urn:string:consent"); + expectedDestination = XMLString::transcode("http://idp.example.org/endpoint"); + expectedIssueInstant = new DateTime(XMLString::transcode("2006-02-21T16:40:00.000Z")); + expectedIssueInstant->parseDateTime(); + expectedSessionIndex = XMLString::transcode("session12345"); + + singleElementFile = data_path + "saml2/core/impl/AuthnQuery.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/AuthnQueryOptionalAttributes.xml"; + childElementsFile = data_path + "saml2/core/impl/AuthnQueryChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedID); + XMLString::release(&expectedVersion); + XMLString::release(&expectedConsent); + XMLString::release(&expectedDestination); + XMLString::release(&expectedSessionIndex); + delete expectedIssueInstant; + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + AuthnQuery* query = dynamic_cast(xo.get()); + TS_ASSERT(query!=NULL); + assertEquals("ID attribute", expectedID, query->getID()); + assertEquals("Version attribute", expectedVersion, query->getVersion()); + TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), query->getIssueInstant()->getEpoch()); + + TS_ASSERT(query->getIssuer()==NULL); + TS_ASSERT(query->getSignature()==NULL); + TS_ASSERT(query->getExtensions()==NULL); + TS_ASSERT(query->getSubject()==NULL); + TS_ASSERT(query->getRequestedAuthnContext()==NULL); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + AuthnQuery* query = dynamic_cast(xo.get()); + TS_ASSERT(query!=NULL); + assertEquals("Consent attribute", expectedConsent, query->getConsent()); + assertEquals("Destination attribute", expectedDestination, query->getDestination()); + assertEquals("SessionIndex attribute", expectedSessionIndex, query->getSessionIndex()); + + TS_ASSERT(query->getIssuer()==NULL); + TS_ASSERT(query->getSignature()==NULL); + TS_ASSERT(query->getExtensions()==NULL); + TS_ASSERT(query->getSubject()==NULL); + TS_ASSERT(query->getRequestedAuthnContext()==NULL); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + AuthnQuery* query= dynamic_cast(xo.get()); + TS_ASSERT(query!=NULL); + TS_ASSERT(query->getIssuer()!=NULL); + TS_ASSERT(query->getSignature()==NULL); + TS_ASSERT(query->getExtensions()==NULL); + TS_ASSERT(query->getSubject()!=NULL); + TS_ASSERT(query->getRequestedAuthnContext()!=NULL); + } + + void testSingleElementMarshall() { + AuthnQuery* query=AuthnQueryBuilder::buildAuthnQuery(); + query->setID(expectedID); + query->setIssueInstant(expectedIssueInstant); + //query->setVersion(expectedVersion); + assertEquals(expectedDOM, query); + } + + void testSingleElementOptionalAttributesMarshall() { + AuthnQuery* query=AuthnQueryBuilder::buildAuthnQuery(); + query->setID(expectedID); + query->setIssueInstant(expectedIssueInstant); + //query->setVersion(expectedVersion); + query->setConsent(expectedConsent); + query->setDestination(expectedDestination); + query->setSessionIndex(expectedSessionIndex); + assertEquals(expectedOptionalAttributesDOM, query); + } + + void testChildElementsMarshall() { + AuthnQuery* query=AuthnQueryBuilder::buildAuthnQuery(); + query->setID(expectedID); + query->setIssueInstant(expectedIssueInstant); + // Do this just so don't have to redeclare the saml namespace prefix on every child element in the control XML file + Namespace* ns = new Namespace(opensaml::SAMLConstants::SAML20_NS, opensaml::SAMLConstants::SAML20_PREFIX); + query->addNamespace(*ns); + query->setIssuer(IssuerBuilder::buildIssuer()); + query->setSubject(SubjectBuilder::buildSubject()); + query->setRequestedAuthnContext(RequestedAuthnContextBuilder::buildRequestedAuthnContext()); + assertEquals(expectedChildElementsDOM, query); + delete ns; + } + +}; diff --git a/samltest/saml2/core/impl/AuthnRequest20Test.h b/samltest/saml2/core/impl/AuthnRequest20Test.h index 140d675..1c0482a 100644 --- a/samltest/saml2/core/impl/AuthnRequest20Test.h +++ b/samltest/saml2/core/impl/AuthnRequest20Test.h @@ -1,181 +1,181 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2p; -using namespace opensaml::saml2; - -class AuthnRequest20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* expectedID; - XMLCh* expectedVersion; - DateTime* expectedIssueInstant; - XMLCh* expectedConsent; - XMLCh* expectedDestination; - bool expectedForceAuthn; - bool expectedIsPassive; - XMLCh* expectedProtocolBinding; - int expectedAssertionConsumerServiceIndex; - XMLCh* expectedAssertionConsumerServiceURL; - int expectedAttributeConsumingServiceIndex; - XMLCh* expectedProviderName; - -public: - void setUp() { - expectedID = XMLString::transcode("abc123");; - expectedVersion = XMLString::transcode("2.0"); - expectedIssueInstant = new DateTime(XMLString::transcode("2006-02-21T16:40:00.000Z")); - expectedIssueInstant->parseDateTime(); - expectedConsent = XMLString::transcode("urn:string:consent"); - expectedDestination = XMLString::transcode("http://idp.example.org/endpoint"); - expectedForceAuthn = true; - expectedIsPassive = true; - expectedProtocolBinding = XMLString::transcode("urn:string:protocol-binding"); - expectedAssertionConsumerServiceIndex = 3; - expectedAssertionConsumerServiceURL = XMLString::transcode("http://sp.example.org/acs"); - expectedAttributeConsumingServiceIndex = 2; - expectedProviderName = XMLString::transcode("Example Org"); - - singleElementFile = data_path + "saml2/core/impl/AuthnRequest.xml"; - singleElementOptionalAttributesFile = data_path + "saml2/core/impl/AuthnRequestOptionalAttributes.xml"; - childElementsFile = data_path + "saml2/core/impl/AuthnRequestChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&expectedID); - XMLString::release(&expectedVersion); - XMLString::release(&expectedConsent); - XMLString::release(&expectedDestination); - XMLString::release(&expectedProtocolBinding); - XMLString::release(&expectedAssertionConsumerServiceURL); - XMLString::release(&expectedProviderName); - delete expectedIssueInstant; - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - AuthnRequest* request = dynamic_cast(xo.get()); - TS_ASSERT(request!=NULL); - assertEquals("ID attribute", expectedID, request->getID()); - assertEquals("Version attribute", expectedVersion, request->getVersion()); - TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), request->getIssueInstant()->getEpoch()); - TSM_ASSERT_EQUALS("ForceAuthn attribute presence", XMLConstants::XML_BOOL_NULL, request->getForceAuthn()); - TSM_ASSERT_EQUALS("IsPassive attribute presence", XMLConstants::XML_BOOL_NULL, request->getIsPassive()); - TSM_ASSERT_EQUALS("AssertionConsumerServiceIndex attribute presence",false, request->getAssertionConsumerServiceIndex().first); - TSM_ASSERT_EQUALS("AttributeConsumingServiceIndex attribute presence", false, request->getAttributeConsumingServiceIndex().first); - - TS_ASSERT(request->getIssuer()==NULL); - TS_ASSERT(request->getSignature()==NULL); - TS_ASSERT(request->getExtensions()==NULL); - TS_ASSERT(request->getSubject()==NULL); - TS_ASSERT(request->getNameIDPolicy()==NULL); - TS_ASSERT(request->getConditions()==NULL); - TS_ASSERT(request->getRequestedAuthnContext()==NULL); - TS_ASSERT(request->getScoping()==NULL); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - AuthnRequest* request = dynamic_cast(xo.get()); - TS_ASSERT(request!=NULL); - - assertEquals("Consent attribute", expectedConsent, request->getConsent()); - assertEquals("Destination attribute", expectedDestination, request->getDestination()); - TSM_ASSERT_EQUALS("ForceAuthn attribute value", expectedForceAuthn, request->ForceAuthn()); - TSM_ASSERT_EQUALS("IsPassive attribute value", expectedIsPassive, request->IsPassive()); - assertEquals("ProtocolBinding attribute", expectedProtocolBinding,request->getProtocolBinding()); - TSM_ASSERT_EQUALS("AssertionConsumerServiceIndex attribute presence",true, request->getAssertionConsumerServiceIndex().first); - TSM_ASSERT_EQUALS("AssertionConsumerServiceIndex attribute value",expectedAssertionConsumerServiceIndex, request->getAssertionConsumerServiceIndex().second); - assertEquals("AssertionConsumerServierURL attribute", expectedAssertionConsumerServiceURL, request->getAssertionConsumerServiceURL()); - TSM_ASSERT_EQUALS("AttributeConsumingServiceIndex attribute presence", true, request->getAttributeConsumingServiceIndex().first); - TSM_ASSERT_EQUALS("AttributeConsumingServiceIndex attribute value", expectedAttributeConsumingServiceIndex, request->getAttributeConsumingServiceIndex().second); - assertEquals("ProviderName attribute", expectedProviderName, request->getProviderName()); - - TS_ASSERT(request->getIssuer()==NULL); - TS_ASSERT(request->getSignature()==NULL); - TS_ASSERT(request->getExtensions()==NULL); - TS_ASSERT(request->getSubject()==NULL); - TS_ASSERT(request->getNameIDPolicy()==NULL); - TS_ASSERT(request->getConditions()==NULL); - TS_ASSERT(request->getRequestedAuthnContext()==NULL); - TS_ASSERT(request->getScoping()==NULL); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - AuthnRequest* request= dynamic_cast(xo.get()); - TS_ASSERT(request!=NULL); - TS_ASSERT(request->getIssuer()!=NULL); - TS_ASSERT(request->getSignature()==NULL); - TS_ASSERT(request->getExtensions()==NULL); - TS_ASSERT(request->getSubject()!=NULL); - TS_ASSERT(request->getNameIDPolicy()!=NULL); - TS_ASSERT(request->getConditions()!=NULL); - TS_ASSERT(request->getRequestedAuthnContext()!=NULL); - TS_ASSERT(request->getScoping()!=NULL); - TSM_ASSERT_EQUALS("ForceAuthn attribute presence", XMLConstants::XML_BOOL_NULL, request->getForceAuthn()); - TSM_ASSERT_EQUALS("IsPassive attribute presence", XMLConstants::XML_BOOL_NULL, request->getIsPassive()); - TSM_ASSERT_EQUALS("AssertionConsumerServiceIndex attribute presence",false, request->getAssertionConsumerServiceIndex().first); - TSM_ASSERT_EQUALS("AttributeConsumingServiceIndex attribute presence", false, request->getAttributeConsumingServiceIndex().first); - } - - void testSingleElementMarshall() { - AuthnRequest* request=AuthnRequestBuilder::buildAuthnRequest(); - request->setID(expectedID); - request->setIssueInstant(expectedIssueInstant); - //request->setVersion(expectedVersion); - assertEquals(expectedDOM, request); - } - - void testSingleElementOptionalAttributesMarshall() { - AuthnRequest* request=AuthnRequestBuilder::buildAuthnRequest(); - request->setID(expectedID); - request->setIssueInstant(expectedIssueInstant); - //request->setVersion(expectedVersion); - request->setConsent(expectedConsent); - request->setDestination(expectedDestination); - request->ForceAuthn(expectedForceAuthn); - request->IsPassive(expectedIsPassive); - request->setProtocolBinding(expectedProtocolBinding); - request->setAssertionConsumerServiceIndex(expectedAssertionConsumerServiceIndex); - request->setAssertionConsumerServiceURL(expectedAssertionConsumerServiceURL); - request->setAttributeConsumingServiceIndex(expectedAttributeConsumingServiceIndex); - request->setProviderName(expectedProviderName); - assertEquals(expectedOptionalAttributesDOM, request); - } - - void testChildElementsMarshall() { - AuthnRequest* request=AuthnRequestBuilder::buildAuthnRequest(); - request->setID(expectedID); - request->setIssueInstant(expectedIssueInstant); - // Do this just so don't have to redeclare the saml namespace prefix on every child element in the control XML file - Namespace* ns = new Namespace(opensaml::SAMLConstants::SAML20_NS, opensaml::SAMLConstants::SAML20_PREFIX); - request->addNamespace(*ns); - request->setIssuer(IssuerBuilder::buildIssuer()); - request->setSubject(SubjectBuilder::buildSubject()); - request->setNameIDPolicy(NameIDPolicyBuilder::buildNameIDPolicy()); - request->setConditions(ConditionsBuilder::buildConditions()); - request->setRequestedAuthnContext(RequestedAuthnContextBuilder::buildRequestedAuthnContext()); - request->setScoping(ScopingBuilder::buildScoping()); - assertEquals(expectedChildElementsDOM, request); - delete ns; - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2p; +using namespace opensaml::saml2; + +class AuthnRequest20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedID; + XMLCh* expectedVersion; + DateTime* expectedIssueInstant; + XMLCh* expectedConsent; + XMLCh* expectedDestination; + bool expectedForceAuthn; + bool expectedIsPassive; + XMLCh* expectedProtocolBinding; + int expectedAssertionConsumerServiceIndex; + XMLCh* expectedAssertionConsumerServiceURL; + int expectedAttributeConsumingServiceIndex; + XMLCh* expectedProviderName; + +public: + void setUp() { + expectedID = XMLString::transcode("abc123");; + expectedVersion = XMLString::transcode("2.0"); + expectedIssueInstant = new DateTime(XMLString::transcode("2006-02-21T16:40:00.000Z")); + expectedIssueInstant->parseDateTime(); + expectedConsent = XMLString::transcode("urn:string:consent"); + expectedDestination = XMLString::transcode("http://idp.example.org/endpoint"); + expectedForceAuthn = true; + expectedIsPassive = true; + expectedProtocolBinding = XMLString::transcode("urn:string:protocol-binding"); + expectedAssertionConsumerServiceIndex = 3; + expectedAssertionConsumerServiceURL = XMLString::transcode("http://sp.example.org/acs"); + expectedAttributeConsumingServiceIndex = 2; + expectedProviderName = XMLString::transcode("Example Org"); + + singleElementFile = data_path + "saml2/core/impl/AuthnRequest.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/AuthnRequestOptionalAttributes.xml"; + childElementsFile = data_path + "saml2/core/impl/AuthnRequestChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedID); + XMLString::release(&expectedVersion); + XMLString::release(&expectedConsent); + XMLString::release(&expectedDestination); + XMLString::release(&expectedProtocolBinding); + XMLString::release(&expectedAssertionConsumerServiceURL); + XMLString::release(&expectedProviderName); + delete expectedIssueInstant; + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + AuthnRequest* request = dynamic_cast(xo.get()); + TS_ASSERT(request!=NULL); + assertEquals("ID attribute", expectedID, request->getID()); + assertEquals("Version attribute", expectedVersion, request->getVersion()); + TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), request->getIssueInstant()->getEpoch()); + TSM_ASSERT_EQUALS("ForceAuthn attribute presence", XMLConstants::XML_BOOL_NULL, request->getForceAuthn()); + TSM_ASSERT_EQUALS("IsPassive attribute presence", XMLConstants::XML_BOOL_NULL, request->getIsPassive()); + TSM_ASSERT_EQUALS("AssertionConsumerServiceIndex attribute presence",false, request->getAssertionConsumerServiceIndex().first); + TSM_ASSERT_EQUALS("AttributeConsumingServiceIndex attribute presence", false, request->getAttributeConsumingServiceIndex().first); + + TS_ASSERT(request->getIssuer()==NULL); + TS_ASSERT(request->getSignature()==NULL); + TS_ASSERT(request->getExtensions()==NULL); + TS_ASSERT(request->getSubject()==NULL); + TS_ASSERT(request->getNameIDPolicy()==NULL); + TS_ASSERT(request->getConditions()==NULL); + TS_ASSERT(request->getRequestedAuthnContext()==NULL); + TS_ASSERT(request->getScoping()==NULL); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + AuthnRequest* request = dynamic_cast(xo.get()); + TS_ASSERT(request!=NULL); + + assertEquals("Consent attribute", expectedConsent, request->getConsent()); + assertEquals("Destination attribute", expectedDestination, request->getDestination()); + TSM_ASSERT_EQUALS("ForceAuthn attribute value", expectedForceAuthn, request->ForceAuthn()); + TSM_ASSERT_EQUALS("IsPassive attribute value", expectedIsPassive, request->IsPassive()); + assertEquals("ProtocolBinding attribute", expectedProtocolBinding,request->getProtocolBinding()); + TSM_ASSERT_EQUALS("AssertionConsumerServiceIndex attribute presence",true, request->getAssertionConsumerServiceIndex().first); + TSM_ASSERT_EQUALS("AssertionConsumerServiceIndex attribute value",expectedAssertionConsumerServiceIndex, request->getAssertionConsumerServiceIndex().second); + assertEquals("AssertionConsumerServierURL attribute", expectedAssertionConsumerServiceURL, request->getAssertionConsumerServiceURL()); + TSM_ASSERT_EQUALS("AttributeConsumingServiceIndex attribute presence", true, request->getAttributeConsumingServiceIndex().first); + TSM_ASSERT_EQUALS("AttributeConsumingServiceIndex attribute value", expectedAttributeConsumingServiceIndex, request->getAttributeConsumingServiceIndex().second); + assertEquals("ProviderName attribute", expectedProviderName, request->getProviderName()); + + TS_ASSERT(request->getIssuer()==NULL); + TS_ASSERT(request->getSignature()==NULL); + TS_ASSERT(request->getExtensions()==NULL); + TS_ASSERT(request->getSubject()==NULL); + TS_ASSERT(request->getNameIDPolicy()==NULL); + TS_ASSERT(request->getConditions()==NULL); + TS_ASSERT(request->getRequestedAuthnContext()==NULL); + TS_ASSERT(request->getScoping()==NULL); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + AuthnRequest* request= dynamic_cast(xo.get()); + TS_ASSERT(request!=NULL); + TS_ASSERT(request->getIssuer()!=NULL); + TS_ASSERT(request->getSignature()==NULL); + TS_ASSERT(request->getExtensions()==NULL); + TS_ASSERT(request->getSubject()!=NULL); + TS_ASSERT(request->getNameIDPolicy()!=NULL); + TS_ASSERT(request->getConditions()!=NULL); + TS_ASSERT(request->getRequestedAuthnContext()!=NULL); + TS_ASSERT(request->getScoping()!=NULL); + TSM_ASSERT_EQUALS("ForceAuthn attribute presence", XMLConstants::XML_BOOL_NULL, request->getForceAuthn()); + TSM_ASSERT_EQUALS("IsPassive attribute presence", XMLConstants::XML_BOOL_NULL, request->getIsPassive()); + TSM_ASSERT_EQUALS("AssertionConsumerServiceIndex attribute presence",false, request->getAssertionConsumerServiceIndex().first); + TSM_ASSERT_EQUALS("AttributeConsumingServiceIndex attribute presence", false, request->getAttributeConsumingServiceIndex().first); + } + + void testSingleElementMarshall() { + AuthnRequest* request=AuthnRequestBuilder::buildAuthnRequest(); + request->setID(expectedID); + request->setIssueInstant(expectedIssueInstant); + //request->setVersion(expectedVersion); + assertEquals(expectedDOM, request); + } + + void testSingleElementOptionalAttributesMarshall() { + AuthnRequest* request=AuthnRequestBuilder::buildAuthnRequest(); + request->setID(expectedID); + request->setIssueInstant(expectedIssueInstant); + //request->setVersion(expectedVersion); + request->setConsent(expectedConsent); + request->setDestination(expectedDestination); + request->ForceAuthn(expectedForceAuthn); + request->IsPassive(expectedIsPassive); + request->setProtocolBinding(expectedProtocolBinding); + request->setAssertionConsumerServiceIndex(expectedAssertionConsumerServiceIndex); + request->setAssertionConsumerServiceURL(expectedAssertionConsumerServiceURL); + request->setAttributeConsumingServiceIndex(expectedAttributeConsumingServiceIndex); + request->setProviderName(expectedProviderName); + assertEquals(expectedOptionalAttributesDOM, request); + } + + void testChildElementsMarshall() { + AuthnRequest* request=AuthnRequestBuilder::buildAuthnRequest(); + request->setID(expectedID); + request->setIssueInstant(expectedIssueInstant); + // Do this just so don't have to redeclare the saml namespace prefix on every child element in the control XML file + Namespace* ns = new Namespace(opensaml::SAMLConstants::SAML20_NS, opensaml::SAMLConstants::SAML20_PREFIX); + request->addNamespace(*ns); + request->setIssuer(IssuerBuilder::buildIssuer()); + request->setSubject(SubjectBuilder::buildSubject()); + request->setNameIDPolicy(NameIDPolicyBuilder::buildNameIDPolicy()); + request->setConditions(ConditionsBuilder::buildConditions()); + request->setRequestedAuthnContext(RequestedAuthnContextBuilder::buildRequestedAuthnContext()); + request->setScoping(ScopingBuilder::buildScoping()); + assertEquals(expectedChildElementsDOM, request); + delete ns; + } + +}; diff --git a/samltest/saml2/core/impl/AuthnStatement20Test.h b/samltest/saml2/core/impl/AuthnStatement20Test.h index e4223be..be23b20 100644 --- a/samltest/saml2/core/impl/AuthnStatement20Test.h +++ b/samltest/saml2/core/impl/AuthnStatement20Test.h @@ -1,111 +1,111 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2; - -class AuthnStatement20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - DateTime* expectedAuthnInstant; - XMLCh* expectedSessionIndex; - DateTime* expectedSessionNotOnOrAfter; - -public: - void setUp() { - expectedAuthnInstant = new DateTime(XMLString::transcode("1984-08-26T10:01:30.043Z")); - expectedAuthnInstant->parseDateTime(); - expectedSessionIndex = (XMLString::transcode("abc123")); - expectedSessionNotOnOrAfter = new DateTime(XMLString::transcode("1984-08-26T10:11:30.043Z")); - expectedSessionNotOnOrAfter->parseDateTime(); - - singleElementFile = data_path + "saml2/core/impl/AuthnStatement.xml"; - singleElementOptionalAttributesFile = data_path + "saml2/core/impl/AuthnStatementOptionalAttributes.xml"; - childElementsFile = data_path + "saml2/core/impl/AuthnStatementChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - delete expectedAuthnInstant; - XMLString::release(&expectedSessionIndex); - delete expectedSessionNotOnOrAfter; - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - AuthnStatement* statement = dynamic_cast(xo.get()); - TS_ASSERT(statement!=NULL); - - TSM_ASSERT_EQUALS("AuthnInstant attribute", expectedAuthnInstant->getEpoch(), statement->getAuthnInstant()->getEpoch()); - TS_ASSERT(statement->getSessionIndex()==NULL); - TS_ASSERT(statement->getSessionNotOnOrAfter()==NULL); - - TS_ASSERT(statement->getSubjectLocality()==NULL); - TS_ASSERT(statement->getAuthnContext()==NULL); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - AuthnStatement* statement = dynamic_cast(xo.get()); - TS_ASSERT(statement!=NULL); - - TSM_ASSERT_EQUALS("AuthnInstant attribute", expectedAuthnInstant->getEpoch(), statement->getAuthnInstant()->getEpoch()); - assertEquals("SessionIndex attribute", expectedSessionIndex, statement->getSessionIndex()); - TSM_ASSERT_EQUALS("SessionNotOnOrAfter attribute", expectedSessionNotOnOrAfter->getEpoch(), statement->getSessionNotOnOrAfter()->getEpoch()); - - TS_ASSERT(statement->getSubjectLocality()==NULL); - TS_ASSERT(statement->getAuthnContext()==NULL); - - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - AuthnStatement* statement= dynamic_cast(xo.get()); - TS_ASSERT(statement!=NULL); - - TS_ASSERT(statement->getAuthnInstant()==NULL); - TS_ASSERT(statement->getSessionIndex()==NULL); - TS_ASSERT(statement->getSessionNotOnOrAfter()==NULL); - - TS_ASSERT(statement->getSubjectLocality()!=NULL); - TS_ASSERT(statement->getAuthnContext()!=NULL); - - } - - void testSingleElementMarshall() { - AuthnStatement* statement=AuthnStatementBuilder::buildAuthnStatement(); - statement->setAuthnInstant(expectedAuthnInstant); - assertEquals(expectedDOM, statement); - } - - void testSingleElementOptionalAttributesMarshall() { - AuthnStatement* statement=AuthnStatementBuilder::buildAuthnStatement(); - statement->setAuthnInstant(expectedAuthnInstant); - statement->setSessionIndex(expectedSessionIndex); - statement->setSessionNotOnOrAfter(expectedSessionNotOnOrAfter); - assertEquals(expectedOptionalAttributesDOM, statement); - } - - void testChildElementsMarshall() { - AuthnStatement* statement=AuthnStatementBuilder::buildAuthnStatement(); - statement->setSubjectLocality(SubjectLocalityBuilder::buildSubjectLocality()); - statement->setAuthnContext(AuthnContextBuilder::buildAuthnContext()); - assertEquals(expectedChildElementsDOM, statement); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +class AuthnStatement20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + DateTime* expectedAuthnInstant; + XMLCh* expectedSessionIndex; + DateTime* expectedSessionNotOnOrAfter; + +public: + void setUp() { + expectedAuthnInstant = new DateTime(XMLString::transcode("1984-08-26T10:01:30.043Z")); + expectedAuthnInstant->parseDateTime(); + expectedSessionIndex = (XMLString::transcode("abc123")); + expectedSessionNotOnOrAfter = new DateTime(XMLString::transcode("1984-08-26T10:11:30.043Z")); + expectedSessionNotOnOrAfter->parseDateTime(); + + singleElementFile = data_path + "saml2/core/impl/AuthnStatement.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/AuthnStatementOptionalAttributes.xml"; + childElementsFile = data_path + "saml2/core/impl/AuthnStatementChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + delete expectedAuthnInstant; + XMLString::release(&expectedSessionIndex); + delete expectedSessionNotOnOrAfter; + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + AuthnStatement* statement = dynamic_cast(xo.get()); + TS_ASSERT(statement!=NULL); + + TSM_ASSERT_EQUALS("AuthnInstant attribute", expectedAuthnInstant->getEpoch(), statement->getAuthnInstant()->getEpoch()); + TS_ASSERT(statement->getSessionIndex()==NULL); + TS_ASSERT(statement->getSessionNotOnOrAfter()==NULL); + + TS_ASSERT(statement->getSubjectLocality()==NULL); + TS_ASSERT(statement->getAuthnContext()==NULL); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + AuthnStatement* statement = dynamic_cast(xo.get()); + TS_ASSERT(statement!=NULL); + + TSM_ASSERT_EQUALS("AuthnInstant attribute", expectedAuthnInstant->getEpoch(), statement->getAuthnInstant()->getEpoch()); + assertEquals("SessionIndex attribute", expectedSessionIndex, statement->getSessionIndex()); + TSM_ASSERT_EQUALS("SessionNotOnOrAfter attribute", expectedSessionNotOnOrAfter->getEpoch(), statement->getSessionNotOnOrAfter()->getEpoch()); + + TS_ASSERT(statement->getSubjectLocality()==NULL); + TS_ASSERT(statement->getAuthnContext()==NULL); + + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + AuthnStatement* statement= dynamic_cast(xo.get()); + TS_ASSERT(statement!=NULL); + + TS_ASSERT(statement->getAuthnInstant()==NULL); + TS_ASSERT(statement->getSessionIndex()==NULL); + TS_ASSERT(statement->getSessionNotOnOrAfter()==NULL); + + TS_ASSERT(statement->getSubjectLocality()!=NULL); + TS_ASSERT(statement->getAuthnContext()!=NULL); + + } + + void testSingleElementMarshall() { + AuthnStatement* statement=AuthnStatementBuilder::buildAuthnStatement(); + statement->setAuthnInstant(expectedAuthnInstant); + assertEquals(expectedDOM, statement); + } + + void testSingleElementOptionalAttributesMarshall() { + AuthnStatement* statement=AuthnStatementBuilder::buildAuthnStatement(); + statement->setAuthnInstant(expectedAuthnInstant); + statement->setSessionIndex(expectedSessionIndex); + statement->setSessionNotOnOrAfter(expectedSessionNotOnOrAfter); + assertEquals(expectedOptionalAttributesDOM, statement); + } + + void testChildElementsMarshall() { + AuthnStatement* statement=AuthnStatementBuilder::buildAuthnStatement(); + statement->setSubjectLocality(SubjectLocalityBuilder::buildSubjectLocality()); + statement->setAuthnContext(AuthnContextBuilder::buildAuthnContext()); + assertEquals(expectedChildElementsDOM, statement); + } + +}; diff --git a/samltest/saml2/core/impl/AuthzDecisionQuery20Test.h b/samltest/saml2/core/impl/AuthzDecisionQuery20Test.h index d1aea19..2f6232d 100644 --- a/samltest/saml2/core/impl/AuthzDecisionQuery20Test.h +++ b/samltest/saml2/core/impl/AuthzDecisionQuery20Test.h @@ -1,138 +1,138 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2p; -using namespace opensaml::saml2; - -class AuthzDecisionQuery20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* expectedID; - XMLCh* expectedVersion; - XMLCh* expectedConsent; - XMLCh* expectedDestination; - DateTime* expectedIssueInstant; - XMLCh* expectedResource; - -public: - void setUp() { - expectedID = XMLString::transcode("abc123");; - expectedVersion = XMLString::transcode("2.0"); - expectedConsent = XMLString::transcode("urn:string:consent"); - expectedDestination = XMLString::transcode("http://idp.example.org/endpoint"); - expectedIssueInstant = new DateTime(XMLString::transcode("2006-02-21T16:40:00.000Z")); - expectedIssueInstant->parseDateTime(); - expectedResource = XMLString::transcode("urn:string:resource"); - - singleElementFile = data_path + "saml2/core/impl/AuthzDecisionQuery.xml"; - singleElementOptionalAttributesFile = data_path + "saml2/core/impl/AuthzDecisionQueryOptionalAttributes.xml"; - childElementsFile = data_path + "saml2/core/impl/AuthzDecisionQueryChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&expectedID); - XMLString::release(&expectedVersion); - XMLString::release(&expectedConsent); - XMLString::release(&expectedDestination); - XMLString::release(&expectedResource); - delete expectedIssueInstant; - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - AuthzDecisionQuery* query = dynamic_cast(xo.get()); - TS_ASSERT(query!=NULL); - assertEquals("ID attribute", expectedID, query->getID()); - assertEquals("Version attribute", expectedVersion, query->getVersion()); - TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), query->getIssueInstant()->getEpoch()); - assertEquals("Resource attribute", expectedResource, query->getResource()); - - TS_ASSERT(query->getIssuer()==NULL); - TS_ASSERT(query->getSignature()==NULL); - TS_ASSERT(query->getExtensions()==NULL); - TS_ASSERT(query->getSubject()==NULL); - TSM_ASSERT_EQUALS("# of Action child elements", 0, query->getActions().size()); - TS_ASSERT(query->getEvidence()==NULL); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - AuthzDecisionQuery* query = dynamic_cast(xo.get()); - TS_ASSERT(query!=NULL); - assertEquals("Consent attribute", expectedConsent, query->getConsent()); - assertEquals("Destination attribute", expectedDestination, query->getDestination()); - - TS_ASSERT(query->getIssuer()==NULL); - TS_ASSERT(query->getSignature()==NULL); - TS_ASSERT(query->getExtensions()==NULL); - TS_ASSERT(query->getSubject()==NULL); - TSM_ASSERT_EQUALS("# of Action child elements", 0, query->getActions().size()); - TS_ASSERT(query->getEvidence()==NULL); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - AuthzDecisionQuery* query= dynamic_cast(xo.get()); - TS_ASSERT(query!=NULL); - TS_ASSERT(query->getIssuer()!=NULL); - TS_ASSERT(query->getSignature()==NULL); - TS_ASSERT(query->getExtensions()==NULL); - TS_ASSERT(query->getSubject()!=NULL); - TSM_ASSERT_EQUALS("# of Action child elements", 2, query->getActions().size()); - TS_ASSERT(query->getEvidence()!=NULL); - } - - void testSingleElementMarshall() { - AuthzDecisionQuery* query=AuthzDecisionQueryBuilder::buildAuthzDecisionQuery(); - query->setID(expectedID); - query->setIssueInstant(expectedIssueInstant); - //query->setVersion(expectedVersion); - query->setResource(expectedResource); - assertEquals(expectedDOM, query); - } - - void testSingleElementOptionalAttributesMarshall() { - AuthzDecisionQuery* query=AuthzDecisionQueryBuilder::buildAuthzDecisionQuery(); - query->setID(expectedID); - query->setIssueInstant(expectedIssueInstant); - //query->setVersion(expectedVersion); - query->setConsent(expectedConsent); - query->setDestination(expectedDestination); - query->setResource(expectedResource); - assertEquals(expectedOptionalAttributesDOM, query); - } - - void testChildElementsMarshall() { - AuthzDecisionQuery* query=AuthzDecisionQueryBuilder::buildAuthzDecisionQuery(); - query->setID(expectedID); - query->setIssueInstant(expectedIssueInstant); - // Do this just so don't have to redeclare the saml namespace prefix on every child element in the control XML file - Namespace* ns = new Namespace(opensaml::SAMLConstants::SAML20_NS, opensaml::SAMLConstants::SAML20_PREFIX); - query->addNamespace(*ns); - query->setIssuer(IssuerBuilder::buildIssuer()); - query->setSubject(SubjectBuilder::buildSubject()); - query->getActions().push_back(ActionBuilder::buildAction()); - query->getActions().push_back(ActionBuilder::buildAction()); - query->setEvidence(EvidenceBuilder::buildEvidence()); - assertEquals(expectedChildElementsDOM, query); - delete ns; - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2p; +using namespace opensaml::saml2; + +class AuthzDecisionQuery20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedID; + XMLCh* expectedVersion; + XMLCh* expectedConsent; + XMLCh* expectedDestination; + DateTime* expectedIssueInstant; + XMLCh* expectedResource; + +public: + void setUp() { + expectedID = XMLString::transcode("abc123");; + expectedVersion = XMLString::transcode("2.0"); + expectedConsent = XMLString::transcode("urn:string:consent"); + expectedDestination = XMLString::transcode("http://idp.example.org/endpoint"); + expectedIssueInstant = new DateTime(XMLString::transcode("2006-02-21T16:40:00.000Z")); + expectedIssueInstant->parseDateTime(); + expectedResource = XMLString::transcode("urn:string:resource"); + + singleElementFile = data_path + "saml2/core/impl/AuthzDecisionQuery.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/AuthzDecisionQueryOptionalAttributes.xml"; + childElementsFile = data_path + "saml2/core/impl/AuthzDecisionQueryChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedID); + XMLString::release(&expectedVersion); + XMLString::release(&expectedConsent); + XMLString::release(&expectedDestination); + XMLString::release(&expectedResource); + delete expectedIssueInstant; + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + AuthzDecisionQuery* query = dynamic_cast(xo.get()); + TS_ASSERT(query!=NULL); + assertEquals("ID attribute", expectedID, query->getID()); + assertEquals("Version attribute", expectedVersion, query->getVersion()); + TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), query->getIssueInstant()->getEpoch()); + assertEquals("Resource attribute", expectedResource, query->getResource()); + + TS_ASSERT(query->getIssuer()==NULL); + TS_ASSERT(query->getSignature()==NULL); + TS_ASSERT(query->getExtensions()==NULL); + TS_ASSERT(query->getSubject()==NULL); + TSM_ASSERT_EQUALS("# of Action child elements", 0, query->getActions().size()); + TS_ASSERT(query->getEvidence()==NULL); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + AuthzDecisionQuery* query = dynamic_cast(xo.get()); + TS_ASSERT(query!=NULL); + assertEquals("Consent attribute", expectedConsent, query->getConsent()); + assertEquals("Destination attribute", expectedDestination, query->getDestination()); + + TS_ASSERT(query->getIssuer()==NULL); + TS_ASSERT(query->getSignature()==NULL); + TS_ASSERT(query->getExtensions()==NULL); + TS_ASSERT(query->getSubject()==NULL); + TSM_ASSERT_EQUALS("# of Action child elements", 0, query->getActions().size()); + TS_ASSERT(query->getEvidence()==NULL); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + AuthzDecisionQuery* query= dynamic_cast(xo.get()); + TS_ASSERT(query!=NULL); + TS_ASSERT(query->getIssuer()!=NULL); + TS_ASSERT(query->getSignature()==NULL); + TS_ASSERT(query->getExtensions()==NULL); + TS_ASSERT(query->getSubject()!=NULL); + TSM_ASSERT_EQUALS("# of Action child elements", 2, query->getActions().size()); + TS_ASSERT(query->getEvidence()!=NULL); + } + + void testSingleElementMarshall() { + AuthzDecisionQuery* query=AuthzDecisionQueryBuilder::buildAuthzDecisionQuery(); + query->setID(expectedID); + query->setIssueInstant(expectedIssueInstant); + //query->setVersion(expectedVersion); + query->setResource(expectedResource); + assertEquals(expectedDOM, query); + } + + void testSingleElementOptionalAttributesMarshall() { + AuthzDecisionQuery* query=AuthzDecisionQueryBuilder::buildAuthzDecisionQuery(); + query->setID(expectedID); + query->setIssueInstant(expectedIssueInstant); + //query->setVersion(expectedVersion); + query->setConsent(expectedConsent); + query->setDestination(expectedDestination); + query->setResource(expectedResource); + assertEquals(expectedOptionalAttributesDOM, query); + } + + void testChildElementsMarshall() { + AuthzDecisionQuery* query=AuthzDecisionQueryBuilder::buildAuthzDecisionQuery(); + query->setID(expectedID); + query->setIssueInstant(expectedIssueInstant); + // Do this just so don't have to redeclare the saml namespace prefix on every child element in the control XML file + Namespace* ns = new Namespace(opensaml::SAMLConstants::SAML20_NS, opensaml::SAMLConstants::SAML20_PREFIX); + query->addNamespace(*ns); + query->setIssuer(IssuerBuilder::buildIssuer()); + query->setSubject(SubjectBuilder::buildSubject()); + query->getActions().push_back(ActionBuilder::buildAction()); + query->getActions().push_back(ActionBuilder::buildAction()); + query->setEvidence(EvidenceBuilder::buildEvidence()); + assertEquals(expectedChildElementsDOM, query); + delete ns; + } + +}; diff --git a/samltest/saml2/core/impl/AuthzDecisionStatement20Test.h b/samltest/saml2/core/impl/AuthzDecisionStatement20Test.h index fb0d5fd..5344c11 100644 --- a/samltest/saml2/core/impl/AuthzDecisionStatement20Test.h +++ b/samltest/saml2/core/impl/AuthzDecisionStatement20Test.h @@ -1,82 +1,82 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2; - -class AuthzDecisionStatement20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* expectedResource; - const XMLCh* expectedDecision; - -public: - void setUp() { - expectedResource = XMLString::transcode("urn:string:resource"); - expectedDecision = AuthzDecisionStatement::DECISION_PERMIT; - - singleElementFile = data_path + "saml2/core/impl/AuthzDecisionStatement.xml"; - childElementsFile = data_path + "saml2/core/impl/AuthzDecisionStatementChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&expectedResource); - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - AuthzDecisionStatement* statement = dynamic_cast(xo.get()); - TS_ASSERT(statement!=NULL); - - assertEquals("Resource attribute", expectedResource, statement->getResource()); - assertEquals("Decision attribute", expectedDecision, statement->getDecision()); - - TSM_ASSERT_EQUALS("# of Action child elements", 0, statement->getActions().size()); - TS_ASSERT(statement->getEvidence()==NULL); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - AuthzDecisionStatement* statement= dynamic_cast(xo.get()); - TS_ASSERT(statement!=NULL); - - assertEquals("Resource attribute", NULL, statement->getResource()); - assertEquals("Decision attribute", NULL, statement->getDecision()); - - TSM_ASSERT_EQUALS("# of Action child elements", 3, statement->getActions().size()); - TS_ASSERT(statement->getEvidence()!=NULL); - } - - void testSingleElementMarshall() { - AuthzDecisionStatement* statement=AuthzDecisionStatementBuilder::buildAuthzDecisionStatement(); - statement->setResource(expectedResource); - statement->setDecision(expectedDecision); - assertEquals(expectedDOM, statement); - } - - void testChildElementsMarshall() { - AuthzDecisionStatement* statement=AuthzDecisionStatementBuilder::buildAuthzDecisionStatement(); - statement->getActions().push_back(ActionBuilder::buildAction()); - statement->getActions().push_back(ActionBuilder::buildAction()); - statement->getActions().push_back(ActionBuilder::buildAction()); - statement->setEvidence(EvidenceBuilder::buildEvidence()); - assertEquals(expectedChildElementsDOM, statement); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +class AuthzDecisionStatement20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedResource; + const XMLCh* expectedDecision; + +public: + void setUp() { + expectedResource = XMLString::transcode("urn:string:resource"); + expectedDecision = AuthzDecisionStatement::DECISION_PERMIT; + + singleElementFile = data_path + "saml2/core/impl/AuthzDecisionStatement.xml"; + childElementsFile = data_path + "saml2/core/impl/AuthzDecisionStatementChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedResource); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + AuthzDecisionStatement* statement = dynamic_cast(xo.get()); + TS_ASSERT(statement!=NULL); + + assertEquals("Resource attribute", expectedResource, statement->getResource()); + assertEquals("Decision attribute", expectedDecision, statement->getDecision()); + + TSM_ASSERT_EQUALS("# of Action child elements", 0, statement->getActions().size()); + TS_ASSERT(statement->getEvidence()==NULL); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + AuthzDecisionStatement* statement= dynamic_cast(xo.get()); + TS_ASSERT(statement!=NULL); + + assertEquals("Resource attribute", NULL, statement->getResource()); + assertEquals("Decision attribute", NULL, statement->getDecision()); + + TSM_ASSERT_EQUALS("# of Action child elements", 3, statement->getActions().size()); + TS_ASSERT(statement->getEvidence()!=NULL); + } + + void testSingleElementMarshall() { + AuthzDecisionStatement* statement=AuthzDecisionStatementBuilder::buildAuthzDecisionStatement(); + statement->setResource(expectedResource); + statement->setDecision(expectedDecision); + assertEquals(expectedDOM, statement); + } + + void testChildElementsMarshall() { + AuthzDecisionStatement* statement=AuthzDecisionStatementBuilder::buildAuthzDecisionStatement(); + statement->getActions().push_back(ActionBuilder::buildAction()); + statement->getActions().push_back(ActionBuilder::buildAction()); + statement->getActions().push_back(ActionBuilder::buildAction()); + statement->setEvidence(EvidenceBuilder::buildEvidence()); + assertEquals(expectedChildElementsDOM, statement); + } + +}; diff --git a/samltest/saml2/core/impl/Conditions20Test.h b/samltest/saml2/core/impl/Conditions20Test.h index e144e5a..e643cf7 100644 --- a/samltest/saml2/core/impl/Conditions20Test.h +++ b/samltest/saml2/core/impl/Conditions20Test.h @@ -1,127 +1,127 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2; - -class Conditions20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - DateTime* expectedNotBefore; - DateTime* expectedNotOnOrAfter; - -public: - void setUp() { - expectedNotBefore = new DateTime(XMLString::transcode("1984-08-26T10:01:30.043Z")); - expectedNotBefore->parseDateTime(); - expectedNotOnOrAfter = new DateTime(XMLString::transcode("1984-08-26T10:11:30.043Z")); - expectedNotOnOrAfter->parseDateTime(); - - singleElementFile = data_path + "saml2/core/impl/Conditions.xml"; - singleElementOptionalAttributesFile = data_path + "saml2/core/impl/ConditionsOptionalAttributes.xml"; - childElementsFile = data_path + "saml2/core/impl/ConditionsChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - delete expectedNotBefore; - delete expectedNotOnOrAfter; - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - Conditions* conditions = dynamic_cast(xo.get()); - TS_ASSERT(conditions!=NULL); - - - TS_ASSERT(conditions->getNotBefore()==NULL); - TS_ASSERT(conditions->getNotOnOrAfter()==NULL); - - TSM_ASSERT_EQUALS("# of Condition child elements", 0, conditions->getConditions().size()); - TSM_ASSERT_EQUALS("# of AudienceRestriction child elements", 0, conditions->getAudienceRestrictions().size()); - TSM_ASSERT_EQUALS("# of OneTimeUse child elements", 0, conditions->getOneTimeUses().size()); - TSM_ASSERT_EQUALS("# of ProxyRestriction child elements", 0, conditions->getProxyRestrictions().size()); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - Conditions* conditions = dynamic_cast(xo.get()); - TS_ASSERT(conditions!=NULL); - - TSM_ASSERT_EQUALS("NotBefore attribute", expectedNotBefore->getEpoch(), conditions->getNotBefore()->getEpoch()); - TSM_ASSERT_EQUALS("NotOnOrAfter attribute", expectedNotOnOrAfter->getEpoch(), conditions->getNotOnOrAfter()->getEpoch()); - - TSM_ASSERT_EQUALS("# of Condition child elements", 0, conditions->getConditions().size()); - TSM_ASSERT_EQUALS("# of AudienceRestriction child elements", 0, conditions->getAudienceRestrictions().size()); - TSM_ASSERT_EQUALS("# of OneTimeUse child elements", 0, conditions->getOneTimeUses().size()); - TSM_ASSERT_EQUALS("# of ProxyRestriction child elements", 0, conditions->getProxyRestrictions().size()); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - Conditions* conditions= dynamic_cast(xo.get()); - TS_ASSERT(conditions!=NULL); - - TS_ASSERT(conditions->getNotBefore()==NULL); - TS_ASSERT(conditions->getNotOnOrAfter()==NULL); - - TSM_ASSERT_EQUALS("# of Condition child elements", 0, conditions->getConditions().size()); - TSM_ASSERT_EQUALS("# of AudienceRestriction child elements", 3, conditions->getAudienceRestrictions().size()); - TSM_ASSERT_EQUALS("# of OneTimeUse child elements", 1, conditions->getOneTimeUses().size()); - TSM_ASSERT_EQUALS("# of ProxyRestriction child elements", 2, conditions->getProxyRestrictions().size()); - } - - void testSingleElementMarshall() { - Conditions* conditions=ConditionsBuilder::buildConditions(); - assertEquals(expectedDOM, conditions); - } - - void testSingleElementOptionalAttributesMarshall() { - Conditions* conditions=ConditionsBuilder::buildConditions(); - conditions->setNotBefore(expectedNotBefore); - conditions->setNotOnOrAfter(expectedNotOnOrAfter); - assertEquals(expectedOptionalAttributesDOM, conditions); - } - - void testChildElementsMarshall() { - Conditions* conditions=ConditionsBuilder::buildConditions(); - - //Test storing children as their direct type - conditions->getAudienceRestrictions().push_back(AudienceRestrictionBuilder::buildAudienceRestriction()); - conditions->getAudienceRestrictions().push_back(AudienceRestrictionBuilder::buildAudienceRestriction()); - conditions->getProxyRestrictions().push_back(ProxyRestrictionBuilder::buildProxyRestriction()); - conditions->getAudienceRestrictions().push_back(AudienceRestrictionBuilder::buildAudienceRestriction()); - conditions->getOneTimeUses().push_back(OneTimeUseBuilder::buildOneTimeUse()); - conditions->getProxyRestrictions().push_back(ProxyRestrictionBuilder::buildProxyRestriction()); - assertEquals(expectedChildElementsDOM, conditions); - - // Note: assertEquals() above has already 'delete'-ed the XMLObject* it was passed - conditions=NULL; - conditions=ConditionsBuilder::buildConditions(); - - //Test storing children as a Condition (each is a derived type of ConditionAbstractType) - conditions->getConditions().push_back(AudienceRestrictionBuilder::buildAudienceRestriction()); - conditions->getConditions().push_back(AudienceRestrictionBuilder::buildAudienceRestriction()); - conditions->getConditions().push_back(ProxyRestrictionBuilder::buildProxyRestriction()); - conditions->getConditions().push_back(AudienceRestrictionBuilder::buildAudienceRestriction()); - conditions->getConditions().push_back(OneTimeUseBuilder::buildOneTimeUse()); - conditions->getConditions().push_back(ProxyRestrictionBuilder::buildProxyRestriction()); - assertEquals(expectedChildElementsDOM, conditions); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +class Conditions20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + DateTime* expectedNotBefore; + DateTime* expectedNotOnOrAfter; + +public: + void setUp() { + expectedNotBefore = new DateTime(XMLString::transcode("1984-08-26T10:01:30.043Z")); + expectedNotBefore->parseDateTime(); + expectedNotOnOrAfter = new DateTime(XMLString::transcode("1984-08-26T10:11:30.043Z")); + expectedNotOnOrAfter->parseDateTime(); + + singleElementFile = data_path + "saml2/core/impl/Conditions.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/ConditionsOptionalAttributes.xml"; + childElementsFile = data_path + "saml2/core/impl/ConditionsChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + delete expectedNotBefore; + delete expectedNotOnOrAfter; + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + Conditions* conditions = dynamic_cast(xo.get()); + TS_ASSERT(conditions!=NULL); + + + TS_ASSERT(conditions->getNotBefore()==NULL); + TS_ASSERT(conditions->getNotOnOrAfter()==NULL); + + TSM_ASSERT_EQUALS("# of Condition child elements", 0, conditions->getConditions().size()); + TSM_ASSERT_EQUALS("# of AudienceRestriction child elements", 0, conditions->getAudienceRestrictions().size()); + TSM_ASSERT_EQUALS("# of OneTimeUse child elements", 0, conditions->getOneTimeUses().size()); + TSM_ASSERT_EQUALS("# of ProxyRestriction child elements", 0, conditions->getProxyRestrictions().size()); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + Conditions* conditions = dynamic_cast(xo.get()); + TS_ASSERT(conditions!=NULL); + + TSM_ASSERT_EQUALS("NotBefore attribute", expectedNotBefore->getEpoch(), conditions->getNotBefore()->getEpoch()); + TSM_ASSERT_EQUALS("NotOnOrAfter attribute", expectedNotOnOrAfter->getEpoch(), conditions->getNotOnOrAfter()->getEpoch()); + + TSM_ASSERT_EQUALS("# of Condition child elements", 0, conditions->getConditions().size()); + TSM_ASSERT_EQUALS("# of AudienceRestriction child elements", 0, conditions->getAudienceRestrictions().size()); + TSM_ASSERT_EQUALS("# of OneTimeUse child elements", 0, conditions->getOneTimeUses().size()); + TSM_ASSERT_EQUALS("# of ProxyRestriction child elements", 0, conditions->getProxyRestrictions().size()); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + Conditions* conditions= dynamic_cast(xo.get()); + TS_ASSERT(conditions!=NULL); + + TS_ASSERT(conditions->getNotBefore()==NULL); + TS_ASSERT(conditions->getNotOnOrAfter()==NULL); + + TSM_ASSERT_EQUALS("# of Condition child elements", 0, conditions->getConditions().size()); + TSM_ASSERT_EQUALS("# of AudienceRestriction child elements", 3, conditions->getAudienceRestrictions().size()); + TSM_ASSERT_EQUALS("# of OneTimeUse child elements", 1, conditions->getOneTimeUses().size()); + TSM_ASSERT_EQUALS("# of ProxyRestriction child elements", 2, conditions->getProxyRestrictions().size()); + } + + void testSingleElementMarshall() { + Conditions* conditions=ConditionsBuilder::buildConditions(); + assertEquals(expectedDOM, conditions); + } + + void testSingleElementOptionalAttributesMarshall() { + Conditions* conditions=ConditionsBuilder::buildConditions(); + conditions->setNotBefore(expectedNotBefore); + conditions->setNotOnOrAfter(expectedNotOnOrAfter); + assertEquals(expectedOptionalAttributesDOM, conditions); + } + + void testChildElementsMarshall() { + Conditions* conditions=ConditionsBuilder::buildConditions(); + + //Test storing children as their direct type + conditions->getAudienceRestrictions().push_back(AudienceRestrictionBuilder::buildAudienceRestriction()); + conditions->getAudienceRestrictions().push_back(AudienceRestrictionBuilder::buildAudienceRestriction()); + conditions->getProxyRestrictions().push_back(ProxyRestrictionBuilder::buildProxyRestriction()); + conditions->getAudienceRestrictions().push_back(AudienceRestrictionBuilder::buildAudienceRestriction()); + conditions->getOneTimeUses().push_back(OneTimeUseBuilder::buildOneTimeUse()); + conditions->getProxyRestrictions().push_back(ProxyRestrictionBuilder::buildProxyRestriction()); + assertEquals(expectedChildElementsDOM, conditions); + + // Note: assertEquals() above has already 'delete'-ed the XMLObject* it was passed + conditions=NULL; + conditions=ConditionsBuilder::buildConditions(); + + //Test storing children as a Condition (each is a derived type of ConditionAbstractType) + conditions->getConditions().push_back(AudienceRestrictionBuilder::buildAudienceRestriction()); + conditions->getConditions().push_back(AudienceRestrictionBuilder::buildAudienceRestriction()); + conditions->getConditions().push_back(ProxyRestrictionBuilder::buildProxyRestriction()); + conditions->getConditions().push_back(AudienceRestrictionBuilder::buildAudienceRestriction()); + conditions->getConditions().push_back(OneTimeUseBuilder::buildOneTimeUse()); + conditions->getConditions().push_back(ProxyRestrictionBuilder::buildProxyRestriction()); + assertEquals(expectedChildElementsDOM, conditions); + } + +}; diff --git a/samltest/saml2/core/impl/Evidence20Test.h b/samltest/saml2/core/impl/Evidence20Test.h index ae03184..5aa0bd5 100644 --- a/samltest/saml2/core/impl/Evidence20Test.h +++ b/samltest/saml2/core/impl/Evidence20Test.h @@ -1,85 +1,85 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2; - -class Evidence20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - -public: - void setUp() { - singleElementFile = data_path + "saml2/core/impl/Evidence.xml"; - childElementsFile = data_path + "saml2/core/impl/EvidenceChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - Evidence* evidence = dynamic_cast(xo.get()); - TS_ASSERT(evidence!=NULL); - - TSM_ASSERT_EQUALS("# of AssertionIDRef child elements", 0, evidence->getAssertionIDRefs().size()); - TSM_ASSERT_EQUALS("# of AssertionURIRef child elements", 0, evidence->getAssertionURIRefs().size()); - TSM_ASSERT_EQUALS("# of Assertion child elements", 0, evidence->getAssertions().size()); - TSM_ASSERT_EQUALS("# of EncryptedAssertion child elements", 0, evidence->getEncryptedAssertions().size()); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - Evidence* evidence= dynamic_cast(xo.get()); - TS_ASSERT(evidence!=NULL); - - TSM_ASSERT_EQUALS("# of AssertionIDRef child elements", 3, evidence->getAssertionIDRefs().size()); - TSM_ASSERT_EQUALS("# of AssertionURIRef child elements", 2, evidence->getAssertionURIRefs().size()); - TSM_ASSERT_EQUALS("# of Assertion child elements", 2, evidence->getAssertions().size()); - TSM_ASSERT_EQUALS("# of EncryptedAssertion child elements", 1, evidence->getEncryptedAssertions().size()); - } - - void testSingleElementMarshall() { - Evidence* evidence=EvidenceBuilder::buildEvidence(); - assertEquals(expectedDOM, evidence); - } - - void testChildElementsMarshall() { - Evidence* evidence=EvidenceBuilder::buildEvidence(); - - Assertion* assertion1 = AssertionBuilder::buildAssertion(); - assertion1->setID(XMLString::transcode("abc123")); - assertion1->setIssueInstant(new DateTime(XMLString::transcode("2006-07-21T22:27:19Z"))); - - Assertion* assertion2 = AssertionBuilder::buildAssertion(); - assertion2->setID(XMLString::transcode("def456")); - assertion2->setIssueInstant(new DateTime(XMLString::transcode("2006-07-21T22:27:19Z"))); - - evidence->getAssertionIDRefs().push_back(AssertionIDRefBuilder::buildAssertionIDRef()); - evidence->getAssertionIDRefs().push_back(AssertionIDRefBuilder::buildAssertionIDRef()); - evidence->getAssertionURIRefs().push_back(AssertionURIRefBuilder::buildAssertionURIRef()); - evidence->getAssertionIDRefs().push_back(AssertionIDRefBuilder::buildAssertionIDRef()); - evidence->getAssertionURIRefs().push_back(AssertionURIRefBuilder::buildAssertionURIRef()); - evidence->getAssertions().push_back(assertion1); - evidence->getEncryptedAssertions().push_back(EncryptedAssertionBuilder::buildEncryptedAssertion()); - evidence->getAssertions().push_back(assertion2); - assertEquals(expectedChildElementsDOM, evidence); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +class Evidence20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + +public: + void setUp() { + singleElementFile = data_path + "saml2/core/impl/Evidence.xml"; + childElementsFile = data_path + "saml2/core/impl/EvidenceChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + Evidence* evidence = dynamic_cast(xo.get()); + TS_ASSERT(evidence!=NULL); + + TSM_ASSERT_EQUALS("# of AssertionIDRef child elements", 0, evidence->getAssertionIDRefs().size()); + TSM_ASSERT_EQUALS("# of AssertionURIRef child elements", 0, evidence->getAssertionURIRefs().size()); + TSM_ASSERT_EQUALS("# of Assertion child elements", 0, evidence->getAssertions().size()); + TSM_ASSERT_EQUALS("# of EncryptedAssertion child elements", 0, evidence->getEncryptedAssertions().size()); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + Evidence* evidence= dynamic_cast(xo.get()); + TS_ASSERT(evidence!=NULL); + + TSM_ASSERT_EQUALS("# of AssertionIDRef child elements", 3, evidence->getAssertionIDRefs().size()); + TSM_ASSERT_EQUALS("# of AssertionURIRef child elements", 2, evidence->getAssertionURIRefs().size()); + TSM_ASSERT_EQUALS("# of Assertion child elements", 2, evidence->getAssertions().size()); + TSM_ASSERT_EQUALS("# of EncryptedAssertion child elements", 1, evidence->getEncryptedAssertions().size()); + } + + void testSingleElementMarshall() { + Evidence* evidence=EvidenceBuilder::buildEvidence(); + assertEquals(expectedDOM, evidence); + } + + void testChildElementsMarshall() { + Evidence* evidence=EvidenceBuilder::buildEvidence(); + + Assertion* assertion1 = AssertionBuilder::buildAssertion(); + assertion1->setID(XMLString::transcode("abc123")); + assertion1->setIssueInstant(new DateTime(XMLString::transcode("2006-07-21T22:27:19Z"))); + + Assertion* assertion2 = AssertionBuilder::buildAssertion(); + assertion2->setID(XMLString::transcode("def456")); + assertion2->setIssueInstant(new DateTime(XMLString::transcode("2006-07-21T22:27:19Z"))); + + evidence->getAssertionIDRefs().push_back(AssertionIDRefBuilder::buildAssertionIDRef()); + evidence->getAssertionIDRefs().push_back(AssertionIDRefBuilder::buildAssertionIDRef()); + evidence->getAssertionURIRefs().push_back(AssertionURIRefBuilder::buildAssertionURIRef()); + evidence->getAssertionIDRefs().push_back(AssertionIDRefBuilder::buildAssertionIDRef()); + evidence->getAssertionURIRefs().push_back(AssertionURIRefBuilder::buildAssertionURIRef()); + evidence->getAssertions().push_back(assertion1); + evidence->getEncryptedAssertions().push_back(EncryptedAssertionBuilder::buildEncryptedAssertion()); + evidence->getAssertions().push_back(assertion2); + assertEquals(expectedChildElementsDOM, evidence); + } + +}; diff --git a/samltest/saml2/core/impl/IDPEntry20Test.h b/samltest/saml2/core/impl/IDPEntry20Test.h index f51d740..5519b7a 100644 --- a/samltest/saml2/core/impl/IDPEntry20Test.h +++ b/samltest/saml2/core/impl/IDPEntry20Test.h @@ -1,77 +1,77 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2p; -using namespace opensaml::saml2; - -class IDPEntry20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* expectedProviderID; - XMLCh* expectedName; - XMLCh* expectedLoc; - -public: - void setUp() { - expectedProviderID = XMLString::transcode("urn:string:providerid");; - expectedName = XMLString::transcode("Example IdP"); - expectedLoc = XMLString::transcode("http://idp.example.org/endpoint"); - - singleElementFile = data_path + "saml2/core/impl/IDPEntry.xml"; - singleElementOptionalAttributesFile = data_path + "saml2/core/impl/IDPEntryOptionalAttributes.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&expectedProviderID); - XMLString::release(&expectedName); - XMLString::release(&expectedLoc); - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - IDPEntry* entry = dynamic_cast(xo.get()); - TS_ASSERT(entry!=NULL); - assertEquals("ProviderID attribute", expectedProviderID, entry->getProviderID()); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - IDPEntry* entry = dynamic_cast(xo.get()); - TS_ASSERT(entry!=NULL); - assertEquals("ProviderID attribute", expectedProviderID, entry->getProviderID()); - assertEquals("Name attribute", expectedName, entry->getName()); - assertEquals("Loc attribute", expectedLoc, entry->getLoc()); - } - - void testSingleElementMarshall() { - IDPEntry* entry=IDPEntryBuilder::buildIDPEntry(); - entry->setProviderID(expectedProviderID); - assertEquals(expectedDOM, entry); - } - - void testSingleElementOptionalAttributesMarshall() { - IDPEntry* entry=IDPEntryBuilder::buildIDPEntry(); - entry->setProviderID(expectedProviderID); - entry->setName(expectedName); - entry->setLoc(expectedLoc); - assertEquals(expectedOptionalAttributesDOM, entry); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2p; +using namespace opensaml::saml2; + +class IDPEntry20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedProviderID; + XMLCh* expectedName; + XMLCh* expectedLoc; + +public: + void setUp() { + expectedProviderID = XMLString::transcode("urn:string:providerid");; + expectedName = XMLString::transcode("Example IdP"); + expectedLoc = XMLString::transcode("http://idp.example.org/endpoint"); + + singleElementFile = data_path + "saml2/core/impl/IDPEntry.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/IDPEntryOptionalAttributes.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedProviderID); + XMLString::release(&expectedName); + XMLString::release(&expectedLoc); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + IDPEntry* entry = dynamic_cast(xo.get()); + TS_ASSERT(entry!=NULL); + assertEquals("ProviderID attribute", expectedProviderID, entry->getProviderID()); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + IDPEntry* entry = dynamic_cast(xo.get()); + TS_ASSERT(entry!=NULL); + assertEquals("ProviderID attribute", expectedProviderID, entry->getProviderID()); + assertEquals("Name attribute", expectedName, entry->getName()); + assertEquals("Loc attribute", expectedLoc, entry->getLoc()); + } + + void testSingleElementMarshall() { + IDPEntry* entry=IDPEntryBuilder::buildIDPEntry(); + entry->setProviderID(expectedProviderID); + assertEquals(expectedDOM, entry); + } + + void testSingleElementOptionalAttributesMarshall() { + IDPEntry* entry=IDPEntryBuilder::buildIDPEntry(); + entry->setProviderID(expectedProviderID); + entry->setName(expectedName); + entry->setLoc(expectedLoc); + assertEquals(expectedOptionalAttributesDOM, entry); + } + +}; diff --git a/samltest/saml2/core/impl/IDPList20Test.h b/samltest/saml2/core/impl/IDPList20Test.h index 2231829..43da267 100644 --- a/samltest/saml2/core/impl/IDPList20Test.h +++ b/samltest/saml2/core/impl/IDPList20Test.h @@ -1,68 +1,68 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2p; -using namespace opensaml::saml2; - -class IDPList20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - -public: - void setUp() { - singleElementFile = data_path + "saml2/core/impl/IDPList.xml"; - childElementsFile = data_path + "saml2/core/impl/IDPListChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - IDPList* list = dynamic_cast(xo.get()); - TS_ASSERT(list!=NULL); - - TS_ASSERT(list->getGetComplete()==NULL); - TSM_ASSERT_EQUALS("# of IDPEntry child elements", 0, list->getIDPEntrys().size()); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - IDPList* list= dynamic_cast(xo.get()); - TS_ASSERT(list!=NULL); - TS_ASSERT(list->getGetComplete()!=NULL); - TSM_ASSERT_EQUALS("# of IDPEntry child elements", 3, list->getIDPEntrys().size()); - } - - void testSingleElementMarshall() { - IDPList* list=IDPListBuilder::buildIDPList(); - assertEquals(expectedDOM, list); - } - - void testChildElementsMarshall() { - IDPList* list=IDPListBuilder::buildIDPList(); - list->getIDPEntrys().push_back(IDPEntryBuilder::buildIDPEntry()); - list->getIDPEntrys().push_back(IDPEntryBuilder::buildIDPEntry()); - list->getIDPEntrys().push_back(IDPEntryBuilder::buildIDPEntry()); - list->setGetComplete(GetCompleteBuilder::buildGetComplete()); - assertEquals(expectedChildElementsDOM, list); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2p; +using namespace opensaml::saml2; + +class IDPList20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + +public: + void setUp() { + singleElementFile = data_path + "saml2/core/impl/IDPList.xml"; + childElementsFile = data_path + "saml2/core/impl/IDPListChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + IDPList* list = dynamic_cast(xo.get()); + TS_ASSERT(list!=NULL); + + TS_ASSERT(list->getGetComplete()==NULL); + TSM_ASSERT_EQUALS("# of IDPEntry child elements", 0, list->getIDPEntrys().size()); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + IDPList* list= dynamic_cast(xo.get()); + TS_ASSERT(list!=NULL); + TS_ASSERT(list->getGetComplete()!=NULL); + TSM_ASSERT_EQUALS("# of IDPEntry child elements", 3, list->getIDPEntrys().size()); + } + + void testSingleElementMarshall() { + IDPList* list=IDPListBuilder::buildIDPList(); + assertEquals(expectedDOM, list); + } + + void testChildElementsMarshall() { + IDPList* list=IDPListBuilder::buildIDPList(); + list->getIDPEntrys().push_back(IDPEntryBuilder::buildIDPEntry()); + list->getIDPEntrys().push_back(IDPEntryBuilder::buildIDPEntry()); + list->getIDPEntrys().push_back(IDPEntryBuilder::buildIDPEntry()); + list->setGetComplete(GetCompleteBuilder::buildGetComplete()); + assertEquals(expectedChildElementsDOM, list); + } + +}; diff --git a/samltest/saml2/core/impl/Issuer20Test.h b/samltest/saml2/core/impl/Issuer20Test.h index 849b436..d9a4070 100644 --- a/samltest/saml2/core/impl/Issuer20Test.h +++ b/samltest/saml2/core/impl/Issuer20Test.h @@ -1,93 +1,93 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2; - -class Issuer20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* expectedNameQualifier; - XMLCh* expectedSPNameQualifier; - XMLCh* expectedFormat; - XMLCh* expectedSPProvidedID; - XMLCh* expectedContent; - -public: - void setUp() { - expectedNameQualifier = XMLString::transcode("nq"); - expectedSPNameQualifier = XMLString::transcode("spnq"); - expectedFormat = XMLString::transcode("format"); - expectedSPProvidedID = XMLString::transcode("spID"); - expectedContent = XMLString::transcode("someIssuer"); - - singleElementFile = data_path + "saml2/core/impl/Issuer.xml"; - singleElementOptionalAttributesFile = data_path + "saml2/core/impl/IssuerOptionalAttributes.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&expectedNameQualifier); - XMLString::release(&expectedSPNameQualifier); - XMLString::release(&expectedFormat); - XMLString::release(&expectedSPProvidedID); - XMLString::release(&expectedContent); - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - Issuer* issuer = dynamic_cast(xo.get()); - TS_ASSERT(issuer!=NULL); - - assertEquals("Element content", expectedContent, issuer->getName()); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - Issuer* issuer = dynamic_cast(xo.get()); - TS_ASSERT(issuer!=NULL); - - assertEquals("NameQualifier attribute", expectedNameQualifier, issuer->getNameQualifier()); - assertEquals("SPNameQualifier attribute", expectedSPNameQualifier, issuer->getSPNameQualifier()); - assertEquals("Format attribute", expectedFormat, issuer->getFormat()); - assertEquals("SPProvidedID attribute", expectedSPProvidedID, issuer->getSPProvidedID()); - assertEquals("Element content", expectedContent, issuer->getName()); - } - - - void testSingleElementMarshall() { - Issuer* issuer = IssuerBuilder::buildIssuer(); - TS_ASSERT(issuer!=NULL); - - issuer->setName(expectedContent); - assertEquals(expectedDOM, issuer); - } - - void testSingleElementOptionalAttributesMarshall() { - Issuer* issuer = IssuerBuilder::buildIssuer(); - TS_ASSERT(issuer!=NULL); - - issuer->setNameQualifier(expectedNameQualifier); - issuer->setSPNameQualifier(expectedSPNameQualifier); - issuer->setFormat(expectedFormat); - issuer->setSPProvidedID(expectedSPProvidedID); - issuer->setName(expectedContent); - assertEquals(expectedOptionalAttributesDOM, issuer); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +class Issuer20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedNameQualifier; + XMLCh* expectedSPNameQualifier; + XMLCh* expectedFormat; + XMLCh* expectedSPProvidedID; + XMLCh* expectedContent; + +public: + void setUp() { + expectedNameQualifier = XMLString::transcode("nq"); + expectedSPNameQualifier = XMLString::transcode("spnq"); + expectedFormat = XMLString::transcode("format"); + expectedSPProvidedID = XMLString::transcode("spID"); + expectedContent = XMLString::transcode("someIssuer"); + + singleElementFile = data_path + "saml2/core/impl/Issuer.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/IssuerOptionalAttributes.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedNameQualifier); + XMLString::release(&expectedSPNameQualifier); + XMLString::release(&expectedFormat); + XMLString::release(&expectedSPProvidedID); + XMLString::release(&expectedContent); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + Issuer* issuer = dynamic_cast(xo.get()); + TS_ASSERT(issuer!=NULL); + + assertEquals("Element content", expectedContent, issuer->getName()); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + Issuer* issuer = dynamic_cast(xo.get()); + TS_ASSERT(issuer!=NULL); + + assertEquals("NameQualifier attribute", expectedNameQualifier, issuer->getNameQualifier()); + assertEquals("SPNameQualifier attribute", expectedSPNameQualifier, issuer->getSPNameQualifier()); + assertEquals("Format attribute", expectedFormat, issuer->getFormat()); + assertEquals("SPProvidedID attribute", expectedSPProvidedID, issuer->getSPProvidedID()); + assertEquals("Element content", expectedContent, issuer->getName()); + } + + + void testSingleElementMarshall() { + Issuer* issuer = IssuerBuilder::buildIssuer(); + TS_ASSERT(issuer!=NULL); + + issuer->setName(expectedContent); + assertEquals(expectedDOM, issuer); + } + + void testSingleElementOptionalAttributesMarshall() { + Issuer* issuer = IssuerBuilder::buildIssuer(); + TS_ASSERT(issuer!=NULL); + + issuer->setNameQualifier(expectedNameQualifier); + issuer->setSPNameQualifier(expectedSPNameQualifier); + issuer->setFormat(expectedFormat); + issuer->setSPProvidedID(expectedSPProvidedID); + issuer->setName(expectedContent); + assertEquals(expectedOptionalAttributesDOM, issuer); + } + +}; diff --git a/samltest/saml2/core/impl/KeyInfoConfirmationDataType20Test.h b/samltest/saml2/core/impl/KeyInfoConfirmationDataType20Test.h index f4aefce..76b274a 100644 --- a/samltest/saml2/core/impl/KeyInfoConfirmationDataType20Test.h +++ b/samltest/saml2/core/impl/KeyInfoConfirmationDataType20Test.h @@ -1,124 +1,124 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2; -using namespace xmlsignature; - -//TODO need testing for ElementProxy and wildcard attributes/elements - -class KeyInfoConfirmationDataType20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - DateTime* expectedNotBefore; - DateTime* expectedNotOnOrAfter; - XMLCh* expectedRecipient; - XMLCh* expectedInResponseTo; - XMLCh* expectedAddress; - -public: - void setUp() { - expectedNotBefore = new DateTime(XMLString::transcode("1984-08-26T10:01:30.043Z")); - expectedNotBefore->parseDateTime(); - expectedNotOnOrAfter = new DateTime(XMLString::transcode("1984-08-26T10:11:30.043Z")); - expectedNotOnOrAfter->parseDateTime(); - expectedRecipient = (XMLString::transcode("recipient")); - expectedInResponseTo = (XMLString::transcode("inresponse")); - expectedAddress = (XMLString::transcode("address")); - - singleElementFile = data_path + "saml2/core/impl/KeyInfoConfirmationDataType.xml"; - singleElementOptionalAttributesFile = data_path + "saml2/core/impl/KeyInfoConfirmationDataTypeOptionalAttributes.xml"; - childElementsFile = data_path + "saml2/core/impl/KeyInfoConfirmationDataTypeChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - delete expectedNotBefore; - delete expectedNotOnOrAfter; - XMLString::release(&expectedRecipient); - XMLString::release(&expectedInResponseTo); - XMLString::release(&expectedAddress); - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - KeyInfoConfirmationDataType* scd = dynamic_cast(xo.get()); - TS_ASSERT(scd!=NULL); - - TS_ASSERT(scd->getNotBefore()==NULL); - TS_ASSERT(scd->getNotOnOrAfter()==NULL); - TS_ASSERT(scd->getRecipient()==NULL); - TS_ASSERT(scd->getInResponseTo()==NULL); - TS_ASSERT(scd->getAddress()==NULL); - TSM_ASSERT_EQUALS("# of KeyInfo child elements", 0, scd->getKeyInfos().size()); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - KeyInfoConfirmationDataType* scd = dynamic_cast(xo.get()); - TS_ASSERT(scd!=NULL); - - TSM_ASSERT_EQUALS("NotBefore attribute", expectedNotBefore->getEpoch(), scd->getNotBefore()->getEpoch()); - TSM_ASSERT_EQUALS("NotOnOrAfter attribute", expectedNotOnOrAfter->getEpoch(), scd->getNotOnOrAfter()->getEpoch()); - assertEquals("Recipient attribute", expectedRecipient, scd->getRecipient()); - assertEquals("InResponseTo attribute", expectedInResponseTo, scd->getInResponseTo()); - assertEquals("Address attribute", expectedAddress, scd->getAddress()); - TSM_ASSERT_EQUALS("# of KeyInfo child elements", 0, scd->getKeyInfos().size()); - - //TODO need to test with some wildcard attributes - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - KeyInfoConfirmationDataType* scd= dynamic_cast(xo.get()); - TS_ASSERT(scd!=NULL); - - TS_ASSERT(scd->getNotBefore()==NULL); - TS_ASSERT(scd->getNotOnOrAfter()==NULL); - TS_ASSERT(scd->getRecipient()==NULL); - TS_ASSERT(scd->getInResponseTo()==NULL); - TS_ASSERT(scd->getAddress()==NULL); - TSM_ASSERT_EQUALS("# of KeyInfo child elements", 1, scd->getKeyInfos().size()); - - //TODO need to test with some wildcard child elements - } - - void testSingleElementMarshall() { - KeyInfoConfirmationDataType* scd=KeyInfoConfirmationDataTypeBuilder::buildKeyInfoConfirmationDataType(); - assertEquals(expectedDOM, scd); - } - - void testSingleElementOptionalAttributesMarshall() { - KeyInfoConfirmationDataType* scd=KeyInfoConfirmationDataTypeBuilder::buildKeyInfoConfirmationDataType(); - scd->setNotBefore(expectedNotBefore); - scd->setNotOnOrAfter(expectedNotOnOrAfter); - scd->setRecipient(expectedRecipient); - scd->setInResponseTo(expectedInResponseTo); - scd->setAddress(expectedAddress); - //TODO need to test with some wilcard attributes - assertEquals(expectedOptionalAttributesDOM, scd); - } - - void testChildElementsMarshall() { - KeyInfoConfirmationDataType* scd=KeyInfoConfirmationDataTypeBuilder::buildKeyInfoConfirmationDataType(); - scd->getKeyInfos().push_back(KeyInfoBuilder::buildKeyInfo()); - //TODO need to test with some wilcard child elements - assertEquals(expectedChildElementsDOM, scd); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; +using namespace xmlsignature; + +//TODO need testing for ElementProxy and wildcard attributes/elements + +class KeyInfoConfirmationDataType20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + DateTime* expectedNotBefore; + DateTime* expectedNotOnOrAfter; + XMLCh* expectedRecipient; + XMLCh* expectedInResponseTo; + XMLCh* expectedAddress; + +public: + void setUp() { + expectedNotBefore = new DateTime(XMLString::transcode("1984-08-26T10:01:30.043Z")); + expectedNotBefore->parseDateTime(); + expectedNotOnOrAfter = new DateTime(XMLString::transcode("1984-08-26T10:11:30.043Z")); + expectedNotOnOrAfter->parseDateTime(); + expectedRecipient = (XMLString::transcode("recipient")); + expectedInResponseTo = (XMLString::transcode("inresponse")); + expectedAddress = (XMLString::transcode("address")); + + singleElementFile = data_path + "saml2/core/impl/KeyInfoConfirmationDataType.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/KeyInfoConfirmationDataTypeOptionalAttributes.xml"; + childElementsFile = data_path + "saml2/core/impl/KeyInfoConfirmationDataTypeChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + delete expectedNotBefore; + delete expectedNotOnOrAfter; + XMLString::release(&expectedRecipient); + XMLString::release(&expectedInResponseTo); + XMLString::release(&expectedAddress); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + KeyInfoConfirmationDataType* scd = dynamic_cast(xo.get()); + TS_ASSERT(scd!=NULL); + + TS_ASSERT(scd->getNotBefore()==NULL); + TS_ASSERT(scd->getNotOnOrAfter()==NULL); + TS_ASSERT(scd->getRecipient()==NULL); + TS_ASSERT(scd->getInResponseTo()==NULL); + TS_ASSERT(scd->getAddress()==NULL); + TSM_ASSERT_EQUALS("# of KeyInfo child elements", 0, scd->getKeyInfos().size()); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + KeyInfoConfirmationDataType* scd = dynamic_cast(xo.get()); + TS_ASSERT(scd!=NULL); + + TSM_ASSERT_EQUALS("NotBefore attribute", expectedNotBefore->getEpoch(), scd->getNotBefore()->getEpoch()); + TSM_ASSERT_EQUALS("NotOnOrAfter attribute", expectedNotOnOrAfter->getEpoch(), scd->getNotOnOrAfter()->getEpoch()); + assertEquals("Recipient attribute", expectedRecipient, scd->getRecipient()); + assertEquals("InResponseTo attribute", expectedInResponseTo, scd->getInResponseTo()); + assertEquals("Address attribute", expectedAddress, scd->getAddress()); + TSM_ASSERT_EQUALS("# of KeyInfo child elements", 0, scd->getKeyInfos().size()); + + //TODO need to test with some wildcard attributes + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + KeyInfoConfirmationDataType* scd= dynamic_cast(xo.get()); + TS_ASSERT(scd!=NULL); + + TS_ASSERT(scd->getNotBefore()==NULL); + TS_ASSERT(scd->getNotOnOrAfter()==NULL); + TS_ASSERT(scd->getRecipient()==NULL); + TS_ASSERT(scd->getInResponseTo()==NULL); + TS_ASSERT(scd->getAddress()==NULL); + TSM_ASSERT_EQUALS("# of KeyInfo child elements", 1, scd->getKeyInfos().size()); + + //TODO need to test with some wildcard child elements + } + + void testSingleElementMarshall() { + KeyInfoConfirmationDataType* scd=KeyInfoConfirmationDataTypeBuilder::buildKeyInfoConfirmationDataType(); + assertEquals(expectedDOM, scd); + } + + void testSingleElementOptionalAttributesMarshall() { + KeyInfoConfirmationDataType* scd=KeyInfoConfirmationDataTypeBuilder::buildKeyInfoConfirmationDataType(); + scd->setNotBefore(expectedNotBefore); + scd->setNotOnOrAfter(expectedNotOnOrAfter); + scd->setRecipient(expectedRecipient); + scd->setInResponseTo(expectedInResponseTo); + scd->setAddress(expectedAddress); + //TODO need to test with some wilcard attributes + assertEquals(expectedOptionalAttributesDOM, scd); + } + + void testChildElementsMarshall() { + KeyInfoConfirmationDataType* scd=KeyInfoConfirmationDataTypeBuilder::buildKeyInfoConfirmationDataType(); + scd->getKeyInfos().push_back(KeyInfoBuilder::buildKeyInfo()); + //TODO need to test with some wilcard child elements + assertEquals(expectedChildElementsDOM, scd); + } + +}; diff --git a/samltest/saml2/core/impl/LogoutRequest20Test.h b/samltest/saml2/core/impl/LogoutRequest20Test.h index 10da621..198be35 100644 --- a/samltest/saml2/core/impl/LogoutRequest20Test.h +++ b/samltest/saml2/core/impl/LogoutRequest20Test.h @@ -1,146 +1,146 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2p; -using namespace opensaml::saml2; - -class LogoutRequest20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* expectedID; - XMLCh* expectedVersion; - DateTime* expectedIssueInstant; - XMLCh* expectedConsent; - XMLCh* expectedDestination; - XMLCh* expectedReason; - DateTime* expectedNotOnOrAfter; - -public: - void setUp() { - expectedID = XMLString::transcode("abc123");; - expectedVersion = XMLString::transcode("2.0"); - expectedIssueInstant = new DateTime(XMLString::transcode("2006-02-21T16:40:00.000Z")); - expectedIssueInstant->parseDateTime(); - expectedConsent = XMLString::transcode("urn:string:consent"); - expectedDestination = XMLString::transcode("http://idp.example.org/endpoint"); - expectedReason = XMLString::transcode("urn:string:reason"); - expectedNotOnOrAfter = new DateTime(XMLString::transcode("2006-02-21T20:45:00.000Z")); - expectedNotOnOrAfter->parseDateTime(); - - singleElementFile = data_path + "saml2/core/impl/LogoutRequest.xml"; - singleElementOptionalAttributesFile = data_path + "saml2/core/impl/LogoutRequestOptionalAttributes.xml"; - childElementsFile = data_path + "saml2/core/impl/LogoutRequestChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&expectedID); - XMLString::release(&expectedVersion); - XMLString::release(&expectedConsent); - XMLString::release(&expectedDestination); - XMLString::release(&expectedReason); - delete expectedIssueInstant; - delete expectedNotOnOrAfter; - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - LogoutRequest* request = dynamic_cast(xo.get()); - TS_ASSERT(request!=NULL); - assertEquals("ID attribute", expectedID, request->getID()); - assertEquals("Version attribute", expectedVersion, request->getVersion()); - TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), request->getIssueInstant()->getEpoch()); - - TS_ASSERT(request->getIssuer()==NULL); - TS_ASSERT(request->getSignature()==NULL); - TS_ASSERT(request->getExtensions()==NULL); - TS_ASSERT(request->getBaseID()==NULL); - TS_ASSERT(request->getNameID()==NULL); - TS_ASSERT(request->getEncryptedID()==NULL); - TSM_ASSERT_EQUALS("# of SessionIndex child elements", 0, request->getSessionIndexs().size()); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - LogoutRequest* request = dynamic_cast(xo.get()); - TS_ASSERT(request!=NULL); - - assertEquals("Consent attribute", expectedConsent, request->getConsent()); - assertEquals("Destination attribute", expectedDestination, request->getDestination()); - assertEquals("Reason attribute", expectedReason, request->getReason()); - TSM_ASSERT_EQUALS("NotOnOrAfter attribute", expectedNotOnOrAfter->getEpoch(), request->getNotOnOrAfter()->getEpoch()); - - TS_ASSERT(request->getIssuer()==NULL); - TS_ASSERT(request->getSignature()==NULL); - TS_ASSERT(request->getExtensions()==NULL); - TS_ASSERT(request->getBaseID()==NULL); - TS_ASSERT(request->getNameID()==NULL); - TS_ASSERT(request->getEncryptedID()==NULL); - TSM_ASSERT_EQUALS("# of SessionIndex child elements", 0, request->getSessionIndexs().size()); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - LogoutRequest* request= dynamic_cast(xo.get()); - TS_ASSERT(request!=NULL); - TS_ASSERT(request->getIssuer()!=NULL); - TS_ASSERT(request->getSignature()==NULL); - TS_ASSERT(request->getExtensions()==NULL); - TS_ASSERT(request->getBaseID()==NULL); - TS_ASSERT(request->getNameID()!=NULL); - TS_ASSERT(request->getEncryptedID()==NULL); - TSM_ASSERT_EQUALS("# of SessionIndex child elements", 2, request->getSessionIndexs().size()); - } - - void testSingleElementMarshall() { - LogoutRequest* request=LogoutRequestBuilder::buildLogoutRequest(); - request->setID(expectedID); - request->setIssueInstant(expectedIssueInstant); - //request->setVersion(expectedVersion); - assertEquals(expectedDOM, request); - } - - void testSingleElementOptionalAttributesMarshall() { - LogoutRequest* request=LogoutRequestBuilder::buildLogoutRequest(); - request->setID(expectedID); - request->setIssueInstant(expectedIssueInstant); - //request->setVersion(expectedVersion); - request->setConsent(expectedConsent); - request->setDestination(expectedDestination); - request->setReason(expectedReason); - request->setNotOnOrAfter(expectedNotOnOrAfter); - assertEquals(expectedOptionalAttributesDOM, request); - } - - void testChildElementsMarshall() { - LogoutRequest* request=LogoutRequestBuilder::buildLogoutRequest(); - request->setID(expectedID); - request->setIssueInstant(expectedIssueInstant); - // Do this just so don't have to redeclare the saml namespace prefix on every child element in the control XML file - Namespace* ns = new Namespace(opensaml::SAMLConstants::SAML20_NS, opensaml::SAMLConstants::SAML20_PREFIX); - request->addNamespace(*ns); - request->setIssuer(IssuerBuilder::buildIssuer()); - request->setNameID(NameIDBuilder::buildNameID()); - request->getSessionIndexs().push_back(SessionIndexBuilder::buildSessionIndex()); - request->getSessionIndexs().push_back(SessionIndexBuilder::buildSessionIndex()); - assertEquals(expectedChildElementsDOM, request); - delete ns; - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2p; +using namespace opensaml::saml2; + +class LogoutRequest20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedID; + XMLCh* expectedVersion; + DateTime* expectedIssueInstant; + XMLCh* expectedConsent; + XMLCh* expectedDestination; + XMLCh* expectedReason; + DateTime* expectedNotOnOrAfter; + +public: + void setUp() { + expectedID = XMLString::transcode("abc123");; + expectedVersion = XMLString::transcode("2.0"); + expectedIssueInstant = new DateTime(XMLString::transcode("2006-02-21T16:40:00.000Z")); + expectedIssueInstant->parseDateTime(); + expectedConsent = XMLString::transcode("urn:string:consent"); + expectedDestination = XMLString::transcode("http://idp.example.org/endpoint"); + expectedReason = XMLString::transcode("urn:string:reason"); + expectedNotOnOrAfter = new DateTime(XMLString::transcode("2006-02-21T20:45:00.000Z")); + expectedNotOnOrAfter->parseDateTime(); + + singleElementFile = data_path + "saml2/core/impl/LogoutRequest.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/LogoutRequestOptionalAttributes.xml"; + childElementsFile = data_path + "saml2/core/impl/LogoutRequestChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedID); + XMLString::release(&expectedVersion); + XMLString::release(&expectedConsent); + XMLString::release(&expectedDestination); + XMLString::release(&expectedReason); + delete expectedIssueInstant; + delete expectedNotOnOrAfter; + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + LogoutRequest* request = dynamic_cast(xo.get()); + TS_ASSERT(request!=NULL); + assertEquals("ID attribute", expectedID, request->getID()); + assertEquals("Version attribute", expectedVersion, request->getVersion()); + TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), request->getIssueInstant()->getEpoch()); + + TS_ASSERT(request->getIssuer()==NULL); + TS_ASSERT(request->getSignature()==NULL); + TS_ASSERT(request->getExtensions()==NULL); + TS_ASSERT(request->getBaseID()==NULL); + TS_ASSERT(request->getNameID()==NULL); + TS_ASSERT(request->getEncryptedID()==NULL); + TSM_ASSERT_EQUALS("# of SessionIndex child elements", 0, request->getSessionIndexs().size()); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + LogoutRequest* request = dynamic_cast(xo.get()); + TS_ASSERT(request!=NULL); + + assertEquals("Consent attribute", expectedConsent, request->getConsent()); + assertEquals("Destination attribute", expectedDestination, request->getDestination()); + assertEquals("Reason attribute", expectedReason, request->getReason()); + TSM_ASSERT_EQUALS("NotOnOrAfter attribute", expectedNotOnOrAfter->getEpoch(), request->getNotOnOrAfter()->getEpoch()); + + TS_ASSERT(request->getIssuer()==NULL); + TS_ASSERT(request->getSignature()==NULL); + TS_ASSERT(request->getExtensions()==NULL); + TS_ASSERT(request->getBaseID()==NULL); + TS_ASSERT(request->getNameID()==NULL); + TS_ASSERT(request->getEncryptedID()==NULL); + TSM_ASSERT_EQUALS("# of SessionIndex child elements", 0, request->getSessionIndexs().size()); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + LogoutRequest* request= dynamic_cast(xo.get()); + TS_ASSERT(request!=NULL); + TS_ASSERT(request->getIssuer()!=NULL); + TS_ASSERT(request->getSignature()==NULL); + TS_ASSERT(request->getExtensions()==NULL); + TS_ASSERT(request->getBaseID()==NULL); + TS_ASSERT(request->getNameID()!=NULL); + TS_ASSERT(request->getEncryptedID()==NULL); + TSM_ASSERT_EQUALS("# of SessionIndex child elements", 2, request->getSessionIndexs().size()); + } + + void testSingleElementMarshall() { + LogoutRequest* request=LogoutRequestBuilder::buildLogoutRequest(); + request->setID(expectedID); + request->setIssueInstant(expectedIssueInstant); + //request->setVersion(expectedVersion); + assertEquals(expectedDOM, request); + } + + void testSingleElementOptionalAttributesMarshall() { + LogoutRequest* request=LogoutRequestBuilder::buildLogoutRequest(); + request->setID(expectedID); + request->setIssueInstant(expectedIssueInstant); + //request->setVersion(expectedVersion); + request->setConsent(expectedConsent); + request->setDestination(expectedDestination); + request->setReason(expectedReason); + request->setNotOnOrAfter(expectedNotOnOrAfter); + assertEquals(expectedOptionalAttributesDOM, request); + } + + void testChildElementsMarshall() { + LogoutRequest* request=LogoutRequestBuilder::buildLogoutRequest(); + request->setID(expectedID); + request->setIssueInstant(expectedIssueInstant); + // Do this just so don't have to redeclare the saml namespace prefix on every child element in the control XML file + Namespace* ns = new Namespace(opensaml::SAMLConstants::SAML20_NS, opensaml::SAMLConstants::SAML20_PREFIX); + request->addNamespace(*ns); + request->setIssuer(IssuerBuilder::buildIssuer()); + request->setNameID(NameIDBuilder::buildNameID()); + request->getSessionIndexs().push_back(SessionIndexBuilder::buildSessionIndex()); + request->getSessionIndexs().push_back(SessionIndexBuilder::buildSessionIndex()); + assertEquals(expectedChildElementsDOM, request); + delete ns; + } + +}; diff --git a/samltest/saml2/core/impl/LogoutResponse20Test.h b/samltest/saml2/core/impl/LogoutResponse20Test.h index 3cd675d..034d245 100644 --- a/samltest/saml2/core/impl/LogoutResponse20Test.h +++ b/samltest/saml2/core/impl/LogoutResponse20Test.h @@ -1,139 +1,139 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2p; -using namespace opensaml::saml2; - -class LogoutResponse20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* expectedID; - XMLCh* expectedInResponseTo; - XMLCh* expectedVersion; - XMLCh* expectedConsent; - XMLCh* expectedDestination; - DateTime* expectedIssueInstant; - -public: - void setUp() { - expectedID = XMLString::transcode("def456"); - expectedInResponseTo = XMLString::transcode("abc123"); - expectedVersion = XMLString::transcode("2.0"); - expectedConsent = XMLString::transcode("urn:string:consent"); - expectedDestination = XMLString::transcode("http://sp.example.org/endpoint"); - expectedIssueInstant = new DateTime(XMLString::transcode("2006-02-21T16:40:00.000Z")); - expectedIssueInstant->parseDateTime(); - - singleElementFile = data_path + "saml2/core/impl/LogoutResponse.xml"; - singleElementOptionalAttributesFile = data_path + "saml2/core/impl/LogoutResponseOptionalAttributes.xml"; - childElementsFile = data_path + "saml2/core/impl/LogoutResponseChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&expectedID); - XMLString::release(&expectedInResponseTo); - XMLString::release(&expectedVersion); - XMLString::release(&expectedConsent); - XMLString::release(&expectedDestination); - delete expectedIssueInstant; - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - LogoutResponse* response = dynamic_cast(xo.get()); - TS_ASSERT(response!=NULL); - - assertEquals("ID attribute", expectedID, response->getID()); - assertEquals("Version attribute", expectedVersion, response->getVersion()); - TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), response->getIssueInstant()->getEpoch()); - - TS_ASSERT(response->getIssuer()==NULL); - TS_ASSERT(response->getSignature()==NULL); - TS_ASSERT(response->getExtensions()==NULL); - TS_ASSERT(response->getStatus()==NULL); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - LogoutResponse* response = dynamic_cast(xo.get()); - TS_ASSERT(response!=NULL); - - assertEquals("Consent attribute", expectedConsent, response->getConsent()); - assertEquals("Destination attribute", expectedDestination, response->getDestination()); - assertEquals("InResponseTo attribute", expectedInResponseTo, response->getInResponseTo()); - - TS_ASSERT(response->getIssuer()==NULL); - TS_ASSERT(response->getSignature()==NULL); - TS_ASSERT(response->getExtensions()==NULL); - TS_ASSERT(response->getStatus()==NULL); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - LogoutResponse* response= dynamic_cast(xo.get()); - TS_ASSERT(response!=NULL); - - TS_ASSERT(response->getIssuer()!=NULL); - TS_ASSERT(response->getSignature()==NULL); - TS_ASSERT(response->getExtensions()==NULL); - TS_ASSERT(response->getStatus()!=NULL); - } - - void testSingleElementMarshall() { - LogoutResponse* response = LogoutResponseBuilder::buildLogoutResponse(); - TS_ASSERT(response!=NULL); - - response->setID(expectedID); - response->setIssueInstant(expectedIssueInstant); - //response->setVersion(expectedVersion); - assertEquals(expectedDOM, response); - } - - void testSingleElementOptionalAttributesMarshall() { - LogoutResponse* response = LogoutResponseBuilder::buildLogoutResponse(); - TS_ASSERT(response!=NULL); - - response->setID(expectedID); - response->setInResponseTo(expectedInResponseTo); - response->setIssueInstant(expectedIssueInstant); - //response->setVersion(expectedVersion); - response->setConsent(expectedConsent); - response->setDestination(expectedDestination); - response->setInResponseTo(expectedInResponseTo); - assertEquals(expectedOptionalAttributesDOM, response); - } - - void testChildElementsMarshall() { - LogoutResponse* response = LogoutResponseBuilder::buildLogoutResponse(); - TS_ASSERT(response!=NULL); - - response->setID(expectedID); - response->setIssueInstant(expectedIssueInstant); - // Do this just so don't have to redeclare the saml namespace prefix on every child element in the control XML file - Namespace* ns = new Namespace(opensaml::SAMLConstants::SAML20_NS, opensaml::SAMLConstants::SAML20_PREFIX); - response->addNamespace(*ns); - response->setIssuer(IssuerBuilder::buildIssuer()); - response->setStatus(StatusBuilder::buildStatus()); - - assertEquals(expectedChildElementsDOM, response); - delete ns; - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2p; +using namespace opensaml::saml2; + +class LogoutResponse20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedID; + XMLCh* expectedInResponseTo; + XMLCh* expectedVersion; + XMLCh* expectedConsent; + XMLCh* expectedDestination; + DateTime* expectedIssueInstant; + +public: + void setUp() { + expectedID = XMLString::transcode("def456"); + expectedInResponseTo = XMLString::transcode("abc123"); + expectedVersion = XMLString::transcode("2.0"); + expectedConsent = XMLString::transcode("urn:string:consent"); + expectedDestination = XMLString::transcode("http://sp.example.org/endpoint"); + expectedIssueInstant = new DateTime(XMLString::transcode("2006-02-21T16:40:00.000Z")); + expectedIssueInstant->parseDateTime(); + + singleElementFile = data_path + "saml2/core/impl/LogoutResponse.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/LogoutResponseOptionalAttributes.xml"; + childElementsFile = data_path + "saml2/core/impl/LogoutResponseChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedID); + XMLString::release(&expectedInResponseTo); + XMLString::release(&expectedVersion); + XMLString::release(&expectedConsent); + XMLString::release(&expectedDestination); + delete expectedIssueInstant; + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + LogoutResponse* response = dynamic_cast(xo.get()); + TS_ASSERT(response!=NULL); + + assertEquals("ID attribute", expectedID, response->getID()); + assertEquals("Version attribute", expectedVersion, response->getVersion()); + TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), response->getIssueInstant()->getEpoch()); + + TS_ASSERT(response->getIssuer()==NULL); + TS_ASSERT(response->getSignature()==NULL); + TS_ASSERT(response->getExtensions()==NULL); + TS_ASSERT(response->getStatus()==NULL); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + LogoutResponse* response = dynamic_cast(xo.get()); + TS_ASSERT(response!=NULL); + + assertEquals("Consent attribute", expectedConsent, response->getConsent()); + assertEquals("Destination attribute", expectedDestination, response->getDestination()); + assertEquals("InResponseTo attribute", expectedInResponseTo, response->getInResponseTo()); + + TS_ASSERT(response->getIssuer()==NULL); + TS_ASSERT(response->getSignature()==NULL); + TS_ASSERT(response->getExtensions()==NULL); + TS_ASSERT(response->getStatus()==NULL); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + LogoutResponse* response= dynamic_cast(xo.get()); + TS_ASSERT(response!=NULL); + + TS_ASSERT(response->getIssuer()!=NULL); + TS_ASSERT(response->getSignature()==NULL); + TS_ASSERT(response->getExtensions()==NULL); + TS_ASSERT(response->getStatus()!=NULL); + } + + void testSingleElementMarshall() { + LogoutResponse* response = LogoutResponseBuilder::buildLogoutResponse(); + TS_ASSERT(response!=NULL); + + response->setID(expectedID); + response->setIssueInstant(expectedIssueInstant); + //response->setVersion(expectedVersion); + assertEquals(expectedDOM, response); + } + + void testSingleElementOptionalAttributesMarshall() { + LogoutResponse* response = LogoutResponseBuilder::buildLogoutResponse(); + TS_ASSERT(response!=NULL); + + response->setID(expectedID); + response->setInResponseTo(expectedInResponseTo); + response->setIssueInstant(expectedIssueInstant); + //response->setVersion(expectedVersion); + response->setConsent(expectedConsent); + response->setDestination(expectedDestination); + response->setInResponseTo(expectedInResponseTo); + assertEquals(expectedOptionalAttributesDOM, response); + } + + void testChildElementsMarshall() { + LogoutResponse* response = LogoutResponseBuilder::buildLogoutResponse(); + TS_ASSERT(response!=NULL); + + response->setID(expectedID); + response->setIssueInstant(expectedIssueInstant); + // Do this just so don't have to redeclare the saml namespace prefix on every child element in the control XML file + Namespace* ns = new Namespace(opensaml::SAMLConstants::SAML20_NS, opensaml::SAMLConstants::SAML20_PREFIX); + response->addNamespace(*ns); + response->setIssuer(IssuerBuilder::buildIssuer()); + response->setStatus(StatusBuilder::buildStatus()); + + assertEquals(expectedChildElementsDOM, response); + delete ns; + } + +}; diff --git a/samltest/saml2/core/impl/ManageNameIDRequest20Test.h b/samltest/saml2/core/impl/ManageNameIDRequest20Test.h index f2cecec..288baf4 100644 --- a/samltest/saml2/core/impl/ManageNameIDRequest20Test.h +++ b/samltest/saml2/core/impl/ManageNameIDRequest20Test.h @@ -1,137 +1,137 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2p; -using namespace opensaml::saml2; - -class ManageNameIDRequest20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* expectedID; - XMLCh* expectedVersion; - DateTime* expectedIssueInstant; - XMLCh* expectedConsent; - XMLCh* expectedDestination; - -public: - void setUp() { - expectedID = XMLString::transcode("abc123");; - expectedVersion = XMLString::transcode("2.0"); - expectedIssueInstant = new DateTime(XMLString::transcode("2006-02-21T16:40:00.000Z")); - expectedIssueInstant->parseDateTime(); - expectedConsent = XMLString::transcode("urn:string:consent"); - expectedDestination = XMLString::transcode("http://idp.example.org/endpoint"); - - singleElementFile = data_path + "saml2/core/impl/ManageNameIDRequest.xml"; - singleElementOptionalAttributesFile = data_path + "saml2/core/impl/ManageNameIDRequestOptionalAttributes.xml"; - childElementsFile = data_path + "saml2/core/impl/ManageNameIDRequestChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&expectedID); - XMLString::release(&expectedVersion); - XMLString::release(&expectedConsent); - XMLString::release(&expectedDestination); - delete expectedIssueInstant; - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - ManageNameIDRequest* request = dynamic_cast(xo.get()); - TS_ASSERT(request!=NULL); - assertEquals("ID attribute", expectedID, request->getID()); - assertEquals("Version attribute", expectedVersion, request->getVersion()); - TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), request->getIssueInstant()->getEpoch()); - - TS_ASSERT(request->getIssuer()==NULL); - TS_ASSERT(request->getSignature()==NULL); - TS_ASSERT(request->getExtensions()==NULL); - TS_ASSERT(request->getNameID()==NULL); - TS_ASSERT(request->getEncryptedID()==NULL); - TS_ASSERT(request->getNewID()==NULL); - TS_ASSERT(request->getNewEncryptedID()==NULL); - TS_ASSERT(request->getTerminate()==NULL); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - ManageNameIDRequest* request = dynamic_cast(xo.get()); - TS_ASSERT(request!=NULL); - - assertEquals("Consent attribute", expectedConsent, request->getConsent()); - assertEquals("Destination attribute", expectedDestination, request->getDestination()); - - TS_ASSERT(request->getIssuer()==NULL); - TS_ASSERT(request->getSignature()==NULL); - TS_ASSERT(request->getExtensions()==NULL); - TS_ASSERT(request->getNameID()==NULL); - TS_ASSERT(request->getEncryptedID()==NULL); - TS_ASSERT(request->getNewID()==NULL); - TS_ASSERT(request->getNewEncryptedID()==NULL); - TS_ASSERT(request->getTerminate()==NULL); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - ManageNameIDRequest* request= dynamic_cast(xo.get()); - TS_ASSERT(request!=NULL); - TS_ASSERT(request->getIssuer()!=NULL); - TS_ASSERT(request->getSignature()==NULL); - TS_ASSERT(request->getExtensions()==NULL); - TS_ASSERT(request->getNameID()!=NULL); - TS_ASSERT(request->getEncryptedID()==NULL); - TS_ASSERT(request->getNewID()!=NULL); - TS_ASSERT(request->getNewEncryptedID()==NULL); - TS_ASSERT(request->getTerminate()==NULL); - } - - void testSingleElementMarshall() { - ManageNameIDRequest* request=ManageNameIDRequestBuilder::buildManageNameIDRequest(); - request->setID(expectedID); - request->setIssueInstant(expectedIssueInstant); - //request->setVersion(expectedVersion); - assertEquals(expectedDOM, request); - } - - void testSingleElementOptionalAttributesMarshall() { - ManageNameIDRequest* request=ManageNameIDRequestBuilder::buildManageNameIDRequest(); - request->setID(expectedID); - request->setIssueInstant(expectedIssueInstant); - //request->setVersion(expectedVersion); - request->setConsent(expectedConsent); - request->setDestination(expectedDestination); - assertEquals(expectedOptionalAttributesDOM, request); - } - - void testChildElementsMarshall() { - ManageNameIDRequest* request=ManageNameIDRequestBuilder::buildManageNameIDRequest(); - request->setID(expectedID); - request->setIssueInstant(expectedIssueInstant); - // Do this just so don't have to redeclare the saml namespace prefix on every child element in the control XML file - Namespace* ns = new Namespace(opensaml::SAMLConstants::SAML20_NS, opensaml::SAMLConstants::SAML20_PREFIX); - request->addNamespace(*ns); - request->setIssuer(IssuerBuilder::buildIssuer()); - request->setNameID(NameIDBuilder::buildNameID()); - request->setNewID(NewIDBuilder::buildNewID()); - assertEquals(expectedChildElementsDOM, request); - delete ns; - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2p; +using namespace opensaml::saml2; + +class ManageNameIDRequest20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedID; + XMLCh* expectedVersion; + DateTime* expectedIssueInstant; + XMLCh* expectedConsent; + XMLCh* expectedDestination; + +public: + void setUp() { + expectedID = XMLString::transcode("abc123");; + expectedVersion = XMLString::transcode("2.0"); + expectedIssueInstant = new DateTime(XMLString::transcode("2006-02-21T16:40:00.000Z")); + expectedIssueInstant->parseDateTime(); + expectedConsent = XMLString::transcode("urn:string:consent"); + expectedDestination = XMLString::transcode("http://idp.example.org/endpoint"); + + singleElementFile = data_path + "saml2/core/impl/ManageNameIDRequest.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/ManageNameIDRequestOptionalAttributes.xml"; + childElementsFile = data_path + "saml2/core/impl/ManageNameIDRequestChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedID); + XMLString::release(&expectedVersion); + XMLString::release(&expectedConsent); + XMLString::release(&expectedDestination); + delete expectedIssueInstant; + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + ManageNameIDRequest* request = dynamic_cast(xo.get()); + TS_ASSERT(request!=NULL); + assertEquals("ID attribute", expectedID, request->getID()); + assertEquals("Version attribute", expectedVersion, request->getVersion()); + TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), request->getIssueInstant()->getEpoch()); + + TS_ASSERT(request->getIssuer()==NULL); + TS_ASSERT(request->getSignature()==NULL); + TS_ASSERT(request->getExtensions()==NULL); + TS_ASSERT(request->getNameID()==NULL); + TS_ASSERT(request->getEncryptedID()==NULL); + TS_ASSERT(request->getNewID()==NULL); + TS_ASSERT(request->getNewEncryptedID()==NULL); + TS_ASSERT(request->getTerminate()==NULL); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + ManageNameIDRequest* request = dynamic_cast(xo.get()); + TS_ASSERT(request!=NULL); + + assertEquals("Consent attribute", expectedConsent, request->getConsent()); + assertEquals("Destination attribute", expectedDestination, request->getDestination()); + + TS_ASSERT(request->getIssuer()==NULL); + TS_ASSERT(request->getSignature()==NULL); + TS_ASSERT(request->getExtensions()==NULL); + TS_ASSERT(request->getNameID()==NULL); + TS_ASSERT(request->getEncryptedID()==NULL); + TS_ASSERT(request->getNewID()==NULL); + TS_ASSERT(request->getNewEncryptedID()==NULL); + TS_ASSERT(request->getTerminate()==NULL); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + ManageNameIDRequest* request= dynamic_cast(xo.get()); + TS_ASSERT(request!=NULL); + TS_ASSERT(request->getIssuer()!=NULL); + TS_ASSERT(request->getSignature()==NULL); + TS_ASSERT(request->getExtensions()==NULL); + TS_ASSERT(request->getNameID()!=NULL); + TS_ASSERT(request->getEncryptedID()==NULL); + TS_ASSERT(request->getNewID()!=NULL); + TS_ASSERT(request->getNewEncryptedID()==NULL); + TS_ASSERT(request->getTerminate()==NULL); + } + + void testSingleElementMarshall() { + ManageNameIDRequest* request=ManageNameIDRequestBuilder::buildManageNameIDRequest(); + request->setID(expectedID); + request->setIssueInstant(expectedIssueInstant); + //request->setVersion(expectedVersion); + assertEquals(expectedDOM, request); + } + + void testSingleElementOptionalAttributesMarshall() { + ManageNameIDRequest* request=ManageNameIDRequestBuilder::buildManageNameIDRequest(); + request->setID(expectedID); + request->setIssueInstant(expectedIssueInstant); + //request->setVersion(expectedVersion); + request->setConsent(expectedConsent); + request->setDestination(expectedDestination); + assertEquals(expectedOptionalAttributesDOM, request); + } + + void testChildElementsMarshall() { + ManageNameIDRequest* request=ManageNameIDRequestBuilder::buildManageNameIDRequest(); + request->setID(expectedID); + request->setIssueInstant(expectedIssueInstant); + // Do this just so don't have to redeclare the saml namespace prefix on every child element in the control XML file + Namespace* ns = new Namespace(opensaml::SAMLConstants::SAML20_NS, opensaml::SAMLConstants::SAML20_PREFIX); + request->addNamespace(*ns); + request->setIssuer(IssuerBuilder::buildIssuer()); + request->setNameID(NameIDBuilder::buildNameID()); + request->setNewID(NewIDBuilder::buildNewID()); + assertEquals(expectedChildElementsDOM, request); + delete ns; + } + +}; diff --git a/samltest/saml2/core/impl/ManageNameIDResponse20Test.h b/samltest/saml2/core/impl/ManageNameIDResponse20Test.h index 3cdea30..c1e0533 100644 --- a/samltest/saml2/core/impl/ManageNameIDResponse20Test.h +++ b/samltest/saml2/core/impl/ManageNameIDResponse20Test.h @@ -1,139 +1,139 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2p; -using namespace opensaml::saml2; - -class ManageNameIDResponse20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* expectedID; - XMLCh* expectedInResponseTo; - XMLCh* expectedVersion; - XMLCh* expectedConsent; - XMLCh* expectedDestination; - DateTime* expectedIssueInstant; - -public: - void setUp() { - expectedID = XMLString::transcode("def456"); - expectedInResponseTo = XMLString::transcode("abc123"); - expectedVersion = XMLString::transcode("2.0"); - expectedConsent = XMLString::transcode("urn:string:consent"); - expectedDestination = XMLString::transcode("http://sp.example.org/endpoint"); - expectedIssueInstant = new DateTime(XMLString::transcode("2006-02-21T16:40:00.000Z")); - expectedIssueInstant->parseDateTime(); - - singleElementFile = data_path + "saml2/core/impl/ManageNameIDResponse.xml"; - singleElementOptionalAttributesFile = data_path + "saml2/core/impl/ManageNameIDResponseOptionalAttributes.xml"; - childElementsFile = data_path + "saml2/core/impl/ManageNameIDResponseChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&expectedID); - XMLString::release(&expectedInResponseTo); - XMLString::release(&expectedVersion); - XMLString::release(&expectedConsent); - XMLString::release(&expectedDestination); - delete expectedIssueInstant; - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - ManageNameIDResponse* response = dynamic_cast(xo.get()); - TS_ASSERT(response!=NULL); - - assertEquals("ID attribute", expectedID, response->getID()); - assertEquals("Version attribute", expectedVersion, response->getVersion()); - TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), response->getIssueInstant()->getEpoch()); - - TS_ASSERT(response->getIssuer()==NULL); - TS_ASSERT(response->getSignature()==NULL); - TS_ASSERT(response->getExtensions()==NULL); - TS_ASSERT(response->getStatus()==NULL); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - ManageNameIDResponse* response = dynamic_cast(xo.get()); - TS_ASSERT(response!=NULL); - - assertEquals("Consent attribute", expectedConsent, response->getConsent()); - assertEquals("Destination attribute", expectedDestination, response->getDestination()); - assertEquals("InResponseTo attribute", expectedInResponseTo, response->getInResponseTo()); - - TS_ASSERT(response->getIssuer()==NULL); - TS_ASSERT(response->getSignature()==NULL); - TS_ASSERT(response->getExtensions()==NULL); - TS_ASSERT(response->getStatus()==NULL); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - ManageNameIDResponse* response= dynamic_cast(xo.get()); - TS_ASSERT(response!=NULL); - - TS_ASSERT(response->getIssuer()!=NULL); - TS_ASSERT(response->getSignature()==NULL); - TS_ASSERT(response->getExtensions()==NULL); - TS_ASSERT(response->getStatus()!=NULL); - } - - void testSingleElementMarshall() { - ManageNameIDResponse* response = ManageNameIDResponseBuilder::buildManageNameIDResponse(); - TS_ASSERT(response!=NULL); - - response->setID(expectedID); - response->setIssueInstant(expectedIssueInstant); - //response->setVersion(expectedVersion); - assertEquals(expectedDOM, response); - } - - void testSingleElementOptionalAttributesMarshall() { - ManageNameIDResponse* response = ManageNameIDResponseBuilder::buildManageNameIDResponse(); - TS_ASSERT(response!=NULL); - - response->setID(expectedID); - response->setInResponseTo(expectedInResponseTo); - response->setIssueInstant(expectedIssueInstant); - //response->setVersion(expectedVersion); - response->setConsent(expectedConsent); - response->setDestination(expectedDestination); - response->setInResponseTo(expectedInResponseTo); - assertEquals(expectedOptionalAttributesDOM, response); - } - - void testChildElementsMarshall() { - ManageNameIDResponse* response = ManageNameIDResponseBuilder::buildManageNameIDResponse(); - TS_ASSERT(response!=NULL); - - response->setID(expectedID); - response->setIssueInstant(expectedIssueInstant); - // Do this just so don't have to redeclare the saml namespace prefix on every child element in the control XML file - Namespace* ns = new Namespace(opensaml::SAMLConstants::SAML20_NS, opensaml::SAMLConstants::SAML20_PREFIX); - response->addNamespace(*ns); - response->setIssuer(IssuerBuilder::buildIssuer()); - response->setStatus(StatusBuilder::buildStatus()); - - assertEquals(expectedChildElementsDOM, response); - delete ns; - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2p; +using namespace opensaml::saml2; + +class ManageNameIDResponse20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedID; + XMLCh* expectedInResponseTo; + XMLCh* expectedVersion; + XMLCh* expectedConsent; + XMLCh* expectedDestination; + DateTime* expectedIssueInstant; + +public: + void setUp() { + expectedID = XMLString::transcode("def456"); + expectedInResponseTo = XMLString::transcode("abc123"); + expectedVersion = XMLString::transcode("2.0"); + expectedConsent = XMLString::transcode("urn:string:consent"); + expectedDestination = XMLString::transcode("http://sp.example.org/endpoint"); + expectedIssueInstant = new DateTime(XMLString::transcode("2006-02-21T16:40:00.000Z")); + expectedIssueInstant->parseDateTime(); + + singleElementFile = data_path + "saml2/core/impl/ManageNameIDResponse.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/ManageNameIDResponseOptionalAttributes.xml"; + childElementsFile = data_path + "saml2/core/impl/ManageNameIDResponseChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedID); + XMLString::release(&expectedInResponseTo); + XMLString::release(&expectedVersion); + XMLString::release(&expectedConsent); + XMLString::release(&expectedDestination); + delete expectedIssueInstant; + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + ManageNameIDResponse* response = dynamic_cast(xo.get()); + TS_ASSERT(response!=NULL); + + assertEquals("ID attribute", expectedID, response->getID()); + assertEquals("Version attribute", expectedVersion, response->getVersion()); + TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), response->getIssueInstant()->getEpoch()); + + TS_ASSERT(response->getIssuer()==NULL); + TS_ASSERT(response->getSignature()==NULL); + TS_ASSERT(response->getExtensions()==NULL); + TS_ASSERT(response->getStatus()==NULL); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + ManageNameIDResponse* response = dynamic_cast(xo.get()); + TS_ASSERT(response!=NULL); + + assertEquals("Consent attribute", expectedConsent, response->getConsent()); + assertEquals("Destination attribute", expectedDestination, response->getDestination()); + assertEquals("InResponseTo attribute", expectedInResponseTo, response->getInResponseTo()); + + TS_ASSERT(response->getIssuer()==NULL); + TS_ASSERT(response->getSignature()==NULL); + TS_ASSERT(response->getExtensions()==NULL); + TS_ASSERT(response->getStatus()==NULL); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + ManageNameIDResponse* response= dynamic_cast(xo.get()); + TS_ASSERT(response!=NULL); + + TS_ASSERT(response->getIssuer()!=NULL); + TS_ASSERT(response->getSignature()==NULL); + TS_ASSERT(response->getExtensions()==NULL); + TS_ASSERT(response->getStatus()!=NULL); + } + + void testSingleElementMarshall() { + ManageNameIDResponse* response = ManageNameIDResponseBuilder::buildManageNameIDResponse(); + TS_ASSERT(response!=NULL); + + response->setID(expectedID); + response->setIssueInstant(expectedIssueInstant); + //response->setVersion(expectedVersion); + assertEquals(expectedDOM, response); + } + + void testSingleElementOptionalAttributesMarshall() { + ManageNameIDResponse* response = ManageNameIDResponseBuilder::buildManageNameIDResponse(); + TS_ASSERT(response!=NULL); + + response->setID(expectedID); + response->setInResponseTo(expectedInResponseTo); + response->setIssueInstant(expectedIssueInstant); + //response->setVersion(expectedVersion); + response->setConsent(expectedConsent); + response->setDestination(expectedDestination); + response->setInResponseTo(expectedInResponseTo); + assertEquals(expectedOptionalAttributesDOM, response); + } + + void testChildElementsMarshall() { + ManageNameIDResponse* response = ManageNameIDResponseBuilder::buildManageNameIDResponse(); + TS_ASSERT(response!=NULL); + + response->setID(expectedID); + response->setIssueInstant(expectedIssueInstant); + // Do this just so don't have to redeclare the saml namespace prefix on every child element in the control XML file + Namespace* ns = new Namespace(opensaml::SAMLConstants::SAML20_NS, opensaml::SAMLConstants::SAML20_PREFIX); + response->addNamespace(*ns); + response->setIssuer(IssuerBuilder::buildIssuer()); + response->setStatus(StatusBuilder::buildStatus()); + + assertEquals(expectedChildElementsDOM, response); + delete ns; + } + +}; diff --git a/samltest/saml2/core/impl/NameID20Test.h b/samltest/saml2/core/impl/NameID20Test.h index 6948cab..9b2cf52 100644 --- a/samltest/saml2/core/impl/NameID20Test.h +++ b/samltest/saml2/core/impl/NameID20Test.h @@ -1,93 +1,93 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2; - -class NameID20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* expectedNameQualifier; - XMLCh* expectedSPNameQualifier; - XMLCh* expectedFormat; - XMLCh* expectedSPProvidedID; - XMLCh* expectedContent; - -public: - void setUp() { - expectedNameQualifier = XMLString::transcode("nq"); - expectedSPNameQualifier = XMLString::transcode("spnq"); - expectedFormat = XMLString::transcode("format"); - expectedSPProvidedID = XMLString::transcode("spID"); - expectedContent = XMLString::transcode("someNameID"); - - singleElementFile = data_path + "saml2/core/impl/NameID.xml"; - singleElementOptionalAttributesFile = data_path + "saml2/core/impl/NameIDOptionalAttributes.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&expectedNameQualifier); - XMLString::release(&expectedSPNameQualifier); - XMLString::release(&expectedFormat); - XMLString::release(&expectedSPProvidedID); - XMLString::release(&expectedContent); - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - NameID* nameid = dynamic_cast(xo.get()); - TS_ASSERT(nameid!=NULL); - - assertEquals("Element content", expectedContent, nameid->getName()); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - NameID* nameid = dynamic_cast(xo.get()); - TS_ASSERT(nameid!=NULL); - - assertEquals("NameQualifier attribute", expectedNameQualifier, nameid->getNameQualifier()); - assertEquals("SPNameQualifier attribute", expectedSPNameQualifier, nameid->getSPNameQualifier()); - assertEquals("Format attribute", expectedFormat, nameid->getFormat()); - assertEquals("SPProvidedID attribute", expectedSPProvidedID, nameid->getSPProvidedID()); - assertEquals("Element content", expectedContent, nameid->getName()); - } - - - void testSingleElementMarshall() { - NameID* nameid = NameIDBuilder::buildNameID(); - TS_ASSERT(nameid!=NULL); - - nameid->setName(expectedContent); - assertEquals(expectedDOM, nameid); - } - - void testSingleElementOptionalAttributesMarshall() { - NameID* nameid = NameIDBuilder::buildNameID(); - TS_ASSERT(nameid!=NULL); - - nameid->setNameQualifier(expectedNameQualifier); - nameid->setSPNameQualifier(expectedSPNameQualifier); - nameid->setFormat(expectedFormat); - nameid->setSPProvidedID(expectedSPProvidedID); - nameid->setName(expectedContent); - assertEquals(expectedOptionalAttributesDOM, nameid); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +class NameID20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedNameQualifier; + XMLCh* expectedSPNameQualifier; + XMLCh* expectedFormat; + XMLCh* expectedSPProvidedID; + XMLCh* expectedContent; + +public: + void setUp() { + expectedNameQualifier = XMLString::transcode("nq"); + expectedSPNameQualifier = XMLString::transcode("spnq"); + expectedFormat = XMLString::transcode("format"); + expectedSPProvidedID = XMLString::transcode("spID"); + expectedContent = XMLString::transcode("someNameID"); + + singleElementFile = data_path + "saml2/core/impl/NameID.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/NameIDOptionalAttributes.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedNameQualifier); + XMLString::release(&expectedSPNameQualifier); + XMLString::release(&expectedFormat); + XMLString::release(&expectedSPProvidedID); + XMLString::release(&expectedContent); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + NameID* nameid = dynamic_cast(xo.get()); + TS_ASSERT(nameid!=NULL); + + assertEquals("Element content", expectedContent, nameid->getName()); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + NameID* nameid = dynamic_cast(xo.get()); + TS_ASSERT(nameid!=NULL); + + assertEquals("NameQualifier attribute", expectedNameQualifier, nameid->getNameQualifier()); + assertEquals("SPNameQualifier attribute", expectedSPNameQualifier, nameid->getSPNameQualifier()); + assertEquals("Format attribute", expectedFormat, nameid->getFormat()); + assertEquals("SPProvidedID attribute", expectedSPProvidedID, nameid->getSPProvidedID()); + assertEquals("Element content", expectedContent, nameid->getName()); + } + + + void testSingleElementMarshall() { + NameID* nameid = NameIDBuilder::buildNameID(); + TS_ASSERT(nameid!=NULL); + + nameid->setName(expectedContent); + assertEquals(expectedDOM, nameid); + } + + void testSingleElementOptionalAttributesMarshall() { + NameID* nameid = NameIDBuilder::buildNameID(); + TS_ASSERT(nameid!=NULL); + + nameid->setNameQualifier(expectedNameQualifier); + nameid->setSPNameQualifier(expectedSPNameQualifier); + nameid->setFormat(expectedFormat); + nameid->setSPProvidedID(expectedSPProvidedID); + nameid->setName(expectedContent); + assertEquals(expectedOptionalAttributesDOM, nameid); + } + +}; diff --git a/samltest/saml2/core/impl/NameIDMappingRequest20Test.h b/samltest/saml2/core/impl/NameIDMappingRequest20Test.h index f14b05c..6489852 100644 --- a/samltest/saml2/core/impl/NameIDMappingRequest20Test.h +++ b/samltest/saml2/core/impl/NameIDMappingRequest20Test.h @@ -1,134 +1,134 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2p; -using namespace opensaml::saml2; - -class NameIDMappingRequest20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* expectedID; - XMLCh* expectedVersion; - DateTime* expectedIssueInstant; - XMLCh* expectedConsent; - XMLCh* expectedDestination; - -public: - void setUp() { - expectedID = XMLString::transcode("abc123");; - expectedVersion = XMLString::transcode("2.0"); - expectedIssueInstant = new DateTime(XMLString::transcode("2006-02-21T16:40:00.000Z")); - expectedIssueInstant->parseDateTime(); - expectedConsent = XMLString::transcode("urn:string:consent"); - expectedDestination = XMLString::transcode("http://idp.example.org/endpoint"); - - singleElementFile = data_path + "saml2/core/impl/NameIDMappingRequest.xml"; - singleElementOptionalAttributesFile = data_path + "saml2/core/impl/NameIDMappingRequestOptionalAttributes.xml"; - childElementsFile = data_path + "saml2/core/impl/NameIDMappingRequestChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&expectedID); - XMLString::release(&expectedVersion); - XMLString::release(&expectedConsent); - XMLString::release(&expectedDestination); - delete expectedIssueInstant; - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - NameIDMappingRequest* request = dynamic_cast(xo.get()); - TS_ASSERT(request!=NULL); - assertEquals("ID attribute", expectedID, request->getID()); - assertEquals("Version attribute", expectedVersion, request->getVersion()); - TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), request->getIssueInstant()->getEpoch()); - - TS_ASSERT(request->getIssuer()==NULL); - TS_ASSERT(request->getSignature()==NULL); - TS_ASSERT(request->getExtensions()==NULL); - TS_ASSERT(request->getBaseID()==NULL); - TS_ASSERT(request->getNameID()==NULL); - TS_ASSERT(request->getEncryptedID()==NULL); - TS_ASSERT(request->getNameIDPolicy()==NULL); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - NameIDMappingRequest* request = dynamic_cast(xo.get()); - TS_ASSERT(request!=NULL); - - assertEquals("Consent attribute", expectedConsent, request->getConsent()); - assertEquals("Destination attribute", expectedDestination, request->getDestination()); - - TS_ASSERT(request->getIssuer()==NULL); - TS_ASSERT(request->getSignature()==NULL); - TS_ASSERT(request->getExtensions()==NULL); - TS_ASSERT(request->getBaseID()==NULL); - TS_ASSERT(request->getNameID()==NULL); - TS_ASSERT(request->getEncryptedID()==NULL); - TS_ASSERT(request->getNameIDPolicy()==NULL); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - NameIDMappingRequest* request= dynamic_cast(xo.get()); - TS_ASSERT(request!=NULL); - TS_ASSERT(request->getIssuer()!=NULL); - TS_ASSERT(request->getSignature()==NULL); - TS_ASSERT(request->getExtensions()==NULL); - TS_ASSERT(request->getBaseID()==NULL); - TS_ASSERT(request->getNameID()!=NULL); - TS_ASSERT(request->getEncryptedID()==NULL); - TS_ASSERT(request->getNameIDPolicy()!=NULL); - } - - void testSingleElementMarshall() { - NameIDMappingRequest* request=NameIDMappingRequestBuilder::buildNameIDMappingRequest(); - request->setID(expectedID); - request->setIssueInstant(expectedIssueInstant); - //request->setVersion(expectedVersion); - assertEquals(expectedDOM, request); - } - - void testSingleElementOptionalAttributesMarshall() { - NameIDMappingRequest* request=NameIDMappingRequestBuilder::buildNameIDMappingRequest(); - request->setID(expectedID); - request->setIssueInstant(expectedIssueInstant); - //request->setVersion(expectedVersion); - request->setConsent(expectedConsent); - request->setDestination(expectedDestination); - assertEquals(expectedOptionalAttributesDOM, request); - } - - void testChildElementsMarshall() { - NameIDMappingRequest* request=NameIDMappingRequestBuilder::buildNameIDMappingRequest(); - request->setID(expectedID); - request->setIssueInstant(expectedIssueInstant); - // Do this just so don't have to redeclare the saml namespace prefix on every child element in the control XML file - Namespace* ns = new Namespace(opensaml::SAMLConstants::SAML20_NS, opensaml::SAMLConstants::SAML20_PREFIX); - request->addNamespace(*ns); - request->setIssuer(IssuerBuilder::buildIssuer()); - request->setNameID(NameIDBuilder::buildNameID()); - request->setNameIDPolicy(NameIDPolicyBuilder::buildNameIDPolicy()); - assertEquals(expectedChildElementsDOM, request); - delete ns; - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2p; +using namespace opensaml::saml2; + +class NameIDMappingRequest20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedID; + XMLCh* expectedVersion; + DateTime* expectedIssueInstant; + XMLCh* expectedConsent; + XMLCh* expectedDestination; + +public: + void setUp() { + expectedID = XMLString::transcode("abc123");; + expectedVersion = XMLString::transcode("2.0"); + expectedIssueInstant = new DateTime(XMLString::transcode("2006-02-21T16:40:00.000Z")); + expectedIssueInstant->parseDateTime(); + expectedConsent = XMLString::transcode("urn:string:consent"); + expectedDestination = XMLString::transcode("http://idp.example.org/endpoint"); + + singleElementFile = data_path + "saml2/core/impl/NameIDMappingRequest.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/NameIDMappingRequestOptionalAttributes.xml"; + childElementsFile = data_path + "saml2/core/impl/NameIDMappingRequestChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedID); + XMLString::release(&expectedVersion); + XMLString::release(&expectedConsent); + XMLString::release(&expectedDestination); + delete expectedIssueInstant; + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + NameIDMappingRequest* request = dynamic_cast(xo.get()); + TS_ASSERT(request!=NULL); + assertEquals("ID attribute", expectedID, request->getID()); + assertEquals("Version attribute", expectedVersion, request->getVersion()); + TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), request->getIssueInstant()->getEpoch()); + + TS_ASSERT(request->getIssuer()==NULL); + TS_ASSERT(request->getSignature()==NULL); + TS_ASSERT(request->getExtensions()==NULL); + TS_ASSERT(request->getBaseID()==NULL); + TS_ASSERT(request->getNameID()==NULL); + TS_ASSERT(request->getEncryptedID()==NULL); + TS_ASSERT(request->getNameIDPolicy()==NULL); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + NameIDMappingRequest* request = dynamic_cast(xo.get()); + TS_ASSERT(request!=NULL); + + assertEquals("Consent attribute", expectedConsent, request->getConsent()); + assertEquals("Destination attribute", expectedDestination, request->getDestination()); + + TS_ASSERT(request->getIssuer()==NULL); + TS_ASSERT(request->getSignature()==NULL); + TS_ASSERT(request->getExtensions()==NULL); + TS_ASSERT(request->getBaseID()==NULL); + TS_ASSERT(request->getNameID()==NULL); + TS_ASSERT(request->getEncryptedID()==NULL); + TS_ASSERT(request->getNameIDPolicy()==NULL); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + NameIDMappingRequest* request= dynamic_cast(xo.get()); + TS_ASSERT(request!=NULL); + TS_ASSERT(request->getIssuer()!=NULL); + TS_ASSERT(request->getSignature()==NULL); + TS_ASSERT(request->getExtensions()==NULL); + TS_ASSERT(request->getBaseID()==NULL); + TS_ASSERT(request->getNameID()!=NULL); + TS_ASSERT(request->getEncryptedID()==NULL); + TS_ASSERT(request->getNameIDPolicy()!=NULL); + } + + void testSingleElementMarshall() { + NameIDMappingRequest* request=NameIDMappingRequestBuilder::buildNameIDMappingRequest(); + request->setID(expectedID); + request->setIssueInstant(expectedIssueInstant); + //request->setVersion(expectedVersion); + assertEquals(expectedDOM, request); + } + + void testSingleElementOptionalAttributesMarshall() { + NameIDMappingRequest* request=NameIDMappingRequestBuilder::buildNameIDMappingRequest(); + request->setID(expectedID); + request->setIssueInstant(expectedIssueInstant); + //request->setVersion(expectedVersion); + request->setConsent(expectedConsent); + request->setDestination(expectedDestination); + assertEquals(expectedOptionalAttributesDOM, request); + } + + void testChildElementsMarshall() { + NameIDMappingRequest* request=NameIDMappingRequestBuilder::buildNameIDMappingRequest(); + request->setID(expectedID); + request->setIssueInstant(expectedIssueInstant); + // Do this just so don't have to redeclare the saml namespace prefix on every child element in the control XML file + Namespace* ns = new Namespace(opensaml::SAMLConstants::SAML20_NS, opensaml::SAMLConstants::SAML20_PREFIX); + request->addNamespace(*ns); + request->setIssuer(IssuerBuilder::buildIssuer()); + request->setNameID(NameIDBuilder::buildNameID()); + request->setNameIDPolicy(NameIDPolicyBuilder::buildNameIDPolicy()); + assertEquals(expectedChildElementsDOM, request); + delete ns; + } + +}; diff --git a/samltest/saml2/core/impl/NameIDMappingResponse20Test.h b/samltest/saml2/core/impl/NameIDMappingResponse20Test.h index ddc8c52..5eb94b6 100644 --- a/samltest/saml2/core/impl/NameIDMappingResponse20Test.h +++ b/samltest/saml2/core/impl/NameIDMappingResponse20Test.h @@ -1,146 +1,146 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2p; -using namespace opensaml::saml2; - -class NameIDMappingResponse20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* expectedID; - XMLCh* expectedInResponseTo; - XMLCh* expectedVersion; - XMLCh* expectedConsent; - XMLCh* expectedDestination; - DateTime* expectedIssueInstant; - -public: - void setUp() { - expectedID = XMLString::transcode("def456"); - expectedInResponseTo = XMLString::transcode("abc123"); - expectedVersion = XMLString::transcode("2.0"); - expectedConsent = XMLString::transcode("urn:string:consent"); - expectedDestination = XMLString::transcode("http://sp.example.org/endpoint"); - expectedIssueInstant = new DateTime(XMLString::transcode("2006-02-21T16:40:00.000Z")); - expectedIssueInstant->parseDateTime(); - - singleElementFile = data_path + "saml2/core/impl/NameIDMappingResponse.xml"; - singleElementOptionalAttributesFile = data_path + "saml2/core/impl/NameIDMappingResponseOptionalAttributes.xml"; - childElementsFile = data_path + "saml2/core/impl/NameIDMappingResponseChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&expectedID); - XMLString::release(&expectedInResponseTo); - XMLString::release(&expectedVersion); - XMLString::release(&expectedConsent); - XMLString::release(&expectedDestination); - delete expectedIssueInstant; - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - NameIDMappingResponse* response = dynamic_cast(xo.get()); - TS_ASSERT(response!=NULL); - - assertEquals("ID attribute", expectedID, response->getID()); - assertEquals("Version attribute", expectedVersion, response->getVersion()); - TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), response->getIssueInstant()->getEpoch()); - - TS_ASSERT(response->getIssuer()==NULL); - TS_ASSERT(response->getSignature()==NULL); - TS_ASSERT(response->getExtensions()==NULL); - TS_ASSERT(response->getStatus()==NULL); - TS_ASSERT(response->getNameID()==NULL); - TS_ASSERT(response->getEncryptedID()==NULL); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - NameIDMappingResponse* response = dynamic_cast(xo.get()); - TS_ASSERT(response!=NULL); - - assertEquals("Consent attribute", expectedConsent, response->getConsent()); - assertEquals("Destination attribute", expectedDestination, response->getDestination()); - assertEquals("InResponseTo attribute", expectedInResponseTo, response->getInResponseTo()); - - TS_ASSERT(response->getIssuer()==NULL); - TS_ASSERT(response->getSignature()==NULL); - TS_ASSERT(response->getExtensions()==NULL); - TS_ASSERT(response->getStatus()==NULL); - TS_ASSERT(response->getNameID()==NULL); - TS_ASSERT(response->getEncryptedID()==NULL); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - NameIDMappingResponse* response= dynamic_cast(xo.get()); - TS_ASSERT(response!=NULL); - - TS_ASSERT(response->getIssuer()!=NULL); - TS_ASSERT(response->getSignature()==NULL); - TS_ASSERT(response->getExtensions()==NULL); - TS_ASSERT(response->getStatus()!=NULL); - TS_ASSERT(response->getNameID()!=NULL); - TS_ASSERT(response->getEncryptedID()==NULL); - } - - void testSingleElementMarshall() { - NameIDMappingResponse* response = NameIDMappingResponseBuilder::buildNameIDMappingResponse(); - TS_ASSERT(response!=NULL); - - response->setID(expectedID); - response->setIssueInstant(expectedIssueInstant); - //response->setVersion(expectedVersion); - assertEquals(expectedDOM, response); - } - - void testSingleElementOptionalAttributesMarshall() { - NameIDMappingResponse* response = NameIDMappingResponseBuilder::buildNameIDMappingResponse(); - TS_ASSERT(response!=NULL); - - response->setID(expectedID); - response->setInResponseTo(expectedInResponseTo); - response->setIssueInstant(expectedIssueInstant); - //response->setVersion(expectedVersion); - response->setConsent(expectedConsent); - response->setDestination(expectedDestination); - response->setInResponseTo(expectedInResponseTo); - assertEquals(expectedOptionalAttributesDOM, response); - } - - void testChildElementsMarshall() { - NameIDMappingResponse* response = NameIDMappingResponseBuilder::buildNameIDMappingResponse(); - TS_ASSERT(response!=NULL); - - response->setID(expectedID); - response->setIssueInstant(expectedIssueInstant); - // Do this just so don't have to redeclare the saml namespace prefix on every child element in the control XML file - Namespace* ns = new Namespace(opensaml::SAMLConstants::SAML20_NS, opensaml::SAMLConstants::SAML20_PREFIX); - response->addNamespace(*ns); - response->setIssuer(IssuerBuilder::buildIssuer()); - response->setStatus(StatusBuilder::buildStatus()); - response->setNameID(NameIDBuilder::buildNameID()); - - assertEquals(expectedChildElementsDOM, response); - delete ns; - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2p; +using namespace opensaml::saml2; + +class NameIDMappingResponse20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedID; + XMLCh* expectedInResponseTo; + XMLCh* expectedVersion; + XMLCh* expectedConsent; + XMLCh* expectedDestination; + DateTime* expectedIssueInstant; + +public: + void setUp() { + expectedID = XMLString::transcode("def456"); + expectedInResponseTo = XMLString::transcode("abc123"); + expectedVersion = XMLString::transcode("2.0"); + expectedConsent = XMLString::transcode("urn:string:consent"); + expectedDestination = XMLString::transcode("http://sp.example.org/endpoint"); + expectedIssueInstant = new DateTime(XMLString::transcode("2006-02-21T16:40:00.000Z")); + expectedIssueInstant->parseDateTime(); + + singleElementFile = data_path + "saml2/core/impl/NameIDMappingResponse.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/NameIDMappingResponseOptionalAttributes.xml"; + childElementsFile = data_path + "saml2/core/impl/NameIDMappingResponseChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedID); + XMLString::release(&expectedInResponseTo); + XMLString::release(&expectedVersion); + XMLString::release(&expectedConsent); + XMLString::release(&expectedDestination); + delete expectedIssueInstant; + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + NameIDMappingResponse* response = dynamic_cast(xo.get()); + TS_ASSERT(response!=NULL); + + assertEquals("ID attribute", expectedID, response->getID()); + assertEquals("Version attribute", expectedVersion, response->getVersion()); + TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), response->getIssueInstant()->getEpoch()); + + TS_ASSERT(response->getIssuer()==NULL); + TS_ASSERT(response->getSignature()==NULL); + TS_ASSERT(response->getExtensions()==NULL); + TS_ASSERT(response->getStatus()==NULL); + TS_ASSERT(response->getNameID()==NULL); + TS_ASSERT(response->getEncryptedID()==NULL); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + NameIDMappingResponse* response = dynamic_cast(xo.get()); + TS_ASSERT(response!=NULL); + + assertEquals("Consent attribute", expectedConsent, response->getConsent()); + assertEquals("Destination attribute", expectedDestination, response->getDestination()); + assertEquals("InResponseTo attribute", expectedInResponseTo, response->getInResponseTo()); + + TS_ASSERT(response->getIssuer()==NULL); + TS_ASSERT(response->getSignature()==NULL); + TS_ASSERT(response->getExtensions()==NULL); + TS_ASSERT(response->getStatus()==NULL); + TS_ASSERT(response->getNameID()==NULL); + TS_ASSERT(response->getEncryptedID()==NULL); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + NameIDMappingResponse* response= dynamic_cast(xo.get()); + TS_ASSERT(response!=NULL); + + TS_ASSERT(response->getIssuer()!=NULL); + TS_ASSERT(response->getSignature()==NULL); + TS_ASSERT(response->getExtensions()==NULL); + TS_ASSERT(response->getStatus()!=NULL); + TS_ASSERT(response->getNameID()!=NULL); + TS_ASSERT(response->getEncryptedID()==NULL); + } + + void testSingleElementMarshall() { + NameIDMappingResponse* response = NameIDMappingResponseBuilder::buildNameIDMappingResponse(); + TS_ASSERT(response!=NULL); + + response->setID(expectedID); + response->setIssueInstant(expectedIssueInstant); + //response->setVersion(expectedVersion); + assertEquals(expectedDOM, response); + } + + void testSingleElementOptionalAttributesMarshall() { + NameIDMappingResponse* response = NameIDMappingResponseBuilder::buildNameIDMappingResponse(); + TS_ASSERT(response!=NULL); + + response->setID(expectedID); + response->setInResponseTo(expectedInResponseTo); + response->setIssueInstant(expectedIssueInstant); + //response->setVersion(expectedVersion); + response->setConsent(expectedConsent); + response->setDestination(expectedDestination); + response->setInResponseTo(expectedInResponseTo); + assertEquals(expectedOptionalAttributesDOM, response); + } + + void testChildElementsMarshall() { + NameIDMappingResponse* response = NameIDMappingResponseBuilder::buildNameIDMappingResponse(); + TS_ASSERT(response!=NULL); + + response->setID(expectedID); + response->setIssueInstant(expectedIssueInstant); + // Do this just so don't have to redeclare the saml namespace prefix on every child element in the control XML file + Namespace* ns = new Namespace(opensaml::SAMLConstants::SAML20_NS, opensaml::SAMLConstants::SAML20_PREFIX); + response->addNamespace(*ns); + response->setIssuer(IssuerBuilder::buildIssuer()); + response->setStatus(StatusBuilder::buildStatus()); + response->setNameID(NameIDBuilder::buildNameID()); + + assertEquals(expectedChildElementsDOM, response); + delete ns; + } + +}; diff --git a/samltest/saml2/core/impl/NameIDPolicy20Test.h b/samltest/saml2/core/impl/NameIDPolicy20Test.h index ac4e292..a8f3a3a 100644 --- a/samltest/saml2/core/impl/NameIDPolicy20Test.h +++ b/samltest/saml2/core/impl/NameIDPolicy20Test.h @@ -1,76 +1,76 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2p; -using namespace opensaml::saml2; - -class NameIDPolicy20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* expectedFormat; - XMLCh* expectedSPNameQualifier; - bool expectedAllowCreate; - -public: - void setUp() { - expectedFormat = XMLString::transcode("urn:string:format");; - expectedSPNameQualifier = XMLString::transcode("urn:string:spname"); - expectedAllowCreate=true; - - singleElementFile = data_path + "saml2/core/impl/NameIDPolicy.xml"; - singleElementOptionalAttributesFile = data_path + "saml2/core/impl/NameIDPolicyOptionalAttributes.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&expectedFormat); - XMLString::release(&expectedSPNameQualifier); - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - NameIDPolicy* policy = dynamic_cast(xo.get()); - TS_ASSERT(policy!=NULL); - TSM_ASSERT_EQUALS("AllowCreate attribute presence", XMLConstants::XML_BOOL_NULL, policy->getAllowCreate()); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - NameIDPolicy* policy = dynamic_cast(xo.get()); - TS_ASSERT(policy!=NULL); - assertEquals("Format attribute", expectedFormat, policy->getFormat()); - assertEquals("SPNameQualifier attribute", expectedSPNameQualifier, policy->getSPNameQualifier()); - TSM_ASSERT_DIFFERS("AllowCreate attribute presence", XMLConstants::XML_BOOL_NULL, policy->getAllowCreate()); - TSM_ASSERT_EQUALS("AllowCreate attribute value", expectedAllowCreate, policy->AllowCreate()); - } - - void testSingleElementMarshall() { - NameIDPolicy* policy=NameIDPolicyBuilder::buildNameIDPolicy(); - assertEquals(expectedDOM, policy); - } - - void testSingleElementOptionalAttributesMarshall() { - NameIDPolicy* policy=NameIDPolicyBuilder::buildNameIDPolicy(); - policy->setFormat(expectedFormat); - policy->setSPNameQualifier(expectedSPNameQualifier); - policy->AllowCreate(expectedAllowCreate); - assertEquals(expectedOptionalAttributesDOM, policy); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2p; +using namespace opensaml::saml2; + +class NameIDPolicy20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedFormat; + XMLCh* expectedSPNameQualifier; + bool expectedAllowCreate; + +public: + void setUp() { + expectedFormat = XMLString::transcode("urn:string:format");; + expectedSPNameQualifier = XMLString::transcode("urn:string:spname"); + expectedAllowCreate=true; + + singleElementFile = data_path + "saml2/core/impl/NameIDPolicy.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/NameIDPolicyOptionalAttributes.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedFormat); + XMLString::release(&expectedSPNameQualifier); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + NameIDPolicy* policy = dynamic_cast(xo.get()); + TS_ASSERT(policy!=NULL); + TSM_ASSERT_EQUALS("AllowCreate attribute presence", XMLConstants::XML_BOOL_NULL, policy->getAllowCreate()); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + NameIDPolicy* policy = dynamic_cast(xo.get()); + TS_ASSERT(policy!=NULL); + assertEquals("Format attribute", expectedFormat, policy->getFormat()); + assertEquals("SPNameQualifier attribute", expectedSPNameQualifier, policy->getSPNameQualifier()); + TSM_ASSERT_DIFFERS("AllowCreate attribute presence", XMLConstants::XML_BOOL_NULL, policy->getAllowCreate()); + TSM_ASSERT_EQUALS("AllowCreate attribute value", expectedAllowCreate, policy->AllowCreate()); + } + + void testSingleElementMarshall() { + NameIDPolicy* policy=NameIDPolicyBuilder::buildNameIDPolicy(); + assertEquals(expectedDOM, policy); + } + + void testSingleElementOptionalAttributesMarshall() { + NameIDPolicy* policy=NameIDPolicyBuilder::buildNameIDPolicy(); + policy->setFormat(expectedFormat); + policy->setSPNameQualifier(expectedSPNameQualifier); + policy->AllowCreate(expectedAllowCreate); + assertEquals(expectedOptionalAttributesDOM, policy); + } + +}; diff --git a/samltest/saml2/core/impl/NameIDType20Test.h b/samltest/saml2/core/impl/NameIDType20Test.h index aa87866..d464805 100644 --- a/samltest/saml2/core/impl/NameIDType20Test.h +++ b/samltest/saml2/core/impl/NameIDType20Test.h @@ -1,139 +1,139 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2; - -/* - This tests building an element of type NameIDType with a non-SAML element name and namespace - */ - -class NameIDType20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* expectedNameQualifier; - XMLCh* expectedSPNameQualifier; - XMLCh* expectedFormat; - XMLCh* expectedSPProvidedID; - XMLCh* expectedContent; - - //TODO possibly move these up to SAMLObjectBaseTestCase, for use in optional helper methods below - XMLCh* elementName; - XMLCh* elementNS; - XMLCh* elementPrefix; - const XMLCh* typeName; - const XMLCh* typeNS; - const XMLCh* typePrefix; - -public: - void setUp() { - expectedNameQualifier = XMLString::transcode("nq"); - expectedSPNameQualifier = XMLString::transcode("spnq"); - expectedFormat = XMLString::transcode("format"); - expectedSPProvidedID = XMLString::transcode("spID"); - expectedContent = XMLString::transcode("someNameID"); - - elementName = XMLString::transcode("Foo");; - elementNS = XMLString::transcode("http://www.example.org/test"); - elementPrefix = XMLString::transcode("test");; - typeName = NameIDType::TYPE_NAME; - typeNS = SAMLConstants::SAML20_NS; - typePrefix = SAMLConstants::SAML20_PREFIX; - - singleElementFile = data_path + "saml2/core/impl/NameIDType.xml"; - singleElementOptionalAttributesFile = data_path + "saml2/core/impl/NameIDTypeOptionalAttributes.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&expectedNameQualifier); - XMLString::release(&expectedSPNameQualifier); - XMLString::release(&expectedFormat); - XMLString::release(&expectedSPProvidedID); - XMLString::release(&expectedContent); - XMLString::release(&elementName); - XMLString::release(&elementNS); - XMLString::release(&elementPrefix); - SAMLObjectBaseTestCase::tearDown(); - } - - //TODO possibly move this functionality up to SAMLObjectBaseTestCase, as optional helper method - void checkNameAndType(XMLObject* xo) { - assertEquals("Element name", elementName, xo->getElementQName().getLocalPart()); - assertEquals("Element namespace", elementNS, xo->getElementQName().getNamespaceURI()); - assertEquals("Element namespace prefix", elementPrefix, xo->getElementQName().getPrefix()); - - assertEquals("Schema type name", typeName, xo->getSchemaType()->getLocalPart()); - assertEquals("Schema type namespace", typeNS, xo->getSchemaType()->getNamespaceURI()); - assertEquals("Schema type namespace prefix", typePrefix, xo->getSchemaType()->getPrefix()); - } - - //TODO possibly move this functionality up to SAMLObjectBaseTestCase, as optional helper method - XMLObject * buildObject() { - const XMLObjectBuilder* builder = XMLObjectBuilder::getBuilder(QName(typeNS,typeName)); - QName type(typeNS,typeName,typePrefix); - return builder->buildObject(elementNS, elementName, elementPrefix, &type); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - NameIDType* nameid = dynamic_cast(xo.get()); - TS_ASSERT(nameid!=NULL); - - checkNameAndType(nameid); - - assertEquals("Element content", expectedContent, nameid->getName()); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - NameIDType* nameid = dynamic_cast(xo.get()); - TS_ASSERT(nameid!=NULL); - - checkNameAndType(nameid); - - assertEquals("NameQualifier attribute", expectedNameQualifier, nameid->getNameQualifier()); - assertEquals("SPNameQualifier attribute", expectedSPNameQualifier, nameid->getSPNameQualifier()); - assertEquals("Format attribute", expectedFormat, nameid->getFormat()); - assertEquals("SPProvidedID attribute", expectedSPProvidedID, nameid->getSPProvidedID()); - assertEquals("Element content", expectedContent, nameid->getName()); - } - - - void testSingleElementMarshall() { - NameIDType* nameid = dynamic_cast(buildObject()); - TS_ASSERT(nameid!=NULL); - checkNameAndType(nameid); - - nameid->setName(expectedContent); - assertEquals(expectedDOM, nameid); - } - - void testSingleElementOptionalAttributesMarshall() { - NameIDType* nameid = dynamic_cast(buildObject()); - TS_ASSERT(nameid!=NULL); - checkNameAndType(nameid); - - nameid->setNameQualifier(expectedNameQualifier); - nameid->setSPNameQualifier(expectedSPNameQualifier); - nameid->setFormat(expectedFormat); - nameid->setSPProvidedID(expectedSPProvidedID); - nameid->setName(expectedContent); - assertEquals(expectedOptionalAttributesDOM, nameid); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +/* + This tests building an element of type NameIDType with a non-SAML element name and namespace + */ + +class NameIDType20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedNameQualifier; + XMLCh* expectedSPNameQualifier; + XMLCh* expectedFormat; + XMLCh* expectedSPProvidedID; + XMLCh* expectedContent; + + //TODO possibly move these up to SAMLObjectBaseTestCase, for use in optional helper methods below + XMLCh* elementName; + XMLCh* elementNS; + XMLCh* elementPrefix; + const XMLCh* typeName; + const XMLCh* typeNS; + const XMLCh* typePrefix; + +public: + void setUp() { + expectedNameQualifier = XMLString::transcode("nq"); + expectedSPNameQualifier = XMLString::transcode("spnq"); + expectedFormat = XMLString::transcode("format"); + expectedSPProvidedID = XMLString::transcode("spID"); + expectedContent = XMLString::transcode("someNameID"); + + elementName = XMLString::transcode("Foo");; + elementNS = XMLString::transcode("http://www.example.org/test"); + elementPrefix = XMLString::transcode("test");; + typeName = NameIDType::TYPE_NAME; + typeNS = SAMLConstants::SAML20_NS; + typePrefix = SAMLConstants::SAML20_PREFIX; + + singleElementFile = data_path + "saml2/core/impl/NameIDType.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/NameIDTypeOptionalAttributes.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedNameQualifier); + XMLString::release(&expectedSPNameQualifier); + XMLString::release(&expectedFormat); + XMLString::release(&expectedSPProvidedID); + XMLString::release(&expectedContent); + XMLString::release(&elementName); + XMLString::release(&elementNS); + XMLString::release(&elementPrefix); + SAMLObjectBaseTestCase::tearDown(); + } + + //TODO possibly move this functionality up to SAMLObjectBaseTestCase, as optional helper method + void checkNameAndType(XMLObject* xo) { + assertEquals("Element name", elementName, xo->getElementQName().getLocalPart()); + assertEquals("Element namespace", elementNS, xo->getElementQName().getNamespaceURI()); + assertEquals("Element namespace prefix", elementPrefix, xo->getElementQName().getPrefix()); + + assertEquals("Schema type name", typeName, xo->getSchemaType()->getLocalPart()); + assertEquals("Schema type namespace", typeNS, xo->getSchemaType()->getNamespaceURI()); + assertEquals("Schema type namespace prefix", typePrefix, xo->getSchemaType()->getPrefix()); + } + + //TODO possibly move this functionality up to SAMLObjectBaseTestCase, as optional helper method + XMLObject * buildObject() { + const XMLObjectBuilder* builder = XMLObjectBuilder::getBuilder(QName(typeNS,typeName)); + QName type(typeNS,typeName,typePrefix); + return builder->buildObject(elementNS, elementName, elementPrefix, &type); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + NameIDType* nameid = dynamic_cast(xo.get()); + TS_ASSERT(nameid!=NULL); + + checkNameAndType(nameid); + + assertEquals("Element content", expectedContent, nameid->getName()); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + NameIDType* nameid = dynamic_cast(xo.get()); + TS_ASSERT(nameid!=NULL); + + checkNameAndType(nameid); + + assertEquals("NameQualifier attribute", expectedNameQualifier, nameid->getNameQualifier()); + assertEquals("SPNameQualifier attribute", expectedSPNameQualifier, nameid->getSPNameQualifier()); + assertEquals("Format attribute", expectedFormat, nameid->getFormat()); + assertEquals("SPProvidedID attribute", expectedSPProvidedID, nameid->getSPProvidedID()); + assertEquals("Element content", expectedContent, nameid->getName()); + } + + + void testSingleElementMarshall() { + NameIDType* nameid = dynamic_cast(buildObject()); + TS_ASSERT(nameid!=NULL); + checkNameAndType(nameid); + + nameid->setName(expectedContent); + assertEquals(expectedDOM, nameid); + } + + void testSingleElementOptionalAttributesMarshall() { + NameIDType* nameid = dynamic_cast(buildObject()); + TS_ASSERT(nameid!=NULL); + checkNameAndType(nameid); + + nameid->setNameQualifier(expectedNameQualifier); + nameid->setSPNameQualifier(expectedSPNameQualifier); + nameid->setFormat(expectedFormat); + nameid->setSPProvidedID(expectedSPProvidedID); + nameid->setName(expectedContent); + assertEquals(expectedOptionalAttributesDOM, nameid); + } + +}; diff --git a/samltest/saml2/core/impl/NewEncryptedID20Test.h b/samltest/saml2/core/impl/NewEncryptedID20Test.h index e9a3ef7..54bbea3 100644 --- a/samltest/saml2/core/impl/NewEncryptedID20Test.h +++ b/samltest/saml2/core/impl/NewEncryptedID20Test.h @@ -1,71 +1,71 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include -#include - -using namespace opensaml; -using namespace opensaml::saml2p; -using namespace xmlencryption; - -class NewEncryptedID20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - -public: - void setUp() { - singleElementFile = data_path + "saml2/core/impl/NewEncryptedID.xml"; - childElementsFile = data_path + "saml2/core/impl/NewEncryptedIDChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - NewEncryptedID* encID = dynamic_cast(xo.get()); - TS_ASSERT(encID!=NULL); - TSM_ASSERT("EncryptedData child element", encID->getEncryptedData()==NULL); - TSM_ASSERT_EQUALS("# of EncryptedKey child elements", 0, encID->getEncryptedKeys().size()); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - NewEncryptedID* encID = dynamic_cast(xo.get()); - TS_ASSERT(encID!=NULL); - TSM_ASSERT("EncryptedData child element", encID->getEncryptedData()!=NULL); - TSM_ASSERT_EQUALS("# of EncryptedKey child elements", 2, encID->getEncryptedKeys().size()); - } - - void testSingleElementMarshall() { - NewEncryptedID* encID=NewEncryptedIDBuilder::buildNewEncryptedID(); - assertEquals(expectedDOM, encID); - } - - void testChildElementsMarshall() { - NewEncryptedID* encID=NewEncryptedIDBuilder::buildNewEncryptedID(); - // Do this just so don't have to redeclare the xenc namespace prefix on every child element in the control XML file - Namespace* ns = new Namespace(xmltooling::XMLConstants::XMLENC_NS, xmltooling::XMLConstants::XMLENC_PREFIX); - encID->addNamespace(*ns); - encID->setEncryptedData(EncryptedDataBuilder::buildEncryptedData()); - encID->getEncryptedKeys().push_back(EncryptedKeyBuilder::buildEncryptedKey()); - encID->getEncryptedKeys().push_back(EncryptedKeyBuilder::buildEncryptedKey()); - assertEquals(expectedChildElementsDOM, encID); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include +#include + +using namespace opensaml; +using namespace opensaml::saml2p; +using namespace xmlencryption; + +class NewEncryptedID20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + +public: + void setUp() { + singleElementFile = data_path + "saml2/core/impl/NewEncryptedID.xml"; + childElementsFile = data_path + "saml2/core/impl/NewEncryptedIDChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + NewEncryptedID* encID = dynamic_cast(xo.get()); + TS_ASSERT(encID!=NULL); + TSM_ASSERT("EncryptedData child element", encID->getEncryptedData()==NULL); + TSM_ASSERT_EQUALS("# of EncryptedKey child elements", 0, encID->getEncryptedKeys().size()); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + NewEncryptedID* encID = dynamic_cast(xo.get()); + TS_ASSERT(encID!=NULL); + TSM_ASSERT("EncryptedData child element", encID->getEncryptedData()!=NULL); + TSM_ASSERT_EQUALS("# of EncryptedKey child elements", 2, encID->getEncryptedKeys().size()); + } + + void testSingleElementMarshall() { + NewEncryptedID* encID=NewEncryptedIDBuilder::buildNewEncryptedID(); + assertEquals(expectedDOM, encID); + } + + void testChildElementsMarshall() { + NewEncryptedID* encID=NewEncryptedIDBuilder::buildNewEncryptedID(); + // Do this just so don't have to redeclare the xenc namespace prefix on every child element in the control XML file + Namespace* ns = new Namespace(xmltooling::XMLConstants::XMLENC_NS, xmltooling::XMLConstants::XMLENC_PREFIX); + encID->addNamespace(*ns); + encID->setEncryptedData(EncryptedDataBuilder::buildEncryptedData()); + encID->getEncryptedKeys().push_back(EncryptedKeyBuilder::buildEncryptedKey()); + encID->getEncryptedKeys().push_back(EncryptedKeyBuilder::buildEncryptedKey()); + assertEquals(expectedChildElementsDOM, encID); + } + +}; diff --git a/samltest/saml2/core/impl/ProxyRestriction20Test.h b/samltest/saml2/core/impl/ProxyRestriction20Test.h index 09416a4..9a5d8ca 100644 --- a/samltest/saml2/core/impl/ProxyRestriction20Test.h +++ b/samltest/saml2/core/impl/ProxyRestriction20Test.h @@ -1,85 +1,85 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2; - -class ProxyRestriction20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - int expectedCount; - -public: - void setUp() { - expectedCount = 5; - singleElementFile = data_path + "saml2/core/impl/ProxyRestriction.xml"; - singleElementOptionalAttributesFile = data_path + "saml2/core/impl/ProxyRestrictionOptionalAttributes.xml"; - childElementsFile = data_path + "saml2/core/impl/ProxyRestrictionChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - ProxyRestriction* pr = dynamic_cast(xo.get()); - TS_ASSERT(pr!=NULL); - - TSM_ASSERT_EQUALS("Count attribute presence", false, pr->getCount().first); - TSM_ASSERT_EQUALS("# of Audience child elements", 0, pr->getAudiences().size()); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - ProxyRestriction* pr = dynamic_cast(xo.get()); - TS_ASSERT(pr!=NULL); - - TSM_ASSERT_EQUALS("Count attribute presence", true, pr->getCount().first); - TSM_ASSERT_EQUALS("Count attribute value", expectedCount, pr->getCount().second); - TSM_ASSERT_EQUALS("# of Audience child elements", 0, pr->getAudiences().size()); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - ProxyRestriction* pr= dynamic_cast(xo.get()); - TS_ASSERT(pr!=NULL); - - TSM_ASSERT_EQUALS("Count attribute presence", false, pr->getCount().first); - TSM_ASSERT_EQUALS("# of Audience child elements", 2, pr->getAudiences().size()); - } - - void testSingleElementMarshall() { - ProxyRestriction* pr=ProxyRestrictionBuilder::buildProxyRestriction(); - assertEquals(expectedDOM, pr); - } - - void testSingleElementOptionalAttributesMarshall() { - ProxyRestriction* pr=ProxyRestrictionBuilder::buildProxyRestriction(); - pr->setCount(expectedCount); - assertEquals(expectedOptionalAttributesDOM, pr); - } - - void testChildElementsMarshall() { - ProxyRestriction* pr=ProxyRestrictionBuilder::buildProxyRestriction(); - pr->getAudiences().push_back(AudienceBuilder::buildAudience()); - pr->getAudiences().push_back(AudienceBuilder::buildAudience()); - assertEquals(expectedChildElementsDOM, pr); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +class ProxyRestriction20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + int expectedCount; + +public: + void setUp() { + expectedCount = 5; + singleElementFile = data_path + "saml2/core/impl/ProxyRestriction.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/ProxyRestrictionOptionalAttributes.xml"; + childElementsFile = data_path + "saml2/core/impl/ProxyRestrictionChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + ProxyRestriction* pr = dynamic_cast(xo.get()); + TS_ASSERT(pr!=NULL); + + TSM_ASSERT_EQUALS("Count attribute presence", false, pr->getCount().first); + TSM_ASSERT_EQUALS("# of Audience child elements", 0, pr->getAudiences().size()); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + ProxyRestriction* pr = dynamic_cast(xo.get()); + TS_ASSERT(pr!=NULL); + + TSM_ASSERT_EQUALS("Count attribute presence", true, pr->getCount().first); + TSM_ASSERT_EQUALS("Count attribute value", expectedCount, pr->getCount().second); + TSM_ASSERT_EQUALS("# of Audience child elements", 0, pr->getAudiences().size()); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + ProxyRestriction* pr= dynamic_cast(xo.get()); + TS_ASSERT(pr!=NULL); + + TSM_ASSERT_EQUALS("Count attribute presence", false, pr->getCount().first); + TSM_ASSERT_EQUALS("# of Audience child elements", 2, pr->getAudiences().size()); + } + + void testSingleElementMarshall() { + ProxyRestriction* pr=ProxyRestrictionBuilder::buildProxyRestriction(); + assertEquals(expectedDOM, pr); + } + + void testSingleElementOptionalAttributesMarshall() { + ProxyRestriction* pr=ProxyRestrictionBuilder::buildProxyRestriction(); + pr->setCount(expectedCount); + assertEquals(expectedOptionalAttributesDOM, pr); + } + + void testChildElementsMarshall() { + ProxyRestriction* pr=ProxyRestrictionBuilder::buildProxyRestriction(); + pr->getAudiences().push_back(AudienceBuilder::buildAudience()); + pr->getAudiences().push_back(AudienceBuilder::buildAudience()); + assertEquals(expectedChildElementsDOM, pr); + } + +}; diff --git a/samltest/saml2/core/impl/RequestedAuthnContext20Test.h b/samltest/saml2/core/impl/RequestedAuthnContext20Test.h index 8695b55..4a6a57c 100644 --- a/samltest/saml2/core/impl/RequestedAuthnContext20Test.h +++ b/samltest/saml2/core/impl/RequestedAuthnContext20Test.h @@ -1,95 +1,95 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2p; -using namespace opensaml::saml2; - -class RequestedAuthnContext20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* expectedComparison; - -public: - void setUp() { - expectedComparison = XMLString::transcode("exact"); - - singleElementFile = data_path + "saml2/core/impl/RequestedAuthnContext.xml"; - singleElementOptionalAttributesFile = data_path + "saml2/core/impl/RequestedAuthnContextOptionalAttributes.xml"; - childElementsFile = data_path + "saml2/core/impl/RequestedAuthnContextChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&expectedComparison); - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - RequestedAuthnContext* rac = dynamic_cast(xo.get()); - TS_ASSERT(rac !=NULL); - TS_ASSERT(rac->getComparison()==NULL); - - TSM_ASSERT_EQUALS("# of AuthnContextClassRef child elements", 0, rac->getAuthnContextClassRefs().size()); - TSM_ASSERT_EQUALS("# of AuthnContextDeclRef child elements", 0, rac->getAuthnContextDeclRefs().size()); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - RequestedAuthnContext* rac = dynamic_cast(xo.get()); - TS_ASSERT(rac!=NULL); - assertEquals("Comparison attribute", expectedComparison, rac->getComparison()); - - TSM_ASSERT_EQUALS("# of AuthnContextClassRef child elements", 0, rac->getAuthnContextClassRefs().size()); - TSM_ASSERT_EQUALS("# of AuthnContextDeclRef child elements", 0, rac->getAuthnContextDeclRefs().size()); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - RequestedAuthnContext* rac = dynamic_cast(xo.get()); - TS_ASSERT(rac !=NULL); - TS_ASSERT(rac->getComparison()==NULL); - - TSM_ASSERT_EQUALS("# of AuthnContextClassRef child elements", 3, rac->getAuthnContextClassRefs().size()); - TSM_ASSERT_EQUALS("# of AuthnContextDeclRef child elements", 0, rac->getAuthnContextDeclRefs().size()); - } - - void testSingleElementMarshall() { - RequestedAuthnContext* rac=RequestedAuthnContextBuilder::buildRequestedAuthnContext(); - assertEquals(expectedDOM, rac); - } - - void testSingleElementOptionalAttributesMarshall() { - RequestedAuthnContext* rac=RequestedAuthnContextBuilder::buildRequestedAuthnContext(); - rac->setComparison(expectedComparison); - assertEquals(expectedOptionalAttributesDOM, rac); - } - - void testChildElementsMarshall() { - RequestedAuthnContext* rac=RequestedAuthnContextBuilder::buildRequestedAuthnContext(); - // Do this just so don't have to redeclare the saml namespace prefix on every child element in the control XML file - Namespace* ns = new Namespace(opensaml::SAMLConstants::SAML20_NS, opensaml::SAMLConstants::SAML20_PREFIX); - rac->addNamespace(*ns); - rac->getAuthnContextClassRefs().push_back(AuthnContextClassRefBuilder::buildAuthnContextClassRef()); - rac->getAuthnContextClassRefs().push_back(AuthnContextClassRefBuilder::buildAuthnContextClassRef()); - rac->getAuthnContextClassRefs().push_back(AuthnContextClassRefBuilder::buildAuthnContextClassRef()); - assertEquals(expectedChildElementsDOM, rac); - delete ns; - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2p; +using namespace opensaml::saml2; + +class RequestedAuthnContext20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedComparison; + +public: + void setUp() { + expectedComparison = XMLString::transcode("exact"); + + singleElementFile = data_path + "saml2/core/impl/RequestedAuthnContext.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/RequestedAuthnContextOptionalAttributes.xml"; + childElementsFile = data_path + "saml2/core/impl/RequestedAuthnContextChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedComparison); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + RequestedAuthnContext* rac = dynamic_cast(xo.get()); + TS_ASSERT(rac !=NULL); + TS_ASSERT(rac->getComparison()==NULL); + + TSM_ASSERT_EQUALS("# of AuthnContextClassRef child elements", 0, rac->getAuthnContextClassRefs().size()); + TSM_ASSERT_EQUALS("# of AuthnContextDeclRef child elements", 0, rac->getAuthnContextDeclRefs().size()); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + RequestedAuthnContext* rac = dynamic_cast(xo.get()); + TS_ASSERT(rac!=NULL); + assertEquals("Comparison attribute", expectedComparison, rac->getComparison()); + + TSM_ASSERT_EQUALS("# of AuthnContextClassRef child elements", 0, rac->getAuthnContextClassRefs().size()); + TSM_ASSERT_EQUALS("# of AuthnContextDeclRef child elements", 0, rac->getAuthnContextDeclRefs().size()); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + RequestedAuthnContext* rac = dynamic_cast(xo.get()); + TS_ASSERT(rac !=NULL); + TS_ASSERT(rac->getComparison()==NULL); + + TSM_ASSERT_EQUALS("# of AuthnContextClassRef child elements", 3, rac->getAuthnContextClassRefs().size()); + TSM_ASSERT_EQUALS("# of AuthnContextDeclRef child elements", 0, rac->getAuthnContextDeclRefs().size()); + } + + void testSingleElementMarshall() { + RequestedAuthnContext* rac=RequestedAuthnContextBuilder::buildRequestedAuthnContext(); + assertEquals(expectedDOM, rac); + } + + void testSingleElementOptionalAttributesMarshall() { + RequestedAuthnContext* rac=RequestedAuthnContextBuilder::buildRequestedAuthnContext(); + rac->setComparison(expectedComparison); + assertEquals(expectedOptionalAttributesDOM, rac); + } + + void testChildElementsMarshall() { + RequestedAuthnContext* rac=RequestedAuthnContextBuilder::buildRequestedAuthnContext(); + // Do this just so don't have to redeclare the saml namespace prefix on every child element in the control XML file + Namespace* ns = new Namespace(opensaml::SAMLConstants::SAML20_NS, opensaml::SAMLConstants::SAML20_PREFIX); + rac->addNamespace(*ns); + rac->getAuthnContextClassRefs().push_back(AuthnContextClassRefBuilder::buildAuthnContextClassRef()); + rac->getAuthnContextClassRefs().push_back(AuthnContextClassRefBuilder::buildAuthnContextClassRef()); + rac->getAuthnContextClassRefs().push_back(AuthnContextClassRefBuilder::buildAuthnContextClassRef()); + assertEquals(expectedChildElementsDOM, rac); + delete ns; + } + +}; diff --git a/samltest/saml2/core/impl/Response20Test.h b/samltest/saml2/core/impl/Response20Test.h index ee2153a..92dbe0c 100644 --- a/samltest/saml2/core/impl/Response20Test.h +++ b/samltest/saml2/core/impl/Response20Test.h @@ -1,181 +1,181 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2p; -using namespace opensaml::saml2; - - -class Response20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* expectedID; - XMLCh* expectedInResponseTo; - XMLCh* expectedVersion; - XMLCh* expectedConsent; - XMLCh* expectedDestination; - DateTime* expectedIssueInstant; - - // Assertion marshaller autogenerates ID, Version and IssueInstant if they are NULL, - // so have to agree on something to put in the control XML - XMLCh* assertionID1, * assertionID2, * assertionID3; - -public: - void setUp() { - expectedID = XMLString::transcode("def456"); - expectedInResponseTo = XMLString::transcode("abc123"); - expectedVersion = XMLString::transcode("2.0"); - expectedConsent = XMLString::transcode("urn:string:consent"); - expectedDestination = XMLString::transcode("http://sp.example.org/endpoint"); - expectedIssueInstant = new DateTime(XMLString::transcode("2006-02-21T16:40:00.000Z")); - expectedIssueInstant->parseDateTime(); - - assertionID1 = XMLString::transcode("test1"); - assertionID2= XMLString::transcode("test2"); - assertionID3 = XMLString::transcode("test3"); - - singleElementFile = data_path + "saml2/core/impl/Response.xml"; - singleElementOptionalAttributesFile = data_path + "saml2/core/impl/ResponseOptionalAttributes.xml"; - childElementsFile = data_path + "saml2/core/impl/ResponseChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&expectedID); - XMLString::release(&expectedInResponseTo); - XMLString::release(&expectedVersion); - XMLString::release(&expectedConsent); - XMLString::release(&expectedDestination); - XMLString::release(&assertionID1); - XMLString::release(&assertionID2); - XMLString::release(&assertionID3); - delete expectedIssueInstant; - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - Response* response = dynamic_cast(xo.get()); - TS_ASSERT(response!=NULL); - - assertEquals("ID attribute", expectedID, response->getID()); - assertEquals("Version attribute", expectedVersion, response->getVersion()); - TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), response->getIssueInstant()->getEpoch()); - - TS_ASSERT(response->getIssuer()==NULL); - TS_ASSERT(response->getSignature()==NULL); - TS_ASSERT(response->getExtensions()==NULL); - TS_ASSERT(response->getStatus()==NULL); - TSM_ASSERT_EQUALS("# of Assertion child elements", 0, response->getAssertions().size()); - TSM_ASSERT_EQUALS("# of EncryptedAssertion child elements", 0, response->getEncryptedAssertions().size()); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - Response* response = dynamic_cast(xo.get()); - TS_ASSERT(response!=NULL); - - assertEquals("Consent attribute", expectedConsent, response->getConsent()); - assertEquals("Destination attribute", expectedDestination, response->getDestination()); - assertEquals("InResponseTo attribute", expectedInResponseTo, response->getInResponseTo()); - - TS_ASSERT(response->getIssuer()==NULL); - TS_ASSERT(response->getSignature()==NULL); - TS_ASSERT(response->getExtensions()==NULL); - TS_ASSERT(response->getStatus()==NULL); - TSM_ASSERT_EQUALS("# of Assertion child elements", 0, response->getAssertions().size()); - TSM_ASSERT_EQUALS("# of EncryptedAssertion child elements", 0, response->getEncryptedAssertions().size()); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - Response* response= dynamic_cast(xo.get()); - TS_ASSERT(response!=NULL); - - TS_ASSERT(response->getIssuer()!=NULL); - TS_ASSERT(response->getSignature()!=NULL); - TS_ASSERT(response->getExtensions()!=NULL); - TS_ASSERT(response->getStatus()!=NULL); - TSM_ASSERT_EQUALS("# of Assertion child elements", 3, response->getAssertions().size()); - TSM_ASSERT_EQUALS("# of EncryptedAssertion child elements", 1, response->getEncryptedAssertions().size()); - } - - void testSingleElementMarshall() { - Response* response = ResponseBuilder::buildResponse(); - TS_ASSERT(response!=NULL); - - response->setID(expectedID); - response->setIssueInstant(expectedIssueInstant); - //response->setVersion(expectedVersion); - assertEquals(expectedDOM, response); - } - - void testSingleElementOptionalAttributesMarshall() { - Response* response = ResponseBuilder::buildResponse(); - TS_ASSERT(response!=NULL); - - response->setID(expectedID); - response->setInResponseTo(expectedInResponseTo); - response->setIssueInstant(expectedIssueInstant); - //response->setVersion(expectedVersion); - response->setConsent(expectedConsent); - response->setDestination(expectedDestination); - response->setInResponseTo(expectedInResponseTo); - assertEquals(expectedOptionalAttributesDOM, response); - } - - void testChildElementsMarshall() { - Response* response = ResponseBuilder::buildResponse(); - TS_ASSERT(response!=NULL); - - response->setID(expectedID); - response->setIssueInstant(expectedIssueInstant); - // Do this just so don't have to redeclare the saml namespace prefix on every child element in the control XML file - Namespace* ns = new Namespace(opensaml::SAMLConstants::SAML20_NS, opensaml::SAMLConstants::SAML20_PREFIX); - response->addNamespace(*ns); - response->setIssuer(IssuerBuilder::buildIssuer()); - // If the form of the default, basic, empty signature that is emittted changes wrt whitespace, etc, - // this will probably break the test. In that case need to fix the control XML. - response->setSignature(xmlsignature::SignatureBuilder::buildSignature()); - response->setExtensions(ExtensionsBuilder::buildExtensions()); - response->setStatus(StatusBuilder::buildStatus()); - - Assertion* assertion=NULL; - - assertion = AssertionBuilder::buildAssertion(); - assertion->setIssueInstant(expectedIssueInstant); - assertion->setID(assertionID1); - response->getAssertions().push_back(assertion); - - assertion = AssertionBuilder::buildAssertion(); - assertion->setIssueInstant(expectedIssueInstant); - assertion->setID(assertionID2); - response->getAssertions().push_back(assertion); - - response->getEncryptedAssertions().push_back((EncryptedAssertionBuilder::buildEncryptedAssertion())); - - assertion = AssertionBuilder::buildAssertion(); - assertion->setIssueInstant(expectedIssueInstant); - assertion->setID(assertionID3); - response->getAssertions().push_back(assertion); - - - assertEquals(expectedChildElementsDOM, response); - delete ns; - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2p; +using namespace opensaml::saml2; + + +class Response20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedID; + XMLCh* expectedInResponseTo; + XMLCh* expectedVersion; + XMLCh* expectedConsent; + XMLCh* expectedDestination; + DateTime* expectedIssueInstant; + + // Assertion marshaller autogenerates ID, Version and IssueInstant if they are NULL, + // so have to agree on something to put in the control XML + XMLCh* assertionID1, * assertionID2, * assertionID3; + +public: + void setUp() { + expectedID = XMLString::transcode("def456"); + expectedInResponseTo = XMLString::transcode("abc123"); + expectedVersion = XMLString::transcode("2.0"); + expectedConsent = XMLString::transcode("urn:string:consent"); + expectedDestination = XMLString::transcode("http://sp.example.org/endpoint"); + expectedIssueInstant = new DateTime(XMLString::transcode("2006-02-21T16:40:00.000Z")); + expectedIssueInstant->parseDateTime(); + + assertionID1 = XMLString::transcode("test1"); + assertionID2= XMLString::transcode("test2"); + assertionID3 = XMLString::transcode("test3"); + + singleElementFile = data_path + "saml2/core/impl/Response.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/ResponseOptionalAttributes.xml"; + childElementsFile = data_path + "saml2/core/impl/ResponseChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedID); + XMLString::release(&expectedInResponseTo); + XMLString::release(&expectedVersion); + XMLString::release(&expectedConsent); + XMLString::release(&expectedDestination); + XMLString::release(&assertionID1); + XMLString::release(&assertionID2); + XMLString::release(&assertionID3); + delete expectedIssueInstant; + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + Response* response = dynamic_cast(xo.get()); + TS_ASSERT(response!=NULL); + + assertEquals("ID attribute", expectedID, response->getID()); + assertEquals("Version attribute", expectedVersion, response->getVersion()); + TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), response->getIssueInstant()->getEpoch()); + + TS_ASSERT(response->getIssuer()==NULL); + TS_ASSERT(response->getSignature()==NULL); + TS_ASSERT(response->getExtensions()==NULL); + TS_ASSERT(response->getStatus()==NULL); + TSM_ASSERT_EQUALS("# of Assertion child elements", 0, response->getAssertions().size()); + TSM_ASSERT_EQUALS("# of EncryptedAssertion child elements", 0, response->getEncryptedAssertions().size()); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + Response* response = dynamic_cast(xo.get()); + TS_ASSERT(response!=NULL); + + assertEquals("Consent attribute", expectedConsent, response->getConsent()); + assertEquals("Destination attribute", expectedDestination, response->getDestination()); + assertEquals("InResponseTo attribute", expectedInResponseTo, response->getInResponseTo()); + + TS_ASSERT(response->getIssuer()==NULL); + TS_ASSERT(response->getSignature()==NULL); + TS_ASSERT(response->getExtensions()==NULL); + TS_ASSERT(response->getStatus()==NULL); + TSM_ASSERT_EQUALS("# of Assertion child elements", 0, response->getAssertions().size()); + TSM_ASSERT_EQUALS("# of EncryptedAssertion child elements", 0, response->getEncryptedAssertions().size()); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + Response* response= dynamic_cast(xo.get()); + TS_ASSERT(response!=NULL); + + TS_ASSERT(response->getIssuer()!=NULL); + TS_ASSERT(response->getSignature()!=NULL); + TS_ASSERT(response->getExtensions()!=NULL); + TS_ASSERT(response->getStatus()!=NULL); + TSM_ASSERT_EQUALS("# of Assertion child elements", 3, response->getAssertions().size()); + TSM_ASSERT_EQUALS("# of EncryptedAssertion child elements", 1, response->getEncryptedAssertions().size()); + } + + void testSingleElementMarshall() { + Response* response = ResponseBuilder::buildResponse(); + TS_ASSERT(response!=NULL); + + response->setID(expectedID); + response->setIssueInstant(expectedIssueInstant); + //response->setVersion(expectedVersion); + assertEquals(expectedDOM, response); + } + + void testSingleElementOptionalAttributesMarshall() { + Response* response = ResponseBuilder::buildResponse(); + TS_ASSERT(response!=NULL); + + response->setID(expectedID); + response->setInResponseTo(expectedInResponseTo); + response->setIssueInstant(expectedIssueInstant); + //response->setVersion(expectedVersion); + response->setConsent(expectedConsent); + response->setDestination(expectedDestination); + response->setInResponseTo(expectedInResponseTo); + assertEquals(expectedOptionalAttributesDOM, response); + } + + void testChildElementsMarshall() { + Response* response = ResponseBuilder::buildResponse(); + TS_ASSERT(response!=NULL); + + response->setID(expectedID); + response->setIssueInstant(expectedIssueInstant); + // Do this just so don't have to redeclare the saml namespace prefix on every child element in the control XML file + Namespace* ns = new Namespace(opensaml::SAMLConstants::SAML20_NS, opensaml::SAMLConstants::SAML20_PREFIX); + response->addNamespace(*ns); + response->setIssuer(IssuerBuilder::buildIssuer()); + // If the form of the default, basic, empty signature that is emittted changes wrt whitespace, etc, + // this will probably break the test. In that case need to fix the control XML. + response->setSignature(xmlsignature::SignatureBuilder::buildSignature()); + response->setExtensions(ExtensionsBuilder::buildExtensions()); + response->setStatus(StatusBuilder::buildStatus()); + + Assertion* assertion=NULL; + + assertion = AssertionBuilder::buildAssertion(); + assertion->setIssueInstant(expectedIssueInstant); + assertion->setID(assertionID1); + response->getAssertions().push_back(assertion); + + assertion = AssertionBuilder::buildAssertion(); + assertion->setIssueInstant(expectedIssueInstant); + assertion->setID(assertionID2); + response->getAssertions().push_back(assertion); + + response->getEncryptedAssertions().push_back((EncryptedAssertionBuilder::buildEncryptedAssertion())); + + assertion = AssertionBuilder::buildAssertion(); + assertion->setIssueInstant(expectedIssueInstant); + assertion->setID(assertionID3); + response->getAssertions().push_back(assertion); + + + assertEquals(expectedChildElementsDOM, response); + delete ns; + } + +}; diff --git a/samltest/saml2/core/impl/Scoping20Test.h b/samltest/saml2/core/impl/Scoping20Test.h index 4db0986..34dd5a6 100644 --- a/samltest/saml2/core/impl/Scoping20Test.h +++ b/samltest/saml2/core/impl/Scoping20Test.h @@ -1,91 +1,91 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2p; -using namespace opensaml::saml2; - -class Scoping20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - int expectedProxycount; - -public: - void setUp() { - expectedProxycount = 5; - singleElementFile = data_path + "saml2/core/impl/Scoping.xml"; - singleElementOptionalAttributesFile = data_path + "saml2/core/impl/ScopingOptionalAttributes.xml"; - childElementsFile = data_path + "saml2/core/impl/ScopingChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - Scoping* scoping = dynamic_cast(xo.get()); - TS_ASSERT(scoping!=NULL); - - TSM_ASSERT_EQUALS("ProxyCount attribute presence", false, scoping->getProxyCount().first); - TS_ASSERT(scoping->getIDPList()==NULL); - TSM_ASSERT_EQUALS("# of RequesterID child elements", 0, scoping->getRequesterIDs().size()); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - Scoping* scoping = dynamic_cast(xo.get()); - TS_ASSERT(scoping!=NULL); - - TSM_ASSERT_EQUALS("ProxyCount attribute presence", true, scoping->getProxyCount().first); - TSM_ASSERT_EQUALS("ProxyCount attribute value", expectedProxycount, scoping->getProxyCount().second); - TS_ASSERT(scoping->getIDPList()==NULL); - TSM_ASSERT_EQUALS("# of RequesterID child elements", 0, scoping->getRequesterIDs().size()); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - Scoping* scoping= dynamic_cast(xo.get()); - TS_ASSERT(scoping!=NULL); - - TSM_ASSERT_EQUALS("ProxyCount attribute presence", false, scoping->getProxyCount().first); - TS_ASSERT(scoping->getIDPList()!=NULL); - TSM_ASSERT_EQUALS("# of RequesterID child elements", 3, scoping->getRequesterIDs().size()); - } - - void testSingleElementMarshall() { - Scoping* scoping=ScopingBuilder::buildScoping(); - assertEquals(expectedDOM, scoping); - } - - void testSingleElementOptionalAttributesMarshall() { - Scoping* scoping=ScopingBuilder::buildScoping(); - scoping->setProxyCount(expectedProxycount); - assertEquals(expectedOptionalAttributesDOM, scoping); - } - - void testChildElementsMarshall() { - Scoping* scoping=ScopingBuilder::buildScoping(); - scoping->setIDPList(IDPListBuilder::buildIDPList()); - scoping->getRequesterIDs().push_back(RequesterIDBuilder::buildRequesterID()); - scoping->getRequesterIDs().push_back(RequesterIDBuilder::buildRequesterID()); - scoping->getRequesterIDs().push_back(RequesterIDBuilder::buildRequesterID()); - assertEquals(expectedChildElementsDOM, scoping); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2p; +using namespace opensaml::saml2; + +class Scoping20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + int expectedProxycount; + +public: + void setUp() { + expectedProxycount = 5; + singleElementFile = data_path + "saml2/core/impl/Scoping.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/ScopingOptionalAttributes.xml"; + childElementsFile = data_path + "saml2/core/impl/ScopingChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + Scoping* scoping = dynamic_cast(xo.get()); + TS_ASSERT(scoping!=NULL); + + TSM_ASSERT_EQUALS("ProxyCount attribute presence", false, scoping->getProxyCount().first); + TS_ASSERT(scoping->getIDPList()==NULL); + TSM_ASSERT_EQUALS("# of RequesterID child elements", 0, scoping->getRequesterIDs().size()); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + Scoping* scoping = dynamic_cast(xo.get()); + TS_ASSERT(scoping!=NULL); + + TSM_ASSERT_EQUALS("ProxyCount attribute presence", true, scoping->getProxyCount().first); + TSM_ASSERT_EQUALS("ProxyCount attribute value", expectedProxycount, scoping->getProxyCount().second); + TS_ASSERT(scoping->getIDPList()==NULL); + TSM_ASSERT_EQUALS("# of RequesterID child elements", 0, scoping->getRequesterIDs().size()); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + Scoping* scoping= dynamic_cast(xo.get()); + TS_ASSERT(scoping!=NULL); + + TSM_ASSERT_EQUALS("ProxyCount attribute presence", false, scoping->getProxyCount().first); + TS_ASSERT(scoping->getIDPList()!=NULL); + TSM_ASSERT_EQUALS("# of RequesterID child elements", 3, scoping->getRequesterIDs().size()); + } + + void testSingleElementMarshall() { + Scoping* scoping=ScopingBuilder::buildScoping(); + assertEquals(expectedDOM, scoping); + } + + void testSingleElementOptionalAttributesMarshall() { + Scoping* scoping=ScopingBuilder::buildScoping(); + scoping->setProxyCount(expectedProxycount); + assertEquals(expectedOptionalAttributesDOM, scoping); + } + + void testChildElementsMarshall() { + Scoping* scoping=ScopingBuilder::buildScoping(); + scoping->setIDPList(IDPListBuilder::buildIDPList()); + scoping->getRequesterIDs().push_back(RequesterIDBuilder::buildRequesterID()); + scoping->getRequesterIDs().push_back(RequesterIDBuilder::buildRequesterID()); + scoping->getRequesterIDs().push_back(RequesterIDBuilder::buildRequesterID()); + assertEquals(expectedChildElementsDOM, scoping); + } + +}; diff --git a/samltest/saml2/core/impl/Status20Test.h b/samltest/saml2/core/impl/Status20Test.h index da96080..e164045 100644 --- a/samltest/saml2/core/impl/Status20Test.h +++ b/samltest/saml2/core/impl/Status20Test.h @@ -1,66 +1,66 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include - -using namespace opensaml::saml2p; - -class Status20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - -public: - void setUp() { - singleElementFile = data_path + "saml2/core/impl/Status.xml"; - childElementsFile = data_path + "saml2/core/impl/StatusChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - Status* status = dynamic_cast(xo.get()); - TS_ASSERT(status!=NULL); - TSM_ASSERT("StatusCode child element", status->getStatusCode()==NULL); - TSM_ASSERT("StatusMessage child element", status->getStatusMessage()==NULL); - TSM_ASSERT("StatusDetail child element", status->getStatusDetail()==NULL); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - Status* status = dynamic_cast(xo.get()); - TS_ASSERT(status!=NULL); - TSM_ASSERT("StatusCode child element", status->getStatusCode()!=NULL); - TSM_ASSERT("StatusMessage child element", status->getStatusMessage()!=NULL); - TSM_ASSERT("StatusDetail child element", status->getStatusDetail()!=NULL); - } - - void testSingleElementMarshall() { - Status* status=StatusBuilder::buildStatus(); - assertEquals(expectedDOM, status); - } - - void testChildElementsMarshall() { - Status* status=StatusBuilder::buildStatus(); - status->setStatusCode(StatusCodeBuilder::buildStatusCode()); - status->setStatusMessage(StatusMessageBuilder::buildStatusMessage()); - status->setStatusDetail(StatusDetailBuilder::buildStatusDetail()); - assertEquals(expectedChildElementsDOM, status); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include + +using namespace opensaml::saml2p; + +class Status20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + +public: + void setUp() { + singleElementFile = data_path + "saml2/core/impl/Status.xml"; + childElementsFile = data_path + "saml2/core/impl/StatusChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + Status* status = dynamic_cast(xo.get()); + TS_ASSERT(status!=NULL); + TSM_ASSERT("StatusCode child element", status->getStatusCode()==NULL); + TSM_ASSERT("StatusMessage child element", status->getStatusMessage()==NULL); + TSM_ASSERT("StatusDetail child element", status->getStatusDetail()==NULL); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + Status* status = dynamic_cast(xo.get()); + TS_ASSERT(status!=NULL); + TSM_ASSERT("StatusCode child element", status->getStatusCode()!=NULL); + TSM_ASSERT("StatusMessage child element", status->getStatusMessage()!=NULL); + TSM_ASSERT("StatusDetail child element", status->getStatusDetail()!=NULL); + } + + void testSingleElementMarshall() { + Status* status=StatusBuilder::buildStatus(); + assertEquals(expectedDOM, status); + } + + void testChildElementsMarshall() { + Status* status=StatusBuilder::buildStatus(); + status->setStatusCode(StatusCodeBuilder::buildStatusCode()); + status->setStatusMessage(StatusMessageBuilder::buildStatusMessage()); + status->setStatusDetail(StatusDetailBuilder::buildStatusDetail()); + assertEquals(expectedChildElementsDOM, status); + } + +}; diff --git a/samltest/saml2/core/impl/StatusCode20Test.h b/samltest/saml2/core/impl/StatusCode20Test.h index 139d48b..7cfb59b 100644 --- a/samltest/saml2/core/impl/StatusCode20Test.h +++ b/samltest/saml2/core/impl/StatusCode20Test.h @@ -1,66 +1,66 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include - -using namespace opensaml::saml2p; - -class StatusCode20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* Value; - -public: - void setUp() { - Value=XMLString::transcode("urn:string"); - singleElementFile = data_path + "saml2/core/impl/StatusCode.xml"; - childElementsFile = data_path + "saml2/core/impl/StatusCodeChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&Value); - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - StatusCode* sc = dynamic_cast(xo.get()); - TS_ASSERT(sc!=NULL); - assertEquals("Value attribute", Value, sc->getValue()); - TSM_ASSERT("StatusCode child element", sc->getStatusCode()==NULL); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - StatusCode* sc = dynamic_cast(xo.get()); - TS_ASSERT(sc!=NULL); - TSM_ASSERT("StatusCode child element", sc->getStatusCode()!=NULL); - } - - void testSingleElementMarshall() { - StatusCode* sc=StatusCodeBuilder::buildStatusCode(); - sc->setValue(Value); - assertEquals(expectedDOM, sc); - } - - void testChildElementsMarshall() { - StatusCode* sc=StatusCodeBuilder::buildStatusCode(); - StatusCode* scChild=StatusCodeBuilder::buildStatusCode(); - sc->setStatusCode(scChild); - assertEquals(expectedChildElementsDOM, sc); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include + +using namespace opensaml::saml2p; + +class StatusCode20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* Value; + +public: + void setUp() { + Value=XMLString::transcode("urn:string"); + singleElementFile = data_path + "saml2/core/impl/StatusCode.xml"; + childElementsFile = data_path + "saml2/core/impl/StatusCodeChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&Value); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + StatusCode* sc = dynamic_cast(xo.get()); + TS_ASSERT(sc!=NULL); + assertEquals("Value attribute", Value, sc->getValue()); + TSM_ASSERT("StatusCode child element", sc->getStatusCode()==NULL); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + StatusCode* sc = dynamic_cast(xo.get()); + TS_ASSERT(sc!=NULL); + TSM_ASSERT("StatusCode child element", sc->getStatusCode()!=NULL); + } + + void testSingleElementMarshall() { + StatusCode* sc=StatusCodeBuilder::buildStatusCode(); + sc->setValue(Value); + assertEquals(expectedDOM, sc); + } + + void testChildElementsMarshall() { + StatusCode* sc=StatusCodeBuilder::buildStatusCode(); + StatusCode* scChild=StatusCodeBuilder::buildStatusCode(); + sc->setStatusCode(scChild); + assertEquals(expectedChildElementsDOM, sc); + } + +}; diff --git a/samltest/saml2/core/impl/StatusDetail20Test.h b/samltest/saml2/core/impl/StatusDetail20Test.h index 03880ff..f31544c 100644 --- a/samltest/saml2/core/impl/StatusDetail20Test.h +++ b/samltest/saml2/core/impl/StatusDetail20Test.h @@ -1,61 +1,61 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include - -using namespace opensaml::saml2p; - -class StatusDetail20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - -public: - void setUp() { - singleElementFile = data_path + "saml2/core/impl/StatusDetail.xml"; - childElementsFile = data_path + "saml2/core/impl/StatusDetailChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - StatusDetail* sd= dynamic_cast(xo.get()); - TS_ASSERT(sd!=NULL); - TSM_ASSERT_EQUALS("StatusDetail child elements", sd->getDetails().size(), 0); - } - - //TODO test with some XMLObject child elements from another namespace - void IGNOREtestChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - StatusDetail* sd= dynamic_cast(xo.get()); - TS_ASSERT(sd!=NULL); - TSM_ASSERT_EQUALS("StatusDetail child elements", sd->getDetails().size(), 3); - } - - void testSingleElementMarshall() { - StatusDetail* sd=StatusDetailBuilder::buildStatusDetail(); - assertEquals(expectedDOM, sd); - } - - //TODO test with some XMLObject child elements from another namespace - void IGNOREtestChildElementsMarshall() { - StatusDetail* sd=StatusDetailBuilder::buildStatusDetail(); - assertEquals(expectedChildElementsDOM, sd); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include + +using namespace opensaml::saml2p; + +class StatusDetail20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + +public: + void setUp() { + singleElementFile = data_path + "saml2/core/impl/StatusDetail.xml"; + childElementsFile = data_path + "saml2/core/impl/StatusDetailChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + StatusDetail* sd= dynamic_cast(xo.get()); + TS_ASSERT(sd!=NULL); + TSM_ASSERT_EQUALS("StatusDetail child elements", sd->getDetails().size(), 0); + } + + //TODO test with some XMLObject child elements from another namespace + void IGNOREtestChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + StatusDetail* sd= dynamic_cast(xo.get()); + TS_ASSERT(sd!=NULL); + TSM_ASSERT_EQUALS("StatusDetail child elements", sd->getDetails().size(), 3); + } + + void testSingleElementMarshall() { + StatusDetail* sd=StatusDetailBuilder::buildStatusDetail(); + assertEquals(expectedDOM, sd); + } + + //TODO test with some XMLObject child elements from another namespace + void IGNOREtestChildElementsMarshall() { + StatusDetail* sd=StatusDetailBuilder::buildStatusDetail(); + assertEquals(expectedChildElementsDOM, sd); + } + +}; diff --git a/samltest/saml2/core/impl/Subject20Test.h b/samltest/saml2/core/impl/Subject20Test.h index 36f4ef0..07cd236 100644 --- a/samltest/saml2/core/impl/Subject20Test.h +++ b/samltest/saml2/core/impl/Subject20Test.h @@ -1,71 +1,71 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2; - -class Subject20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - -public: - void setUp() { - singleElementFile = data_path + "saml2/core/impl/Subject.xml"; - childElementsFile = data_path + "saml2/core/impl/SubjectChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - Subject* subject = dynamic_cast(xo.get()); - TS_ASSERT(subject!=NULL); - - TS_ASSERT(subject->getBaseID()==NULL); - TS_ASSERT(subject->getNameID()==NULL); - TS_ASSERT(subject->getEncryptedID()==NULL); - TSM_ASSERT_EQUALS("# of SubjectConfirmation child elements", 0, subject->getSubjectConfirmations().size()); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - Subject* subject= dynamic_cast(xo.get()); - TS_ASSERT(subject!=NULL); - - TS_ASSERT(subject->getBaseID()==NULL); - TS_ASSERT(subject->getNameID()!=NULL); - TS_ASSERT(subject->getEncryptedID()==NULL); - TSM_ASSERT_EQUALS("# of SubjectConfirmation child elements", 2, subject->getSubjectConfirmations().size()); - } - - void testSingleElementMarshall() { - Subject* subject=SubjectBuilder::buildSubject(); - assertEquals(expectedDOM, subject); - } - - void testChildElementsMarshall() { - Subject* subject=SubjectBuilder::buildSubject(); - subject->setNameID(NameIDBuilder::buildNameID()); - subject->getSubjectConfirmations().push_back(SubjectConfirmationBuilder::buildSubjectConfirmation()); - subject->getSubjectConfirmations().push_back(SubjectConfirmationBuilder::buildSubjectConfirmation()); - assertEquals(expectedChildElementsDOM, subject); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +class Subject20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + +public: + void setUp() { + singleElementFile = data_path + "saml2/core/impl/Subject.xml"; + childElementsFile = data_path + "saml2/core/impl/SubjectChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + Subject* subject = dynamic_cast(xo.get()); + TS_ASSERT(subject!=NULL); + + TS_ASSERT(subject->getBaseID()==NULL); + TS_ASSERT(subject->getNameID()==NULL); + TS_ASSERT(subject->getEncryptedID()==NULL); + TSM_ASSERT_EQUALS("# of SubjectConfirmation child elements", 0, subject->getSubjectConfirmations().size()); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + Subject* subject= dynamic_cast(xo.get()); + TS_ASSERT(subject!=NULL); + + TS_ASSERT(subject->getBaseID()==NULL); + TS_ASSERT(subject->getNameID()!=NULL); + TS_ASSERT(subject->getEncryptedID()==NULL); + TSM_ASSERT_EQUALS("# of SubjectConfirmation child elements", 2, subject->getSubjectConfirmations().size()); + } + + void testSingleElementMarshall() { + Subject* subject=SubjectBuilder::buildSubject(); + assertEquals(expectedDOM, subject); + } + + void testChildElementsMarshall() { + Subject* subject=SubjectBuilder::buildSubject(); + subject->setNameID(NameIDBuilder::buildNameID()); + subject->getSubjectConfirmations().push_back(SubjectConfirmationBuilder::buildSubjectConfirmation()); + subject->getSubjectConfirmations().push_back(SubjectConfirmationBuilder::buildSubjectConfirmation()); + assertEquals(expectedChildElementsDOM, subject); + } + +}; diff --git a/samltest/saml2/core/impl/SubjectConfirmation20Test.h b/samltest/saml2/core/impl/SubjectConfirmation20Test.h index cc12ece..b4058f8 100644 --- a/samltest/saml2/core/impl/SubjectConfirmation20Test.h +++ b/samltest/saml2/core/impl/SubjectConfirmation20Test.h @@ -1,77 +1,77 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2; - -class SubjectConfirmation20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* expectedMethod; - -public: - void setUp() { - expectedMethod = XMLString::transcode("urn:string:cm"); - - singleElementFile = data_path + "saml2/core/impl/SubjectConfirmation.xml"; - childElementsFile = data_path + "saml2/core/impl/SubjectConfirmationChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&expectedMethod); - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - SubjectConfirmation* sc = dynamic_cast(xo.get()); - TS_ASSERT(sc!=NULL); - - assertEquals("Method attribute", expectedMethod, sc->getMethod()); - - TS_ASSERT(sc->getBaseID()==NULL); - TS_ASSERT(sc->getNameID()==NULL); - TS_ASSERT(sc->getEncryptedID()==NULL); - TS_ASSERT(sc->getSubjectConfirmationData()==NULL); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - SubjectConfirmation* sc= dynamic_cast(xo.get()); - TS_ASSERT(sc!=NULL); - - TS_ASSERT(sc->getBaseID()==NULL); - TS_ASSERT(sc->getNameID()!=NULL); - TS_ASSERT(sc->getEncryptedID()==NULL); - TS_ASSERT(sc->getSubjectConfirmationData()!=NULL); - } - - void testSingleElementMarshall() { - SubjectConfirmation* sc=SubjectConfirmationBuilder::buildSubjectConfirmation(); - sc->setMethod(expectedMethod); - assertEquals(expectedDOM, sc); - } - - void testChildElementsMarshall() { - SubjectConfirmation* sc=SubjectConfirmationBuilder::buildSubjectConfirmation(); - sc->setNameID(NameIDBuilder::buildNameID()); - sc->setSubjectConfirmationData(SubjectConfirmationDataBuilder::buildSubjectConfirmationData()); - assertEquals(expectedChildElementsDOM, sc); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +class SubjectConfirmation20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedMethod; + +public: + void setUp() { + expectedMethod = XMLString::transcode("urn:string:cm"); + + singleElementFile = data_path + "saml2/core/impl/SubjectConfirmation.xml"; + childElementsFile = data_path + "saml2/core/impl/SubjectConfirmationChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedMethod); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + SubjectConfirmation* sc = dynamic_cast(xo.get()); + TS_ASSERT(sc!=NULL); + + assertEquals("Method attribute", expectedMethod, sc->getMethod()); + + TS_ASSERT(sc->getBaseID()==NULL); + TS_ASSERT(sc->getNameID()==NULL); + TS_ASSERT(sc->getEncryptedID()==NULL); + TS_ASSERT(sc->getSubjectConfirmationData()==NULL); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + SubjectConfirmation* sc= dynamic_cast(xo.get()); + TS_ASSERT(sc!=NULL); + + TS_ASSERT(sc->getBaseID()==NULL); + TS_ASSERT(sc->getNameID()!=NULL); + TS_ASSERT(sc->getEncryptedID()==NULL); + TS_ASSERT(sc->getSubjectConfirmationData()!=NULL); + } + + void testSingleElementMarshall() { + SubjectConfirmation* sc=SubjectConfirmationBuilder::buildSubjectConfirmation(); + sc->setMethod(expectedMethod); + assertEquals(expectedDOM, sc); + } + + void testChildElementsMarshall() { + SubjectConfirmation* sc=SubjectConfirmationBuilder::buildSubjectConfirmation(); + sc->setNameID(NameIDBuilder::buildNameID()); + sc->setSubjectConfirmationData(SubjectConfirmationDataBuilder::buildSubjectConfirmationData()); + assertEquals(expectedChildElementsDOM, sc); + } + +}; diff --git a/samltest/saml2/core/impl/SubjectConfirmationData20Test.h b/samltest/saml2/core/impl/SubjectConfirmationData20Test.h index fcf2e0c..9fa9b4d 100644 --- a/samltest/saml2/core/impl/SubjectConfirmationData20Test.h +++ b/samltest/saml2/core/impl/SubjectConfirmationData20Test.h @@ -1,119 +1,119 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2; - -//TODO need testing for ElementProxy and wildcard attributes/elements - -class SubjectConfirmationData20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - DateTime* expectedNotBefore; - DateTime* expectedNotOnOrAfter; - XMLCh* expectedRecipient; - XMLCh* expectedInResponseTo; - XMLCh* expectedAddress; - -public: - void setUp() { - expectedNotBefore = new DateTime(XMLString::transcode("1984-08-26T10:01:30.043Z")); - expectedNotBefore->parseDateTime(); - expectedNotOnOrAfter = new DateTime(XMLString::transcode("1984-08-26T10:11:30.043Z")); - expectedNotOnOrAfter->parseDateTime(); - expectedRecipient = (XMLString::transcode("recipient")); - expectedInResponseTo = (XMLString::transcode("inresponse")); - expectedAddress = (XMLString::transcode("address")); - - singleElementFile = data_path + "saml2/core/impl/SubjectConfirmationData.xml"; - singleElementOptionalAttributesFile = data_path + "saml2/core/impl/SubjectConfirmationDataOptionalAttributes.xml"; - childElementsFile = data_path + "saml2/core/impl/SubjectConfirmationDataChildElements.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - delete expectedNotBefore; - delete expectedNotOnOrAfter; - XMLString::release(&expectedRecipient); - XMLString::release(&expectedInResponseTo); - XMLString::release(&expectedAddress); - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - SubjectConfirmationData* scd = dynamic_cast(xo.get()); - TS_ASSERT(scd!=NULL); - - TS_ASSERT(scd->getNotBefore()==NULL); - TS_ASSERT(scd->getNotOnOrAfter()==NULL); - TS_ASSERT(scd->getRecipient()==NULL); - TS_ASSERT(scd->getInResponseTo()==NULL); - TS_ASSERT(scd->getAddress()==NULL); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - SubjectConfirmationData* scd = dynamic_cast(xo.get()); - TS_ASSERT(scd!=NULL); - - TSM_ASSERT_EQUALS("NotBefore attribute", expectedNotBefore->getEpoch(), scd->getNotBefore()->getEpoch()); - TSM_ASSERT_EQUALS("NotOnOrAfter attribute", expectedNotOnOrAfter->getEpoch(), scd->getNotOnOrAfter()->getEpoch()); - assertEquals("Recipient attribute", expectedRecipient, scd->getRecipient()); - assertEquals("InResponseTo attribute", expectedInResponseTo, scd->getInResponseTo()); - assertEquals("Address attribute", expectedAddress, scd->getAddress()); - - //TODO need to test with some wildcard attributes - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - SubjectConfirmationData* scd= dynamic_cast(xo.get()); - TS_ASSERT(scd!=NULL); - - TS_ASSERT(scd->getNotBefore()==NULL); - TS_ASSERT(scd->getNotOnOrAfter()==NULL); - TS_ASSERT(scd->getRecipient()==NULL); - TS_ASSERT(scd->getInResponseTo()==NULL); - TS_ASSERT(scd->getAddress()==NULL); - - //TODO need to test with some wildcard child elements - } - - void testSingleElementMarshall() { - SubjectConfirmationData* scd=SubjectConfirmationDataBuilder::buildSubjectConfirmationData(); - assertEquals(expectedDOM, scd); - } - - void testSingleElementOptionalAttributesMarshall() { - SubjectConfirmationData* scd=SubjectConfirmationDataBuilder::buildSubjectConfirmationData(); - scd->setNotBefore(expectedNotBefore); - scd->setNotOnOrAfter(expectedNotOnOrAfter); - scd->setRecipient(expectedRecipient); - scd->setInResponseTo(expectedInResponseTo); - scd->setAddress(expectedAddress); - //TODO need to test with some wilcard attributes - assertEquals(expectedOptionalAttributesDOM, scd); - } - - void testChildElementsMarshall() { - SubjectConfirmationData* scd=SubjectConfirmationDataBuilder::buildSubjectConfirmationData(); - //TODO need to test with some wilcard child elements - assertEquals(expectedChildElementsDOM, scd); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +//TODO need testing for ElementProxy and wildcard attributes/elements + +class SubjectConfirmationData20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + DateTime* expectedNotBefore; + DateTime* expectedNotOnOrAfter; + XMLCh* expectedRecipient; + XMLCh* expectedInResponseTo; + XMLCh* expectedAddress; + +public: + void setUp() { + expectedNotBefore = new DateTime(XMLString::transcode("1984-08-26T10:01:30.043Z")); + expectedNotBefore->parseDateTime(); + expectedNotOnOrAfter = new DateTime(XMLString::transcode("1984-08-26T10:11:30.043Z")); + expectedNotOnOrAfter->parseDateTime(); + expectedRecipient = (XMLString::transcode("recipient")); + expectedInResponseTo = (XMLString::transcode("inresponse")); + expectedAddress = (XMLString::transcode("address")); + + singleElementFile = data_path + "saml2/core/impl/SubjectConfirmationData.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/SubjectConfirmationDataOptionalAttributes.xml"; + childElementsFile = data_path + "saml2/core/impl/SubjectConfirmationDataChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + delete expectedNotBefore; + delete expectedNotOnOrAfter; + XMLString::release(&expectedRecipient); + XMLString::release(&expectedInResponseTo); + XMLString::release(&expectedAddress); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + SubjectConfirmationData* scd = dynamic_cast(xo.get()); + TS_ASSERT(scd!=NULL); + + TS_ASSERT(scd->getNotBefore()==NULL); + TS_ASSERT(scd->getNotOnOrAfter()==NULL); + TS_ASSERT(scd->getRecipient()==NULL); + TS_ASSERT(scd->getInResponseTo()==NULL); + TS_ASSERT(scd->getAddress()==NULL); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + SubjectConfirmationData* scd = dynamic_cast(xo.get()); + TS_ASSERT(scd!=NULL); + + TSM_ASSERT_EQUALS("NotBefore attribute", expectedNotBefore->getEpoch(), scd->getNotBefore()->getEpoch()); + TSM_ASSERT_EQUALS("NotOnOrAfter attribute", expectedNotOnOrAfter->getEpoch(), scd->getNotOnOrAfter()->getEpoch()); + assertEquals("Recipient attribute", expectedRecipient, scd->getRecipient()); + assertEquals("InResponseTo attribute", expectedInResponseTo, scd->getInResponseTo()); + assertEquals("Address attribute", expectedAddress, scd->getAddress()); + + //TODO need to test with some wildcard attributes + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + SubjectConfirmationData* scd= dynamic_cast(xo.get()); + TS_ASSERT(scd!=NULL); + + TS_ASSERT(scd->getNotBefore()==NULL); + TS_ASSERT(scd->getNotOnOrAfter()==NULL); + TS_ASSERT(scd->getRecipient()==NULL); + TS_ASSERT(scd->getInResponseTo()==NULL); + TS_ASSERT(scd->getAddress()==NULL); + + //TODO need to test with some wildcard child elements + } + + void testSingleElementMarshall() { + SubjectConfirmationData* scd=SubjectConfirmationDataBuilder::buildSubjectConfirmationData(); + assertEquals(expectedDOM, scd); + } + + void testSingleElementOptionalAttributesMarshall() { + SubjectConfirmationData* scd=SubjectConfirmationDataBuilder::buildSubjectConfirmationData(); + scd->setNotBefore(expectedNotBefore); + scd->setNotOnOrAfter(expectedNotOnOrAfter); + scd->setRecipient(expectedRecipient); + scd->setInResponseTo(expectedInResponseTo); + scd->setAddress(expectedAddress); + //TODO need to test with some wilcard attributes + assertEquals(expectedOptionalAttributesDOM, scd); + } + + void testChildElementsMarshall() { + SubjectConfirmationData* scd=SubjectConfirmationDataBuilder::buildSubjectConfirmationData(); + //TODO need to test with some wilcard child elements + assertEquals(expectedChildElementsDOM, scd); + } + +}; diff --git a/samltest/saml2/core/impl/SubjectLocality20Test.h b/samltest/saml2/core/impl/SubjectLocality20Test.h index 953c918..bca3f77 100644 --- a/samltest/saml2/core/impl/SubjectLocality20Test.h +++ b/samltest/saml2/core/impl/SubjectLocality20Test.h @@ -1,69 +1,69 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2; - -class SubjectLocality20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* expectedAddress; - XMLCh* expectedDNSName; - -public: - void setUp() { - expectedAddress = XMLString::transcode("10.1.2.3");; - expectedDNSName = XMLString::transcode("client.example.org"); - - singleElementFile = data_path + "saml2/core/impl/SubjectLocality.xml"; - singleElementOptionalAttributesFile = data_path + "saml2/core/impl/SubjectLocalityOptionalAttributes.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&expectedAddress); - XMLString::release(&expectedDNSName); - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - SubjectLocality* sl = dynamic_cast(xo.get()); - TS_ASSERT(sl!=NULL); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - SubjectLocality* sl = dynamic_cast(xo.get()); - TS_ASSERT(sl!=NULL); - assertEquals("Address attribute", expectedAddress, sl->getAddress()); - assertEquals("DNSName attribute", expectedDNSName, sl->getDNSName()); - } - - void testSingleElementMarshall() { - SubjectLocality* sl=SubjectLocalityBuilder::buildSubjectLocality(); - assertEquals(expectedDOM, sl); - } - - void testSingleElementOptionalAttributesMarshall() { - SubjectLocality* sl=SubjectLocalityBuilder::buildSubjectLocality(); - sl->setAddress(expectedAddress); - sl->setDNSName(expectedDNSName); - assertEquals(expectedOptionalAttributesDOM, sl); - } - -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +class SubjectLocality20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedAddress; + XMLCh* expectedDNSName; + +public: + void setUp() { + expectedAddress = XMLString::transcode("10.1.2.3");; + expectedDNSName = XMLString::transcode("client.example.org"); + + singleElementFile = data_path + "saml2/core/impl/SubjectLocality.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/SubjectLocalityOptionalAttributes.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedAddress); + XMLString::release(&expectedDNSName); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + SubjectLocality* sl = dynamic_cast(xo.get()); + TS_ASSERT(sl!=NULL); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + SubjectLocality* sl = dynamic_cast(xo.get()); + TS_ASSERT(sl!=NULL); + assertEquals("Address attribute", expectedAddress, sl->getAddress()); + assertEquals("DNSName attribute", expectedDNSName, sl->getDNSName()); + } + + void testSingleElementMarshall() { + SubjectLocality* sl=SubjectLocalityBuilder::buildSubjectLocality(); + assertEquals(expectedDOM, sl); + } + + void testSingleElementOptionalAttributesMarshall() { + SubjectLocality* sl=SubjectLocalityBuilder::buildSubjectLocality(); + sl->setAddress(expectedAddress); + sl->setDNSName(expectedDNSName); + assertEquals(expectedOptionalAttributesDOM, sl); + } + +}; diff --git a/samltest/saml2/metadata/FilesystemMetadataProviderTest.h b/samltest/saml2/metadata/FilesystemMetadataProviderTest.h index 3e736ba..d422cd5 100644 --- a/samltest/saml2/metadata/FilesystemMetadataProviderTest.h +++ b/samltest/saml2/metadata/FilesystemMetadataProviderTest.h @@ -1,146 +1,146 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include -#include -#include - -using namespace opensaml::saml2md; -using namespace opensaml::saml2p; - -class FilesystemMetadataProviderTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* entityID; - XMLCh* entityID2; - XMLCh* supportedProtocol; - XMLCh* supportedProtocol2; - -public: - void setUp() { - entityID=XMLString::transcode("urn:mace:incommon:washington.edu"); - entityID2=XMLString::transcode("urn:mace:incommon:rochester.edu"); - supportedProtocol=XMLString::transcode("urn:oasis:names:tc:SAML:1.1:protocol"); - supportedProtocol2=XMLString::transcode("urn:mace:shibboleth:1.0"); - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&entityID); - XMLString::release(&entityID2); - XMLString::release(&supportedProtocol); - XMLString::release(&supportedProtocol2); - SAMLObjectBaseTestCase::tearDown(); - } - - void testFilesystemProvider() { - string config = data_path + "saml2/metadata/FilesystemMetadataProvider.xml"; - ifstream in(config.c_str()); - DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); - XercesJanitor janitor(doc); - - auto_ptr_XMLCh path("path"); - string s = data_path + "saml2/metadata/InCommon-metadata.xml"; - auto_ptr_XMLCh file(s.c_str()); - doc->getDocumentElement()->setAttributeNS(NULL,path.get(),file.get()); - - auto_ptr metadataProvider( - SAMLConfig::getConfig().MetadataProviderManager.newPlugin(FILESYSTEM_METADATA_PROVIDER,doc->getDocumentElement()) - ); - try { - metadataProvider->init(); - } - catch (XMLToolingException& ex) { - TS_TRACE(ex.what()); - throw; - } - - Locker locker(metadataProvider.get()); - const EntityDescriptor* descriptor = metadataProvider->getEntityDescriptor(entityID); - TSM_ASSERT("Retrieved entity descriptor was null", descriptor!=NULL); - assertEquals("Entity's ID does not match requested ID", entityID, descriptor->getEntityID()); - TSM_ASSERT_EQUALS("Unexpected number of roles", 1, descriptor->getIDPSSODescriptors().size()); - TSM_ASSERT("Role lookup failed", descriptor->getIDPSSODescriptor(supportedProtocol)!=NULL); - TSM_ASSERT("Role lookup failed", descriptor->getIDPSSODescriptor(supportedProtocol2)!=NULL); - - auto_ptr artifact( - new SAML2ArtifactType0004(SAMLConfig::getConfig().hashSHA1("urn:mace:incommon:washington.edu"),1) - ); - descriptor = metadataProvider->getEntityDescriptor(artifact.get()); - TSM_ASSERT("Retrieved entity descriptor was null", descriptor!=NULL); - assertEquals("Entity's ID does not match requested ID", entityID, descriptor->getEntityID()); - } - - void testFilesystemWithBlacklists() { - string config = data_path + "saml2/metadata/FilesystemWithBlacklists.xml"; - ifstream in(config.c_str()); - DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); - XercesJanitor janitor(doc); - - auto_ptr_XMLCh path("path"); - string s = data_path + "saml2/metadata/InCommon-metadata.xml"; - auto_ptr_XMLCh file(s.c_str()); - doc->getDocumentElement()->setAttributeNS(NULL,path.get(),file.get()); - - auto_ptr metadataProvider( - SAMLConfig::getConfig().MetadataProviderManager.newPlugin(FILESYSTEM_METADATA_PROVIDER,doc->getDocumentElement()) - ); - try { - metadataProvider->init(); - } - catch (XMLToolingException& ex) { - TS_TRACE(ex.what()); - throw; - } - - Locker locker(metadataProvider.get()); - const EntityDescriptor* descriptor = metadataProvider->getEntityDescriptor(entityID); - TSM_ASSERT("Retrieved entity descriptor was not null", descriptor==NULL); - descriptor = metadataProvider->getEntityDescriptor(entityID2); - TSM_ASSERT("Retrieved entity descriptor was null", descriptor!=NULL); - assertEquals("Entity's ID does not match requested ID", entityID2, descriptor->getEntityID()); - } - - void testFilesystemWithWhitelists() { - string config = data_path + "saml2/metadata/FilesystemWithWhitelists.xml"; - ifstream in(config.c_str()); - DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); - XercesJanitor janitor(doc); - - auto_ptr_XMLCh path("path"); - string s = data_path + "saml2/metadata/InCommon-metadata.xml"; - auto_ptr_XMLCh file(s.c_str()); - doc->getDocumentElement()->setAttributeNS(NULL,path.get(),file.get()); - - auto_ptr metadataProvider( - SAMLConfig::getConfig().MetadataProviderManager.newPlugin(FILESYSTEM_METADATA_PROVIDER,doc->getDocumentElement()) - ); - try { - metadataProvider->init(); - } - catch (XMLToolingException& ex) { - TS_TRACE(ex.what()); - throw; - } - - Locker locker(metadataProvider.get()); - const EntityDescriptor* descriptor = metadataProvider->getEntityDescriptor(entityID2); - TSM_ASSERT("Retrieved entity descriptor was not null", descriptor==NULL); - descriptor = metadataProvider->getEntityDescriptor(entityID); - TSM_ASSERT("Retrieved entity descriptor was null", descriptor!=NULL); - assertEquals("Entity's ID does not match requested ID", entityID, descriptor->getEntityID()); - } -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include +#include +#include + +using namespace opensaml::saml2md; +using namespace opensaml::saml2p; + +class FilesystemMetadataProviderTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* entityID; + XMLCh* entityID2; + XMLCh* supportedProtocol; + XMLCh* supportedProtocol2; + +public: + void setUp() { + entityID=XMLString::transcode("urn:mace:incommon:washington.edu"); + entityID2=XMLString::transcode("urn:mace:incommon:rochester.edu"); + supportedProtocol=XMLString::transcode("urn:oasis:names:tc:SAML:1.1:protocol"); + supportedProtocol2=XMLString::transcode("urn:mace:shibboleth:1.0"); + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&entityID); + XMLString::release(&entityID2); + XMLString::release(&supportedProtocol); + XMLString::release(&supportedProtocol2); + SAMLObjectBaseTestCase::tearDown(); + } + + void testFilesystemProvider() { + string config = data_path + "saml2/metadata/FilesystemMetadataProvider.xml"; + ifstream in(config.c_str()); + DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); + XercesJanitor janitor(doc); + + auto_ptr_XMLCh path("path"); + string s = data_path + "saml2/metadata/InCommon-metadata.xml"; + auto_ptr_XMLCh file(s.c_str()); + doc->getDocumentElement()->setAttributeNS(NULL,path.get(),file.get()); + + auto_ptr metadataProvider( + SAMLConfig::getConfig().MetadataProviderManager.newPlugin(FILESYSTEM_METADATA_PROVIDER,doc->getDocumentElement()) + ); + try { + metadataProvider->init(); + } + catch (XMLToolingException& ex) { + TS_TRACE(ex.what()); + throw; + } + + Locker locker(metadataProvider.get()); + const EntityDescriptor* descriptor = metadataProvider->getEntityDescriptor(entityID); + TSM_ASSERT("Retrieved entity descriptor was null", descriptor!=NULL); + assertEquals("Entity's ID does not match requested ID", entityID, descriptor->getEntityID()); + TSM_ASSERT_EQUALS("Unexpected number of roles", 1, descriptor->getIDPSSODescriptors().size()); + TSM_ASSERT("Role lookup failed", descriptor->getIDPSSODescriptor(supportedProtocol)!=NULL); + TSM_ASSERT("Role lookup failed", descriptor->getIDPSSODescriptor(supportedProtocol2)!=NULL); + + auto_ptr artifact( + new SAML2ArtifactType0004(SAMLConfig::getConfig().hashSHA1("urn:mace:incommon:washington.edu"),1) + ); + descriptor = metadataProvider->getEntityDescriptor(artifact.get()); + TSM_ASSERT("Retrieved entity descriptor was null", descriptor!=NULL); + assertEquals("Entity's ID does not match requested ID", entityID, descriptor->getEntityID()); + } + + void testFilesystemWithBlacklists() { + string config = data_path + "saml2/metadata/FilesystemWithBlacklists.xml"; + ifstream in(config.c_str()); + DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); + XercesJanitor janitor(doc); + + auto_ptr_XMLCh path("path"); + string s = data_path + "saml2/metadata/InCommon-metadata.xml"; + auto_ptr_XMLCh file(s.c_str()); + doc->getDocumentElement()->setAttributeNS(NULL,path.get(),file.get()); + + auto_ptr metadataProvider( + SAMLConfig::getConfig().MetadataProviderManager.newPlugin(FILESYSTEM_METADATA_PROVIDER,doc->getDocumentElement()) + ); + try { + metadataProvider->init(); + } + catch (XMLToolingException& ex) { + TS_TRACE(ex.what()); + throw; + } + + Locker locker(metadataProvider.get()); + const EntityDescriptor* descriptor = metadataProvider->getEntityDescriptor(entityID); + TSM_ASSERT("Retrieved entity descriptor was not null", descriptor==NULL); + descriptor = metadataProvider->getEntityDescriptor(entityID2); + TSM_ASSERT("Retrieved entity descriptor was null", descriptor!=NULL); + assertEquals("Entity's ID does not match requested ID", entityID2, descriptor->getEntityID()); + } + + void testFilesystemWithWhitelists() { + string config = data_path + "saml2/metadata/FilesystemWithWhitelists.xml"; + ifstream in(config.c_str()); + DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); + XercesJanitor janitor(doc); + + auto_ptr_XMLCh path("path"); + string s = data_path + "saml2/metadata/InCommon-metadata.xml"; + auto_ptr_XMLCh file(s.c_str()); + doc->getDocumentElement()->setAttributeNS(NULL,path.get(),file.get()); + + auto_ptr metadataProvider( + SAMLConfig::getConfig().MetadataProviderManager.newPlugin(FILESYSTEM_METADATA_PROVIDER,doc->getDocumentElement()) + ); + try { + metadataProvider->init(); + } + catch (XMLToolingException& ex) { + TS_TRACE(ex.what()); + throw; + } + + Locker locker(metadataProvider.get()); + const EntityDescriptor* descriptor = metadataProvider->getEntityDescriptor(entityID2); + TSM_ASSERT("Retrieved entity descriptor was not null", descriptor==NULL); + descriptor = metadataProvider->getEntityDescriptor(entityID); + TSM_ASSERT("Retrieved entity descriptor was null", descriptor!=NULL); + assertEquals("Entity's ID does not match requested ID", entityID, descriptor->getEntityID()); + } +}; diff --git a/samltest/samltest.h b/samltest/samltest.h index 2e6f5a5..a65544b 100644 --- a/samltest/samltest.h +++ b/samltest/samltest.h @@ -1,69 +1,69 @@ -/* - * Copyright 2001-2005 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include -#include -#include -#include - -//#define SAML_LEAKCHECK - -std::string data_path = "../samltest/data/"; - -class SAMLFixture : public CxxTest::GlobalFixture -{ -public: - bool setUpWorld() { - XMLToolingConfig::getConfig().log_config(); - if (!SAMLConfig::getConfig().init()) - return false; - XMLToolingConfig::getConfig().setReplayCache(new ReplayCache()); - SAMLConfig::getConfig().setArtifactMap(new ArtifactMap()); - - if (getenv("SAMLTEST_DATA")) - data_path=std::string(getenv("SAMLTEST_DATA")) + "/"; - //std::string catpath=data_path + "catalog.xml"; - //auto_ptr_XMLCh temp(catpath.c_str()); - //return XMLToolingConfig::getConfig().getValidatingParser().loadCatalog(temp.get()); - return true; - } - bool tearDownWorld() { - SAMLConfig::getConfig().term(); -#if defined(_MSC_VER ) && defined(SAML_LEAKCHECK) - _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE ); - _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDOUT ); - _CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE ); - _CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDOUT ); - _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE ); - _CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDOUT ); - _CrtDumpMemoryLeaks(); -#endif - return true; - } - //bool setUp() { printf( "" ); return true; } - //bool tearDown() { printf( "" ); return true; } -}; - -static SAMLFixture globalFixture; - -class GlobalTest : public CxxTest::TestSuite -{ -public: - void testGlobal() { - } -}; +/* + * Copyright 2001-2005 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include +#include +#include +#include + +//#define SAML_LEAKCHECK + +std::string data_path = "../samltest/data/"; + +class SAMLFixture : public CxxTest::GlobalFixture +{ +public: + bool setUpWorld() { + XMLToolingConfig::getConfig().log_config(); + if (!SAMLConfig::getConfig().init()) + return false; + XMLToolingConfig::getConfig().setReplayCache(new ReplayCache()); + SAMLConfig::getConfig().setArtifactMap(new ArtifactMap()); + + if (getenv("SAMLTEST_DATA")) + data_path=std::string(getenv("SAMLTEST_DATA")) + "/"; + //std::string catpath=data_path + "catalog.xml"; + //auto_ptr_XMLCh temp(catpath.c_str()); + //return XMLToolingConfig::getConfig().getValidatingParser().loadCatalog(temp.get()); + return true; + } + bool tearDownWorld() { + SAMLConfig::getConfig().term(); +#if defined(_MSC_VER ) && defined(SAML_LEAKCHECK) + _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE ); + _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDOUT ); + _CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE ); + _CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDOUT ); + _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE ); + _CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDOUT ); + _CrtDumpMemoryLeaks(); +#endif + return true; + } + //bool setUp() { printf( "" ); return true; } + //bool tearDown() { printf( "" ); return true; } +}; + +static SAMLFixture globalFixture; + +class GlobalTest : public CxxTest::TestSuite +{ +public: + void testGlobal() { + } +}; diff --git a/samltest/security/AbstractPKIXTrustEngineTest.h b/samltest/security/AbstractPKIXTrustEngineTest.h index 346bade..d27d2c0 100644 --- a/samltest/security/AbstractPKIXTrustEngineTest.h +++ b/samltest/security/AbstractPKIXTrustEngineTest.h @@ -1,142 +1,142 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include -#include - -using namespace opensaml::saml2; -using namespace opensaml::saml2md; -using namespace xmlsignature; - -namespace { - class SampleTrustEngine : public AbstractPKIXTrustEngine { - public: - SampleTrustEngine() {} - ~SampleTrustEngine() {} - - class SampleIterator : public PKIXValidationInfoIterator { - vector m_crls; - KeyResolver::ResolvedCertificates m_certs; - KeyResolver* m_resolver; - bool m_done; - public: - SampleIterator() : m_resolver(NULL), m_done(false) { - string config = data_path + "security/FilesystemKeyResolver.xml"; - ifstream in(config.c_str()); - DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); - XercesJanitor janitor(doc); - m_resolver = XMLToolingConfig::getConfig().KeyResolverManager.newPlugin( - FILESYSTEM_KEY_RESOLVER,doc->getDocumentElement() - ); - m_resolver->resolveCertificates((KeyInfo*)NULL,m_certs); - } - - ~SampleIterator() { - delete m_resolver; - } - - bool next() { - if (m_done) - return false; - m_done = true; - return true; - } - - int getVerificationDepth() const { - return 0; - } - - const vector& getTrustAnchors() const { - return m_certs.v(); - } - - const vector& getCRLs() const { - return m_crls; - } - }; - - PKIXValidationInfoIterator* getPKIXValidationInfoIterator(const RoleDescriptor& role) const { - return new SampleIterator(); - } - }; -}; - -class AbstractPKIXTrustEngineTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { -public: - void setUp() { - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - SAMLObjectBaseTestCase::tearDown(); - } - - void testExplicitKeyTrustEngine() { - string config = data_path + "security/FilesystemMetadataProvider.xml"; - ifstream in(config.c_str()); - DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); - XercesJanitor janitor(doc); - - auto_ptr_XMLCh path("path"); - string s = data_path + "security/example-metadata.xml"; - auto_ptr_XMLCh file(s.c_str()); - doc->getDocumentElement()->setAttributeNS(NULL,path.get(),file.get()); - - // Build metadata provider. - auto_ptr metadataProvider( - SAMLConfig::getConfig().MetadataProviderManager.newPlugin(FILESYSTEM_METADATA_PROVIDER,doc->getDocumentElement()) - ); - try { - metadataProvider->init(); - } - catch (XMLToolingException& ex) { - TS_TRACE(ex.what()); - throw; - } - - // Build trust engine. - auto_ptr trustEngine(new SampleTrustEngine()); - - // Get signed assertion. - config = data_path + "signature/SAML2Assertion.xml"; - ifstream in2(config.c_str()); - DOMDocument* doc2=XMLToolingConfig::getConfig().getParser().parse(in2); - XercesJanitor janitor2(doc2); - auto_ptr assertion(dynamic_cast(XMLObjectBuilder::getBuilder(doc2->getDocumentElement())->buildFromDocument(doc2))); - janitor2.release(); - - Locker locker(metadataProvider.get()); - const EntityDescriptor* descriptor = metadataProvider->getEntityDescriptor("https://idp.example.org"); - TSM_ASSERT("Retrieved entity descriptor was null", descriptor!=NULL); - - RoleDescriptor* role=descriptor->getIDPSSODescriptors().front(); - TSM_ASSERT("Role not present", role!=NULL); - - Signature* sig=assertion->getSignature(); - TSM_ASSERT("Signature not present", sig!=NULL); - TSM_ASSERT("Signature failed to validate.", trustEngine->validate(*sig, *role, metadataProvider->getKeyResolver())); - - descriptor = metadataProvider->getEntityDescriptor("https://idp2.example.org"); - TSM_ASSERT("Retrieved entity descriptor was null", descriptor!=NULL); - - role=descriptor->getIDPSSODescriptors().front(); - TSM_ASSERT("Role not present", role!=NULL); - - TSM_ASSERT("Signature validated.", !trustEngine->validate(*sig, *role, metadataProvider->getKeyResolver())); - } -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include +#include + +using namespace opensaml::saml2; +using namespace opensaml::saml2md; +using namespace xmlsignature; + +namespace { + class SampleTrustEngine : public AbstractPKIXTrustEngine { + public: + SampleTrustEngine() {} + ~SampleTrustEngine() {} + + class SampleIterator : public PKIXValidationInfoIterator { + vector m_crls; + KeyResolver::ResolvedCertificates m_certs; + KeyResolver* m_resolver; + bool m_done; + public: + SampleIterator() : m_resolver(NULL), m_done(false) { + string config = data_path + "security/FilesystemKeyResolver.xml"; + ifstream in(config.c_str()); + DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); + XercesJanitor janitor(doc); + m_resolver = XMLToolingConfig::getConfig().KeyResolverManager.newPlugin( + FILESYSTEM_KEY_RESOLVER,doc->getDocumentElement() + ); + m_resolver->resolveCertificates((KeyInfo*)NULL,m_certs); + } + + ~SampleIterator() { + delete m_resolver; + } + + bool next() { + if (m_done) + return false; + m_done = true; + return true; + } + + int getVerificationDepth() const { + return 0; + } + + const vector& getTrustAnchors() const { + return m_certs.v(); + } + + const vector& getCRLs() const { + return m_crls; + } + }; + + PKIXValidationInfoIterator* getPKIXValidationInfoIterator(const RoleDescriptor& role) const { + return new SampleIterator(); + } + }; +}; + +class AbstractPKIXTrustEngineTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { +public: + void setUp() { + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + SAMLObjectBaseTestCase::tearDown(); + } + + void testExplicitKeyTrustEngine() { + string config = data_path + "security/FilesystemMetadataProvider.xml"; + ifstream in(config.c_str()); + DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); + XercesJanitor janitor(doc); + + auto_ptr_XMLCh path("path"); + string s = data_path + "security/example-metadata.xml"; + auto_ptr_XMLCh file(s.c_str()); + doc->getDocumentElement()->setAttributeNS(NULL,path.get(),file.get()); + + // Build metadata provider. + auto_ptr metadataProvider( + SAMLConfig::getConfig().MetadataProviderManager.newPlugin(FILESYSTEM_METADATA_PROVIDER,doc->getDocumentElement()) + ); + try { + metadataProvider->init(); + } + catch (XMLToolingException& ex) { + TS_TRACE(ex.what()); + throw; + } + + // Build trust engine. + auto_ptr trustEngine(new SampleTrustEngine()); + + // Get signed assertion. + config = data_path + "signature/SAML2Assertion.xml"; + ifstream in2(config.c_str()); + DOMDocument* doc2=XMLToolingConfig::getConfig().getParser().parse(in2); + XercesJanitor janitor2(doc2); + auto_ptr assertion(dynamic_cast(XMLObjectBuilder::getBuilder(doc2->getDocumentElement())->buildFromDocument(doc2))); + janitor2.release(); + + Locker locker(metadataProvider.get()); + const EntityDescriptor* descriptor = metadataProvider->getEntityDescriptor("https://idp.example.org"); + TSM_ASSERT("Retrieved entity descriptor was null", descriptor!=NULL); + + RoleDescriptor* role=descriptor->getIDPSSODescriptors().front(); + TSM_ASSERT("Role not present", role!=NULL); + + Signature* sig=assertion->getSignature(); + TSM_ASSERT("Signature not present", sig!=NULL); + TSM_ASSERT("Signature failed to validate.", trustEngine->validate(*sig, *role, metadataProvider->getKeyResolver())); + + descriptor = metadataProvider->getEntityDescriptor("https://idp2.example.org"); + TSM_ASSERT("Retrieved entity descriptor was null", descriptor!=NULL); + + role=descriptor->getIDPSSODescriptors().front(); + TSM_ASSERT("Role not present", role!=NULL); + + TSM_ASSERT("Signature validated.", !trustEngine->validate(*sig, *role, metadataProvider->getKeyResolver())); + } +}; diff --git a/samltest/security/ExplicitKeyTrustEngineTest.h b/samltest/security/ExplicitKeyTrustEngineTest.h index e531e8a..ebb8e2f 100644 --- a/samltest/security/ExplicitKeyTrustEngineTest.h +++ b/samltest/security/ExplicitKeyTrustEngineTest.h @@ -1,91 +1,91 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include -#include - -using namespace opensaml::saml2; -using namespace opensaml::saml2md; -using namespace xmlsignature; - -class ExplicitKeyTrustEngineTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { -public: - void setUp() { - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - SAMLObjectBaseTestCase::tearDown(); - } - - void testExplicitKeyTrustEngine() { - string config = data_path + "security/FilesystemMetadataProvider.xml"; - ifstream in(config.c_str()); - DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); - XercesJanitor janitor(doc); - - auto_ptr_XMLCh path("path"); - string s = data_path + "security/example-metadata.xml"; - auto_ptr_XMLCh file(s.c_str()); - doc->getDocumentElement()->setAttributeNS(NULL,path.get(),file.get()); - - // Build metadata provider. - auto_ptr metadataProvider( - SAMLConfig::getConfig().MetadataProviderManager.newPlugin(FILESYSTEM_METADATA_PROVIDER,doc->getDocumentElement()) - ); - try { - metadataProvider->init(); - } - catch (XMLToolingException& ex) { - TS_TRACE(ex.what()); - throw; - } - - // Build trust engine. - auto_ptr trustEngine( - SAMLConfig::getConfig().TrustEngineManager.newPlugin(EXPLICIT_KEY_SAMLTRUSTENGINE, NULL) - ); - - // Get signed assertion. - config = data_path + "signature/SAML2Assertion.xml"; - ifstream in2(config.c_str()); - DOMDocument* doc2=XMLToolingConfig::getConfig().getParser().parse(in2); - XercesJanitor janitor2(doc2); - auto_ptr assertion(dynamic_cast(XMLObjectBuilder::getBuilder(doc2->getDocumentElement())->buildFromDocument(doc2))); - janitor2.release(); - - Locker locker(metadataProvider.get()); - const EntityDescriptor* descriptor = metadataProvider->getEntityDescriptor("https://idp.example.org"); - TSM_ASSERT("Retrieved entity descriptor was null", descriptor!=NULL); - - RoleDescriptor* role=descriptor->getIDPSSODescriptors().front(); - TSM_ASSERT("Role not present", role!=NULL); - - Signature* sig=assertion->getSignature(); - TSM_ASSERT("Signature not present", sig!=NULL); - TSM_ASSERT("Signature failed to validate.", trustEngine->validate(*sig, *role, metadataProvider->getKeyResolver())); - - descriptor = metadataProvider->getEntityDescriptor("https://idp2.example.org"); - TSM_ASSERT("Retrieved entity descriptor was null", descriptor!=NULL); - - role=descriptor->getIDPSSODescriptors().front(); - TSM_ASSERT("Role not present", role!=NULL); - - TSM_ASSERT("Signature validated.", !trustEngine->validate(*sig, *role, metadataProvider->getKeyResolver())); - } -}; +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include +#include + +using namespace opensaml::saml2; +using namespace opensaml::saml2md; +using namespace xmlsignature; + +class ExplicitKeyTrustEngineTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { +public: + void setUp() { + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + SAMLObjectBaseTestCase::tearDown(); + } + + void testExplicitKeyTrustEngine() { + string config = data_path + "security/FilesystemMetadataProvider.xml"; + ifstream in(config.c_str()); + DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); + XercesJanitor janitor(doc); + + auto_ptr_XMLCh path("path"); + string s = data_path + "security/example-metadata.xml"; + auto_ptr_XMLCh file(s.c_str()); + doc->getDocumentElement()->setAttributeNS(NULL,path.get(),file.get()); + + // Build metadata provider. + auto_ptr metadataProvider( + SAMLConfig::getConfig().MetadataProviderManager.newPlugin(FILESYSTEM_METADATA_PROVIDER,doc->getDocumentElement()) + ); + try { + metadataProvider->init(); + } + catch (XMLToolingException& ex) { + TS_TRACE(ex.what()); + throw; + } + + // Build trust engine. + auto_ptr trustEngine( + SAMLConfig::getConfig().TrustEngineManager.newPlugin(EXPLICIT_KEY_SAMLTRUSTENGINE, NULL) + ); + + // Get signed assertion. + config = data_path + "signature/SAML2Assertion.xml"; + ifstream in2(config.c_str()); + DOMDocument* doc2=XMLToolingConfig::getConfig().getParser().parse(in2); + XercesJanitor janitor2(doc2); + auto_ptr assertion(dynamic_cast(XMLObjectBuilder::getBuilder(doc2->getDocumentElement())->buildFromDocument(doc2))); + janitor2.release(); + + Locker locker(metadataProvider.get()); + const EntityDescriptor* descriptor = metadataProvider->getEntityDescriptor("https://idp.example.org"); + TSM_ASSERT("Retrieved entity descriptor was null", descriptor!=NULL); + + RoleDescriptor* role=descriptor->getIDPSSODescriptors().front(); + TSM_ASSERT("Role not present", role!=NULL); + + Signature* sig=assertion->getSignature(); + TSM_ASSERT("Signature not present", sig!=NULL); + TSM_ASSERT("Signature failed to validate.", trustEngine->validate(*sig, *role, metadataProvider->getKeyResolver())); + + descriptor = metadataProvider->getEntityDescriptor("https://idp2.example.org"); + TSM_ASSERT("Retrieved entity descriptor was null", descriptor!=NULL); + + role=descriptor->getIDPSSODescriptors().front(); + TSM_ASSERT("Role not present", role!=NULL); + + TSM_ASSERT("Signature validated.", !trustEngine->validate(*sig, *role, metadataProvider->getKeyResolver())); + } +}; diff --git a/samltest/signature/SAML1AssertionTest.h b/samltest/signature/SAML1AssertionTest.h index ba26d9d..2314bad 100644 --- a/samltest/signature/SAML1AssertionTest.h +++ b/samltest/signature/SAML1AssertionTest.h @@ -1,103 +1,103 @@ -/* - * Copyright 2001-2005 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "signature/SAMLSignatureTestBase.h" -#include - -#include - -using namespace opensaml::saml1; - -class SAML1AssertionTest : public CxxTest::TestSuite, public SAMLSignatureTestBase { -public: - void setUp() { - childElementsFile = data_path + "signature/SAML1Assertion.xml"; - SAMLSignatureTestBase::setUp(); - } - - void tearDown() { - SAMLSignatureTestBase::tearDown(); - } - - void testSignature() { - auto_ptr_XMLCh issuer("issuer"); - auto_ptr_XMLCh issueInstant("1970-01-02T01:01:02.100Z"); - auto_ptr_XMLCh id("ident"); - auto_ptr_XMLCh method("method"); - auto_ptr_XMLCh nameid("John Doe"); - - NameIdentifier* n=NameIdentifierBuilder::buildNameIdentifier(); - n->setName(nameid.get()); - Subject* subject=SubjectBuilder::buildSubject(); - subject->setNameIdentifier(n); - - AuthenticationStatement* statement=AuthenticationStatementBuilder::buildAuthenticationStatement(); - statement->setAuthenticationInstant(issueInstant.get()); - statement->setAuthenticationMethod(method.get()); - statement->setSubject(subject); - - auto_ptr assertion(AssertionBuilder::buildAssertion()); - assertion->setAssertionID(id.get()); - assertion->setIssueInstant(issueInstant.get()); - assertion->setIssuer(issuer.get()); - assertion->getAuthenticationStatements().push_back(statement); - - // Append a Signature. - Signature* sig=SignatureBuilder::buildSignature(); - assertion->setSignature(sig); - Locker locker(m_resolver); - sig->setSigningKey(m_resolver->getKey()); - - // Build KeyInfo. - KeyInfo* keyInfo=KeyInfoBuilder::buildKeyInfo(); - X509Data* x509Data=X509DataBuilder::buildX509Data(); - keyInfo->getX509Datas().push_back(x509Data); - for_each(m_resolver->getCertificates().begin(),m_resolver->getCertificates().end(),bind1st(_addcert(),x509Data)); - sig->setKeyInfo(keyInfo); - - // Sign while marshalling. - vector sigs(1,sig); - DOMElement* rootElement = NULL; - try { - rootElement=assertion->marshall((DOMDocument*)NULL,&sigs); - } - catch (XMLToolingException& e) { - TS_TRACE(e.what()); - throw; - } - - string buf; - XMLHelper::serialize(rootElement, buf); - istringstream in(buf); - DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); - const XMLObjectBuilder* b = XMLObjectBuilder::getBuilder(doc->getDocumentElement()); - - auto_ptr assertion2(b->buildFromDocument(doc)); - assertEquals("Unmarshalled assertion does not match", expectedChildElementsDOM, assertion2.get(), false); - - try { - SignatureProfileValidator spv; - SignatureValidator sv(new KeyResolver(m_resolver->getKey())); - spv.validate(dynamic_cast(assertion2.get())->getSignature()); - sv.validate(dynamic_cast(assertion2.get())->getSignature()); - } - catch (XMLToolingException& e) { - TS_TRACE(e.what()); - throw; - } - } - -}; +/* + * Copyright 2001-2005 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "signature/SAMLSignatureTestBase.h" +#include + +#include + +using namespace opensaml::saml1; + +class SAML1AssertionTest : public CxxTest::TestSuite, public SAMLSignatureTestBase { +public: + void setUp() { + childElementsFile = data_path + "signature/SAML1Assertion.xml"; + SAMLSignatureTestBase::setUp(); + } + + void tearDown() { + SAMLSignatureTestBase::tearDown(); + } + + void testSignature() { + auto_ptr_XMLCh issuer("issuer"); + auto_ptr_XMLCh issueInstant("1970-01-02T01:01:02.100Z"); + auto_ptr_XMLCh id("ident"); + auto_ptr_XMLCh method("method"); + auto_ptr_XMLCh nameid("John Doe"); + + NameIdentifier* n=NameIdentifierBuilder::buildNameIdentifier(); + n->setName(nameid.get()); + Subject* subject=SubjectBuilder::buildSubject(); + subject->setNameIdentifier(n); + + AuthenticationStatement* statement=AuthenticationStatementBuilder::buildAuthenticationStatement(); + statement->setAuthenticationInstant(issueInstant.get()); + statement->setAuthenticationMethod(method.get()); + statement->setSubject(subject); + + auto_ptr assertion(AssertionBuilder::buildAssertion()); + assertion->setAssertionID(id.get()); + assertion->setIssueInstant(issueInstant.get()); + assertion->setIssuer(issuer.get()); + assertion->getAuthenticationStatements().push_back(statement); + + // Append a Signature. + Signature* sig=SignatureBuilder::buildSignature(); + assertion->setSignature(sig); + Locker locker(m_resolver); + sig->setSigningKey(m_resolver->getKey()); + + // Build KeyInfo. + KeyInfo* keyInfo=KeyInfoBuilder::buildKeyInfo(); + X509Data* x509Data=X509DataBuilder::buildX509Data(); + keyInfo->getX509Datas().push_back(x509Data); + for_each(m_resolver->getCertificates().begin(),m_resolver->getCertificates().end(),bind1st(_addcert(),x509Data)); + sig->setKeyInfo(keyInfo); + + // Sign while marshalling. + vector sigs(1,sig); + DOMElement* rootElement = NULL; + try { + rootElement=assertion->marshall((DOMDocument*)NULL,&sigs); + } + catch (XMLToolingException& e) { + TS_TRACE(e.what()); + throw; + } + + string buf; + XMLHelper::serialize(rootElement, buf); + istringstream in(buf); + DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); + const XMLObjectBuilder* b = XMLObjectBuilder::getBuilder(doc->getDocumentElement()); + + auto_ptr assertion2(b->buildFromDocument(doc)); + assertEquals("Unmarshalled assertion does not match", expectedChildElementsDOM, assertion2.get(), false); + + try { + SignatureProfileValidator spv; + SignatureValidator sv(new KeyResolver(m_resolver->getKey())); + spv.validate(dynamic_cast(assertion2.get())->getSignature()); + sv.validate(dynamic_cast(assertion2.get())->getSignature()); + } + catch (XMLToolingException& e) { + TS_TRACE(e.what()); + throw; + } + } + +}; diff --git a/samltest/signature/SAML1RequestTest.h b/samltest/signature/SAML1RequestTest.h index 6b63d1b..e6f5416 100644 --- a/samltest/signature/SAML1RequestTest.h +++ b/samltest/signature/SAML1RequestTest.h @@ -1,103 +1,103 @@ -/* - * Copyright 2001-2005 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "signature/SAMLSignatureTestBase.h" - -#include -#include - -#include - -using namespace opensaml::saml1p; -using namespace opensaml::saml1; - -class SAML1RequestTest : public CxxTest::TestSuite, public SAMLSignatureTestBase { -public: - void setUp() { - childElementsFile = data_path + "signature/SAML1Request.xml"; - SAMLSignatureTestBase::setUp(); - } - - void tearDown() { - SAMLSignatureTestBase::tearDown(); - } - - void testSignature() { - auto_ptr_XMLCh issueInstant("1970-01-02T01:01:02.100Z"); - auto_ptr_XMLCh id("ident"); - auto_ptr_XMLCh method("method"); - auto_ptr_XMLCh nameid("John Doe"); - - NameIdentifier* n=NameIdentifierBuilder::buildNameIdentifier(); - n->setName(nameid.get()); - Subject* subject=SubjectBuilder::buildSubject(); - subject->setNameIdentifier(n); - - AuthenticationQuery* query=AuthenticationQueryBuilder::buildAuthenticationQuery(); - query->setAuthenticationMethod(method.get()); - query->setSubject(subject); - - auto_ptr request(RequestBuilder::buildRequest()); - request->setRequestID(id.get()); - request->setIssueInstant(issueInstant.get()); - request->setAuthenticationQuery(query); - - // Append a Signature. - Signature* sig=SignatureBuilder::buildSignature(); - request->setSignature(sig); - Locker locker(m_resolver); - sig->setSigningKey(m_resolver->getKey()); - - // Build KeyInfo. - KeyInfo* keyInfo=KeyInfoBuilder::buildKeyInfo(); - X509Data* x509Data=X509DataBuilder::buildX509Data(); - keyInfo->getX509Datas().push_back(x509Data); - for_each(m_resolver->getCertificates().begin(),m_resolver->getCertificates().end(),bind1st(_addcert(),x509Data)); - sig->setKeyInfo(keyInfo); - - // Sign while marshalling. - vector sigs(1,sig); - DOMElement* rootElement = NULL; - try { - rootElement=request->marshall((DOMDocument*)NULL,&sigs); - } - catch (XMLToolingException& e) { - TS_TRACE(e.what()); - throw; - } - - string buf; - XMLHelper::serialize(rootElement, buf); - istringstream in(buf); - DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); - const XMLObjectBuilder* b = XMLObjectBuilder::getBuilder(doc->getDocumentElement()); - - auto_ptr request2(b->buildFromDocument(doc)); - assertEquals("Unmarshalled request does not match", expectedChildElementsDOM, request2.get(), false); - - try { - SignatureProfileValidator spv; - SignatureValidator sv(new KeyResolver(m_resolver->getKey())); - spv.validate(dynamic_cast(request2.get())->getSignature()); - sv.validate(dynamic_cast(request2.get())->getSignature()); - } - catch (XMLToolingException& e) { - TS_TRACE(e.what()); - throw; - } - } - -}; +/* + * Copyright 2001-2005 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "signature/SAMLSignatureTestBase.h" + +#include +#include + +#include + +using namespace opensaml::saml1p; +using namespace opensaml::saml1; + +class SAML1RequestTest : public CxxTest::TestSuite, public SAMLSignatureTestBase { +public: + void setUp() { + childElementsFile = data_path + "signature/SAML1Request.xml"; + SAMLSignatureTestBase::setUp(); + } + + void tearDown() { + SAMLSignatureTestBase::tearDown(); + } + + void testSignature() { + auto_ptr_XMLCh issueInstant("1970-01-02T01:01:02.100Z"); + auto_ptr_XMLCh id("ident"); + auto_ptr_XMLCh method("method"); + auto_ptr_XMLCh nameid("John Doe"); + + NameIdentifier* n=NameIdentifierBuilder::buildNameIdentifier(); + n->setName(nameid.get()); + Subject* subject=SubjectBuilder::buildSubject(); + subject->setNameIdentifier(n); + + AuthenticationQuery* query=AuthenticationQueryBuilder::buildAuthenticationQuery(); + query->setAuthenticationMethod(method.get()); + query->setSubject(subject); + + auto_ptr request(RequestBuilder::buildRequest()); + request->setRequestID(id.get()); + request->setIssueInstant(issueInstant.get()); + request->setAuthenticationQuery(query); + + // Append a Signature. + Signature* sig=SignatureBuilder::buildSignature(); + request->setSignature(sig); + Locker locker(m_resolver); + sig->setSigningKey(m_resolver->getKey()); + + // Build KeyInfo. + KeyInfo* keyInfo=KeyInfoBuilder::buildKeyInfo(); + X509Data* x509Data=X509DataBuilder::buildX509Data(); + keyInfo->getX509Datas().push_back(x509Data); + for_each(m_resolver->getCertificates().begin(),m_resolver->getCertificates().end(),bind1st(_addcert(),x509Data)); + sig->setKeyInfo(keyInfo); + + // Sign while marshalling. + vector sigs(1,sig); + DOMElement* rootElement = NULL; + try { + rootElement=request->marshall((DOMDocument*)NULL,&sigs); + } + catch (XMLToolingException& e) { + TS_TRACE(e.what()); + throw; + } + + string buf; + XMLHelper::serialize(rootElement, buf); + istringstream in(buf); + DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); + const XMLObjectBuilder* b = XMLObjectBuilder::getBuilder(doc->getDocumentElement()); + + auto_ptr request2(b->buildFromDocument(doc)); + assertEquals("Unmarshalled request does not match", expectedChildElementsDOM, request2.get(), false); + + try { + SignatureProfileValidator spv; + SignatureValidator sv(new KeyResolver(m_resolver->getKey())); + spv.validate(dynamic_cast(request2.get())->getSignature()); + sv.validate(dynamic_cast(request2.get())->getSignature()); + } + catch (XMLToolingException& e) { + TS_TRACE(e.what()); + throw; + } + } + +}; diff --git a/samltest/signature/SAML1ResponseTest.h b/samltest/signature/SAML1ResponseTest.h index c52354c..a27bbe3 100644 --- a/samltest/signature/SAML1ResponseTest.h +++ b/samltest/signature/SAML1ResponseTest.h @@ -1,136 +1,136 @@ -/* - * Copyright 2001-2005 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "signature/SAMLSignatureTestBase.h" - -#include -#include - -#include - -using namespace opensaml::saml1p; -using namespace opensaml::saml1; - -class SAML1ResponseTest : public CxxTest::TestSuite, public SAMLSignatureTestBase { -public: - void setUp() { - childElementsFile = data_path + "signature/SAML1Response.xml"; - SAMLSignatureTestBase::setUp(); - } - - void tearDown() { - SAMLSignatureTestBase::tearDown(); - } - - void testSignature() { - auto_ptr_XMLCh issuer("issuer"); - auto_ptr_XMLCh issueInstant("1970-01-02T01:01:02.100Z"); - auto_ptr_XMLCh aid("aident"); - auto_ptr_XMLCh rid("rident"); - auto_ptr_XMLCh method("method"); - auto_ptr_XMLCh nameid("John Doe"); - - NameIdentifier* n=NameIdentifierBuilder::buildNameIdentifier(); - n->setName(nameid.get()); - Subject* subject=SubjectBuilder::buildSubject(); - subject->setNameIdentifier(n); - - AuthenticationStatement* statement=AuthenticationStatementBuilder::buildAuthenticationStatement(); - statement->setAuthenticationInstant(issueInstant.get()); - statement->setAuthenticationMethod(method.get()); - statement->setSubject(subject); - - Assertion* assertion=AssertionBuilder::buildAssertion(); - assertion->setAssertionID(aid.get()); - assertion->setIssueInstant(issueInstant.get()); - assertion->setIssuer(issuer.get()); - assertion->getAuthenticationStatements().push_back(statement); - - // Append a Signature. - assertion->setSignature(SignatureBuilder::buildSignature()); - Locker locker(m_resolver); - assertion->getSignature()->setSigningKey(m_resolver->getKey()); - - // Build KeyInfo. - KeyInfo* keyInfo=KeyInfoBuilder::buildKeyInfo(); - X509Data* x509Data=X509DataBuilder::buildX509Data(); - keyInfo->getX509Datas().push_back(x509Data); - for_each(m_resolver->getCertificates().begin(),m_resolver->getCertificates().end(),bind1st(_addcert(),x509Data)); - assertion->getSignature()->setKeyInfo(keyInfo); - - // Sign assertion while marshalling. - vector sigs(1,assertion->getSignature()); - DOMElement* rootElement = NULL; - try { - rootElement=assertion->marshall((DOMDocument*)NULL,&sigs); - } - catch (XMLToolingException& e) { - TS_TRACE(e.what()); - delete assertion; - throw; - } - - StatusCode* sc=StatusCodeBuilder::buildStatusCode(); - sc->setValue(&StatusCode::SUCCESS); - Status* status=StatusBuilder::buildStatus(); - status->setStatusCode(sc); - - auto_ptr response(ResponseBuilder::buildResponse()); - response->setResponseID(rid.get()); - response->setIssueInstant(issueInstant.get()); - response->setStatus(status); - response->getAssertions().push_back(assertion); - response->setSignature(SignatureBuilder::buildSignature()); - response->getSignature()->setSigningKey(m_resolver->getKey()); - response->getSignature()->setKeyInfo(keyInfo->cloneKeyInfo()); - - // Sign response while marshalling. - sigs.clear(); - sigs.push_back(response->getSignature()); - rootElement = NULL; - try { - rootElement=response->marshall((DOMDocument*)NULL,&sigs); - } - catch (XMLToolingException& e) { - TS_TRACE(e.what()); - throw; - } - - string buf; - XMLHelper::serialize(rootElement, buf); - istringstream in(buf); - DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); - const XMLObjectBuilder* b = XMLObjectBuilder::getBuilder(doc->getDocumentElement()); - - auto_ptr response2(b->buildFromDocument(doc)); - assertEquals("Unmarshalled response does not match", expectedChildElementsDOM, response2.get(), false); - - try { - SignatureProfileValidator spv; - spv.validate(dynamic_cast(response2.get())->getAssertions().front()->getSignature()); - spv.validate(dynamic_cast(response2.get())->getSignature()); - - SignatureValidator sv(new KeyResolver(m_resolver->getKey())); - sv.validate(dynamic_cast(response2.get())->getAssertions().front()->getSignature()); - sv.validate(dynamic_cast(response2.get())->getSignature()); - } - catch (XMLToolingException& e) { - TS_TRACE(e.what()); - throw; - } - } - -}; +/* + * Copyright 2001-2005 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "signature/SAMLSignatureTestBase.h" + +#include +#include + +#include + +using namespace opensaml::saml1p; +using namespace opensaml::saml1; + +class SAML1ResponseTest : public CxxTest::TestSuite, public SAMLSignatureTestBase { +public: + void setUp() { + childElementsFile = data_path + "signature/SAML1Response.xml"; + SAMLSignatureTestBase::setUp(); + } + + void tearDown() { + SAMLSignatureTestBase::tearDown(); + } + + void testSignature() { + auto_ptr_XMLCh issuer("issuer"); + auto_ptr_XMLCh issueInstant("1970-01-02T01:01:02.100Z"); + auto_ptr_XMLCh aid("aident"); + auto_ptr_XMLCh rid("rident"); + auto_ptr_XMLCh method("method"); + auto_ptr_XMLCh nameid("John Doe"); + + NameIdentifier* n=NameIdentifierBuilder::buildNameIdentifier(); + n->setName(nameid.get()); + Subject* subject=SubjectBuilder::buildSubject(); + subject->setNameIdentifier(n); + + AuthenticationStatement* statement=AuthenticationStatementBuilder::buildAuthenticationStatement(); + statement->setAuthenticationInstant(issueInstant.get()); + statement->setAuthenticationMethod(method.get()); + statement->setSubject(subject); + + Assertion* assertion=AssertionBuilder::buildAssertion(); + assertion->setAssertionID(aid.get()); + assertion->setIssueInstant(issueInstant.get()); + assertion->setIssuer(issuer.get()); + assertion->getAuthenticationStatements().push_back(statement); + + // Append a Signature. + assertion->setSignature(SignatureBuilder::buildSignature()); + Locker locker(m_resolver); + assertion->getSignature()->setSigningKey(m_resolver->getKey()); + + // Build KeyInfo. + KeyInfo* keyInfo=KeyInfoBuilder::buildKeyInfo(); + X509Data* x509Data=X509DataBuilder::buildX509Data(); + keyInfo->getX509Datas().push_back(x509Data); + for_each(m_resolver->getCertificates().begin(),m_resolver->getCertificates().end(),bind1st(_addcert(),x509Data)); + assertion->getSignature()->setKeyInfo(keyInfo); + + // Sign assertion while marshalling. + vector sigs(1,assertion->getSignature()); + DOMElement* rootElement = NULL; + try { + rootElement=assertion->marshall((DOMDocument*)NULL,&sigs); + } + catch (XMLToolingException& e) { + TS_TRACE(e.what()); + delete assertion; + throw; + } + + StatusCode* sc=StatusCodeBuilder::buildStatusCode(); + sc->setValue(&StatusCode::SUCCESS); + Status* status=StatusBuilder::buildStatus(); + status->setStatusCode(sc); + + auto_ptr response(ResponseBuilder::buildResponse()); + response->setResponseID(rid.get()); + response->setIssueInstant(issueInstant.get()); + response->setStatus(status); + response->getAssertions().push_back(assertion); + response->setSignature(SignatureBuilder::buildSignature()); + response->getSignature()->setSigningKey(m_resolver->getKey()); + response->getSignature()->setKeyInfo(keyInfo->cloneKeyInfo()); + + // Sign response while marshalling. + sigs.clear(); + sigs.push_back(response->getSignature()); + rootElement = NULL; + try { + rootElement=response->marshall((DOMDocument*)NULL,&sigs); + } + catch (XMLToolingException& e) { + TS_TRACE(e.what()); + throw; + } + + string buf; + XMLHelper::serialize(rootElement, buf); + istringstream in(buf); + DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); + const XMLObjectBuilder* b = XMLObjectBuilder::getBuilder(doc->getDocumentElement()); + + auto_ptr response2(b->buildFromDocument(doc)); + assertEquals("Unmarshalled response does not match", expectedChildElementsDOM, response2.get(), false); + + try { + SignatureProfileValidator spv; + spv.validate(dynamic_cast(response2.get())->getAssertions().front()->getSignature()); + spv.validate(dynamic_cast(response2.get())->getSignature()); + + SignatureValidator sv(new KeyResolver(m_resolver->getKey())); + sv.validate(dynamic_cast(response2.get())->getAssertions().front()->getSignature()); + sv.validate(dynamic_cast(response2.get())->getSignature()); + } + catch (XMLToolingException& e) { + TS_TRACE(e.what()); + throw; + } + } + +}; diff --git a/samltest/signature/SAML2AssertionTest.h b/samltest/signature/SAML2AssertionTest.h index 6bf5bec..22a8a57 100644 --- a/samltest/signature/SAML2AssertionTest.h +++ b/samltest/signature/SAML2AssertionTest.h @@ -1,111 +1,111 @@ -/* - * Copyright 2001-2005 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "signature/SAMLSignatureTestBase.h" -#include - -#include - -using namespace opensaml::saml2; - -class SAML2AssertionTest : public CxxTest::TestSuite, public SAMLSignatureTestBase { -public: - void setUp() { - childElementsFile = data_path + "signature/SAML2Assertion.xml"; - SAMLSignatureTestBase::setUp(); - } - - void tearDown() { - SAMLSignatureTestBase::tearDown(); - } - - void testSignature() { - auto_ptr_XMLCh issuer("issuer"); - auto_ptr_XMLCh issueInstant("1970-01-02T01:01:02.100Z"); - auto_ptr_XMLCh id("ident"); - auto_ptr_XMLCh method("method"); - auto_ptr_XMLCh nameid("John Doe"); - - Issuer* is=IssuerBuilder::buildIssuer(); - is->setName(issuer.get()); - - NameID* n=NameIDBuilder::buildNameID(); - n->setName(nameid.get()); - Subject* subject=SubjectBuilder::buildSubject(); - subject->setNameID(n); - - AuthnStatement* statement=AuthnStatementBuilder::buildAuthnStatement(); - statement->setAuthnInstant(issueInstant.get()); - - AuthnContext* ac=AuthnContextBuilder::buildAuthnContext(); - AuthnContextClassRef* acc=AuthnContextClassRefBuilder::buildAuthnContextClassRef(); - acc->setReference(method.get()); - ac->setAuthnContextClassRef(acc); - statement->setAuthnContext(ac); - - auto_ptr assertion(AssertionBuilder::buildAssertion()); - assertion->setID(id.get()); - assertion->setIssueInstant(issueInstant.get()); - assertion->setIssuer(is); - assertion->setSubject(subject); - assertion->getAuthnStatements().push_back(statement); - - // Append a Signature. - Signature* sig=SignatureBuilder::buildSignature(); - assertion->setSignature(sig); - Locker locker(m_resolver); - sig->setSigningKey(m_resolver->getKey()); - - // Build KeyInfo. - KeyInfo* keyInfo=KeyInfoBuilder::buildKeyInfo(); - X509Data* x509Data=X509DataBuilder::buildX509Data(); - keyInfo->getX509Datas().push_back(x509Data); - for_each(m_resolver->getCertificates().begin(),m_resolver->getCertificates().end(),bind1st(_addcert(),x509Data)); - sig->setKeyInfo(keyInfo); - - // Sign while marshalling. - vector sigs(1,sig); - DOMElement* rootElement = NULL; - try { - rootElement=assertion->marshall((DOMDocument*)NULL,&sigs); - } - catch (XMLToolingException& e) { - TS_TRACE(e.what()); - throw; - } - - string buf; - XMLHelper::serialize(rootElement, buf); - istringstream in(buf); - DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); - const XMLObjectBuilder* b = XMLObjectBuilder::getBuilder(doc->getDocumentElement()); - - auto_ptr assertion2(b->buildFromDocument(doc)); - assertEquals("Unmarshalled assertion does not match", expectedChildElementsDOM, assertion2.get(), false); - - try { - SignatureProfileValidator spv; - SignatureValidator sv(new KeyResolver(m_resolver->getKey())); - spv.validate(dynamic_cast(assertion2.get())->getSignature()); - sv.validate(dynamic_cast(assertion2.get())->getSignature()); - } - catch (XMLToolingException& e) { - TS_TRACE(e.what()); - throw; - } - } - -}; +/* + * Copyright 2001-2005 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "signature/SAMLSignatureTestBase.h" +#include + +#include + +using namespace opensaml::saml2; + +class SAML2AssertionTest : public CxxTest::TestSuite, public SAMLSignatureTestBase { +public: + void setUp() { + childElementsFile = data_path + "signature/SAML2Assertion.xml"; + SAMLSignatureTestBase::setUp(); + } + + void tearDown() { + SAMLSignatureTestBase::tearDown(); + } + + void testSignature() { + auto_ptr_XMLCh issuer("issuer"); + auto_ptr_XMLCh issueInstant("1970-01-02T01:01:02.100Z"); + auto_ptr_XMLCh id("ident"); + auto_ptr_XMLCh method("method"); + auto_ptr_XMLCh nameid("John Doe"); + + Issuer* is=IssuerBuilder::buildIssuer(); + is->setName(issuer.get()); + + NameID* n=NameIDBuilder::buildNameID(); + n->setName(nameid.get()); + Subject* subject=SubjectBuilder::buildSubject(); + subject->setNameID(n); + + AuthnStatement* statement=AuthnStatementBuilder::buildAuthnStatement(); + statement->setAuthnInstant(issueInstant.get()); + + AuthnContext* ac=AuthnContextBuilder::buildAuthnContext(); + AuthnContextClassRef* acc=AuthnContextClassRefBuilder::buildAuthnContextClassRef(); + acc->setReference(method.get()); + ac->setAuthnContextClassRef(acc); + statement->setAuthnContext(ac); + + auto_ptr assertion(AssertionBuilder::buildAssertion()); + assertion->setID(id.get()); + assertion->setIssueInstant(issueInstant.get()); + assertion->setIssuer(is); + assertion->setSubject(subject); + assertion->getAuthnStatements().push_back(statement); + + // Append a Signature. + Signature* sig=SignatureBuilder::buildSignature(); + assertion->setSignature(sig); + Locker locker(m_resolver); + sig->setSigningKey(m_resolver->getKey()); + + // Build KeyInfo. + KeyInfo* keyInfo=KeyInfoBuilder::buildKeyInfo(); + X509Data* x509Data=X509DataBuilder::buildX509Data(); + keyInfo->getX509Datas().push_back(x509Data); + for_each(m_resolver->getCertificates().begin(),m_resolver->getCertificates().end(),bind1st(_addcert(),x509Data)); + sig->setKeyInfo(keyInfo); + + // Sign while marshalling. + vector sigs(1,sig); + DOMElement* rootElement = NULL; + try { + rootElement=assertion->marshall((DOMDocument*)NULL,&sigs); + } + catch (XMLToolingException& e) { + TS_TRACE(e.what()); + throw; + } + + string buf; + XMLHelper::serialize(rootElement, buf); + istringstream in(buf); + DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); + const XMLObjectBuilder* b = XMLObjectBuilder::getBuilder(doc->getDocumentElement()); + + auto_ptr assertion2(b->buildFromDocument(doc)); + assertEquals("Unmarshalled assertion does not match", expectedChildElementsDOM, assertion2.get(), false); + + try { + SignatureProfileValidator spv; + SignatureValidator sv(new KeyResolver(m_resolver->getKey())); + spv.validate(dynamic_cast(assertion2.get())->getSignature()); + sv.validate(dynamic_cast(assertion2.get())->getSignature()); + } + catch (XMLToolingException& e) { + TS_TRACE(e.what()); + throw; + } + } + +}; diff --git a/samltest/signature/SAMLSignatureTestBase.h b/samltest/signature/SAMLSignatureTestBase.h index 24148d6..8cd7a7b 100644 --- a/samltest/signature/SAMLSignatureTestBase.h +++ b/samltest/signature/SAMLSignatureTestBase.h @@ -1,56 +1,56 @@ -/* - * Copyright 2001-2005 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include - -#include -#include -#include - -using namespace xmlsignature; - -class _addcert : public std::binary_function { -public: - void operator()(X509Data* bag, XSECCryptoX509* cert) const { - safeBuffer& buf=cert->getDEREncodingSB(); - X509Certificate* x=X509CertificateBuilder::buildX509Certificate(); - x->setValue(buf.sbStrToXMLCh()); - bag->getX509Certificates().push_back(x); - } -}; - -class SAMLSignatureTestBase : public SAMLObjectBaseTestCase { -protected: - CredentialResolver* m_resolver; -public: - void setUp() { - m_resolver=NULL; - SAMLObjectBaseTestCase::setUp(); - string config = data_path + "FilesystemCredentialResolver.xml"; - ifstream in(config.c_str()); - DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); - XercesJanitor janitor(doc); - m_resolver = XMLToolingConfig::getConfig().CredentialResolverManager.newPlugin( - FILESYSTEM_CREDENTIAL_RESOLVER,doc->getDocumentElement() - ); - } - - void tearDown() { - delete m_resolver; - SAMLObjectBaseTestCase::tearDown(); - } -}; +/* + * Copyright 2001-2005 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include + +#include +#include +#include + +using namespace xmlsignature; + +class _addcert : public std::binary_function { +public: + void operator()(X509Data* bag, XSECCryptoX509* cert) const { + safeBuffer& buf=cert->getDEREncodingSB(); + X509Certificate* x=X509CertificateBuilder::buildX509Certificate(); + x->setValue(buf.sbStrToXMLCh()); + bag->getX509Certificates().push_back(x); + } +}; + +class SAMLSignatureTestBase : public SAMLObjectBaseTestCase { +protected: + CredentialResolver* m_resolver; +public: + void setUp() { + m_resolver=NULL; + SAMLObjectBaseTestCase::setUp(); + string config = data_path + "FilesystemCredentialResolver.xml"; + ifstream in(config.c_str()); + DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in); + XercesJanitor janitor(doc); + m_resolver = XMLToolingConfig::getConfig().CredentialResolverManager.newPlugin( + FILESYSTEM_CREDENTIAL_RESOLVER,doc->getDocumentElement() + ); + } + + void tearDown() { + delete m_resolver; + SAMLObjectBaseTestCase::tearDown(); + } +}; -- 2.1.4