From 31bc751c4d57cbefbcda84e5a6afc7dffee22dcf Mon Sep 17 00:00:00 2001 From: Brent Putman Date: Thu, 6 Jul 2006 22:31:41 +0000 Subject: [PATCH] Multi-line svn commit, see body. Initial check-in of SAML 2.0 Core protocol namespace implementation classes and unit tests. --- .gitignore | 18 + saml/.gitignore | 4 + saml/Makefile.am | 10 +- saml/SAMLConfig.cpp | 2 + saml/saml2/core/Protocols.h | 50 +- saml/saml2/core/impl/Protocols20Impl.cpp | 1741 ++++++++++++++++++++ .../core/impl/Protocols20SchemaValidators.cpp | 252 +++ samltest/.gitignore | 5 + samltest/Makefile.am | 33 +- .../core/impl/ArtifactResolveChildElements.xml | Bin 484 -> 594 bytes .../core/impl/ArtifactResponseChildElements.xml | Bin 472 -> 758 bytes .../core/impl/AssertionIDRequestChildElements.xml | Bin 582 -> 690 bytes .../core/impl/AttributeQueryChildElements.xml | Bin 600 -> 708 bytes .../saml2/core/impl/AuthnQueryChildElements.xml | Bin 508 -> 616 bytes samltest/data/saml2/core/impl/AuthnRequest.xml | Bin 400 -> 406 bytes .../saml2/core/impl/AuthnRequestChildElements.xml | Bin 654 -> 762 bytes .../core/impl/AuthnRequestOptionalAttributes.xml | Bin 1052 -> 1044 bytes .../core/impl/AuthzDecisionQueryChildElements.xml | Bin 568 -> 676 bytes .../saml2/core/impl/LogoutRequestChildElements.xml | Bin 562 -> 670 bytes .../core/impl/LogoutResponseChildElements.xml | Bin 464 -> 572 bytes .../core/impl/ManageNameIDRequestChildElements.xml | Bin 530 -> 638 bytes .../impl/ManageNameIDResponseChildElements.xml | Bin 488 -> 598 bytes .../impl/NameIDMappingRequestChildElements.xml | Bin 544 -> 652 bytes .../impl/NameIDMappingResponseChildElements.xml | Bin 520 -> 628 bytes samltest/data/saml2/core/impl/NameIDPolicy.xml | Bin 230 -> 234 bytes .../core/impl/NameIDPolicyOptionalAttributes.xml | Bin 392 -> 390 bytes samltest/data/saml2/core/impl/NewEncryptedID.xml | Bin 0 -> 238 bytes .../core/impl/NewEncryptedIDChildElements.xml | Bin 0 -> 502 bytes .../data/saml2/core/impl/ResponseChildElements.xml | Bin 932 -> 1792 bytes samltest/data/saml2/core/impl/StatusResponse.xml | Bin 0 -> 626 bytes .../core/impl/StatusResponseChildElements.xml | Bin 0 -> 788 bytes .../core/impl/StatusResponseOptionalAttributes.xml | Bin 0 -> 818 bytes samltest/saml2/core/impl/.gitignore | 1 + samltest/saml2/core/impl/Artifact20Test.h | 51 + samltest/saml2/core/impl/ArtifactResolve20Test.h | 122 ++ samltest/saml2/core/impl/ArtifactResponse20Test.h | 154 ++ .../saml2/core/impl/AssertionIDRequest20Test.h | 124 ++ samltest/saml2/core/impl/AttributeQuery20Test.h | 127 ++ samltest/saml2/core/impl/AuthnQuery20Test.h | 131 ++ samltest/saml2/core/impl/AuthnRequest20Test.h | 182 ++ .../saml2/core/impl/AuthzDecisionQuery20Test.h | 137 ++ samltest/saml2/core/impl/GetComplete20Test.h | 51 + samltest/saml2/core/impl/IDPEntry20Test.h | 77 + samltest/saml2/core/impl/IDPList20Test.h | 68 + samltest/saml2/core/impl/LogoutRequest20Test.h | 144 ++ samltest/saml2/core/impl/LogoutResponse20Test.h | 138 ++ .../saml2/core/impl/ManageNameIDRequest20Test.h | 136 ++ .../saml2/core/impl/ManageNameIDResponse20Test.h | 138 ++ .../saml2/core/impl/NameIDMappingRequest20Test.h | 133 ++ .../saml2/core/impl/NameIDMappingResponse20Test.h | 145 ++ samltest/saml2/core/impl/NameIDPolicy20Test.h | 76 + samltest/saml2/core/impl/NewEncryptedID20Test.h | 71 + samltest/saml2/core/impl/NewID20Test.h | 51 + .../saml2/core/impl/RequestedAuthnContext20Test.h | 95 ++ samltest/saml2/core/impl/RequesterID20Test.h | 51 + samltest/saml2/core/impl/Response20Test.h | 180 ++ samltest/saml2/core/impl/Scoping20Test.h | 91 + samltest/saml2/core/impl/SessionIndex20Test.h | 51 + samltest/saml2/core/impl/Status20Test.h | 66 + samltest/saml2/core/impl/StatusCode20Test.h | 66 + samltest/saml2/core/impl/StatusDetail20Test.h | 61 + samltest/saml2/core/impl/StatusMessage20Test.h | 51 + samltest/saml2/core/impl/StatusResponse20Test.h | 186 +++ samltest/saml2/core/impl/Terminate20Test.h | 46 + schemas/.gitignore | 5 + 65 files changed, 5310 insertions(+), 11 deletions(-) create mode 100644 saml/saml2/core/impl/Protocols20SchemaValidators.cpp create mode 100644 samltest/data/saml2/core/impl/NewEncryptedID.xml create mode 100644 samltest/data/saml2/core/impl/NewEncryptedIDChildElements.xml create mode 100644 samltest/data/saml2/core/impl/StatusResponse.xml create mode 100644 samltest/data/saml2/core/impl/StatusResponseChildElements.xml create mode 100644 samltest/data/saml2/core/impl/StatusResponseOptionalAttributes.xml create mode 100644 samltest/saml2/core/impl/.gitignore create mode 100644 samltest/saml2/core/impl/Artifact20Test.h create mode 100644 samltest/saml2/core/impl/ArtifactResolve20Test.h create mode 100644 samltest/saml2/core/impl/ArtifactResponse20Test.h create mode 100644 samltest/saml2/core/impl/AssertionIDRequest20Test.h create mode 100644 samltest/saml2/core/impl/AttributeQuery20Test.h create mode 100644 samltest/saml2/core/impl/AuthnQuery20Test.h create mode 100644 samltest/saml2/core/impl/AuthnRequest20Test.h create mode 100644 samltest/saml2/core/impl/AuthzDecisionQuery20Test.h create mode 100644 samltest/saml2/core/impl/GetComplete20Test.h create mode 100644 samltest/saml2/core/impl/IDPEntry20Test.h create mode 100644 samltest/saml2/core/impl/IDPList20Test.h create mode 100644 samltest/saml2/core/impl/LogoutRequest20Test.h create mode 100644 samltest/saml2/core/impl/LogoutResponse20Test.h create mode 100644 samltest/saml2/core/impl/ManageNameIDRequest20Test.h create mode 100644 samltest/saml2/core/impl/ManageNameIDResponse20Test.h create mode 100644 samltest/saml2/core/impl/NameIDMappingRequest20Test.h create mode 100644 samltest/saml2/core/impl/NameIDMappingResponse20Test.h create mode 100644 samltest/saml2/core/impl/NameIDPolicy20Test.h create mode 100644 samltest/saml2/core/impl/NewEncryptedID20Test.h create mode 100644 samltest/saml2/core/impl/NewID20Test.h create mode 100644 samltest/saml2/core/impl/RequestedAuthnContext20Test.h create mode 100644 samltest/saml2/core/impl/RequesterID20Test.h create mode 100644 samltest/saml2/core/impl/Response20Test.h create mode 100644 samltest/saml2/core/impl/Scoping20Test.h create mode 100644 samltest/saml2/core/impl/SessionIndex20Test.h create mode 100644 samltest/saml2/core/impl/Status20Test.h create mode 100644 samltest/saml2/core/impl/StatusCode20Test.h create mode 100644 samltest/saml2/core/impl/StatusDetail20Test.h create mode 100644 samltest/saml2/core/impl/StatusMessage20Test.h create mode 100644 samltest/saml2/core/impl/StatusResponse20Test.h create mode 100644 samltest/saml2/core/impl/Terminate20Test.h create mode 100644 schemas/.gitignore diff --git a/.gitignore b/.gitignore index d259f48..c958642 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,21 @@ /*.ncb /*.suo /debug +/aclocal.m4 +/autom4te.cache +/config.guess +/config.h +/config.h.in +/config.log +/config.status +/config.sub +/configure +/depcomp +/install-sh +/libtool +/Makefile +/Makefile.in +/missing +/opensaml.spec +/pkginfo +/stamp-h1 diff --git a/saml/.gitignore b/saml/.gitignore index 994c81d..968d2de 100644 --- a/saml/.gitignore +++ b/saml/.gitignore @@ -1,2 +1,6 @@ /Debug /*.user +/.deps +/.libs +/Makefile +/Makefile.in diff --git a/saml/Makefile.am b/saml/Makefile.am index e27f6d4..e36b1cd 100644 --- a/saml/Makefile.am +++ b/saml/Makefile.am @@ -42,10 +42,10 @@ saml2coreinclude_HEADERS = \ saml2/core/Protocols.h saml2mdinclude_HEADERS = \ - saml2/metadata/Metadata.h \ - saml2/metadata/MetadataFilter.h \ - saml2/metadata/MetadataProvider.h \ - saml2/metadata/MetadataResolver.h + saml2/metadata/Metadata.h +# saml2/metadata/MetadataFilter.h \ +# saml2/metadata/MetadataProvider.h \ +# saml2/metadata/MetadataResolver.h noinst_HEADERS = \ internal.h @@ -60,8 +60,8 @@ libsaml_la_SOURCES = \ saml2/core/impl/Assertions20Impl.cpp \ saml2/core/impl/Assertions20SchemaValidators.cpp \ saml2/core/impl/Protocols20Impl.cpp \ + saml2/core/impl/Protocols20SchemaValidators.cpp \ saml2/metadata/impl/MetadataImpl.cpp \ - saml2/metadata/impl/MetadataProvider.cpp \ saml2/metadata/impl/MetadataSchemaValidators.cpp \ signature/ContentReference.cpp \ signature/SignatureProfileValidator.cpp \ diff --git a/saml/SAMLConfig.cpp b/saml/SAMLConfig.cpp index 7859e9b..1f84e92 100644 --- a/saml/SAMLConfig.cpp +++ b/saml/SAMLConfig.cpp @@ -27,6 +27,7 @@ #include "SAMLConfig.h" #include "saml1/core/Assertions.h" #include "saml1/core/Protocols.h" +#include "saml2/core/Protocols.h" #include "saml2/metadata/Metadata.h" #include "util/SAMLConstants.h" @@ -74,6 +75,7 @@ bool SAMLInternalConfig::init() saml1::registerAssertionClasses(); saml1p::registerProtocolClasses(); saml2::registerAssertionClasses(); + saml2p::registerProtocolClasses(); saml2md::registerMetadataClasses(); log.info("library initialization complete"); diff --git a/saml/saml2/core/Protocols.h b/saml/saml2/core/Protocols.h index 029bb8a..42dc463 100644 --- a/saml/saml2/core/Protocols.h +++ b/saml/saml2/core/Protocols.h @@ -37,6 +37,8 @@ namespace opensaml { */ namespace saml2p { + //TODO sync C++ and Java class/interface names, e.g. -Type or no -Type, etc + DECL_XMLOBJECT_SIMPLE(SAML_API,Artifact,Artifact,SAML 2.0 Artifact element); DECL_XMLOBJECT_SIMPLE(SAML_API,GetComplete,GetComplete,SAML 2.0 GetComplete element); DECL_XMLOBJECT_SIMPLE(SAML_API,NewID,NewID,SAML 2.0 NewID element); @@ -90,10 +92,12 @@ namespace opensaml { DECL_DATETIME_ATTRIB(IssueInstant,ISSUEINSTANT); DECL_STRING_ATTRIB(Destination,DESTINATION); DECL_STRING_ATTRIB(Consent,CONSENT); + DECL_TYPED_FOREIGN_CHILD(Issuer,saml2); DECL_TYPED_FOREIGN_CHILD(Signature,xmlsignature); DECL_TYPED_CHILD(Extensions); DECL_TYPED_CHILD(Status); + /** StatusResponseType local name */ static const XMLCh TYPE_NAME[]; END_XMLOBJECT; @@ -165,7 +169,7 @@ namespace opensaml { END_XMLOBJECT; BEGIN_XMLOBJECT(SAML_API,IDPList,xmltooling::XMLObject,SAML 2.0 IDPList element); - DECL_TYPED_CHILD(IDPEntry); + DECL_TYPED_CHILDREN(IDPEntry); DECL_TYPED_CHILD(GetComplete); /** IDPListType local name */ static const XMLCh TYPE_NAME[]; @@ -177,6 +181,8 @@ namespace opensaml { DECL_TYPED_CHILDREN(RequesterID); /** ScopingType local name */ static const XMLCh TYPE_NAME[]; + /** ProxyCount value to express no restriction*/ + static const int NO_PROXY_COUNT; END_XMLOBJECT; BEGIN_XMLOBJECT(SAML_API,AuthnRequest,Request,SAML 2.0 AuthnRequest element); @@ -211,6 +217,7 @@ namespace opensaml { END_XMLOBJECT; BEGIN_XMLOBJECT(SAML_API,ArtifactResponse,StatusResponse,SAML 2.0 ArtifactResponse element); + DECL_XMLOBJECT_CHILD(Payload); /** ArtifiactResponseType local name */ static const XMLCh TYPE_NAME[]; END_XMLOBJECT; @@ -220,7 +227,7 @@ namespace opensaml { static const XMLCh TYPE_NAME[]; END_XMLOBJECT; - BEGIN_XMLOBJECT(SAML_API,NewEncryptedID,saml2::EncryptedElementType,SAML 2.0 EncryptedNewID element); + BEGIN_XMLOBJECT(SAML_API,NewEncryptedID,saml2::EncryptedElementType,SAML 2.0 NewEncryptedID element); END_XMLOBJECT; BEGIN_XMLOBJECT(SAML_API,ManageNameIDRequest,Request,SAML 2.0 ManageNameIDRequest element); @@ -266,8 +273,6 @@ namespace opensaml { static const XMLCh TYPE_NAME[]; END_XMLOBJECT; - //TODO custom builders, if any - // Builders DECL_SAML2POBJECTBUILDER(Artifact); DECL_SAML2POBJECTBUILDER(ArtifactResolve); @@ -301,11 +306,46 @@ namespace opensaml { DECL_SAML2POBJECTBUILDER(StatusMessage); DECL_SAML2POBJECTBUILDER(Terminate); + // + // Custom builders + // + + /** + * Builder for StatusResponse objects. + * + * This is customized to force the element name to be specified. + */ + class SAML_API StatusResponseBuilder : public xmltooling::XMLObjectBuilder { + public: + virtual ~StatusResponseBuilder() {} + /** Builder that allows element/type override. */ + virtual StatusResponse* buildObject( + const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL + ) const; + + /** Singleton builder. */ + static StatusResponse* buildStatusResponse(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL) { + const StatusResponseBuilder* b = dynamic_cast( + XMLObjectBuilder::getBuilder(xmltooling::QName(SAMLConstants::SAML20P_NS,StatusResponse::TYPE_NAME)) + ); + if (b) { + xmltooling::QName schemaType(SAMLConstants::SAML20P_NS,StatusResponse::TYPE_NAME,SAMLConstants::SAML20P_PREFIX); + return b->buildObject(nsURI, localName, prefix, &schemaType); + } + throw xmltooling::XMLObjectException("Unable to obtain typed builder for StatusResponse."); + } + }; + /** - * Registers builders and validators for Protocol classes into the runtime. + * Registers builders and validators for SAML 2.0 Protocol classes into the runtime. */ void SAML_API registerProtocolClasses(); + + /** + * Validator suite for SAML 2.0 Protocol schema validation. + */ + extern SAML_API xmltooling::ValidatorSuite ProtocolSchemaValidators; }; }; diff --git a/saml/saml2/core/impl/Protocols20Impl.cpp b/saml/saml2/core/impl/Protocols20Impl.cpp index 121a0f4..8f4a3d6 100644 --- a/saml/saml2/core/impl/Protocols20Impl.cpp +++ b/saml/saml2/core/impl/Protocols20Impl.cpp @@ -22,12 +22,14 @@ #include "internal.h" #include "exceptions.h" +#include "saml/encryption/EncryptedKeyResolver.h" #include "saml2/core/Protocols.h" #include #include #include #include +#include #include #include #include @@ -41,6 +43,7 @@ using namespace opensaml::saml2p; using namespace opensaml::saml2; using namespace opensaml; using namespace xmlsignature; +using namespace xmlencryption; using namespace xmltooling; using namespace std; @@ -52,7 +55,1619 @@ using namespace std; 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); + + //TODO need unit test for this, using objects from another namespace + class SAML_DLLLOCAL ExtensionsImpl : public virtual Extensions, + public AbstractDOMCachingXMLObject, + public AbstractElementProxy, + public AbstractValidatingXMLObject, + 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), AbstractDOMCachingXMLObject(src), AbstractElementProxy(src), + AbstractValidatingXMLObject(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 AbstractValidatingXMLObject, + 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), + AbstractDOMCachingXMLObject(src), + AbstractValidatingXMLObject(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 AbstractValidatingXMLObject, + 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), + AbstractDOMCachingXMLObject(src), + AbstractValidatingXMLObject(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 AbstractValidatingXMLObject, + 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), + AbstractDOMCachingXMLObject(src), + AbstractValidatingXMLObject(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 RequestImpl : public virtual Request, + public AbstractComplexElement, + public AbstractDOMCachingXMLObject, + public AbstractValidatingXMLObject, + 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: + RequestImpl() { + init(); + } + public: + virtual ~RequestImpl() { + XMLString::release(&m_ID); + XMLString::release(&m_Version); + XMLString::release(&m_Destination); + XMLString::release(&m_Consent); + delete m_IssueInstant; + } + + RequestImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) + { + init(); + } + + RequestImpl(const RequestImpl& src) : AbstractXMLObject(src), + AbstractDOMCachingXMLObject(src), + AbstractValidatingXMLObject(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()); + } + + const XMLCh* getId() const { + return getID(); + } + + //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_XMLOBJECT_CLONE(Request); + IMPL_STRING_ATTRIB(Version); + IMPL_STRING_ATTRIB(ID); + IMPL_DATETIME_ATTRIB(IssueInstant); + 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_IssueInstant=new DateTime(time(NULL)); + 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 RequestImpl + { + 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), + RequestImpl(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); + 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); + RequestImpl::processChildElement(childXMLObject,root); + } + }; + + class SAML_DLLLOCAL SubjectQueryImpl : public virtual SubjectQuery, public RequestImpl + { + 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), + RequestImpl(src) + { + init(); + if (src.getSubject()) + setSubject(src.getSubject()->cloneSubject()); + } + + IMPL_XMLOBJECT_CLONE(SubjectQuery); + IMPL_TYPED_FOREIGN_CHILD(Subject,saml2); + + protected: + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { + PROC_TYPED_FOREIGN_CHILD(Subject,saml2,SAMLConstants::SAML20_NS,false); + RequestImpl::processChildElement(childXMLObject,root); + } + }; + + + class SAML_DLLLOCAL RequestedAuthnContextImpl : public virtual RequestedAuthnContext, + public AbstractComplexElement, + public AbstractDOMCachingXMLObject, + public AbstractValidatingXMLObject, + 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), + AbstractDOMCachingXMLObject(src), + AbstractValidatingXMLObject(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); + 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); + 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); + 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 AbstractChildlessElement, + public AbstractDOMCachingXMLObject, + public AbstractValidatingXMLObject, + 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), + AbstractDOMCachingXMLObject(src), + AbstractValidatingXMLObject(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 AbstractChildlessElement, + public AbstractDOMCachingXMLObject, + public AbstractValidatingXMLObject, + 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), + AbstractDOMCachingXMLObject(src), + AbstractValidatingXMLObject(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 AbstractValidatingXMLObject, + 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), + AbstractValidatingXMLObject(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 AbstractValidatingXMLObject, + 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), + AbstractValidatingXMLObject(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 RequestImpl + { + 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), + RequestImpl(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); + + 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); + RequestImpl::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); + RequestImpl::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); + RequestImpl::processAttribute(attribute); + } + }; + + class SAML_DLLLOCAL StatusResponseImpl : public virtual StatusResponse, + public AbstractComplexElement, + public AbstractDOMCachingXMLObject, + public AbstractValidatingXMLObject, + 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: + StatusResponseImpl() { + init(); + } + public: + virtual ~StatusResponseImpl() { + XMLString::release(&m_ID); + XMLString::release(&m_InResponseTo); + XMLString::release(&m_Version); + XMLString::release(&m_Destination); + XMLString::release(&m_Consent); + delete m_IssueInstant; + } + + StatusResponseImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) + { + init(); + } + + StatusResponseImpl(const StatusResponseImpl& src) : AbstractXMLObject(src), + AbstractDOMCachingXMLObject(src), + AbstractValidatingXMLObject(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()); + } + + const XMLCh* getId() const { + return getID(); + } + + //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_XMLOBJECT_CLONE(StatusResponse); + IMPL_STRING_ATTRIB(Version); + IMPL_STRING_ATTRIB(ID); + IMPL_STRING_ATTRIB(InResponseTo); + IMPL_DATETIME_ATTRIB(IssueInstant); + 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_IssueInstant=new DateTime(time(NULL)); + 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 StatusResponseImpl + { + 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), + StatusResponseImpl(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); + 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); + StatusResponseImpl::processChildElement(childXMLObject,root); + } + }; + + class SAML_DLLLOCAL ArtifactResolveImpl : public virtual ArtifactResolve, public RequestImpl + { + 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), + RequestImpl(src) + { + init(); + if(src.getArtifact()) + setArtifact(src.getArtifact()->cloneArtifact()); + } + + IMPL_XMLOBJECT_CLONE(ArtifactResolve); + IMPL_TYPED_CHILD(Artifact); + + protected: + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { + PROC_TYPED_CHILD(Artifact,SAMLConstants::SAML20P_NS,false); + RequestImpl::processChildElement(childXMLObject,root); + } + }; + + class SAML_DLLLOCAL ArtifactResponseImpl : public virtual ArtifactResponse, public StatusResponseImpl + { + 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), + StatusResponseImpl(src) + { + init(); + if (src.getPayload()) + setPayload(getPayload()->clone()); + + } + + IMPL_XMLOBJECT_CLONE(ArtifactResponse); + IMPL_XMLOBJECT_CHILD(Payload); + + protected: + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { + // These are valid elements for the parent StatusResponse, 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; + } + + StatusResponseImpl::processChildElement(childXMLObject,root); + } + }; + + class SAML_DLLLOCAL NewEncryptedIDImpl : public virtual NewEncryptedID, + public AbstractComplexElement, + public AbstractDOMCachingXMLObject, + public AbstractValidatingXMLObject, + 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), AbstractDOMCachingXMLObject(src), AbstractValidatingXMLObject(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 AbstractChildlessElement, + public AbstractDOMCachingXMLObject, + public AbstractValidatingXMLObject, + 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), + AbstractDOMCachingXMLObject(src), + AbstractValidatingXMLObject(src) { } + + IMPL_XMLOBJECT_CLONE(Terminate); + + protected: + // has no attributes or children + }; + + class SAML_DLLLOCAL ManageNameIDRequestImpl : public virtual ManageNameIDRequest, public RequestImpl + { + 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), + RequestImpl(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); + + 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); + RequestImpl::processChildElement(childXMLObject,root); + } + }; + + class SAML_DLLLOCAL ManageNameIDResponseImpl : public virtual ManageNameIDResponse, public StatusResponseImpl + { + 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), + StatusResponseImpl(src) { } + + IMPL_XMLOBJECT_CLONE(ManageNameIDResponse); + }; + + class SAML_DLLLOCAL LogoutRequestImpl : public virtual LogoutRequest, public RequestImpl + { + 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), + RequestImpl(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); + + IMPL_STRING_ATTRIB(Reason); + IMPL_DATETIME_ATTRIB(NotOnOrAfter); + 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); + RequestImpl::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); + RequestImpl::processChildElement(childXMLObject,root); + } + void processAttribute(const DOMAttr* attribute) { + PROC_STRING_ATTRIB(Reason,REASON,NULL); + PROC_DATETIME_ATTRIB(NotOnOrAfter,NOTONORAFTER,NULL); + RequestImpl::processAttribute(attribute); + } + }; + + class SAML_DLLLOCAL LogoutResponseImpl : public virtual LogoutResponse, public StatusResponseImpl + { + 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), + StatusResponseImpl(src) { } + + IMPL_XMLOBJECT_CLONE(LogoutResponse); + }; + + + class SAML_DLLLOCAL NameIDMappingRequestImpl : public virtual NameIDMappingRequest, public RequestImpl + { + 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), + RequestImpl(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); + + 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); + RequestImpl::processChildElement(childXMLObject,root); + } + }; + + class SAML_DLLLOCAL NameIDMappingResponseImpl : public virtual NameIDMappingResponse, public StatusResponseImpl + { + 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), + StatusResponseImpl(src) + { + init(); + + if (src.getNameID()) + setNameID(getNameID()->cloneNameID()); + if (src.getEncryptedID()) + setEncryptedID(getEncryptedID()->cloneEncryptedID()); + + } + + IMPL_XMLOBJECT_CLONE(NameIDMappingResponse); + 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); + StatusResponseImpl::processChildElement(childXMLObject,root); + } + }; }; }; @@ -61,6 +1676,132 @@ namespace opensaml { #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(StatusResponse); +IMPL_XMLOBJECTBUILDER(Terminate); // 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 Request::LOCAL_NAME[] = {chNull}; +const XMLCh Request::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 Request::ID_ATTRIB_NAME[] = UNICODE_LITERAL_2(I,D); +const XMLCh Request::VER_ATTRIB_NAME[] = UNICODE_LITERAL_7(V,e,r,s,i,o,n); +const XMLCh Request::ISSUEINSTANT_ATTRIB_NAME[] = UNICODE_LITERAL_12(I,s,s,u,e,I,n,s,t,a,n,t); +const XMLCh Request::DESTINATION_ATTRIB_NAME[] = UNICODE_LITERAL_11(D,e,s,t,i,n,a,t,i,o,n); +const XMLCh Request::CONSENT_ATTRIB_NAME[] = UNICODE_LITERAL_7(C,o,n,s,e,n,t); +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 StatusResponse::LOCAL_NAME[] = {chNull}; +const XMLCh StatusResponse::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 StatusResponse::ID_ATTRIB_NAME[] = UNICODE_LITERAL_2(I,D); +const XMLCh StatusResponse::INRESPONSETO_ATTRIB_NAME[] = UNICODE_LITERAL_12(I,n,R,e,s,p,o,n,s,e,T,o); +const XMLCh StatusResponse::VER_ATTRIB_NAME[] = UNICODE_LITERAL_7(V,e,r,s,i,o,n); +const XMLCh StatusResponse::ISSUEINSTANT_ATTRIB_NAME[] = UNICODE_LITERAL_12(I,s,s,u,e,I,n,s,t,a,n,t); +const XMLCh StatusResponse::DESTINATION_ATTRIB_NAME[] = UNICODE_LITERAL_11(D,e,s,t,i,n,a,t,i,o,n); +const XMLCh StatusResponse::CONSENT_ATTRIB_NAME[] = UNICODE_LITERAL_7(C,o,n,s,e,n,t); +const XMLCh SubjectQuery::LOCAL_NAME[] = {chNull}; +const XMLCh SubjectQuery::TYPE_NAME[] = UNICODE_LITERAL_16(S,u,b,j,e,c,t,Q,u,e,r,y,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); diff --git a/saml/saml2/core/impl/Protocols20SchemaValidators.cpp b/saml/saml2/core/impl/Protocols20SchemaValidators.cpp new file mode 100644 index 0000000..22838de --- /dev/null +++ b/saml/saml2/core/impl/Protocols20SchemaValidators.cpp @@ -0,0 +1,252 @@ +/* +* 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. + */ + +/** + * Protocols20SchemaValidators.cpp + * + * Schema-based validators for SAML 2.0 Protocols classes + */ + +#include "internal.h" +#include "exceptions.h" +#include "saml2/core/Protocols.h" + +using namespace opensaml::saml2p; +using namespace opensaml::saml2; +using namespace opensaml; +using namespace xmltooling; +using namespace std; + +//TODO add in rules from normative spec document + +namespace opensaml { + namespace saml2p { + + XMLOBJECTVALIDATOR_SIMPLE(SAML_DLLLOCAL,Artifact); + XMLOBJECTVALIDATOR_SIMPLE(SAML_DLLLOCAL,GetComplete); + XMLOBJECTVALIDATOR_SIMPLE(SAML_DLLLOCAL,NewID); + XMLOBJECTVALIDATOR_SIMPLE(SAML_DLLLOCAL,RequesterID); + XMLOBJECTVALIDATOR_SIMPLE(SAML_DLLLOCAL,SessionIndex); + XMLOBJECTVALIDATOR_SIMPLE(SAML_DLLLOCAL,StatusMessage); + + class SAML_DLLLOCAL checkWildcardNS { + public: + void operator()(const XMLObject* xmlObject) const { + const XMLCh* ns=xmlObject->getElementQName().getNamespaceURI(); + if (XMLString::equals(ns,SAMLConstants::SAML20P_NS) || !ns || !*ns) { + throw ValidationException( + "Object contains an illegal extension child element ($1).", + params(1,xmlObject->getElementQName().toString().c_str()) + ); + } + } + }; + + BEGIN_XMLOBJECTVALIDATOR(SAML_DLLLOCAL,Extensions); + if (!ptr->hasChildren()) + throw ValidationException("Extensions must have at least one child element."); + const list& anys=ptr->getXMLObjects(); + for_each(anys.begin(),anys.end(),checkWildcardNS()); + END_XMLOBJECTVALIDATOR; + + BEGIN_XMLOBJECTVALIDATOR(SAML_DLLLOCAL,StatusCode); + XMLOBJECTVALIDATOR_REQUIRE(StatusCode,Value); + END_XMLOBJECTVALIDATOR; + + BEGIN_XMLOBJECTVALIDATOR(SAML_DLLLOCAL,Status); + XMLOBJECTVALIDATOR_REQUIRE(Status,StatusCode); + END_XMLOBJECTVALIDATOR; + + BEGIN_XMLOBJECTVALIDATOR(SAML_DLLLOCAL,AssertionIDRequest); + XMLOBJECTVALIDATOR_REQUIRE(AssertionIDRequest,ID); + XMLOBJECTVALIDATOR_REQUIRE(AssertionIDRequest,Version); + XMLOBJECTVALIDATOR_REQUIRE(AssertionIDRequest,IssueInstant); + XMLOBJECTVALIDATOR_NONEMPTY(AssertionIDRequest,AssertionIDRef); + END_XMLOBJECTVALIDATOR; + + BEGIN_XMLOBJECTVALIDATOR(SAML_DLLLOCAL,RequestedAuthnContext); + if (ptr->getAuthnContextClassRefs().empty() && ptr->getAuthnContextDeclRefs().empty()) + throw xmltooling::ValidationException("RequestedAuthnContext must have at least one AuthnContextClassRef or AuthnContextDeclRef"); + if (!ptr->getAuthnContextClassRefs().empty() && !ptr->getAuthnContextDeclRefs().empty()) + throw xmltooling::ValidationException("RequestedAuthnContext may not have both AuthnContextClassRef and AuthnContextDeclRef"); + if (!XMLString::equals(ptr->getComparison(),RequestedAuthnContext::COMPARISON_EXACT) && + !XMLString::equals(ptr->getComparison(),RequestedAuthnContext::COMPARISON_MINIMUM) && + !XMLString::equals(ptr->getComparison(),RequestedAuthnContext::COMPARISON_MAXIMUM) && + !XMLString::equals(ptr->getComparison(),RequestedAuthnContext::COMPARISON_BETTER)) + throw ValidationException("Comparison must be one of: 'exact', 'minimum', 'maximum', or 'better'."); + END_XMLOBJECTVALIDATOR; + + BEGIN_XMLOBJECTVALIDATOR(SAML_DLLLOCAL,AuthnQuery); + XMLOBJECTVALIDATOR_REQUIRE(AuthnQuery,Subject); + END_XMLOBJECTVALIDATOR; + + BEGIN_XMLOBJECTVALIDATOR(SAML_DLLLOCAL,AttributeQuery); + XMLOBJECTVALIDATOR_REQUIRE(AttributeQuery,Subject); + END_XMLOBJECTVALIDATOR; + + BEGIN_XMLOBJECTVALIDATOR(SAML_DLLLOCAL,AuthzDecisionQuery); + XMLOBJECTVALIDATOR_REQUIRE(AuthzDecisionQuery,Resource); + XMLOBJECTVALIDATOR_REQUIRE(AuthzDecisionQuery,Subject); + XMLOBJECTVALIDATOR_NONEMPTY(AuthzDecisionQuery,Action); + END_XMLOBJECTVALIDATOR; + + BEGIN_XMLOBJECTVALIDATOR(SAML_DLLLOCAL,IDPEntry); + XMLOBJECTVALIDATOR_REQUIRE(IDPEntry,ProviderID); + END_XMLOBJECTVALIDATOR; + + BEGIN_XMLOBJECTVALIDATOR(SAML_DLLLOCAL,IDPList); + XMLOBJECTVALIDATOR_NONEMPTY(IDPList,IDPEntry); + END_XMLOBJECTVALIDATOR; + + BEGIN_XMLOBJECTVALIDATOR(SAML_DLLLOCAL,Scoping); + pair pc = ptr->getProxyCount(); + if (pc.first && pc.second < 0) + throw xmltooling::ValidationException("ProxyCount attribute on Scoping element must be non-negative"); + END_XMLOBJECTVALIDATOR; + + BEGIN_XMLOBJECTVALIDATOR(SAML_DLLLOCAL,AuthnRequest); + //TODO no schema, but need spec constraints + END_XMLOBJECTVALIDATOR; + + BEGIN_XMLOBJECTVALIDATOR(SAML_DLLLOCAL,StatusResponse); + XMLOBJECTVALIDATOR_REQUIRE(StatusResponse,Status); + END_XMLOBJECTVALIDATOR; + + BEGIN_XMLOBJECTVALIDATOR(SAML_DLLLOCAL,Response); + XMLOBJECTVALIDATOR_REQUIRE(Response,Status); + END_XMLOBJECTVALIDATOR; + + BEGIN_XMLOBJECTVALIDATOR(SAML_DLLLOCAL,ArtifactResolve); + XMLOBJECTVALIDATOR_REQUIRE(ArtifactResolve,Artifact); + END_XMLOBJECTVALIDATOR; + + BEGIN_XMLOBJECTVALIDATOR(SAML_DLLLOCAL,ArtifactResponse); + XMLOBJECTVALIDATOR_REQUIRE(ArtifactResponse,Status); + END_XMLOBJECTVALIDATOR; + + BEGIN_XMLOBJECTVALIDATOR(SAML_DLLLOCAL,NewEncryptedID); + XMLOBJECTVALIDATOR_REQUIRE(NewEncryptedID,EncryptedData); + END_XMLOBJECTVALIDATOR; + + BEGIN_XMLOBJECTVALIDATOR(SAML_DLLLOCAL,ManageNameIDRequest); + XMLOBJECTVALIDATOR_ONLYONEOF(ManageNameIDRequest,NameID,EncryptedID); + XMLOBJECTVALIDATOR_ONLYONEOF3(ManageNameIDRequest,NewID,NewEncryptedID,Terminate); + END_XMLOBJECTVALIDATOR; + + + BEGIN_XMLOBJECTVALIDATOR(SAML_DLLLOCAL,ManageNameIDResponse); + XMLOBJECTVALIDATOR_REQUIRE(ManageNameIDResponse,Status); + END_XMLOBJECTVALIDATOR; + + BEGIN_XMLOBJECTVALIDATOR(SAML_DLLLOCAL,LogoutRequest); + XMLOBJECTVALIDATOR_ONLYONEOF3(LogoutRequest,BaseID,NameID,EncryptedID); + END_XMLOBJECTVALIDATOR; + + BEGIN_XMLOBJECTVALIDATOR(SAML_DLLLOCAL,LogoutResponse); + XMLOBJECTVALIDATOR_REQUIRE(LogoutResponse,Status); + END_XMLOBJECTVALIDATOR; + + BEGIN_XMLOBJECTVALIDATOR(SAML_DLLLOCAL,NameIDMappingRequest); + XMLOBJECTVALIDATOR_ONLYONEOF3(NameIDMappingRequest,BaseID,NameID,EncryptedID); + XMLOBJECTVALIDATOR_REQUIRE(NameIDMappingRequest,NameIDPolicy); + END_XMLOBJECTVALIDATOR; + + BEGIN_XMLOBJECTVALIDATOR(SAML_DLLLOCAL,NameIDMappingResponse); + XMLOBJECTVALIDATOR_REQUIRE(NameIDMappingResponse,Status); + XMLOBJECTVALIDATOR_ONLYONEOF(NameIDMappingResponse,NameID,EncryptedID); + END_XMLOBJECTVALIDATOR; + + + }; +}; + +#define REGISTER_ELEMENT(cname) \ + q=QName(SAMLConstants::SAML20P_NS,cname::LOCAL_NAME); \ + XMLObjectBuilder::registerBuilder(q,new cname##Builder()); \ + ProtocolSchemaValidators.registerValidator(q,new cname##SchemaValidator()) + +#define REGISTER_TYPE(cname) \ + q=QName(SAMLConstants::SAML20P_NS,cname::TYPE_NAME); \ + XMLObjectBuilder::registerBuilder(q,new cname##Builder()); \ + ProtocolSchemaValidators.registerValidator(q,new cname##SchemaValidator()) + +#define REGISTER_ELEMENT_NOVAL(cname) \ + q=QName(SAMLConstants::SAML20P_NS,cname::LOCAL_NAME); \ + XMLObjectBuilder::registerBuilder(q,new cname##Builder()); + +#define REGISTER_TYPE_NOVAL(cname) \ + q=QName(SAMLConstants::SAML20P_NS,cname::TYPE_NAME); \ + XMLObjectBuilder::registerBuilder(q,new cname##Builder()); + +ValidatorSuite opensaml::saml2p::ProtocolSchemaValidators("ProtocolSchemaValidators"); + +void opensaml::saml2p::registerProtocolClasses() { + QName q; + REGISTER_ELEMENT(Artifact); + REGISTER_ELEMENT(ArtifactResolve); + REGISTER_ELEMENT(ArtifactResponse); + REGISTER_ELEMENT(AssertionIDRequest); + REGISTER_ELEMENT(AttributeQuery); + REGISTER_ELEMENT(AuthnQuery); + REGISTER_ELEMENT(AuthnRequest); + REGISTER_ELEMENT(AuthzDecisionQuery); + REGISTER_ELEMENT(Extensions); + REGISTER_ELEMENT(GetComplete); + REGISTER_ELEMENT(IDPEntry); + REGISTER_ELEMENT(IDPList); + REGISTER_ELEMENT(LogoutRequest); + REGISTER_ELEMENT(LogoutResponse); + REGISTER_ELEMENT(ManageNameIDRequest); + REGISTER_ELEMENT(ManageNameIDResponse); + REGISTER_ELEMENT(NameIDMappingRequest); + REGISTER_ELEMENT(NameIDMappingResponse); + REGISTER_ELEMENT_NOVAL(NameIDPolicy); + REGISTER_ELEMENT(NewEncryptedID); + REGISTER_ELEMENT(NewID); + REGISTER_ELEMENT(RequestedAuthnContext); + REGISTER_ELEMENT(RequesterID); + REGISTER_ELEMENT(Response); + REGISTER_ELEMENT(Scoping); + REGISTER_ELEMENT(SessionIndex); + REGISTER_ELEMENT(Status); + REGISTER_ELEMENT(StatusCode); + REGISTER_ELEMENT_NOVAL(StatusDetail); + REGISTER_ELEMENT(StatusMessage); + REGISTER_ELEMENT_NOVAL(Terminate); + REGISTER_TYPE(ArtifactResolve); + REGISTER_TYPE(ArtifactResponse); + REGISTER_TYPE(AssertionIDRequest); + REGISTER_TYPE(AttributeQuery); + REGISTER_TYPE(AuthnQuery); + REGISTER_TYPE(AuthnRequest); + REGISTER_TYPE(AuthzDecisionQuery); + REGISTER_TYPE(Extensions); + REGISTER_TYPE(IDPEntry); + REGISTER_TYPE(IDPList); + REGISTER_TYPE(LogoutRequest); + REGISTER_TYPE(ManageNameIDRequest); + REGISTER_TYPE(NameIDMappingRequest); + REGISTER_TYPE(NameIDMappingResponse); + REGISTER_TYPE_NOVAL(NameIDPolicy); + REGISTER_TYPE(RequestedAuthnContext); + REGISTER_TYPE(Response); + REGISTER_TYPE(Scoping); + REGISTER_TYPE(Status); + REGISTER_TYPE(StatusCode); + REGISTER_TYPE(StatusResponse); + REGISTER_TYPE_NOVAL(StatusDetail); + REGISTER_TYPE_NOVAL(Terminate); +} diff --git a/samltest/.gitignore b/samltest/.gitignore index 39a97ca..7039371 100644 --- a/samltest/.gitignore +++ b/samltest/.gitignore @@ -1,3 +1,8 @@ /Debug /*.user /*.cpp +/.deps +/.libs +/Makefile +/Makefile.in +/samltest diff --git a/samltest/Makefile.am b/samltest/Makefile.am index f7594ae..b959c5a 100644 --- a/samltest/Makefile.am +++ b/samltest/Makefile.am @@ -22,7 +22,38 @@ samltest_h = \ saml1/core/impl/AttributeTest.h \ saml1/core/impl/AudienceRestrictionConditionTest.h \ saml1/core/impl/AudienceTest.h \ - saml1/core/impl/AuthenticationStatementTest.h + saml1/core/impl/AuthenticationStatementTest.h \ + saml2/core/impl/Artifact20Test.h \ + saml2/core/impl/ArtifactResolve20Test.h \ + saml2/core/impl/ArtifactResponse20Test.h \ + saml2/core/impl/AssertionIDRequest20Test.h \ + saml2/core/impl/AttributeQuery20Test.h \ + saml2/core/impl/AuthnQuery20Test.h \ + saml2/core/impl/AuthnRequest20Test.h \ + saml2/core/impl/AuthzDecisionQuery20Test.h \ + saml2/core/impl/GetComplete20Test.h \ + saml2/core/impl/IDPEntry20Test.h \ + saml2/core/impl/IDPList20Test.h \ + saml2/core/impl/LogoutRequest20Test.h \ + saml2/core/impl/LogoutResponse20Test.h \ + saml2/core/impl/ManageNameIDRequest20Test.h \ + saml2/core/impl/ManageNameIDResponse20Test.h \ + saml2/core/impl/NameIDMappingRequest20Test.h \ + saml2/core/impl/NameIDMappingResponse20Test.h \ + saml2/core/impl/NameIDPolicy20Test.h \ + saml2/core/impl/NewEncryptedID20Test.h \ + saml2/core/impl/NewID20Test.h \ + saml2/core/impl/RequesterID20Test.h \ + saml2/core/impl/RequestedAuthnContext20Test.h \ + saml2/core/impl/Response20Test.h \ + saml2/core/impl/Scoping20Test.h \ + saml2/core/impl/SessionIndex20Test.h \ + saml2/core/impl/Status20Test.h \ + saml2/core/impl/StatusCode20Test.h \ + saml2/core/impl/StatusDetail20Test.h \ + saml2/core/impl/StatusMessage20Test.h \ + saml2/core/impl/StatusResponse20Test.h\ + saml2/core/impl/Terminate20Test.h noinst_HEADERS = \ internal.h \ diff --git a/samltest/data/saml2/core/impl/ArtifactResolveChildElements.xml b/samltest/data/saml2/core/impl/ArtifactResolveChildElements.xml index b9779b35c1e1eaae962af7c450d4fc821fc0108f..a305b8534260a52289f0fe6304bc421cd5cc89c2 100644 GIT binary patch delta 122 zcmaFDe2Ha)KclcGgA0Q#gAzj`LlQ$WgCT|qJTOSCTB3#urTm4Z~*{7 C#1i)a delta 37 scmcb_@`QPVKci$ALn=cNLoq`pLq0(6&Obogn)_Zh*M11Sk#?F$B5IpUQ5Vyok|^ Ig#qX^0N-RQS^xk5 delta 19 bcmeyydV_gGAmijVuwpO)idli>^}wV7L)7E|#&0YPybN3bkr)yM delta 11 ScmdnQdW>a5DC6Y4j2{6TLIlbH diff --git a/samltest/data/saml2/core/impl/AttributeQueryChildElements.xml b/samltest/data/saml2/core/impl/AttributeQueryChildElements.xml index e1a94ef57dd708ff1ec909af7a2ed25747431b67..8bf961d777dcd20b41660c72b2d39d44b3ba2c7a 100644 GIT binary patch delta 118 zcmcb?a)fn*FQc$0gA0Q#gAzj`LlQ$WgCT|q9&&>eqmwYW#9q;?i&*c delta 15 XcmX@YdV^(yFXQA?Mybi?89xF5FCzvE diff --git a/samltest/data/saml2/core/impl/AuthnQueryChildElements.xml b/samltest/data/saml2/core/impl/AuthnQueryChildElements.xml index 6e70021e6192881d27382d6e4d30df2d4f726c73..65fa548cc98f8bf75dd5d6461307e2614bcdbbe8 100644 GIT binary patch delta 118 zcmeyv{DNhJE2FR{gA0Q#gAzj`LlQ$WgCT|q9(^ME?{BcW#9q;1)37$ delta 15 XcmaFC@`rhYE92x?Mybii8Rr53G6eUz6NN`WdofpWzRB|zPIKoVq*5m1c*gBgP^kTe34MnE$|fY^+|iopaZW(Af9 SnFNASn-duI7+Dy28MpxXT@|JP delta 16 Xcmeyx+Q+)VlW}q)qtxcpjM|I|q9*4so?&6&W#9q;)`Jqc delta 15 XcmZ3&x`SmyDC6W@Mybiy8BYQLEE@&8 diff --git a/samltest/data/saml2/core/impl/LogoutRequestChildElements.xml b/samltest/data/saml2/core/impl/LogoutRequestChildElements.xml index 534967588a5da222403d5b61dd6656ada9483889..2fef7a29deae67f2b26cbf96a88a2faac09119da 100644 GIT binary patch delta 118 zcmdnQGLLnGH>0p8gA0Q#gAzj`LlQ$WgCT|q9!LXUSMJ1W#9q;$l(%` delta 15 XcmbQox`}0jH{;}FMybhX8P5U$Dz62V diff --git a/samltest/data/saml2/core/impl/LogoutResponseChildElements.xml b/samltest/data/saml2/core/impl/LogoutResponseChildElements.xml index 731b911fc3eb38b8a701910c1e5c7af3161bb741..b4d29be7b5100ed435802b19570d72df8efe5622 100644 GIT binary patch delta 118 zcmcb>yoY6jFQc$0gA0Q#gAzjuLn=cWg9(EvgV|&cMtNTa22X}!AS?xndott!StSgK zK)M91+K9mb2+bIDfus?TG-5Dh2mxX<1}mT$20#)duLmX#7@{VpFy^o@@G@`#0O^Gi AfdBvi delta 15 WcmdnPa)Eh+FXQA?Mybi?88ZPbp#^aO diff --git a/samltest/data/saml2/core/impl/ManageNameIDRequestChildElements.xml b/samltest/data/saml2/core/impl/ManageNameIDRequestChildElements.xml index fab47ac31115c2d4b6012dc8c3814d4f820dc743..660c94c8a54e6caf202e9f840fb4adb7138a55a4 100644 GIT binary patch delta 144 zcmbQl@{eUhIAgshgA0Q#gAzj`LlQ$WgCT8T5Koy=qxnhPAhD0D;0##)IRAt7X3nYzzq!EK5LkJL?F<1djHvp0#d5}pU S7{vlIaB>l284Ck10~Y{&a29$1 delta 15 Wcmcb{@`8CoB;({lMybhn8A|~%VFlFy diff --git a/samltest/data/saml2/core/impl/NameIDMappingRequestChildElements.xml b/samltest/data/saml2/core/impl/NameIDMappingRequestChildElements.xml index 1f9dae7b57b95a042549d8d8ea23ba29eb7ebddd..89e0086696f5e7c82237c9f10069a77251b6f438 100644 GIT binary patch delta 144 zcmZ3$(!;tTlCj>C!G*z=L5U%eA&DWG!H~g-!5GL>Uz6NN`WdofpWzRB|zPIKoVq*5m1c*gBgP^kTe34MnE$|fY^+|iopaZW(Af9 SnFNASlM5I(urTm4Z~*|jb`{D1 delta 15 WcmeBSUBI#-l5uh&qtxWvjB5cYuLXMm diff --git a/samltest/data/saml2/core/impl/NameIDMappingResponseChildElements.xml b/samltest/data/saml2/core/impl/NameIDMappingResponseChildElements.xml index f1b51c671e159a42e4e3e98f0db27676a1553313..ad1cddea0cef78de79ce58cbed14f31615e12b2c 100644 GIT binary patch delta 118 zcmeBR`NFaxno-!3!G*z=L5U%SA(bJG!Gyt-!EACEqr9&IgC|2V5S9YPJsI+VtP+Mq zAYB4hZNy*zgk}u7K+*_E8Zj6$gaEM_gB8#W10V^K*8`IV3{jJd7^kr?@G@`#0Pe67 A#sB~S delta 15 Wcmeyu(!sJJnsIV5qtxWPjFSN_j|H{> diff --git a/samltest/data/saml2/core/impl/NameIDPolicy.xml b/samltest/data/saml2/core/impl/NameIDPolicy.xml index 330538cdbba9d59320c6b4b623ebfea04b217d8b..08e69cbc60da3ff7facea85c5b358acb4e5fcfe3 100644 GIT binary patch delta 11 ScmaFH_=<7DGZqG31}*>_(gS1w delta 6 NcmaFG_>6JFGXM)H14#e? diff --git a/samltest/data/saml2/core/impl/NameIDPolicyOptionalAttributes.xml b/samltest/data/saml2/core/impl/NameIDPolicyOptionalAttributes.xml index b2e7868964d2129718f2edbf0ab85c8852c7c31b..effbe3f3f427385b8466003ec5c66f286fd97499 100644 GIT binary patch delta 19 acmeBRZe!k1&B$%Ypv0ihV8_7Azy$y+4+A3r delta 21 ccmZo;?qJ?f&B$BAP{dHmkjkLMpwD0j06gIYod5s; diff --git a/samltest/data/saml2/core/impl/NewEncryptedID.xml b/samltest/data/saml2/core/impl/NewEncryptedID.xml new file mode 100644 index 0000000000000000000000000000000000000000..82d7d20c81813b5788104b6f4d55e6a05cec789e GIT binary patch literal 238 zcmYk0OA5k35JcZv@D9Pf--U}o4T1`Sx={}xCWsIxA&I}st2LdCi(#6ouIl&sG9l*0 zjf{u~DJ2zGay(Ny4Cyh@AIb5Yr6+Pd7jussSkcwiSUWK@+O*VIak9n&$4<#7OG}r$ zDX66+tXZhFx$Kp2f2nZ!E)p*_S63hk8{T?Tn`_ZH_RQI`(KIqrr~XozS})LM#@=tp Ee!^=guK)l5 literal 0 HcmV?d00001 diff --git a/samltest/data/saml2/core/impl/NewEncryptedIDChildElements.xml b/samltest/data/saml2/core/impl/NewEncryptedIDChildElements.xml new file mode 100644 index 0000000000000000000000000000000000000000..d91405cfc3c7d3e7c931909721fdd5d39be49356 GIT binary patch literal 502 zcmbV}%}N775QM+8;5#gOHXEaO7&JkMg7|Y$A3#iqLYxho(IhXgemkqM2T_n=dWY_+ z>gwM24~`kJ=7l*0Z%nCK@=QhKgdO(j(f3Li-2)M^|xh?sS!`JHqVxaE{{&cxY_3+HLHrF?8N< e&G5sVV?8HtA@?urrQSCGK$e}|{l4-1hdu%MN>e|YXXEvfAhF^h1VpkFIK;pqH_K~`C9_7}B|v^W@O4iHV+TtK zK_F{qAJfxaRb4Z_f6$h8b*oE_mFTAinyS)B6P4OlLv5`o<(@E8s?Ya=*-}HFJ=KZ6 zs!7xaF}vE)C#{gNQqMD9Dc5&aR=Vr(m#o<6*xa&L%LnOgUFXYuT>BQ1W%cS5v|w zN{=ueIW_x?UG3>e-*^fba~MupQ*)V0;r6 delta 61 tcmZqRTf#n}bn;|YnTbDBCLd;$nHt{~&nwpl!db-@|HUz8r;ygJ1ADf|=&lb)`58mOLTJss0L##2iBi(rI zjQFe0b>Y)V^vwU^bfcPB(}1%fW8{djqpjn_3H0f9hW-vu4?dfD4!XIq37IcjFL)Vn M2U3(C-U7cJzn`CIFaQ7m literal 0 HcmV?d00001 diff --git a/samltest/data/saml2/core/impl/StatusResponseChildElements.xml b/samltest/data/saml2/core/impl/StatusResponseChildElements.xml new file mode 100644 index 0000000000000000000000000000000000000000..7b5b997ba3bc7c8f6f902b81cf56f5ad86015364 GIT binary patch literal 788 zcmbu7NlU{}6ot=P@IM6iogBJ&Xp101K{vLFxC?D;g*GWk>hR~)@7~uytGJTKdui`* z&bh*?~B?uO+*9HywErV^ew(O8S=G-V&C$h?Y%%_cF%lX5rY z-r=u^vTZP=$u`GuM!NFc8TMzL>dbc_(F6bYcPQ2zb4<~Oh>;`4xz&yn=iFzeUAolb s_TaP43ZPrhY!9q^cAmUr19q*^9>8qSOSWa#_p`3(?NH_Zp8EcN106Pm=>Px# literal 0 HcmV?d00001 diff --git a/samltest/data/saml2/core/impl/StatusResponseOptionalAttributes.xml b/samltest/data/saml2/core/impl/StatusResponseOptionalAttributes.xml new file mode 100644 index 0000000000000000000000000000000000000000..a465020edf7fd20405b0eae39009a2ec61157581 GIT binary patch literal 818 zcmZ{iNlOD!5QOV2_#c9Ivl#U-Xo467K`(BIw`j&hNZy3Zxczzcs~)2XD35sw{i>^~ zmyb^!sINE8G*v?{%C%6bClyLM)RsDGs?BeMm!t>cBVLon@p`Q*ooE}>KA66G+SCS& z73h*X_J`vgp-Ik6V!HBOVei)w+BG0`3L+bFbjt8<;{5*HKrXBwhx zFIF0cyF8rM)zn%`C;zME_!+`Brvv$l?lRN0uQHZ_o`N^$GcFVU3!<*d^`$_#0~yX9 zxG!}S-ZQFkKQpoyGa#T8JzRZdmjA1YG!er6`G|kqQi4?U1!c5>Kwa0)gW?5 z#2>Y*y_k;U>5sf3utVMBq=Ub1c)1~WeG_WuHGhfbGYB&-yI%!QJ*|Bv(}ruCuY))5 zM}`wu?rFLQK6jyY{8L4uy49|ldl54plj%;?)f#6f13VbxEpTUk_jY}=O8VIZ`}d^1 U*&`4|@R+&B4!7W2-{RQrFQ=-CsQ>@~ literal 0 HcmV?d00001 diff --git a/samltest/saml2/core/impl/.gitignore b/samltest/saml2/core/impl/.gitignore new file mode 100644 index 0000000..e16b497 --- /dev/null +++ b/samltest/saml2/core/impl/.gitignore @@ -0,0 +1 @@ +/*.cpp diff --git a/samltest/saml2/core/impl/Artifact20Test.h b/samltest/saml2/core/impl/Artifact20Test.h new file mode 100644 index 0000000..b826c78 --- /dev/null +++ b/samltest/saml2/core/impl/Artifact20Test.h @@ -0,0 +1,51 @@ +/* + * 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 Artifact20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedContent; + +public: + void setUp() { + expectedContent=XMLString::transcode("abc123"); + singleElementFile = data_path + "saml2/core/impl/Artifact.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedContent); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + Artifact* artifact = dynamic_cast(xo.get()); + TS_ASSERT(artifact!=NULL); + assertEquals("Artifact text content", expectedContent, artifact->getArtifact()); + } + + void testSingleElementMarshall() { + Artifact * artifact = ArtifactBuilder::buildArtifact(); + artifact->setArtifact(expectedContent); + assertEquals(expectedDOM, artifact); + } + + +}; diff --git a/samltest/saml2/core/impl/ArtifactResolve20Test.h b/samltest/saml2/core/impl/ArtifactResolve20Test.h new file mode 100644 index 0000000..ad2bb4e --- /dev/null +++ b/samltest/saml2/core/impl/ArtifactResolve20Test.h @@ -0,0 +1,122 @@ +/* + * 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")); + + 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()); + assertEquals("IssueInstant attribute", expectedIssueInstant->getFormattedString(), request->getIssueInstant()->getFormattedString()); + + 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 new file mode 100644 index 0000000..e01b9f9 --- /dev/null +++ b/samltest/saml2/core/impl/ArtifactResponse20Test.h @@ -0,0 +1,154 @@ +/* + * 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")); + + 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()); + assertEquals("IssueInstant attribute", expectedIssueInstant->getFormattedString(), response->getIssueInstant()->getFormattedString()); + + 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/AssertionIDRequest20Test.h b/samltest/saml2/core/impl/AssertionIDRequest20Test.h new file mode 100644 index 0000000..8a6dda1 --- /dev/null +++ b/samltest/saml2/core/impl/AssertionIDRequest20Test.h @@ -0,0 +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::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")); + + 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()); + assertEquals("IssueInstant attribute", expectedIssueInstant->getFormattedString(), request->getIssueInstant()->getFormattedString()); + + 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/AttributeQuery20Test.h b/samltest/saml2/core/impl/AttributeQuery20Test.h new file mode 100644 index 0000000..7e9e4df --- /dev/null +++ b/samltest/saml2/core/impl/AttributeQuery20Test.h @@ -0,0 +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::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")); + + 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()); + assertEquals("IssueInstant attribute", expectedIssueInstant->getFormattedString(), query->getIssueInstant()->getFormattedString()); + + 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/AuthnQuery20Test.h b/samltest/saml2/core/impl/AuthnQuery20Test.h new file mode 100644 index 0000000..23275bd --- /dev/null +++ b/samltest/saml2/core/impl/AuthnQuery20Test.h @@ -0,0 +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. + */ + +#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")); + 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()); + assertEquals("IssueInstant attribute", expectedIssueInstant->getFormattedString(), query->getIssueInstant()->getFormattedString()); + + 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 new file mode 100644 index 0000000..979beac --- /dev/null +++ b/samltest/saml2/core/impl/AuthnRequest20Test.h @@ -0,0 +1,182 @@ +/* + * 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")); + 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()); + assertEquals("IssueInstant attribute", expectedIssueInstant->getFormattedString(), request->getIssueInstant()->getFormattedString()); + TSM_ASSERT_EQUALS("ForceAuthn attribute presence", false, request->ForceAuthn().first); + TSM_ASSERT_EQUALS("IsPassive attribute presence", false, request->IsPassive().first); + 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 presence", true, request->ForceAuthn().first); + TSM_ASSERT_EQUALS("ForceAuthn attribute value", expectedForceAuthn, request->ForceAuthn().second); + TSM_ASSERT_EQUALS("IsPassive attribute presence", true, request->IsPassive().first); + TSM_ASSERT_EQUALS("IsPassive attribute value", expectedIsPassive, request->IsPassive().second); + 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", false, request->ForceAuthn().first); + TSM_ASSERT_EQUALS("IsPassive attribute presence", false, request->IsPassive().first); + 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/AuthzDecisionQuery20Test.h b/samltest/saml2/core/impl/AuthzDecisionQuery20Test.h new file mode 100644 index 0000000..1e892a8 --- /dev/null +++ b/samltest/saml2/core/impl/AuthzDecisionQuery20Test.h @@ -0,0 +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 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")); + 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()); + assertEquals("IssueInstant attribute", expectedIssueInstant->getFormattedString(), query->getIssueInstant()->getFormattedString()); + 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/GetComplete20Test.h b/samltest/saml2/core/impl/GetComplete20Test.h new file mode 100644 index 0000000..d50ca98 --- /dev/null +++ b/samltest/saml2/core/impl/GetComplete20Test.h @@ -0,0 +1,51 @@ +/* + * 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 GetComplete20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedContent; + +public: + void setUp() { + expectedContent=XMLString::transcode("http://sp.example.org/idplist.xml"); + singleElementFile = data_path + "saml2/core/impl/GetComplete.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedContent); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + GetComplete* gc = dynamic_cast(xo.get()); + TS_ASSERT(gc!=NULL); + assertEquals("GetComplete text content", expectedContent, gc->getGetComplete()); + } + + void testSingleElementMarshall() { + GetComplete * gc = GetCompleteBuilder::buildGetComplete(); + gc->setGetComplete(expectedContent); + assertEquals(expectedDOM, gc); + } + + +}; diff --git a/samltest/saml2/core/impl/IDPEntry20Test.h b/samltest/saml2/core/impl/IDPEntry20Test.h new file mode 100644 index 0000000..f51d740 --- /dev/null +++ b/samltest/saml2/core/impl/IDPEntry20Test.h @@ -0,0 +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); + } + +}; diff --git a/samltest/saml2/core/impl/IDPList20Test.h b/samltest/saml2/core/impl/IDPList20Test.h new file mode 100644 index 0000000..2231829 --- /dev/null +++ b/samltest/saml2/core/impl/IDPList20Test.h @@ -0,0 +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); + } + +}; diff --git a/samltest/saml2/core/impl/LogoutRequest20Test.h b/samltest/saml2/core/impl/LogoutRequest20Test.h new file mode 100644 index 0000000..ab87823 --- /dev/null +++ b/samltest/saml2/core/impl/LogoutRequest20Test.h @@ -0,0 +1,144 @@ +/* + * 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")); + 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")); + + 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()); + assertEquals("IssueInstant attribute", expectedIssueInstant->getFormattedString(), request->getIssueInstant()->getFormattedString()); + + 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()); + assertEquals("NotOnOrAfter attribute", expectedNotOnOrAfter->getFormattedString(), request->getNotOnOrAfter()->getFormattedString()); + + 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 new file mode 100644 index 0000000..40c9a4e --- /dev/null +++ b/samltest/saml2/core/impl/LogoutResponse20Test.h @@ -0,0 +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 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")); + + 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()); + assertEquals("IssueInstant attribute", expectedIssueInstant->getFormattedString(), response->getIssueInstant()->getFormattedString()); + + 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 new file mode 100644 index 0000000..ad26ac1 --- /dev/null +++ b/samltest/saml2/core/impl/ManageNameIDRequest20Test.h @@ -0,0 +1,136 @@ +/* + * 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")); + 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()); + assertEquals("IssueInstant attribute", expectedIssueInstant->getFormattedString(), request->getIssueInstant()->getFormattedString()); + + 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 new file mode 100644 index 0000000..d7a9105 --- /dev/null +++ b/samltest/saml2/core/impl/ManageNameIDResponse20Test.h @@ -0,0 +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 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")); + + 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()); + assertEquals("IssueInstant attribute", expectedIssueInstant->getFormattedString(), response->getIssueInstant()->getFormattedString()); + + 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/NameIDMappingRequest20Test.h b/samltest/saml2/core/impl/NameIDMappingRequest20Test.h new file mode 100644 index 0000000..877a0da --- /dev/null +++ b/samltest/saml2/core/impl/NameIDMappingRequest20Test.h @@ -0,0 +1,133 @@ +/* + * 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")); + 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()); + assertEquals("IssueInstant attribute", expectedIssueInstant->getFormattedString(), request->getIssueInstant()->getFormattedString()); + + 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 new file mode 100644 index 0000000..379ee7e --- /dev/null +++ b/samltest/saml2/core/impl/NameIDMappingResponse20Test.h @@ -0,0 +1,145 @@ +/* + * 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")); + + 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()); + assertEquals("IssueInstant attribute", expectedIssueInstant->getFormattedString(), response->getIssueInstant()->getFormattedString()); + + 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 new file mode 100644 index 0000000..27418c2 --- /dev/null +++ b/samltest/saml2/core/impl/NameIDPolicy20Test.h @@ -0,0 +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", false, policy->AllowCreate().first); + } + + 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_EQUALS("AllowCreate attribute presence", true, policy->AllowCreate().first); + TSM_ASSERT_EQUALS("AllowCreate attribute value", expectedAllowCreate, policy->AllowCreate().second); + } + + 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/NewEncryptedID20Test.h b/samltest/saml2/core/impl/NewEncryptedID20Test.h new file mode 100644 index 0000000..e9a3ef7 --- /dev/null +++ b/samltest/saml2/core/impl/NewEncryptedID20Test.h @@ -0,0 +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); + } + +}; diff --git a/samltest/saml2/core/impl/NewID20Test.h b/samltest/saml2/core/impl/NewID20Test.h new file mode 100644 index 0000000..6fa1ed9 --- /dev/null +++ b/samltest/saml2/core/impl/NewID20Test.h @@ -0,0 +1,51 @@ +/* + * 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 NewID20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedContent; + +public: + void setUp() { + expectedContent=XMLString::transcode("SomeSAMLNameID"); + singleElementFile = data_path + "saml2/core/impl/NewID.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedContent); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + NewID* newid = dynamic_cast(xo.get()); + TS_ASSERT(newid!=NULL); + assertEquals("NewID text content", expectedContent, newid->getNewID()); + } + + void testSingleElementMarshall() { + NewID * newid = NewIDBuilder::buildNewID(); + newid->setNewID(expectedContent); + assertEquals(expectedDOM, newid); + } + + +}; diff --git a/samltest/saml2/core/impl/RequestedAuthnContext20Test.h b/samltest/saml2/core/impl/RequestedAuthnContext20Test.h new file mode 100644 index 0000000..8695b55 --- /dev/null +++ b/samltest/saml2/core/impl/RequestedAuthnContext20Test.h @@ -0,0 +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; + } + +}; diff --git a/samltest/saml2/core/impl/RequesterID20Test.h b/samltest/saml2/core/impl/RequesterID20Test.h new file mode 100644 index 0000000..c9f1ccf --- /dev/null +++ b/samltest/saml2/core/impl/RequesterID20Test.h @@ -0,0 +1,51 @@ +/* + * 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 RequesterID20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedContent; + +public: + void setUp() { + expectedContent=XMLString::transcode("urn:string:requester"); + singleElementFile = data_path + "saml2/core/impl/RequesterID.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedContent); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + RequesterID* reqid = dynamic_cast(xo.get()); + TS_ASSERT(reqid!=NULL); + assertEquals("RequesterID text content", expectedContent, reqid->getRequesterID()); + } + + void testSingleElementMarshall() { + RequesterID * reqid = RequesterIDBuilder::buildRequesterID(); + reqid->setRequesterID(expectedContent); + assertEquals(expectedDOM, reqid); + } + + +}; diff --git a/samltest/saml2/core/impl/Response20Test.h b/samltest/saml2/core/impl/Response20Test.h new file mode 100644 index 0000000..8989446 --- /dev/null +++ b/samltest/saml2/core/impl/Response20Test.h @@ -0,0 +1,180 @@ +/* + * 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")); + + 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()); + assertEquals("IssueInstant attribute", expectedIssueInstant->getFormattedString(), response->getIssueInstant()->getFormattedString()); + + 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 new file mode 100644 index 0000000..4db0986 --- /dev/null +++ b/samltest/saml2/core/impl/Scoping20Test.h @@ -0,0 +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); + } + +}; diff --git a/samltest/saml2/core/impl/SessionIndex20Test.h b/samltest/saml2/core/impl/SessionIndex20Test.h new file mode 100644 index 0000000..694522d --- /dev/null +++ b/samltest/saml2/core/impl/SessionIndex20Test.h @@ -0,0 +1,51 @@ +/* + * 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 SessionIndex20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedContent; + +public: + void setUp() { + expectedContent=XMLString::transcode("Session1234"); + singleElementFile = data_path + "saml2/core/impl/SessionIndex.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedContent); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + SessionIndex* si = dynamic_cast(xo.get()); + TS_ASSERT(si!=NULL); + assertEquals("SessionIndex text content", expectedContent, si->getSessionIndex()); + } + + void testSingleElementMarshall() { + SessionIndex * si = SessionIndexBuilder::buildSessionIndex(); + si->setSessionIndex(expectedContent); + assertEquals(expectedDOM, si); + } + + +}; diff --git a/samltest/saml2/core/impl/Status20Test.h b/samltest/saml2/core/impl/Status20Test.h new file mode 100644 index 0000000..da96080 --- /dev/null +++ b/samltest/saml2/core/impl/Status20Test.h @@ -0,0 +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); + } + +}; diff --git a/samltest/saml2/core/impl/StatusCode20Test.h b/samltest/saml2/core/impl/StatusCode20Test.h new file mode 100644 index 0000000..139d48b --- /dev/null +++ b/samltest/saml2/core/impl/StatusCode20Test.h @@ -0,0 +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); + } + +}; diff --git a/samltest/saml2/core/impl/StatusDetail20Test.h b/samltest/saml2/core/impl/StatusDetail20Test.h new file mode 100644 index 0000000..03880ff --- /dev/null +++ b/samltest/saml2/core/impl/StatusDetail20Test.h @@ -0,0 +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); + } + +}; diff --git a/samltest/saml2/core/impl/StatusMessage20Test.h b/samltest/saml2/core/impl/StatusMessage20Test.h new file mode 100644 index 0000000..170a3bb --- /dev/null +++ b/samltest/saml2/core/impl/StatusMessage20Test.h @@ -0,0 +1,51 @@ +/* + * 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 StatusMessage20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedContent; + +public: + void setUp() { + expectedContent=XMLString::transcode("Status Message"); + singleElementFile = data_path + "saml2/core/impl/StatusMessage.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedContent); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + StatusMessage* sm = dynamic_cast(xo.get()); + TS_ASSERT(sm!=NULL); + assertEquals("StatusMessage text content", expectedContent, sm->getMessage()); + } + + void testSingleElementMarshall() { + StatusMessage * sm = StatusMessageBuilder::buildStatusMessage(); + sm->setMessage(expectedContent); + assertEquals(expectedDOM, sm); + } + + +}; diff --git a/samltest/saml2/core/impl/StatusResponse20Test.h b/samltest/saml2/core/impl/StatusResponse20Test.h new file mode 100644 index 0000000..834dbd4 --- /dev/null +++ b/samltest/saml2/core/impl/StatusResponse20Test.h @@ -0,0 +1,186 @@ +/* + * 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; + +/* + This tests building an element of type StatusResponseType with a non-SAML element name and namespace + */ + +class StatusResponse20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedID; + XMLCh* expectedInResponseTo; + XMLCh* expectedVersion; + XMLCh* expectedConsent; + XMLCh* expectedDestination; + DateTime* expectedIssueInstant; + + //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() { + 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")); + + elementName = XMLString::transcode("Foo");; + elementNS = XMLString::transcode("http://www.example.org/test"); + elementPrefix = XMLString::transcode("test");; + typeName = StatusResponse::TYPE_NAME; + typeNS = SAMLConstants::SAML20P_NS; + typePrefix = SAMLConstants::SAML20P_PREFIX; + + singleElementFile = data_path + "saml2/core/impl/StatusResponse.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/StatusResponseOptionalAttributes.xml"; + childElementsFile = data_path + "saml2/core/impl/StatusResponseChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedID); + XMLString::release(&expectedInResponseTo); + XMLString::release(&expectedVersion); + XMLString::release(&expectedConsent); + XMLString::release(&expectedDestination); + XMLString::release(&elementName); + XMLString::release(&elementNS); + XMLString::release(&elementPrefix); + delete expectedIssueInstant; + 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)); + StatusResponse* response = dynamic_cast(xo.get()); + TS_ASSERT(response!=NULL); + + checkNameAndType(response); + + assertEquals("ID attribute", expectedID, response->getID()); + assertEquals("Version attribute", expectedVersion, response->getVersion()); + assertEquals("IssueInstant attribute", expectedIssueInstant->getFormattedString(), response->getIssueInstant()->getFormattedString()); + + 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)); + StatusResponse* response = dynamic_cast(xo.get()); + TS_ASSERT(response!=NULL); + + checkNameAndType(response); + + 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)); + StatusResponse* response= dynamic_cast(xo.get()); + TS_ASSERT(response!=NULL); + + checkNameAndType(response); + + TS_ASSERT(response->getIssuer()!=NULL); + TS_ASSERT(response->getSignature()==NULL); + TS_ASSERT(response->getExtensions()==NULL); + TS_ASSERT(response->getStatus()!=NULL); + } + + void testSingleElementMarshall() { + StatusResponse* response = dynamic_cast(buildObject()); + TS_ASSERT(response!=NULL); + checkNameAndType(response); + + response->setID(expectedID); + response->setIssueInstant(expectedIssueInstant); + //response->setVersion(expectedVersion); + assertEquals(expectedDOM, response); + } + + void testSingleElementOptionalAttributesMarshall() { + StatusResponse* response = dynamic_cast(buildObject()); + TS_ASSERT(response!=NULL); + checkNameAndType(response); + + 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() { + StatusResponse* response = dynamic_cast(buildObject()); + TS_ASSERT(response!=NULL); + checkNameAndType(response); + + 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/Terminate20Test.h b/samltest/saml2/core/impl/Terminate20Test.h new file mode 100644 index 0000000..d086094 --- /dev/null +++ b/samltest/saml2/core/impl/Terminate20Test.h @@ -0,0 +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. + */ + +#include "internal.h" +#include + +using namespace opensaml::saml2p; + +class Terminate20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + +public: + void setUp() { + singleElementFile = data_path + "saml2/core/impl/Terminate.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + Terminate* terminate = dynamic_cast(xo.get()); + TS_ASSERT(terminate!=NULL); + } + + void testSingleElementMarshall() { + Terminate * terminate = TerminateBuilder::buildTerminate(); + assertEquals(expectedDOM, terminate); + } + + +}; diff --git a/schemas/.gitignore b/schemas/.gitignore new file mode 100644 index 0000000..182ce7d --- /dev/null +++ b/schemas/.gitignore @@ -0,0 +1,5 @@ +/Makefile +/Makefile.in +/saml10-catalog.xml +/saml11-catalog.xml +/saml20-catalog.xml -- 2.1.4