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 9A15B17AA8 for ; Fri, 27 Feb 2015 17:26:12 +0000 (UTC) Received: (qmail 91600 invoked by uid 500); 27 Feb 2015 17:26:12 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 91545 invoked by uid 500); 27 Feb 2015 17:26:12 -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 91536 invoked by uid 99); 27 Feb 2015 17:26:12 -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; Fri, 27 Feb 2015 17:26:12 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 3F0AAE0531; Fri, 27 Feb 2015 17:26:12 +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 Message-Id: <752a3ac9d5474757a4ace6c47e37b304@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: cxf-fediz git commit: Adding an initial @Ignored test-case for SAML SSO Date: Fri, 27 Feb 2015 17:26:12 +0000 (UTC) Repository: cxf-fediz Updated Branches: refs/heads/master 113a2f8ba -> 6732b3197 Adding an initial @Ignored test-case for SAML SSO Project: http://git-wip-us.apache.org/repos/asf/cxf-fediz/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf-fediz/commit/6732b319 Tree: http://git-wip-us.apache.org/repos/asf/cxf-fediz/tree/6732b319 Diff: http://git-wip-us.apache.org/repos/asf/cxf-fediz/diff/6732b319 Branch: refs/heads/master Commit: 6732b3197df26a158355f5f188331148d848783f Parents: 113a2f8 Author: Colm O hEigeartaigh Authored: Fri Feb 27 17:25:41 2015 +0000 Committer: Colm O hEigeartaigh Committed: Fri Feb 27 17:25:41 2015 +0000 ---------------------------------------------------------------------- systests/federation/pom.xml | 37 ++ systests/federation/samlsso/pom.xml | 268 +++++++++++ .../cxf/fediz/integrationtests/SAMLSSOTest.java | 215 +++++++++ .../samlsso/src/test/resources/client.jks | Bin 0 -> 2060 bytes .../src/test/resources/entities-realma.xml | 465 +++++++++++++++++++ .../test/resources/fediz_config_saml_sso.xml | 38 ++ .../samlsso/src/test/resources/server.jks | Bin 0 -> 1863 bytes .../samlsso/src/test/resources/ststrust.jks | Bin 0 -> 2561 bytes systests/pom.xml | 1 + 9 files changed, 1024 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/6732b319/systests/federation/pom.xml ---------------------------------------------------------------------- diff --git a/systests/federation/pom.xml b/systests/federation/pom.xml new file mode 100644 index 0000000..b69e6e5 --- /dev/null +++ b/systests/federation/pom.xml @@ -0,0 +1,37 @@ + + + + 4.0.0 + + org.apache.cxf.fediz + fediz-systests + 1.2.0-SNAPSHOT + ../pom.xml + + org.apache.cxf.fediz.systests + fediz-systests-federation + Apache Fediz Federation Systests + pom + + + samlsso + + + http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/6732b319/systests/federation/samlsso/pom.xml ---------------------------------------------------------------------- diff --git a/systests/federation/samlsso/pom.xml b/systests/federation/samlsso/pom.xml new file mode 100644 index 0000000..3fd7390 --- /dev/null +++ b/systests/federation/samlsso/pom.xml @@ -0,0 +1,268 @@ + + + + 4.0.0 + + org.apache.cxf.fediz.systests + fediz-systests-federation + 1.2.0-SNAPSHOT + ../pom.xml + + org.apache.cxf.fediz.systests.federation + fediz-systests-federation-samlsso + Apache Fediz Federation Systests Tomcat 7 SAML SSO + jar + + UTF-8 + UTF-8 + + + + org.apache.tomcat.embed + tomcat-embed-core + ${tomcat.version} + test + + + org.apache.tomcat.embed + tomcat-embed-logging-juli + ${tomcat.version} + test + + + org.eclipse.jdt.core.compiler + ecj + 3.7.1 + test + + + org.apache.tomcat.embed + tomcat-embed-jasper + ${tomcat.version} + test + + + junit + junit + ${junit.version} + test + + + org.apache.cxf.fediz + fediz-tomcat + ${project.version} + test + + + org.apache.cxf.fediz.systests + fediz-systests-tests + ${project.version} + test-jar + test + + + org.slf4j + slf4j-api + ${slf4j.version} + test + + + org.slf4j + slf4j-jdk14 + ${slf4j.version} + test + + + hsqldb + hsqldb + ${hsqldb.version} + test + + + + + + src/test/resources + true + + **/fediz_config*.xml + + + + src/test/resources + false + + **/fediz_config*.xml + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + reserve-network-port + + reserve-network-port + + initialize + + + idp.https.port + rp.https.port + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-idp-sts + generate-resources + + unpack + + + + + org.apache.cxf.fediz + fediz-idp + ${project.version} + war + true + target/tomcat/idp/webapps/fediz-idp + + + org.apache.cxf.fediz + fediz-idp-sts + ${project.version} + war + true + target/tomcat/idp/webapps/fediz-idp-sts + + + org.apache.cxf.fediz.systests + fediz-systests-simpleWebapp + ${project.version} + war + true + target/tomcat/rp/webapps/simpleWebapp + + + true + true + true + true + + + + copy-xalan-to-idp + generate-resources + + copy + + + + + xalan + xalan + ${xalan.version} + target/tomcat/idp/webapps/fediz-idp/WEB-INF/lib + + + + + + + + maven-resources-plugin + 2.7 + + + copy-entities-to-idp + generate-test-sources + + copy-resources + + + ${basedir}/target/tomcat/idp/webapps/fediz-idp/WEB-INF/classes + + + ${basedir}/src/test/resources + + entities-realma.xml + + true + + + + + + + + maven-failsafe-plugin + true + + + integration-test + integration-test + + integration-test + + + false + + true + ${idp.https.port} + ${rp.https.port} + + + **/integrationtests/** + + -Xms512m -Xmx1024m + -XX:MaxPermSize=256m + + + + verify + verify + + verify + + + + + + org.apache.maven.plugins + maven-surefire-plugin + true + + + **/integrationtests/** + + + + + + http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/6732b319/systests/federation/samlsso/src/test/java/org/apache/cxf/fediz/integrationtests/SAMLSSOTest.java ---------------------------------------------------------------------- diff --git a/systests/federation/samlsso/src/test/java/org/apache/cxf/fediz/integrationtests/SAMLSSOTest.java b/systests/federation/samlsso/src/test/java/org/apache/cxf/fediz/integrationtests/SAMLSSOTest.java new file mode 100644 index 0000000..17913e1 --- /dev/null +++ b/systests/federation/samlsso/src/test/java/org/apache/cxf/fediz/integrationtests/SAMLSSOTest.java @@ -0,0 +1,215 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.cxf.fediz.integrationtests; + + +import java.io.File; + +import org.apache.catalina.Context; +import org.apache.catalina.LifecycleState; +import org.apache.catalina.connector.Connector; +import org.apache.catalina.startup.Tomcat; +import org.apache.cxf.fediz.tomcat.FederationAuthenticator; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; + +/** + */ +public class SAMLSSOTest { + + static String idpHttpsPort; + static String rpHttpsPort; + + private static Tomcat idpServer; + private static Tomcat rpServer; + + @BeforeClass + public static void init() { + System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog"); + System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true"); + System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "info"); + System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "info"); + System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.webflow", "info"); + System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.security.web", "info"); + System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf.fediz", "info"); + System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf", "info"); + + idpHttpsPort = System.getProperty("idp.https.port"); + Assert.assertNotNull("Property 'idp.https.port' null", idpHttpsPort); + rpHttpsPort = System.getProperty("rp.https.port"); + Assert.assertNotNull("Property 'rp.https.port' null", rpHttpsPort); + + initIdp(); + initRp(); + } + + private static void initIdp() { + try { + idpServer = new Tomcat(); + idpServer.setPort(0); + String currentDir = new File(".").getCanonicalPath(); + idpServer.setBaseDir(currentDir + File.separator + "target"); + + idpServer.getHost().setAppBase("tomcat/idp/webapps"); + idpServer.getHost().setAutoDeploy(true); + idpServer.getHost().setDeployOnStartup(true); + + Connector httpsConnector = new Connector(); + httpsConnector.setPort(Integer.parseInt(idpHttpsPort)); + httpsConnector.setSecure(true); + httpsConnector.setScheme("https"); + //httpsConnector.setAttribute("keyAlias", keyAlias); + httpsConnector.setAttribute("keystorePass", "tompass"); + httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks"); + httpsConnector.setAttribute("truststorePass", "tompass"); + httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks"); + httpsConnector.setAttribute("clientAuth", "want"); + // httpsConnector.setAttribute("clientAuth", "false"); + httpsConnector.setAttribute("sslProtocol", "TLS"); + httpsConnector.setAttribute("SSLEnabled", true); + + idpServer.getService().addConnector(httpsConnector); + + idpServer.addWebapp("/fediz-idp-sts", "fediz-idp-sts"); + idpServer.addWebapp("/fediz-idp", "fediz-idp"); + + idpServer.start(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private static void initRp() { + try { + rpServer = new Tomcat(); + rpServer.setPort(0); + String currentDir = new File(".").getCanonicalPath(); + rpServer.setBaseDir(currentDir + File.separator + "target"); + + rpServer.getHost().setAppBase("tomcat/rp/webapps"); + rpServer.getHost().setAutoDeploy(true); + rpServer.getHost().setDeployOnStartup(true); + + Connector httpsConnector = new Connector(); + httpsConnector.setPort(Integer.parseInt(rpHttpsPort)); + httpsConnector.setSecure(true); + httpsConnector.setScheme("https"); + //httpsConnector.setAttribute("keyAlias", keyAlias); + httpsConnector.setAttribute("keystorePass", "tompass"); + httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks"); + httpsConnector.setAttribute("truststorePass", "tompass"); + httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks"); + // httpsConnector.setAttribute("clientAuth", "false"); + httpsConnector.setAttribute("clientAuth", "want"); + httpsConnector.setAttribute("sslProtocol", "TLS"); + httpsConnector.setAttribute("SSLEnabled", true); + + rpServer.getService().addConnector(httpsConnector); + + //Context ctx = + Context cxt = rpServer.addWebapp("/fedizhelloworld", "simpleWebapp"); + FederationAuthenticator fa = new FederationAuthenticator(); + fa.setConfigFile(currentDir + File.separator + "target" + File.separator + + "test-classes" + File.separator + "fediz_config_saml_sso.xml"); + cxt.getPipeline().addValve(fa); + + + rpServer.start(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @AfterClass + public static void cleanup() { + try { + if (idpServer.getServer() != null + && idpServer.getServer().getState() != LifecycleState.DESTROYED) { + if (idpServer.getServer().getState() != LifecycleState.STOPPED) { + idpServer.stop(); + } + idpServer.destroy(); + } + } catch (Exception e) { + e.printStackTrace(); + } + + try { + if (rpServer.getServer() != null + && rpServer.getServer().getState() != LifecycleState.DESTROYED) { + if (rpServer.getServer().getState() != LifecycleState.STOPPED) { + rpServer.stop(); + } + rpServer.destroy(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public String getIdpHttpsPort() { + return idpHttpsPort; + } + + public String getRpHttpsPort() { + return rpHttpsPort; + } + + public String getServletContextName() { + return "fedizhelloworld"; + } + + @org.junit.Test + @org.junit.Ignore + public void testSAMLSSO() throws Exception { + String url = "https://localhost:" + getRpHttpsPort() + "/fedizhelloworld/secure/fedservlet"; + // String user = "alice"; + // String password = "ecila"; + + System.out.println("URL: " + url); + + Thread.sleep(60 * 2 * 1000); + /* + final String bodyTextContent = + HTTPTestUtils.login(url, user, password, getIdpHttpsPort()); + + Assert.assertTrue("Principal not " + user, + bodyTextContent.contains("userPrincipal=" + user)); + Assert.assertTrue("User " + user + " does not have role Admin", + bodyTextContent.contains("role:Admin=false")); + Assert.assertTrue("User " + user + " does not have role Manager", + bodyTextContent.contains("role:Manager=false")); + Assert.assertTrue("User " + user + " must have role User", + bodyTextContent.contains("role:User=true")); + + String claim = ClaimTypes.FIRSTNAME.toString(); + Assert.assertTrue("User " + user + " claim " + claim + " is not 'Alice'", + bodyTextContent.contains(claim + "=Alice")); + claim = ClaimTypes.LASTNAME.toString(); + Assert.assertTrue("User " + user + " claim " + claim + " is not 'Smith'", + bodyTextContent.contains(claim + "=Smith")); + claim = ClaimTypes.EMAILADDRESS.toString(); + Assert.assertTrue("User " + user + " claim " + claim + " is not 'alice@realma.org'", + bodyTextContent.contains(claim + "=alice@realma.org")); + */ + } + +} http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/6732b319/systests/federation/samlsso/src/test/resources/client.jks ---------------------------------------------------------------------- diff --git a/systests/federation/samlsso/src/test/resources/client.jks b/systests/federation/samlsso/src/test/resources/client.jks new file mode 100644 index 0000000..720dbda Binary files /dev/null and b/systests/federation/samlsso/src/test/resources/client.jks differ http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/6732b319/systests/federation/samlsso/src/test/resources/entities-realma.xml ---------------------------------------------------------------------- diff --git a/systests/federation/samlsso/src/test/resources/entities-realma.xml b/systests/federation/samlsso/src/test/resources/entities-realma.xml new file mode 100644 index 0000000..2f66591 --- /dev/null +++ b/systests/federation/samlsso/src/test/resources/entities-realma.xml @@ -0,0 +1,465 @@ + + + + + + + + + + + + + + + + + http://docs.oasis-open.org/wsfed/federation/200706 + + http://docs.oasis-open.org/ws-sx/ws-trust/200512 + + + + + + urn:oasis:names:tc:SAML:1.0:assertion + urn:oasis:names:tc:SAML:2.0:assertion + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/6732b319/systests/federation/samlsso/src/test/resources/fediz_config_saml_sso.xml ---------------------------------------------------------------------- diff --git a/systests/federation/samlsso/src/test/resources/fediz_config_saml_sso.xml b/systests/federation/samlsso/src/test/resources/fediz_config_saml_sso.xml new file mode 100644 index 0000000..8137315 --- /dev/null +++ b/systests/federation/samlsso/src/test/resources/fediz_config_saml_sso.xml @@ -0,0 +1,38 @@ + + + + + + urn:org:apache:cxf:fediz:fedizhelloworld + + + + + + + + + + 1000 + + urn:org:apache:cxf:fediz:fedizhelloworld + https://localhost:${idp.https.port}/fediz-idp/federation + , + http://schemas.xmlsoap.org/ws/2005/05/identity/claims/role + 10 + urn:org:apache:cxf:fediz:idp:realm-B + + + + + /secure/logout + /index.html + + + http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/6732b319/systests/federation/samlsso/src/test/resources/server.jks ---------------------------------------------------------------------- diff --git a/systests/federation/samlsso/src/test/resources/server.jks b/systests/federation/samlsso/src/test/resources/server.jks new file mode 100644 index 0000000..2f0fdf3 Binary files /dev/null and b/systests/federation/samlsso/src/test/resources/server.jks differ http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/6732b319/systests/federation/samlsso/src/test/resources/ststrust.jks ---------------------------------------------------------------------- diff --git a/systests/federation/samlsso/src/test/resources/ststrust.jks b/systests/federation/samlsso/src/test/resources/ststrust.jks new file mode 100644 index 0000000..911945c Binary files /dev/null and b/systests/federation/samlsso/src/test/resources/ststrust.jks differ http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/6732b319/systests/pom.xml ---------------------------------------------------------------------- diff --git a/systests/pom.xml b/systests/pom.xml index 5259158..6019c60 100644 --- a/systests/pom.xml +++ b/systests/pom.xml @@ -40,6 +40,7 @@ tomcat7 spring cxf + federation