public AbstractXMLObjectMarshaller,
public AbstractXMLObjectUnmarshaller
{
+ protected:
+ SubjectStatementImpl() {}
public:
virtual ~SubjectStatementImpl() {}
}
AuthenticationStatementImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
- : SubjectStatementImpl(nsURI, localName, prefix, schemaType) {
+ : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
init();
}
}
AuthorizationDecisionStatementImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
- : SubjectStatementImpl(nsURI, localName, prefix, schemaType) {
+ : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
init();
}
virtual ~AttributeStatementImpl() {}
AttributeStatementImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
- : SubjectStatementImpl(nsURI, localName, prefix, schemaType) {
+ : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
init();
}
getAuthenticationStatements().push_back(authst->cloneAuthenticationStatement());
continue;
}
+
+ AttributeStatement* attst=dynamic_cast<AttributeStatement*>(*i);
+ if (attst) {
+ getAttributeStatements().push_back(attst->cloneAttributeStatement());
+ continue;
+ }
+
+ AuthorizationDecisionStatement* authzst=dynamic_cast<AuthorizationDecisionStatement*>(*i);
+ if (authzst) {
+ getAuthorizationDecisionStatements().push_back(authzst->cloneAuthorizationDecisionStatement());
+ continue;
+ }
SubjectStatement* subst=dynamic_cast<SubjectStatement*>(*i);
if (subst) {
IMPL_TYPED_CHILDREN(Statement, m_pos_Signature);
IMPL_TYPED_CHILDREN(SubjectStatement, m_pos_Signature);
IMPL_TYPED_CHILDREN(AuthenticationStatement, m_pos_Signature);
+ IMPL_TYPED_CHILDREN(AttributeStatement, m_pos_Signature);
+ IMPL_TYPED_CHILDREN(AuthorizationDecisionStatement, m_pos_Signature);
protected:
void marshallAttributes(DOMElement* domElement) const {
PROC_TYPED_CHILD(Advice,SAMLConstants::SAML1_NS,false);
PROC_TYPED_CHILD(Signature,XMLConstants::XMLSIG_NS,false);
PROC_TYPED_CHILDREN(AuthenticationStatement,SAMLConstants::SAML1_NS,false);
+ PROC_TYPED_CHILDREN(AttributeStatement,SAMLConstants::SAML1_NS,false);
+ PROC_TYPED_CHILDREN(AuthorizationDecisionStatement,SAMLConstants::SAML1_NS,false);
PROC_TYPED_CHILDREN(SubjectStatement,SAMLConstants::SAML1_NS,true);
PROC_TYPED_CHILDREN(Statement,SAMLConstants::SAML1_NS,true);
AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
--- /dev/null
+/*\r
+ * Copyright 2001-2006 Internet2\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#include "internal.h"\r
+#include <saml/saml1/core/Assertions.h>\r
+\r
+using namespace opensaml::saml1;\r
+\r
+class AssertionTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {\r
+ int expectedMinorVersion;\r
+ XMLCh* expectedIssuer;\r
+ XMLCh* expectedIssueInstant;\r
+ XMLCh* expectedID;\r
+\r
+public:\r
+ void setUp() {\r
+ expectedID=XMLString::transcode("ident");\r
+ expectedMinorVersion=1;\r
+ expectedIssueInstant=XMLString::transcode("1970-01-02T01:01:02.100Z");\r
+ expectedIssuer=XMLString::transcode("issuer");\r
+ singleElementFile = data_path + "saml1/core/impl/singleAssertion.xml";\r
+ singleElementOptionalAttributesFile = data_path + "saml1/core/impl/singleAssertionAttributes.xml";\r
+ childElementsFile = data_path + "saml1/core/impl/AssertionWithChildren.xml"; \r
+ SAMLObjectBaseTestCase::setUp();\r
+ }\r
+ \r
+ void tearDown() {\r
+ XMLString::release(&expectedID);\r
+ XMLString::release(&expectedIssueInstant);\r
+ XMLString::release(&expectedIssuer);\r
+ SAMLObjectBaseTestCase::tearDown();\r
+ }\r
+\r
+ void testSingleElementUnmarshall() {\r
+ auto_ptr<XMLObject> xo(unmarshallElement(singleElementFile));\r
+ Assertion& assertion = dynamic_cast<Assertion&>(*xo.get());\r
+ TSM_ASSERT("Issuer attribute", assertion.getIssuer()==NULL);\r
+ TSM_ASSERT_SAME_DATA("IssueInstant attribute", expectedIssueInstant, assertion.getIssueInstant()->getRawData(), XMLString::stringLen(expectedIssueInstant));\r
+ TSM_ASSERT_SAME_DATA("ID attribute", expectedID, assertion.getAssertionID(), XMLString::stringLen(expectedID));\r
+\r
+ TSM_ASSERT("Conditions element", assertion.getConditions()==NULL);\r
+ TSM_ASSERT("Advice element", assertion.getAdvice()==NULL);\r
+\r
+ TSM_ASSERT_EQUALS("Statement element count", 0, assertion.getStatements().size());\r
+ TSM_ASSERT_EQUALS("SubjectStatements element count", 0, assertion.getSubjectStatements().size());\r
+ TSM_ASSERT_EQUALS("AttributeStatements element count", 0, assertion.getAttributeStatements().size());\r
+ TSM_ASSERT_EQUALS("AuthenticationStatements element count", 0, assertion.getAuthenticationStatements().size());\r
+ TSM_ASSERT_EQUALS("AuthorizationDecisionStatements element count", 0, assertion.getAuthorizationDecisionStatements().size());\r
+ }\r
+\r
+ void testSingleElementOptionalAttributesUnmarshall() {\r
+ auto_ptr<XMLObject> xo(unmarshallElement(singleElementOptionalAttributesFile));\r
+ Assertion& assertion = dynamic_cast<Assertion&>(*xo.get());\r
+\r
+ TSM_ASSERT_SAME_DATA("Issuer attribute", expectedIssuer, assertion.getIssuer(), XMLString::stringLen(expectedIssuer));\r
+ TSM_ASSERT_SAME_DATA("IssueInstant attribute", expectedIssueInstant, assertion.getIssueInstant()->getRawData(), XMLString::stringLen(expectedIssueInstant));\r
+ TSM_ASSERT_SAME_DATA("ID attribute", expectedID, assertion.getAssertionID(), XMLString::stringLen(expectedID));\r
+ TSM_ASSERT_EQUALS("Issuer expectedMinorVersion", expectedMinorVersion, assertion.getMinorVersion());\r
+\r
+ TSM_ASSERT("Conditions element", assertion.getConditions()==NULL);\r
+ TSM_ASSERT("Advice element", assertion.getAdvice()==NULL);\r
+\r
+ TSM_ASSERT_EQUALS("Statement element count", 0, assertion.getStatements().size());\r
+ TSM_ASSERT_EQUALS("SubjectStatements element count", 0, assertion.getSubjectStatements().size());\r
+ TSM_ASSERT_EQUALS("AttributeStatements element count", 0, assertion.getAttributeStatements().size());\r
+ TSM_ASSERT_EQUALS("AuthenticationStatements element count", 0, assertion.getAuthenticationStatements().size());\r
+ TSM_ASSERT_EQUALS("AuthorizationDecisionStatements element count", 0, assertion.getAuthorizationDecisionStatements().size());\r
+ }\r
+\r
+ void testChildElementsUnmarshall() {\r
+ auto_ptr<XMLObject> xo(unmarshallElement(childElementsFile));\r
+ Assertion& assertion = dynamic_cast<Assertion&>(*xo.get());\r
+\r
+ TSM_ASSERT("Issuer attribute", assertion.getIssuer()==NULL);\r
+ TSM_ASSERT_SAME_DATA("IssueInstant attribute", expectedIssueInstant, assertion.getIssueInstant()->getRawData(), XMLString::stringLen(expectedIssueInstant));\r
+ TSM_ASSERT_SAME_DATA("ID attribute", expectedID, assertion.getAssertionID(), XMLString::stringLen(expectedID));\r
+\r
+ TSM_ASSERT("Conditions element null", assertion.getConditions()!=NULL);\r
+ TSM_ASSERT("Advice element null", assertion.getAdvice()!=NULL);\r
+\r
+ TSM_ASSERT_EQUALS("AuthenticationStatements element count", 2, assertion.getAuthenticationStatements().size());\r
+ TSM_ASSERT_EQUALS("AttributeStatements element count", 3, assertion.getAttributeStatements().size());\r
+ TSM_ASSERT_EQUALS("AuthorizationDecisionStatements element count", 3, assertion.getAuthorizationDecisionStatements().size());\r
+ }\r
+\r
+ void testSingleElementMarshall() {\r
+ Assertion* assertion=AssertionBuilder::buildAssertion();\r
+ assertion->setAssertionID(expectedID);\r
+ assertion->setIssueInstant(expectedIssueInstant);\r
+ assertEquals(expectedDOM, assertion);\r
+ }\r
+\r
+ void testSingleElementOptionalAttributesMarshall() {\r
+ Assertion* assertion=AssertionBuilder::buildAssertion();\r
+ assertion->setIssueInstant(expectedIssueInstant);\r
+ assertion->setAssertionID(expectedID);\r
+ assertion->setIssuer(expectedIssuer);\r
+ assertEquals(expectedOptionalAttributesDOM, assertion);\r
+ }\r
+\r
+ void testChildElementsMarshall() {\r
+ Assertion* assertion=AssertionBuilder::buildAssertion();\r
+ assertion->setIssueInstant(expectedIssueInstant);\r
+ assertion->setAssertionID(expectedID);\r
+ assertion->setConditions(ConditionsBuilder::buildConditions());\r
+ assertion->setAdvice(AdviceBuilder::buildAdvice());\r
+ assertion->getAuthenticationStatements().push_back(\r
+ AuthenticationStatementBuilder::buildAuthenticationStatement()\r
+ );\r
+ assertion->getAuthorizationDecisionStatements().push_back(\r
+ AuthorizationDecisionStatementBuilder::buildAuthorizationDecisionStatement()\r
+ );\r
+ assertion->getAttributeStatements().push_back(\r
+ AttributeStatementBuilder::buildAttributeStatement()\r
+ );\r
+ assertion->getAuthenticationStatements().push_back(\r
+ AuthenticationStatementBuilder::buildAuthenticationStatement()\r
+ );\r
+ assertion->getAuthorizationDecisionStatements().push_back(\r
+ AuthorizationDecisionStatementBuilder::buildAuthorizationDecisionStatement()\r
+ );\r
+ assertion->getAttributeStatements().push_back(\r
+ AttributeStatementBuilder::buildAttributeStatement()\r
+ );\r
+ assertion->getAuthorizationDecisionStatements().push_back(\r
+ AuthorizationDecisionStatementBuilder::buildAuthorizationDecisionStatement()\r
+ );\r
+ assertion->getAttributeStatements().push_back(\r
+ AttributeStatementBuilder::buildAttributeStatement()\r
+ );\r
+ assertEquals(expectedChildElementsDOM, assertion);\r
+ }\r
+\r
+};\r