From 051466742f8c7ceb2d3eb4f08041272f5a4bb02a Mon Sep 17 00:00:00 2001 From: Scott Cantor Date: Thu, 31 Aug 2006 23:57:47 +0000 Subject: [PATCH] Revise boolean attribute methods to handle defaults. --- saml/saml2/core/Protocols.h | 6 +++--- saml/saml2/metadata/Metadata.h | 14 +++++++------- samltest/saml2/core/impl/AuthnRequest20Test.h | 14 ++++++-------- samltest/saml2/core/impl/NameIDPolicy20Test.h | 6 +++--- 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/saml/saml2/core/Protocols.h b/saml/saml2/core/Protocols.h index f43149d..4b0dcf8 100644 --- a/saml/saml2/core/Protocols.h +++ b/saml/saml2/core/Protocols.h @@ -223,7 +223,7 @@ namespace opensaml { BEGIN_XMLOBJECT(SAML_API,NameIDPolicy,xmltooling::XMLObject,SAML 2.0 NameIDPolicy element); DECL_STRING_ATTRIB(Format,FORMAT); DECL_STRING_ATTRIB(SPNameQualifier,SPNAMEQUALIFIER); - DECL_BOOLEAN_ATTRIB(AllowCreate,ALLOWCREATE); + DECL_BOOLEAN_ATTRIB(AllowCreate,ALLOWCREATE,false); /** NameIDPolicyType local name */ static const XMLCh TYPE_NAME[]; END_XMLOBJECT; @@ -252,8 +252,8 @@ namespace opensaml { END_XMLOBJECT; BEGIN_XMLOBJECT(SAML_API,AuthnRequest,Request,SAML 2.0 AuthnRequest element); - DECL_BOOLEAN_ATTRIB(ForceAuthn,FORCEAUTHN); - DECL_BOOLEAN_ATTRIB(IsPassive,ISPASSIVE); + DECL_BOOLEAN_ATTRIB(ForceAuthn,FORCEAUTHN,false); + DECL_BOOLEAN_ATTRIB(IsPassive,ISPASSIVE,false); DECL_STRING_ATTRIB(ProtocolBinding,PROTOCOLBINDING); DECL_INTEGER_ATTRIB(AssertionConsumerServiceIndex,ASSERTIONCONSUMERSERVICEINDEX); DECL_STRING_ATTRIB(AssertionConsumerServiceURL,ASSERTIONCONSUMERSERVICEURL); diff --git a/saml/saml2/metadata/Metadata.h b/saml/saml2/metadata/Metadata.h index dd1b88e..eee2f66 100644 --- a/saml/saml2/metadata/Metadata.h +++ b/saml/saml2/metadata/Metadata.h @@ -190,7 +190,7 @@ namespace opensaml { BEGIN_XMLOBJECT(SAML_API,IndexedEndpointType,EndpointType,SAML 2.0 IndexedEndpointType type); DECL_INTEGER_ATTRIB(Index,INDEX); - DECL_BOOLEAN_ATTRIB(isDefault,ISDEFAULT); + DECL_BOOLEAN_ATTRIB(isDefault,ISDEFAULT,false); /** IndexedEndpointType local name */ static const XMLCh TYPE_NAME[]; END_XMLOBJECT; @@ -223,7 +223,7 @@ namespace opensaml { END_XMLOBJECT; BEGIN_XMLOBJECT(SAML_API,IDPSSODescriptor,SSODescriptorType,SAML 2.0 IDPSSODescriptor element); - DECL_BOOLEAN_ATTRIB(WantAuthnRequestsSigned,WANTAUTHNREQUESTSSIGNED); + DECL_BOOLEAN_ATTRIB(WantAuthnRequestsSigned,WANTAUTHNREQUESTSSIGNED,false); DECL_TYPED_CHILDREN(SingleSignOnService); DECL_TYPED_CHILDREN(NameIDMappingService); DECL_TYPED_CHILDREN(AssertionIDRequestService); @@ -242,14 +242,14 @@ namespace opensaml { END_XMLOBJECT; BEGIN_XMLOBJECT(SAML_API,RequestedAttribute,saml2::Attribute,SAML 2.0 RequestedAttribute element); - DECL_BOOLEAN_ATTRIB(isRequired,ISREQUIRED); + DECL_BOOLEAN_ATTRIB(isRequired,ISREQUIRED,false); /** RequestedAttributeType local name */ static const XMLCh TYPE_NAME[]; END_XMLOBJECT; BEGIN_XMLOBJECT(SAML_API,AttributeConsumingService,xmltooling::XMLObject,SAML 2.0 AttributeConsumingService element); DECL_INTEGER_ATTRIB(Index,INDEX); - DECL_BOOLEAN_ATTRIB(isDefault,ISDEFAULT); + DECL_BOOLEAN_ATTRIB(isDefault,ISDEFAULT,false); DECL_TYPED_CHILDREN(ServiceName); DECL_TYPED_CHILDREN(ServiceDescription); DECL_TYPED_CHILDREN(RequestedAttribute); @@ -261,8 +261,8 @@ namespace opensaml { END_XMLOBJECT; BEGIN_XMLOBJECT(SAML_API,SPSSODescriptor,SSODescriptorType,SAML 2.0 SPSSODescriptor element); - DECL_BOOLEAN_ATTRIB(AuthnRequestsSigned,AUTHNREQUESTSSIGNED); - DECL_BOOLEAN_ATTRIB(WantAssertionsSigned,WANTASSERTIONSSIGNED); + DECL_BOOLEAN_ATTRIB(AuthnRequestsSigned,AUTHNREQUESTSSIGNED,false); + DECL_BOOLEAN_ATTRIB(WantAssertionsSigned,WANTASSERTIONSSIGNED,false); DECL_TYPED_CHILDREN(AssertionConsumerService); DECL_TYPED_CHILDREN(AttributeConsumingService); /** SPSSODescriptorType local name */ @@ -305,7 +305,7 @@ namespace opensaml { END_XMLOBJECT; BEGIN_XMLOBJECT(SAML_API,QueryDescriptorType,RoleDescriptor,SAML 2.0 QueryDescriptorType abstract type); - DECL_BOOLEAN_ATTRIB(WantAssertionsSigned,WANTASSERTIONSSIGNED); + DECL_BOOLEAN_ATTRIB(WantAssertionsSigned,WANTASSERTIONSSIGNED,false); DECL_TYPED_CHILDREN(NameIDFormat); /** QueryDescriptorType local name */ static const XMLCh TYPE_NAME[]; diff --git a/samltest/saml2/core/impl/AuthnRequest20Test.h b/samltest/saml2/core/impl/AuthnRequest20Test.h index 5c5a689..140d675 100644 --- a/samltest/saml2/core/impl/AuthnRequest20Test.h +++ b/samltest/saml2/core/impl/AuthnRequest20Test.h @@ -76,8 +76,8 @@ public: assertEquals("ID attribute", expectedID, request->getID()); assertEquals("Version attribute", expectedVersion, request->getVersion()); TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), request->getIssueInstant()->getEpoch()); - TSM_ASSERT_EQUALS("ForceAuthn attribute presence", false, request->ForceAuthn().first); - TSM_ASSERT_EQUALS("IsPassive attribute presence", false, request->IsPassive().first); + TSM_ASSERT_EQUALS("ForceAuthn attribute presence", XMLConstants::XML_BOOL_NULL, request->getForceAuthn()); + TSM_ASSERT_EQUALS("IsPassive attribute presence", XMLConstants::XML_BOOL_NULL, request->getIsPassive()); TSM_ASSERT_EQUALS("AssertionConsumerServiceIndex attribute presence",false, request->getAssertionConsumerServiceIndex().first); TSM_ASSERT_EQUALS("AttributeConsumingServiceIndex attribute presence", false, request->getAttributeConsumingServiceIndex().first); @@ -98,10 +98,8 @@ public: 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); + TSM_ASSERT_EQUALS("ForceAuthn attribute value", expectedForceAuthn, request->ForceAuthn()); + TSM_ASSERT_EQUALS("IsPassive attribute value", expectedIsPassive, request->IsPassive()); assertEquals("ProtocolBinding attribute", expectedProtocolBinding,request->getProtocolBinding()); TSM_ASSERT_EQUALS("AssertionConsumerServiceIndex attribute presence",true, request->getAssertionConsumerServiceIndex().first); TSM_ASSERT_EQUALS("AssertionConsumerServiceIndex attribute value",expectedAssertionConsumerServiceIndex, request->getAssertionConsumerServiceIndex().second); @@ -132,8 +130,8 @@ public: 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("ForceAuthn attribute presence", XMLConstants::XML_BOOL_NULL, request->getForceAuthn()); + TSM_ASSERT_EQUALS("IsPassive attribute presence", XMLConstants::XML_BOOL_NULL, request->getIsPassive()); TSM_ASSERT_EQUALS("AssertionConsumerServiceIndex attribute presence",false, request->getAssertionConsumerServiceIndex().first); TSM_ASSERT_EQUALS("AttributeConsumingServiceIndex attribute presence", false, request->getAttributeConsumingServiceIndex().first); } diff --git a/samltest/saml2/core/impl/NameIDPolicy20Test.h b/samltest/saml2/core/impl/NameIDPolicy20Test.h index 27418c2..ac4e292 100644 --- a/samltest/saml2/core/impl/NameIDPolicy20Test.h +++ b/samltest/saml2/core/impl/NameIDPolicy20Test.h @@ -47,7 +47,7 @@ public: 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); + TSM_ASSERT_EQUALS("AllowCreate attribute presence", XMLConstants::XML_BOOL_NULL, policy->getAllowCreate()); } void testSingleElementOptionalAttributesUnmarshall() { @@ -56,8 +56,8 @@ public: 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); + TSM_ASSERT_DIFFERS("AllowCreate attribute presence", XMLConstants::XML_BOOL_NULL, policy->getAllowCreate()); + TSM_ASSERT_EQUALS("AllowCreate attribute value", expectedAllowCreate, policy->AllowCreate()); } void testSingleElementMarshall() { -- 2.1.4