From: Scott Cantor Date: Thu, 13 Mar 2008 15:51:29 +0000 (+0000) Subject: Add nil flag to AttributeValue. X-Git-Tag: 2.0.0~6 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fcpp-opensaml.git;a=commitdiff_plain;h=fc51c80cb50454ac8f662f076445e9aa36875ddf Add nil flag to AttributeValue. --- diff --git a/saml/saml2/core/Assertions.h b/saml/saml2/core/Assertions.h index 91ac1fe..765b7a9 100644 --- a/saml/saml2/core/Assertions.h +++ b/saml/saml2/core/Assertions.h @@ -314,6 +314,7 @@ namespace opensaml { END_XMLOBJECT; BEGIN_XMLOBJECT(SAML_API,AttributeValue,xmltooling::ElementProxy,SAML 2.0 AttributeValue element); + DECL_BOOLEAN_ATTRIB(Nil,NIL,false); END_XMLOBJECT; BEGIN_XMLOBJECT2(SAML_API,Attribute,xmltooling::AttributeExtensibleXMLObject,EncryptableObject,SAML 2.0 Attribute element); diff --git a/saml/saml2/core/impl/Assertions20Impl.cpp b/saml/saml2/core/impl/Assertions20Impl.cpp index af0dbf0..9a7d4e8 100644 --- a/saml/saml2/core/impl/Assertions20Impl.cpp +++ b/saml/saml2/core/impl/Assertions20Impl.cpp @@ -40,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 ) @@ -1092,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); + } }; @@ -1556,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);