X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fcpp-opensaml.git;a=blobdiff_plain;f=saml%2Fsaml2%2Fcore%2Fimpl%2FAssertions20Impl.cpp;h=9a7d4e8d9e9551fa5b1c0b426a85ce69a683d1ed;hp=f4fe15ac20028e81d8bf2b339779088fcd36c590;hb=fc51c80cb50454ac8f662f076445e9aa36875ddf;hpb=2abbdf45777f2f87dc5fdb25b848756b0e5e87b5 diff --git a/saml/saml2/core/impl/Assertions20Impl.cpp b/saml/saml2/core/impl/Assertions20Impl.cpp index f4fe15a..9a7d4e8 100644 --- a/saml/saml2/core/impl/Assertions20Impl.cpp +++ b/saml/saml2/core/impl/Assertions20Impl.cpp @@ -27,7 +27,6 @@ #include #include -#include #include #include #include @@ -41,10 +40,13 @@ using namespace xmlencryption; using namespace xmlsignature; using namespace xmltooling; using namespace std; +using xmlconstants::XSI_NS; using xmlconstants::XMLSIG_NS; using xmlconstants::XMLENC_NS; +using xmlconstants::XML_BOOL_NULL; using samlconstants::SAML20_NS; + #if defined (_MSC_VER) #pragma warning( push ) #pragma warning( disable : 4250 4251 ) @@ -52,7 +54,7 @@ using samlconstants::SAML20_NS; namespace opensaml { namespace saml2 { - + DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,AssertionIDRef); DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,AssertionURIRef); DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,Audience); @@ -191,24 +193,6 @@ namespace opensaml { } } } - - 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(EncryptedElementType); IMPL_TYPED_FOREIGN_CHILD(EncryptedData,xmlencryption); @@ -222,7 +206,6 @@ namespace opensaml { } }; - //TODO unit test for this class SAML_DLLLOCAL EncryptedIDImpl : public virtual EncryptedID, public EncryptedElementTypeImpl { public: @@ -433,10 +416,7 @@ namespace opensaml { } }; - class SAML_DLLLOCAL SubjectConfirmationDataTypeImpl : public virtual SubjectConfirmationDataType, - public AbstractDOMCachingXMLObject, - public AbstractXMLObjectMarshaller, - public AbstractXMLObjectUnmarshaller + class SAML_DLLLOCAL SubjectConfirmationDataTypeImpl : public virtual SubjectConfirmationDataType, public virtual AbstractXMLObject { void init() { m_NotBefore=m_NotOnOrAfter=NULL; @@ -462,7 +442,7 @@ namespace opensaml { init(); } - SubjectConfirmationDataTypeImpl(const SubjectConfirmationDataTypeImpl& src) : AbstractDOMCachingXMLObject(src) { + SubjectConfirmationDataTypeImpl(const SubjectConfirmationDataTypeImpl& src) : AbstractXMLObject(src) { init(); setNotBefore(src.getNotBefore()); setNotOnOrAfter(src.getNotOnOrAfter()); @@ -492,7 +472,6 @@ namespace opensaml { PROC_STRING_ATTRIB(Recipient,RECIPIENT,NULL); PROC_STRING_ATTRIB(InResponseTo,INRESPONSETO,NULL); PROC_STRING_ATTRIB(Address,ADDRESS,NULL); - AbstractXMLObjectUnmarshaller::processAttribute(attribute); } }; @@ -546,12 +525,24 @@ namespace opensaml { SubjectConfirmationDataTypeImpl::marshallAttributes(domElement); AnyElementImpl::marshallAttributes(domElement); } + + void processAttribute(const DOMAttr* attribute) { + PROC_DATETIME_ATTRIB(NotBefore,NOTBEFORE,NULL); + PROC_DATETIME_ATTRIB(NotOnOrAfter,NOTONORAFTER,NULL); + PROC_STRING_ATTRIB(Recipient,RECIPIENT,NULL); + PROC_STRING_ATTRIB(InResponseTo,INRESPONSETO,NULL); + PROC_STRING_ATTRIB(Address,ADDRESS,NULL); + AnyElementImpl::processAttribute(attribute); + } }; class SAML_DLLLOCAL KeyInfoConfirmationDataTypeImpl : public virtual KeyInfoConfirmationDataType, public SubjectConfirmationDataTypeImpl, public AbstractComplexElement, - public AbstractAttributeExtensibleXMLObject + public AbstractAttributeExtensibleXMLObject, + public AbstractDOMCachingXMLObject, + public AbstractXMLObjectMarshaller, + public AbstractXMLObjectUnmarshaller { public: virtual ~KeyInfoConfirmationDataTypeImpl() {} @@ -562,7 +553,7 @@ namespace opensaml { KeyInfoConfirmationDataTypeImpl(const KeyInfoConfirmationDataTypeImpl& src) : AbstractXMLObject(src), SubjectConfirmationDataTypeImpl(src), AbstractComplexElement(src), - AbstractAttributeExtensibleXMLObject(src) { + AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) { VectorOf(KeyInfo) v=getKeyInfos(); for (vector::const_iterator i=src.m_KeyInfos.begin(); i!=src.m_KeyInfos.end(); ++i) v.push_back((*i)->cloneKeyInfo()); @@ -1104,20 +1095,47 @@ namespace opensaml { } }; - //TODO need unit test for this class SAML_DLLLOCAL AttributeValueImpl : public virtual AttributeValue, public AnyElementImpl { + void init() { + m_Nil=XML_BOOL_NULL; + } public: virtual ~AttributeValueImpl() {} AttributeValueImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { + init(); } AttributeValueImpl(const AttributeValueImpl& src) : AnyElementImpl(src) { + init(); + Nil(m_Nil); } IMPL_XMLOBJECT_CLONE(AttributeValue); + IMPL_BOOLEAN_ATTRIB(Nil); + + void setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID=false) { + if (XMLString::equals(qualifiedName.getNamespaceURI(), xmlconstants::XSI_NS)) { + if (XMLString::equals(qualifiedName.getLocalPart(),NIL_ATTRIB_NAME)) { + setNil(value); + return; + } + } + AnyElementImpl::setAttribute(qualifiedName, value, ID); + } + + protected: + void marshallAttributes(DOMElement* domElement) const { + MARSHALL_BOOLEAN_ATTRIB(Nil,NIL,NULL); + AnyElementImpl::marshallAttributes(domElement); + } + + void processAttribute(const DOMAttr* attribute) { + PROC_BOOLEAN_ATTRIB(Nil,NIL,NULL); + AnyElementImpl::processAttribute(attribute); + } }; @@ -1568,6 +1586,7 @@ const XMLCh Attribute::FRIENDLYNAME_ATTRIB_NAME[] = UNICODE_LITERAL_12(F,r,i,e,n const XMLCh AttributeStatement::LOCAL_NAME[] = UNICODE_LITERAL_18(A,t,t,r,i,b,u,t,e,S,t,a,t,e,m,e,n,t); const XMLCh AttributeStatement::TYPE_NAME[] = UNICODE_LITERAL_22(A,t,t,r,i,b,u,t,e,S,t,a,t,e,m,e,n,t,T,y,p,e); const XMLCh AttributeValue::LOCAL_NAME[] = UNICODE_LITERAL_14(A,t,t,r,i,b,u,t,e,V,a,l,u,e); +const XMLCh AttributeValue::NIL_ATTRIB_NAME[] = UNICODE_LITERAL_3(n,i,l); const XMLCh Audience::LOCAL_NAME[] = UNICODE_LITERAL_8(A,u,d,i,e,n,c,e); const XMLCh AudienceRestriction::LOCAL_NAME[] = UNICODE_LITERAL_19(A,u,d,i,e,n,c,e,R,e,s,t,r,i,c,t,i,o,n); const XMLCh AudienceRestriction::TYPE_NAME[] = UNICODE_LITERAL_23(A,u,d,i,e,n,c,e,R,e,s,t,r,i,c,t,i,o,n,T,y,p,e); @@ -1601,7 +1620,7 @@ const XMLCh EncryptedAssertion::LOCAL_NAME[] = UNICODE_LITERAL_18(E,n,c,r,y const XMLCh EncryptedAttribute::LOCAL_NAME[] = UNICODE_LITERAL_18(E,n,c,r,y,p,t,e,d,A,t,t,r,i,b,u,t,e); const XMLCh EncryptedElementType::LOCAL_NAME[] = {chNull}; const XMLCh EncryptedElementType::TYPE_NAME[] = UNICODE_LITERAL_20(E,n,c,r,y,p,t,e,d,E,l,e,m,e,n,t,T,y,p,e); -const XMLCh EncryptedID::LOCAL_NAME[] = UNICODE_LITERAL_11(E,n,c,r,y,p,t,e,d,I,d); +const XMLCh EncryptedID::LOCAL_NAME[] = UNICODE_LITERAL_11(E,n,c,r,y,p,t,e,d,I,D); const XMLCh Evidence::LOCAL_NAME[] = UNICODE_LITERAL_8(E,v,i,d,e,n,c,e); const XMLCh Evidence::TYPE_NAME[] = UNICODE_LITERAL_12(E,v,i,d,e,n,c,e,T,y,p,e); const XMLCh Issuer::LOCAL_NAME[] = UNICODE_LITERAL_6(I,s,s,u,e,r);