Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 402F8189B5 for ; Thu, 30 Jul 2015 20:59:39 +0000 (UTC) Received: (qmail 47694 invoked by uid 500); 30 Jul 2015 20:59:39 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 47506 invoked by uid 500); 30 Jul 2015 20:59:39 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 47235 invoked by uid 99); 30 Jul 2015 20:59:39 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Jul 2015 20:59:39 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D55CAE7156; Thu, 30 Jul 2015 20:59:38 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: coheigea@apache.org To: commits@cxf.apache.org Date: Thu, 30 Jul 2015 20:59:41 -0000 Message-Id: <99c094999b774737872762607dd31ff7@git.apache.org> In-Reply-To: <165b1e39644b47e294762df4f649e66c@git.apache.org> References: <165b1e39644b47e294762df4f649e66c@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [4/4] cxf git commit: Fixing merge Fixing merge Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/5988f473 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/5988f473 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/5988f473 Branch: refs/heads/2.7.x-fixes Commit: 5988f47316feb71692d98f372e7c4992fa0ca4af Parents: fdaf2f3 Author: Colm O hEigeartaigh Authored: Thu Jul 30 21:59:25 2015 +0100 Committer: Colm O hEigeartaigh Committed: Thu Jul 30 21:59:25 2015 +0100 ---------------------------------------------------------------------- .../saml/sso/SAMLSSOResponseValidator.java | 11 +---- .../saml/sso/CombinedValidatorTest.java | 48 ++++++++++---------- 2 files changed, 27 insertions(+), 32 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/5988f473/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/SAMLSSOResponseValidator.java ---------------------------------------------------------------------- diff --git a/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/SAMLSSOResponseValidator.java b/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/SAMLSSOResponseValidator.java index 65fe7b5..2d864a5 100644 --- a/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/SAMLSSOResponseValidator.java +++ b/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/SAMLSSOResponseValidator.java @@ -134,17 +134,10 @@ public class SAMLSSOResponseValidator { SSOValidatorResponse validatorResponse = new SSOValidatorResponse(); validatorResponse.setResponseId(samlResponse.getID()); validatorResponse.setSessionNotOnOrAfter(sessionNotOnOrAfter); - // the assumption for now is that SAMLResponse will contain only a single assertion -<<<<<<< HEAD - Element assertionElement = samlResponse.getAssertions().get(0).getDOM(); - validatorResponse.setAssertion(DOM2Writer.nodeToString(assertionElement.cloneNode(true))); -======= + Element assertionElement = validAssertion.getDOM(); - Element clonedAssertionElement = (Element)assertionElement.cloneNode(true); - validatorResponse.setAssertionElement(clonedAssertionElement); - validatorResponse.setAssertion(DOM2Writer.nodeToString(clonedAssertionElement)); + validatorResponse.setAssertion(DOM2Writer.nodeToString(assertionElement.cloneNode(true))); ->>>>>>> 1c2a530... Adding SAML SSO tests. return validatorResponse; } http://git-wip-us.apache.org/repos/asf/cxf/blob/5988f473/rt/rs/security/sso/saml/src/test/java/org/apache/cxf/rs/security/saml/sso/CombinedValidatorTest.java ---------------------------------------------------------------------- diff --git a/rt/rs/security/sso/saml/src/test/java/org/apache/cxf/rs/security/saml/sso/CombinedValidatorTest.java b/rt/rs/security/sso/saml/src/test/java/org/apache/cxf/rs/security/saml/sso/CombinedValidatorTest.java index 5893af8..7b9a9c1 100644 --- a/rt/rs/security/sso/saml/src/test/java/org/apache/cxf/rs/security/saml/sso/CombinedValidatorTest.java +++ b/rt/rs/security/sso/saml/src/test/java/org/apache/cxf/rs/security/saml/sso/CombinedValidatorTest.java @@ -20,6 +20,7 @@ package org.apache.cxf.rs.security.saml.sso; import java.io.InputStream; +import java.io.StringReader; import java.security.KeyStore; import java.util.Collections; @@ -28,20 +29,19 @@ import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; - -import org.apache.wss4j.common.crypto.Crypto; -import org.apache.wss4j.common.crypto.Merlin; -import org.apache.wss4j.common.saml.OpenSAMLUtil; -import org.apache.wss4j.common.saml.SAMLCallback; -import org.apache.wss4j.common.saml.SAMLUtil; -import org.apache.wss4j.common.saml.SamlAssertionWrapper; -import org.apache.wss4j.common.saml.bean.AudienceRestrictionBean; -import org.apache.wss4j.common.saml.bean.ConditionsBean; -import org.apache.wss4j.common.saml.bean.SubjectConfirmationDataBean; -import org.apache.wss4j.common.saml.builder.SAML2Constants; -import org.apache.wss4j.common.util.Loader; -import org.apache.wss4j.dom.WSConstants; -import org.apache.wss4j.dom.WSSConfig; +import org.apache.cxf.staxutils.StaxUtils; +import org.apache.ws.security.WSConstants; +import org.apache.ws.security.WSSConfig; +import org.apache.ws.security.components.crypto.Crypto; +import org.apache.ws.security.components.crypto.Merlin; +import org.apache.ws.security.saml.ext.AssertionWrapper; +import org.apache.ws.security.saml.ext.OpenSAMLUtil; +import org.apache.ws.security.saml.ext.SAMLParms; +import org.apache.ws.security.saml.ext.bean.AudienceRestrictionBean; +import org.apache.ws.security.saml.ext.bean.ConditionsBean; +import org.apache.ws.security.saml.ext.bean.SubjectConfirmationDataBean; +import org.apache.ws.security.saml.ext.builder.SAML2Constants; +import org.apache.ws.security.util.Loader; import org.joda.time.DateTime; import org.opensaml.common.xml.SAMLConstants; import org.opensaml.saml2.core.Response; @@ -87,10 +87,11 @@ public class CombinedValidatorTest extends org.junit.Assert { // Parse the response SSOValidatorResponse ssoResponse = ssoValidator.validateSamlResponse(marshalledResponse, false); - SamlAssertionWrapper parsedAssertion = - new SamlAssertionWrapper(ssoResponse.getAssertionElement()); + Document assertionDoc = StaxUtils.read(new StringReader(ssoResponse.getAssertion())); + AssertionWrapper parsedAssertion = + new AssertionWrapper(assertionDoc.getDocumentElement()); - assertEquals("alice", parsedAssertion.getSubjectName()); + assertEquals("alice", parsedAssertion.getSaml2().getSubject().getNameID().getValue()); } @org.junit.Test @@ -150,10 +151,11 @@ public class CombinedValidatorTest extends org.junit.Assert { // Parse the response SSOValidatorResponse ssoResponse = ssoValidator.validateSamlResponse(marshalledResponse, false); - SamlAssertionWrapper parsedAssertion = - new SamlAssertionWrapper(ssoResponse.getAssertionElement()); + Document assertionDoc = StaxUtils.read(new StringReader(ssoResponse.getAssertion())); + AssertionWrapper parsedAssertion = + new AssertionWrapper(assertionDoc.getDocumentElement()); - assertEquals("alice", parsedAssertion.getSubjectName()); + assertEquals("alice", parsedAssertion.getSaml2().getSubject().getNameID().getValue()); } private Element createResponse() throws Exception { @@ -194,9 +196,9 @@ public class CombinedValidatorTest extends org.junit.Assert { conditions.setAudienceRestrictions(Collections.singletonList(audienceRestriction)); callbackHandler.setConditions(conditions); - SAMLCallback samlCallback = new SAMLCallback(); - SAMLUtil.doSAMLCallback(callbackHandler, samlCallback); - SamlAssertionWrapper assertion = new SamlAssertionWrapper(samlCallback); + SAMLParms samlParms = new SAMLParms(); + samlParms.setCallbackHandler(callbackHandler); + AssertionWrapper assertion = new AssertionWrapper(samlParms); Crypto issuerCrypto = new Merlin(); KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());