[1/2] cxf-fediz git commit: Adding some wrapping tests
Repository: cxf-fediz Updated Branches: refs/heads/1.2.x-fixes 4cc318db3 -> 5a225d15d Adding some wrapping tests Project: http://git-wip-us.apache.org/repos/asf/cxf-fediz/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf-fediz/commit/c9332939 Tree: http://git-wip-us.apache.org/repos/asf/cxf-fediz/tree/c9332939 Diff: http://git-wip-us.apache.org/repos/asf/cxf-fediz/diff/c9332939 Branch: refs/heads/1.2.x-fixes Commit: c93329392ff7175d5c2b0668c3f9859b9dee3ce3 Parents: 4cc318d Author: Colm O hEigeartaigh Authored: Fri Jul 31 14:15:22 2015 +0100 Committer: Colm O hEigeartaigh Committed: Fri Jul 31 14:25:09 2015 +0100 -- .../core/federation/FederationResponseTest.java | 308 ++- 1 file changed, 238 insertions(+), 70 deletions(-) -- http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/c9332939/plugins/core/src/test/java/org/apache/cxf/fediz/core/federation/FederationResponseTest.java -- diff --git a/plugins/core/src/test/java/org/apache/cxf/fediz/core/federation/FederationResponseTest.java b/plugins/core/src/test/java/org/apache/cxf/fediz/core/federation/FederationResponseTest.java index 02b8370..125a2ec 100644 --- a/plugins/core/src/test/java/org/apache/cxf/fediz/core/federation/FederationResponseTest.java +++ b/plugins/core/src/test/java/org/apache/cxf/fediz/core/federation/FederationResponseTest.java @@ -32,7 +32,6 @@ import javax.security.auth.callback.UnsupportedCallbackException; import org.w3c.dom.Document; import org.w3c.dom.Element; -import org.w3c.dom.Node; import org.apache.cxf.fediz.common.STSUtil; import org.apache.cxf.fediz.common.SecurityTestUtil; import org.apache.cxf.fediz.core.AbstractSAMLCallbackHandler; @@ -76,6 +75,7 @@ import org.apache.wss4j.common.saml.bean.ConditionsBean; import org.apache.wss4j.common.saml.builder.SAML1Constants; import org.apache.wss4j.common.saml.builder.SAML2Constants; import org.apache.wss4j.common.util.DOM2Writer; +import org.apache.wss4j.common.util.XMLUtils; import org.apache.wss4j.dom.WSConstants; import org.apache.wss4j.dom.message.WSSecEncrypt; import org.joda.time.DateTime; @@ -90,6 +90,20 @@ import static org.junit.Assert.fail; * Some tests for the WS-Federation "FederationProcessor". */ public class FederationResponseTest { +public static final String SAMPLE_MULTIPLE_RSTR_COLL_MSG = +"" ++ "http://docs.oasis-open.org/ws-sx/ws-trust/200512\";> " ++ "" ++ "" ++ "" ++ "" ++ "" ++ "" ++ "" ++ "" ++ ""; + static final String TEST_USER = "alice"; static final String TEST_RSTR_ISSUER = "FedizSTSIssuer"; static final String TEST_AUDIENCE = "https://localhost/fedizhelloworld";; @@ -760,6 +774,221 @@ public class FederationResponseTest { } } +@org.junit.Test +public void testUnsignedAssertionAfterSignedAssertion() throws Exception { +// First assertion +SAML2CallbackHandler callbackHandler = new SAML2CallbackHandler(); +callbackHandler.setStatement(SAML2CallbackHandler.Statement.ATTR); +callbackHandler.setConfirmationMethod(SAML2Constants.CONF_BEARER); +callbackHandler.setIssuer(TEST_RSTR_ISSUER); +callbackHandler.setSubjectName(TEST_USER); +ConditionsBean cp = new ConditionsBean(); +AudienceRestrictionBean audienceRestriction = new AudienceRestrictionBean(); +audienceRestriction.getAudienceURIs().add(TEST_AUDIENCE); + cp.setAudienceRestrictions(Collections.singletonList(audienceRestriction)); +callbackHandler.setConditions(cp); + +SAMLCallback samlCallback = new SAMLCallback(); +SAMLUtil.doSAMLCallback(callbackHandler, samlCallback); +SamlAssertionWrapper assertion1 = new SamlAssertionWrapper(samlCallback); + +// Second assertion +SAML2CallbackHandler callbackHandler2 = new SAML2CallbackHandler(); +callbackHandler2.setStatement(SAML2CallbackHandler.Statement.ATTR); +callbackHandler2.setConfirmationMethod(SAML2Constants.CONF_BEARER); +callbackHandler2.setIssuer(TEST_RSTR_ISSUER); +callbackHandler2.setSubjectName("bob"); +ConditionsBean cp2 = new ConditionsBean(); +AudienceRestrictionBean audienceRestriction2 = new AudienceRestrictionBean(); +audienceRestriction2.getAudienceURIs().add(TEST_AUDIENCE); + cp2.setAudienceRestrictions(Collections.singletonList(audienceRestriction2)); +callbackHandler2.setConditions(cp2); + +SAMLCallback samlCallback2 = new SAMLCallback(); +SAMLUtil.doSAMLCallback(callbackHandler2, samlCallback2); +SamlAssertionWrapper assertion2 = new SamlAssertionWrapper(samlCallback2); +
cxf-fediz git commit: Adding some wrapping tests
Repository: cxf-fediz Updated Branches: refs/heads/master 2eab7d841 -> 3e2f6642b Adding some wrapping tests Project: http://git-wip-us.apache.org/repos/asf/cxf-fediz/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf-fediz/commit/3e2f6642 Tree: http://git-wip-us.apache.org/repos/asf/cxf-fediz/tree/3e2f6642 Diff: http://git-wip-us.apache.org/repos/asf/cxf-fediz/diff/3e2f6642 Branch: refs/heads/master Commit: 3e2f6642b7bb0f23ecf191c2b1df27d6879b8c7e Parents: 2eab7d8 Author: Colm O hEigeartaigh Authored: Fri Jul 31 14:15:22 2015 +0100 Committer: Colm O hEigeartaigh Committed: Fri Jul 31 14:15:22 2015 +0100 -- .../core/federation/FederationResponseTest.java | 308 ++- 1 file changed, 238 insertions(+), 70 deletions(-) -- http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/3e2f6642/plugins/core/src/test/java/org/apache/cxf/fediz/core/federation/FederationResponseTest.java -- diff --git a/plugins/core/src/test/java/org/apache/cxf/fediz/core/federation/FederationResponseTest.java b/plugins/core/src/test/java/org/apache/cxf/fediz/core/federation/FederationResponseTest.java index 02b8370..125a2ec 100644 --- a/plugins/core/src/test/java/org/apache/cxf/fediz/core/federation/FederationResponseTest.java +++ b/plugins/core/src/test/java/org/apache/cxf/fediz/core/federation/FederationResponseTest.java @@ -32,7 +32,6 @@ import javax.security.auth.callback.UnsupportedCallbackException; import org.w3c.dom.Document; import org.w3c.dom.Element; -import org.w3c.dom.Node; import org.apache.cxf.fediz.common.STSUtil; import org.apache.cxf.fediz.common.SecurityTestUtil; import org.apache.cxf.fediz.core.AbstractSAMLCallbackHandler; @@ -76,6 +75,7 @@ import org.apache.wss4j.common.saml.bean.ConditionsBean; import org.apache.wss4j.common.saml.builder.SAML1Constants; import org.apache.wss4j.common.saml.builder.SAML2Constants; import org.apache.wss4j.common.util.DOM2Writer; +import org.apache.wss4j.common.util.XMLUtils; import org.apache.wss4j.dom.WSConstants; import org.apache.wss4j.dom.message.WSSecEncrypt; import org.joda.time.DateTime; @@ -90,6 +90,20 @@ import static org.junit.Assert.fail; * Some tests for the WS-Federation "FederationProcessor". */ public class FederationResponseTest { +public static final String SAMPLE_MULTIPLE_RSTR_COLL_MSG = +"" ++ "http://docs.oasis-open.org/ws-sx/ws-trust/200512\";> " ++ "" ++ "" ++ "" ++ "" ++ "" ++ "" ++ "" ++ "" ++ ""; + static final String TEST_USER = "alice"; static final String TEST_RSTR_ISSUER = "FedizSTSIssuer"; static final String TEST_AUDIENCE = "https://localhost/fedizhelloworld";; @@ -760,6 +774,221 @@ public class FederationResponseTest { } } +@org.junit.Test +public void testUnsignedAssertionAfterSignedAssertion() throws Exception { +// First assertion +SAML2CallbackHandler callbackHandler = new SAML2CallbackHandler(); +callbackHandler.setStatement(SAML2CallbackHandler.Statement.ATTR); +callbackHandler.setConfirmationMethod(SAML2Constants.CONF_BEARER); +callbackHandler.setIssuer(TEST_RSTR_ISSUER); +callbackHandler.setSubjectName(TEST_USER); +ConditionsBean cp = new ConditionsBean(); +AudienceRestrictionBean audienceRestriction = new AudienceRestrictionBean(); +audienceRestriction.getAudienceURIs().add(TEST_AUDIENCE); + cp.setAudienceRestrictions(Collections.singletonList(audienceRestriction)); +callbackHandler.setConditions(cp); + +SAMLCallback samlCallback = new SAMLCallback(); +SAMLUtil.doSAMLCallback(callbackHandler, samlCallback); +SamlAssertionWrapper assertion1 = new SamlAssertionWrapper(samlCallback); + +// Second assertion +SAML2CallbackHandler callbackHandler2 = new SAML2CallbackHandler(); +callbackHandler2.setStatement(SAML2CallbackHandler.Statement.ATTR); +callbackHandler2.setConfirmationMethod(SAML2Constants.CONF_BEARER); +callbackHandler2.setIssuer(TEST_RSTR_ISSUER); +callbackHandler2.setSubjectName("bob"); +ConditionsBean cp2 = new ConditionsBean(); +AudienceRestrictionBean audienceRestriction2 = new AudienceRestrictionBean(); +audienceRestriction2.getAudienceURIs().add(TEST_AUDIENCE); + cp2.setAudienceRestrictions(Collections.singletonList(audienceRestriction2)); +callbackHandler2.setConditions(cp2); + +SAMLCallback samlCallback2 = new SAMLCallback(); +SAMLUtil.doSAMLCallback(callbackHandler2, samlCallback2); +SamlAssertionWrapper assertion2 = new SamlAssertionWrapper(samlCallback2); + +