X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=saml%2Fsaml1%2Fcore%2Fimpl%2FProtocolsImpl.cpp;h=e3becd65b9558ea67affe96e9c2b1e72b9d6b8fc;hb=0beb48ce00d0b6a3f177f7d9b48af1870ee92190;hp=6f73c7932097dc02c8acc242ddbcd8206d54254f;hpb=9ed63e5f63e98b3697c439fb5d1e664d00db751f;p=shibboleth%2Fcpp-opensaml.git diff --git a/saml/saml1/core/impl/ProtocolsImpl.cpp b/saml/saml1/core/impl/ProtocolsImpl.cpp index 6f73c79..e3becd6 100644 --- a/saml/saml1/core/impl/ProtocolsImpl.cpp +++ b/saml/saml1/core/impl/ProtocolsImpl.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2006 Internet2 + * Copyright 2001-2007 Internet2 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,11 +22,10 @@ #include "internal.h" #include "exceptions.h" +#include "saml1/core/Assertions.h" #include "saml1/core/Protocols.h" -#include #include -#include #include #include #include @@ -38,10 +37,14 @@ using namespace opensaml::saml1p; using namespace opensaml::saml1; -using namespace opensaml; using namespace xmlsignature; using namespace xmltooling; using namespace std; +using xmlconstants::XMLSIG_NS; +using xmlconstants::XML_ONE; +using samlconstants::SAML1P_NS; +using samlconstants::SAML1_NS; +using samlconstants::SAML1P_PREFIX; #if defined (_MSC_VER) #pragma warning( push ) @@ -55,8 +58,7 @@ namespace opensaml { DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,StatusMessage); class SAML_DLLLOCAL RespondWithImpl : public virtual RespondWith, - protected AbstractSimpleElement, - public AbstractChildlessElement, + public AbstractSimpleElement, public AbstractDOMCachingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller @@ -91,7 +93,6 @@ namespace opensaml { } IMPL_XMLOBJECT_CLONE(RespondWith); - IMPL_XMLOBJECT_CONTENT; }; class SAML_DLLLOCAL SubjectQueryImpl : public virtual SubjectQuery, @@ -117,7 +118,8 @@ namespace opensaml { init(); } - SubjectQueryImpl(const SubjectQueryImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { + SubjectQueryImpl(const SubjectQueryImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); if (src.getSubject()) setSubject(src.getSubject()->cloneSubject()); @@ -127,7 +129,7 @@ namespace opensaml { protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_CHILD(Subject,SAMLConstants::SAML1_NS,true); + PROC_TYPED_CHILD(Subject,SAML1_NS,true); AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); } }; @@ -216,7 +218,7 @@ namespace opensaml { } void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_CHILDREN(AttributeDesignator,SAMLConstants::SAML1_NS,true); + PROC_TYPED_CHILDREN(AttributeDesignator,SAML1_NS,true); SubjectQueryImpl::processChildElement(childXMLObject,root); } @@ -276,8 +278,8 @@ namespace opensaml { } void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_CHILD(Evidence,SAMLConstants::SAML1_NS,false); - PROC_TYPED_CHILDREN(Action,SAMLConstants::SAML1_NS,false); + PROC_TYPED_CHILD(Evidence,SAML1_NS,false); + PROC_TYPED_CHILDREN(Action,SAML1_NS,false); SubjectQueryImpl::processChildElement(childXMLObject,root); } @@ -317,7 +319,8 @@ namespace opensaml { init(); } - RequestAbstractTypeImpl(const RequestAbstractTypeImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { + RequestAbstractTypeImpl(const RequestAbstractTypeImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); setMinorVersion(src.m_MinorVersion); setRequestID(src.getRequestID()); @@ -356,15 +359,18 @@ namespace opensaml { pair v = getMinorVersion(); return (!v.first || v.second > 0) ? m_RequestID : NULL; } + const XMLCh* getID() const { + return getRequestID(); + } IMPL_DATETIME_ATTRIB(IssueInstant,0); IMPL_TYPED_CHILDREN(RespondWith,m_pos_Signature); protected: void marshallAttributes(DOMElement* domElement) const { static const XMLCh MAJORVERSION[] = UNICODE_LITERAL_12(M,a,j,o,r,V,e,r,s,i,o,n); - domElement->setAttributeNS(NULL,MAJORVERSION,XMLConstants::XML_ONE); + domElement->setAttributeNS(NULL,MAJORVERSION,XML_ONE); if (!m_MinorVersion) - const_cast(this)->m_MinorVersion=XMLString::replicate(XMLConstants::XML_ONE); + const_cast(this)->m_MinorVersion=XMLString::replicate(XML_ONE); MARSHALL_INTEGER_ATTRIB(MinorVersion,MINORVERSION,NULL); if (!m_RequestID) const_cast(this)->m_RequestID=SAMLConfig::getConfig().generateIdentifier(); @@ -377,15 +383,15 @@ namespace opensaml { } void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_CHILDREN(RespondWith,SAMLConstants::SAML1P_NS,false); - PROC_TYPED_CHILD(Signature,XMLConstants::XMLSIG_NS,false); + PROC_TYPED_CHILDREN(RespondWith,SAML1P_NS,false); + PROC_TYPED_CHILD(Signature,XMLSIG_NS,false); AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); } void processAttribute(const DOMAttr* attribute) { static const XMLCh MAJORVERSION[] = UNICODE_LITERAL_12(M,a,j,o,r,V,e,r,s,i,o,n); if (XMLHelper::isNodeNamed(attribute,NULL,MAJORVERSION)) { - if (!XMLString::equals(attribute->getValue(),XMLConstants::XML_ONE)) + if (!XMLString::equals(attribute->getValue(),XML_ONE)) throw UnmarshallingException("Request has invalid major version."); } PROC_INTEGER_ATTRIB(MinorVersion,MINORVERSION,NULL); @@ -465,9 +471,9 @@ namespace opensaml { protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_CHILD(Query,SAMLConstants::SAML1P_NS,true); - PROC_TYPED_CHILDREN(AssertionIDReference,SAMLConstants::SAML1_NS,false); - PROC_TYPED_CHILDREN(AssertionArtifact,SAMLConstants::SAML1P_NS,false); + PROC_TYPED_CHILD(Query,SAML1P_NS,true); + PROC_TYPED_CHILDREN(AssertionIDReference,SAML1_NS,false); + PROC_TYPED_CHILDREN(AssertionArtifact,SAML1P_NS,false); RequestAbstractTypeImpl::processChildElement(childXMLObject,root); } }; @@ -494,7 +500,8 @@ namespace opensaml { init(); } - StatusCodeImpl(const StatusCodeImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { + StatusCodeImpl(const StatusCodeImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); setValue(src.getValue()); if (src.getStatusCode()) @@ -511,7 +518,7 @@ namespace opensaml { } void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_CHILD(StatusCode,SAMLConstants::SAML1P_NS,true); + PROC_TYPED_CHILD(StatusCode,SAML1P_NS,true); AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); } @@ -533,21 +540,19 @@ namespace opensaml { : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - StatusDetailImpl(const StatusDetailImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { - VectorOf(XMLObject) v=getDetails(); - for (vector::const_iterator i=src.m_Details.begin(); i!=src.m_Details.end(); i++) { - if (*i) { - v.push_back((*i)->clone()); - } - } + StatusDetailImpl(const StatusDetailImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { + VectorOf(XMLObject) v=getUnknownXMLObjects(); + for (vector::const_iterator i=src.m_UnknownXMLObjects.begin(); i!=src.m_UnknownXMLObjects.end(); ++i) + v.push_back((*i)->clone()); } IMPL_XMLOBJECT_CLONE(StatusDetail); - IMPL_XMLOBJECT_CHILDREN(Detail,m_children.end()); + IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject,m_children.end()); protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - getDetails().push_back(childXMLObject); + getUnknownXMLObjects().push_back(childXMLObject); } }; @@ -578,7 +583,8 @@ namespace opensaml { init(); } - StatusImpl(const StatusImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { + StatusImpl(const StatusImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); if (src.getStatusCode()) setStatusCode(src.getStatusCode()->cloneStatusCode()); @@ -595,9 +601,9 @@ namespace opensaml { protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_CHILD(StatusCode,SAMLConstants::SAML1P_NS,false); - PROC_TYPED_CHILD(StatusMessage,SAMLConstants::SAML1P_NS,false); - PROC_TYPED_CHILD(StatusDetail,SAMLConstants::SAML1P_NS,false); + PROC_TYPED_CHILD(StatusCode,SAML1P_NS,false); + PROC_TYPED_CHILD(StatusMessage,SAML1P_NS,false); + PROC_TYPED_CHILD(StatusDetail,SAML1P_NS,false); AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); } }; @@ -636,7 +642,8 @@ namespace opensaml { init(); } - ResponseAbstractTypeImpl(const ResponseAbstractTypeImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { + ResponseAbstractTypeImpl(const ResponseAbstractTypeImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); setMinorVersion(src.m_MinorVersion); setResponseID(src.getResponseID()); @@ -671,6 +678,9 @@ namespace opensaml { pair v = getMinorVersion(); return (!v.first || v.second > 0) ? m_ResponseID : NULL; } + const XMLCh* getID() const { + return getResponseID(); + } IMPL_STRING_ATTRIB(InResponseTo); IMPL_DATETIME_ATTRIB(IssueInstant,0); IMPL_STRING_ATTRIB(Recipient); @@ -678,9 +688,9 @@ namespace opensaml { protected: void marshallAttributes(DOMElement* domElement) const { static const XMLCh MAJORVERSION[] = UNICODE_LITERAL_12(M,a,j,o,r,V,e,r,s,i,o,n); - domElement->setAttributeNS(NULL,MAJORVERSION,XMLConstants::XML_ONE); + domElement->setAttributeNS(NULL,MAJORVERSION,XML_ONE); if (!m_MinorVersion) - const_cast(this)->m_MinorVersion=XMLString::replicate(XMLConstants::XML_ONE); + const_cast(this)->m_MinorVersion=XMLString::replicate(XML_ONE); MARSHALL_INTEGER_ATTRIB(MinorVersion,MINORVERSION,NULL); if (!m_ResponseID) const_cast(this)->m_ResponseID=SAMLConfig::getConfig().generateIdentifier(); @@ -695,14 +705,14 @@ namespace opensaml { } void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_CHILD(Signature,XMLConstants::XMLSIG_NS,false); + PROC_TYPED_CHILD(Signature,XMLSIG_NS,false); AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); } void processAttribute(const DOMAttr* attribute) { static const XMLCh MAJORVERSION[] = UNICODE_LITERAL_12(M,a,j,o,r,V,e,r,s,i,o,n); if (XMLHelper::isNodeNamed(attribute,NULL,MAJORVERSION)) { - if (!XMLString::equals(attribute->getValue(),XMLConstants::XML_ONE)) + if (!XMLString::equals(attribute->getValue(),XML_ONE)) throw UnmarshallingException("Response has invalid major version."); } PROC_INTEGER_ATTRIB(MinorVersion,MINORVERSION,NULL); @@ -733,8 +743,8 @@ namespace opensaml { init(); if (src.getStatus()) setStatus(src.getStatus()->cloneStatus()); - VectorOf(Assertion) v=getAssertions(); - for (vector::const_iterator i=src.m_Assertions.begin(); i!=src.m_Assertions.end(); i++) { + VectorOf(saml1::Assertion) v=getAssertions(); + for (vector::const_iterator i=src.m_Assertions.begin(); i!=src.m_Assertions.end(); i++) { if (*i) { v.push_back((*i)->cloneAssertion()); } @@ -746,12 +756,12 @@ namespace opensaml { return cloneResponse(); } IMPL_TYPED_CHILD(Status); - IMPL_TYPED_CHILDREN(Assertion, m_children.end()); + IMPL_TYPED_FOREIGN_CHILDREN(Assertion,saml1,m_children.end()); protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { - PROC_TYPED_CHILD(Status,SAMLConstants::SAML1P_NS,false); - PROC_TYPED_CHILDREN(Assertion,SAMLConstants::SAML1_NS,true); + PROC_TYPED_CHILD(Status,SAML1P_NS,false); + PROC_TYPED_FOREIGN_CHILDREN(Assertion,saml1,SAML1_NS,true); ResponseAbstractTypeImpl::processChildElement(childXMLObject,root); } }; @@ -824,7 +834,7 @@ const XMLCh _REQUESTER[] = UNICODE_LITERAL_9(R, const XMLCh _RESPONDER[] = UNICODE_LITERAL_9(R,e,s,p,o,n,d,e,r); const XMLCh _VERSIONMISMATCH[] = UNICODE_LITERAL_15(V,e,r,s,i,o,n,M,i,s,m,a,t,c,h); -QName StatusCode::SUCCESS(SAMLConstants::SAML1P_NS,_SUCCESS,SAMLConstants::SAML1P_PREFIX); -QName StatusCode::REQUESTER(SAMLConstants::SAML1P_NS,_REQUESTER,SAMLConstants::SAML1P_PREFIX); -QName StatusCode::RESPONDER(SAMLConstants::SAML1P_NS,_RESPONDER,SAMLConstants::SAML1P_PREFIX); -QName StatusCode::VERSIONMISMATCH(SAMLConstants::SAML1P_NS,_VERSIONMISMATCH,SAMLConstants::SAML1P_PREFIX); +QName StatusCode::SUCCESS(SAML1P_NS,_SUCCESS,SAML1P_PREFIX); +QName StatusCode::REQUESTER(SAML1P_NS,_REQUESTER,SAML1P_PREFIX); +QName StatusCode::RESPONDER(SAML1P_NS,_RESPONDER,SAML1P_PREFIX); +QName StatusCode::VERSIONMISMATCH(SAML1P_NS,_VERSIONMISMATCH,SAML1P_PREFIX);