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 CC611D6FA for ; Fri, 8 Mar 2013 18:43:39 +0000 (UTC) Received: (qmail 99029 invoked by uid 500); 8 Mar 2013 18:43:39 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 98946 invoked by uid 500); 8 Mar 2013 18:43: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 98937 invoked by uid 99); 8 Mar 2013 18:43:39 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Mar 2013 18:43:39 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Mar 2013 18:43:36 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id EB2D52388A74; Fri, 8 Mar 2013 18:43:16 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1454493 - in /cxf/fediz/trunk/systests: ./ spring/ spring/src/ spring/src/test/ spring/src/test/java/ spring/src/test/java/org/ spring/src/test/java/org/apache/ spring/src/test/java/org/apache/cxf/ spring/src/test/java/org/apache/cxf/fediz... Date: Fri, 08 Mar 2013 18:43:15 -0000 To: commits@cxf.apache.org From: owulff@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130308184316.EB2D52388A74@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: owulff Date: Fri Mar 8 18:43:14 2013 New Revision: 1454493 URL: http://svn.apache.org/r1454493 Log: Integration tests added for spring-security plugin Added: cxf/fediz/trunk/systests/spring/ cxf/fediz/trunk/systests/spring/pom.xml cxf/fediz/trunk/systests/spring/src/ cxf/fediz/trunk/systests/spring/src/test/ cxf/fediz/trunk/systests/spring/src/test/java/ cxf/fediz/trunk/systests/spring/src/test/java/org/ cxf/fediz/trunk/systests/spring/src/test/java/org/apache/ cxf/fediz/trunk/systests/spring/src/test/java/org/apache/cxf/ cxf/fediz/trunk/systests/spring/src/test/java/org/apache/cxf/fediz/ cxf/fediz/trunk/systests/spring/src/test/java/org/apache/cxf/fediz/integrationtests/ cxf/fediz/trunk/systests/spring/src/test/java/org/apache/cxf/fediz/integrationtests/JettyUtils.java cxf/fediz/trunk/systests/spring/src/test/java/org/apache/cxf/fediz/integrationtests/SpringTest.java cxf/fediz/trunk/systests/spring/src/test/resources/ cxf/fediz/trunk/systests/spring/src/test/resources/fediz_config.xml cxf/fediz/trunk/systests/spring/src/test/resources/idp-server.xml cxf/fediz/trunk/systests/spring/src/test/resources/log4j.properties cxf/fediz/trunk/systests/spring/src/test/resources/logging.properties cxf/fediz/trunk/systests/spring/src/test/resources/rp-server.xml cxf/fediz/trunk/systests/spring/src/test/resources/server.jks cxf/fediz/trunk/systests/springWebapp/pom.xml cxf/fediz/trunk/systests/springWebapp/src/main/java/org/apache/cxf/fediz/example/FederationServlet.java cxf/fediz/trunk/systests/springWebapp/src/main/resources/log4j.properties cxf/fediz/trunk/systests/springWebapp/src/main/resources/logging.properties cxf/fediz/trunk/systests/springWebapp/src/main/resources/stsstore.jks (with props) cxf/fediz/trunk/systests/springWebapp/src/main/webapp/META-INF/context.xml cxf/fediz/trunk/systests/springWebapp/src/main/webapp/WEB-INF/applicationContext-security.xml cxf/fediz/trunk/systests/springWebapp/src/main/webapp/WEB-INF/web.xml cxf/fediz/trunk/systests/springWebapp/src/main/webapp/index.html cxf/fediz/trunk/systests/springWebapp/src/main/webapp/secure/test.html Modified: cxf/fediz/trunk/systests/pom.xml cxf/fediz/trunk/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/AbstractTests.java Modified: cxf/fediz/trunk/systests/pom.xml URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/pom.xml?rev=1454493&r1=1454492&r2=1454493&view=diff ============================================================================== --- cxf/fediz/trunk/systests/pom.xml (original) +++ cxf/fediz/trunk/systests/pom.xml Fri Mar 8 18:43:14 2013 @@ -33,8 +33,10 @@ tests simpleWebapp springPreauthWebapp + springWebapp jetty8 tomcat7 + spring Added: cxf/fediz/trunk/systests/spring/pom.xml URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/spring/pom.xml?rev=1454493&view=auto ============================================================================== --- cxf/fediz/trunk/systests/spring/pom.xml (added) +++ cxf/fediz/trunk/systests/spring/pom.xml Fri Mar 8 18:43:14 2013 @@ -0,0 +1,211 @@ + + + + 4.0.0 + + org.apache.cxf.fediz + systests + 1.1.0-SNAPSHOT + ../pom.xml + + org.apache.cxf.fediz.systests + systests-spring + Apache Fediz Systests Spring Security + jar + + UTF-8 + UTF-8 + + + + org.eclipse.jetty + jetty-server + ${jetty.version} + + + org.eclipse.jetty + jetty-security + ${jetty.version} + + + org.eclipse.jetty + jetty-xml + ${jetty.version} + test + + + org.eclipse.jetty + jetty-webapp + ${jetty.version} + test + + + org.eclipse.jetty + jetty-jsp + ${jetty.version} + test + + + junit + junit + ${junit.version} + test + + + org.apache.cxf.fediz.systests + systests-tests + ${project.version} + test-jar + test + + + + + + src/test/resources + true + + **/idp-server.xml + **/rp-server.xml + **/fediz_config.xml + + + + src/test/resources + false + + **/idp-server.xml + **/rp-server.xml + **/fediz_config.xml + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.7 + + + reserve-network-port + + reserve-network-port + + initialize + + + idp.https.port + rp.https.port + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.6 + + + copy-idp-sts + generate-resources + + copy + + + + + org.apache.cxf.fediz + fediz-idp + ${project.version} + war + true + + + org.apache.cxf.fediz + fediz-idp-sts + ${project.version} + war + true + + + org.apache.cxf.fediz.systests + systests-springWebapp + ${project.version} + war + true + + + true + target + true + true + true + + + + + + maven-failsafe-plugin + 2.12.2 + true + + + integration-test + integration-test + + integration-test + + + false + + true + ${idp.https.port} + ${rp.https.port} + + + **/integrationtests/** + + -XX:MaxPermSize=512M + + + + verify + verify + + verify + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.12 + true + + + **/integrationtests/** + + + + + + Added: cxf/fediz/trunk/systests/spring/src/test/java/org/apache/cxf/fediz/integrationtests/JettyUtils.java URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/spring/src/test/java/org/apache/cxf/fediz/integrationtests/JettyUtils.java?rev=1454493&view=auto ============================================================================== --- cxf/fediz/trunk/systests/spring/src/test/java/org/apache/cxf/fediz/integrationtests/JettyUtils.java (added) +++ cxf/fediz/trunk/systests/spring/src/test/java/org/apache/cxf/fediz/integrationtests/JettyUtils.java Fri Mar 8 18:43:14 2013 @@ -0,0 +1,100 @@ +/** + * 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 org.eclipse.jetty.server.Server; +import org.eclipse.jetty.util.resource.Resource; +import org.eclipse.jetty.xml.XmlConfiguration; + +public final class JettyUtils { + + private static Server idpServer; + private static Server rpServer; + + private JettyUtils() { + } + + public static void initIdpServer() { + if (idpServer == null) { + try { + Resource testServerConfig = Resource.newSystemResource("idp-server.xml"); + XmlConfiguration configuration = new XmlConfiguration(testServerConfig.getInputStream()); + idpServer = (Server)configuration.configure(); + + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + public static void startIdpServer() { + if (idpServer != null && !idpServer.isStarted()) { + try { + idpServer.start(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + public static void stopIdpServer() { + if (idpServer != null && idpServer.isStarted()) { + try { + idpServer.stop(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + public static void initRpServer() { + if (rpServer == null) { + try { + Resource testServerConfig = Resource.newSystemResource("rp-server.xml"); + XmlConfiguration configuration = new XmlConfiguration(testServerConfig.getInputStream()); + rpServer = (Server)configuration.configure(); + + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + public static void startRpServer() { + if (rpServer != null && !rpServer.isStarted()) { + try { + rpServer.start(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + public static void stopRpServer() { + if (rpServer != null && rpServer.isStarted()) { + try { + rpServer.stop(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + +} Added: cxf/fediz/trunk/systests/spring/src/test/java/org/apache/cxf/fediz/integrationtests/SpringTest.java URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/spring/src/test/java/org/apache/cxf/fediz/integrationtests/SpringTest.java?rev=1454493&view=auto ============================================================================== --- cxf/fediz/trunk/systests/spring/src/test/java/org/apache/cxf/fediz/integrationtests/SpringTest.java (added) +++ cxf/fediz/trunk/systests/spring/src/test/java/org/apache/cxf/fediz/integrationtests/SpringTest.java Fri Mar 8 18:43:14 2013 @@ -0,0 +1,76 @@ +/** + * 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 org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; + + +public class SpringTest extends AbstractTests { + + static String idpHttpsPort; + static String rpHttpsPort; + + @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", "debug"); + + System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug"); + + 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); + + JettyUtils.initIdpServer(); + JettyUtils.startIdpServer(); + JettyUtils.initRpServer(); + JettyUtils.startRpServer(); + } + + @AfterClass + public static void cleanup() { + JettyUtils.stopIdpServer(); + JettyUtils.stopRpServer(); + } + + @Override + public String getIdpHttpsPort() { + return idpHttpsPort; + } + + @Override + public String getRpHttpsPort() { + return rpHttpsPort; + } + + @Override + public String getServletContextName() { + return "fedizhelloworld"; + } + + +} Added: cxf/fediz/trunk/systests/spring/src/test/resources/fediz_config.xml URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/spring/src/test/resources/fediz_config.xml?rev=1454493&view=auto ============================================================================== --- cxf/fediz/trunk/systests/spring/src/test/resources/fediz_config.xml (added) +++ cxf/fediz/trunk/systests/spring/src/test/resources/fediz_config.xml Fri Mar 8 18:43:14 2013 @@ -0,0 +1,39 @@ + + + + + + urn:org:apache:cxf:fediz:fedizhelloworld + + + + + + + + + + 1000 + + urn:org:apache:cxf:fediz:fedizhelloworld + https://localhost:${idp.https.port}/fediz-idp/ + , + http://schemas.xmlsoap.org/ws/2005/05/identity/claims/role + /j_spring_fediz_security_check + + + + + + + + + + + + Added: cxf/fediz/trunk/systests/spring/src/test/resources/idp-server.xml URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/spring/src/test/resources/idp-server.xml?rev=1454493&view=auto ============================================================================== --- cxf/fediz/trunk/systests/spring/src/test/resources/idp-server.xml (added) +++ cxf/fediz/trunk/systests/spring/src/test/resources/idp-server.xml Fri Mar 8 18:43:14 2013 @@ -0,0 +1,51 @@ + + + + + + + + true + + + + + + + + + ./target/test-classes/server.jks + tompass + tompass + + + ${idp.https.port} + 30000 + + + + + + + + + + + /fediz-idp + ./target/fediz-idp.war + true + + + + + /fediz-idp-sts + ./target/fediz-idp-sts.war + true + + + + + + + + Added: cxf/fediz/trunk/systests/spring/src/test/resources/log4j.properties URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/spring/src/test/resources/log4j.properties?rev=1454493&view=auto ============================================================================== --- cxf/fediz/trunk/systests/spring/src/test/resources/log4j.properties (added) +++ cxf/fediz/trunk/systests/spring/src/test/resources/log4j.properties Fri Mar 8 18:43:14 2013 @@ -0,0 +1,20 @@ +# Set root category priority to INFO and its only appender to CONSOLE. +#log4j.rootLogger=INFO, CONSOLE +log4j.rootLogger=DEBUG, CONSOLE +#log4j.logger.org.springframework=INFO, CONSOLE +#log4j.logger.org.springframework.security=DEBUG, CONSOLE,LOGFILE +#log4j.logger.org.apache.cxf.fediz=DEBUG, CONSOLE,LOGFILE + +# CONSOLE is set to be a ConsoleAppender using a PatternLayout. +log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender +log4j.appender.CONSOLE.Threshold=DEBUG +log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout +log4j.appender.CONSOLE.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n + +# LOGFILE is set to be a File appender using a PatternLayout. +log4j.appender.LOGFILE=org.apache.log4j.FileAppender +log4j.appender.LOGFILE.File=fedizhelloworld.log +log4j.appender.LOGFILE.Append=false +log4j.appender.LOGFILE.Threshold=DEBUG +log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout +log4j.appender.LOGFILE.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n Added: cxf/fediz/trunk/systests/spring/src/test/resources/logging.properties URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/spring/src/test/resources/logging.properties?rev=1454493&view=auto ============================================================================== --- cxf/fediz/trunk/systests/spring/src/test/resources/logging.properties (added) +++ cxf/fediz/trunk/systests/spring/src/test/resources/logging.properties Fri Mar 8 18:43:14 2013 @@ -0,0 +1,53 @@ +############################################################ +# Default Logging Configuration File +# +# You can use a different file by specifying a filename +# with the java.util.logging.config.file system property. +# For example java -Djava.util.logging.config.file=myfile +############################################################ + +############################################################ +# Global properties +############################################################ + +# "handlers" specifies a comma separated list of log Handler +# classes. These handlers will be installed during VM startup. +# Note that these classes must be on the system classpath. +# By default we only configure a ConsoleHandler, which will only +# show messages at the WARNING and above levels. +handlers= java.util.logging.ConsoleHandler +#handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler + +# Default global logging level. +# This specifies which kinds of events are logged across +# all loggers. For any given facility this global level +# can be overridden by a facility specific level +# Note that the ConsoleHandler also has a separate level +# setting to limit messages printed to the console. +.level= FINEST + +############################################################ +# Handler specific properties. +# Describes specific configuration info for Handlers. +############################################################ + +# default file output is in user's home directory. +java.util.logging.FileHandler.pattern = %h/java%u.log +java.util.logging.FileHandler.limit = 50000 +java.util.logging.FileHandler.count = 1 +java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter + +# Limit the message that are printed on the console to WARNING and above. +java.util.logging.ConsoleHandler.level = FINEST +java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter + + +############################################################ +# Facility specific properties. +# Provides extra control for each logger. +############################################################ + +# For example, set the com.xyz.foo logger to only log SEVERE +# messages: +#com.xyz.foo.level = SEVERE +#org.apache.cxf.fediz.level = FINEST Added: cxf/fediz/trunk/systests/spring/src/test/resources/rp-server.xml URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/spring/src/test/resources/rp-server.xml?rev=1454493&view=auto ============================================================================== --- cxf/fediz/trunk/systests/spring/src/test/resources/rp-server.xml (added) +++ cxf/fediz/trunk/systests/spring/src/test/resources/rp-server.xml Fri Mar 8 18:43:14 2013 @@ -0,0 +1,44 @@ + + + + + + + + true + + + + + + + + + ./target/test-classes/server.jks + tompass + tompass + + + ${rp.https.port} + 30000 + + + + + + + + + + + /fedizhelloworld + ./target/systests-springWebapp.war + true + + + + + + + + Added: cxf/fediz/trunk/systests/spring/src/test/resources/server.jks URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/spring/src/test/resources/server.jks?rev=1454493&view=auto ============================================================================== Files cxf/fediz/trunk/systests/spring/src/test/resources/server.jks (added) and cxf/fediz/trunk/systests/spring/src/test/resources/server.jks Fri Mar 8 18:43:14 2013 differ Added: cxf/fediz/trunk/systests/springWebapp/pom.xml URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/springWebapp/pom.xml?rev=1454493&view=auto ============================================================================== --- cxf/fediz/trunk/systests/springWebapp/pom.xml (added) +++ cxf/fediz/trunk/systests/springWebapp/pom.xml Fri Mar 8 18:43:14 2013 @@ -0,0 +1,108 @@ + + + + + 4.0.0 + + org.apache.cxf.fediz + systests + 1.1.0-SNAPSHOT + ../pom.xml + + + org.apache.cxf.fediz.systests + systests-springWebapp + Apache Fediz Systests SpringWebapp + war + + + UTF-8 + + + + + javax.servlet + servlet-api + ${servlet.version} + provided + + + org.apache.cxf.fediz + fediz-cxf + ${project.version} + + + org.slf4j + slf4j-log4j12 + ${slf4j.version} + + + org.apache.cxf.fediz + fediz-spring + ${project.version} + + + org.apache.commons + commons-lang3 + ${commons.lang.version} + + + log4j + log4j + ${log4j.version} + + + javax.mail + mail + + + javax.jms + jms + + + com.sun.jdmk + jmxtools + + + com.sun.jmx + jmxri + + + + + + + + + org.codehaus.mojo + tomcat-maven-plugin + 1.1 + + myTomcat + http://localhost:8080/manager/text + /${project.build.finalName} + + + + + fedizhelloworld + + + Added: cxf/fediz/trunk/systests/springWebapp/src/main/java/org/apache/cxf/fediz/example/FederationServlet.java URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/springWebapp/src/main/java/org/apache/cxf/fediz/example/FederationServlet.java?rev=1454493&view=auto ============================================================================== --- cxf/fediz/trunk/systests/springWebapp/src/main/java/org/apache/cxf/fediz/example/FederationServlet.java (added) +++ cxf/fediz/trunk/systests/springWebapp/src/main/java/org/apache/cxf/fediz/example/FederationServlet.java Fri Mar 8 18:43:14 2013 @@ -0,0 +1,108 @@ +/** + * 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.example; + +import java.io.IOException; +import java.io.PrintWriter; +import java.security.Principal; +import java.util.Arrays; +import java.util.List; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.w3c.dom.Element; + +import org.apache.cxf.fediz.core.Claim; +import org.apache.cxf.fediz.core.ClaimCollection; +import org.apache.cxf.fediz.cxf.web.SecurityTokenThreadLocal; +import org.apache.cxf.fediz.spring.authentication.FederationAuthenticationToken; + +import org.springframework.security.core.Authentication; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.context.SecurityContextHolder; + +public class FederationServlet extends HttpServlet { + + /** + * + */ + private static final long serialVersionUID = -9019993850246851112L; + + public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, + IOException { + + response.setContentType("text/html"); + PrintWriter out = response.getWriter(); + + out.println(""); + out.println("WS Federation Systests Spring Examples"); + out.println(""); + out.println("

Request url: " + request.getRequestURL().toString() + "

"); + + out.print("

userPrincipal="); + Principal p = request.getUserPrincipal(); + if (p != null) { + out.print(p.getName()); + } + out.println("

"); + + // Access Spring security context + Authentication auth = SecurityContextHolder.getContext().getAuthentication(); + + if (auth instanceof FederationAuthenticationToken) { + FederationAuthenticationToken fedToken = (FederationAuthenticationToken)auth; + List roleListToCheck = Arrays.asList("Admin", "Manager", "User", "Authenticated"); + + for (String item : roleListToCheck) { + boolean found = false; + for (GrantedAuthority ga : fedToken.getAuthorities()) { + if (ga.getAuthority().toLowerCase().indexOf(item.toLowerCase()) > -1) { + found = true; + break; + } + } + out.println("

role:" + item + "=" + (found ? "true" : "false") + "

"); + } + + ClaimCollection claims = fedToken.getClaims(); + for (Claim c : claims) { + out.println("

" + c.getClaimType().toString() + "=" + c.getValue() + "

"); + } + + Element el = fedToken.getLoginToken(); + if (el != null) { + out.println("loginToken=FOUND{FederationPrincipal}

"); + } + + el = SecurityTokenThreadLocal.getToken(); + if (el != null) { + out.println("loginToken=FOUND{SecurityTokenThreadLocal}

"); + } + + } + + out.println(""); + + } + +} Added: cxf/fediz/trunk/systests/springWebapp/src/main/resources/log4j.properties URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/springWebapp/src/main/resources/log4j.properties?rev=1454493&view=auto ============================================================================== --- cxf/fediz/trunk/systests/springWebapp/src/main/resources/log4j.properties (added) +++ cxf/fediz/trunk/systests/springWebapp/src/main/resources/log4j.properties Fri Mar 8 18:43:14 2013 @@ -0,0 +1,16 @@ +# Set root category priority to INFO and its only appender to CONSOLE. +log4j.rootLogger=INFO, CONSOLE +log4j.logger.org.springframework=INFO, CONSOLE +log4j.additivity.org.springframework=false +log4j.logger.org.springframework.security=DEBUG, CONSOLE +log4j.additivity.org.springframework.security=false +log4j.logger.org.apache.cxf.fediz=DEBUG, CONSOLE +log4j.additivity.org.apache.cxf.fediz=false + +# CONSOLE is set to be a ConsoleAppender using a PatternLayout. +log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender +log4j.appender.CONSOLE.Threshold=INFO +log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout +log4j.appender.CONSOLE.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n + + Added: cxf/fediz/trunk/systests/springWebapp/src/main/resources/logging.properties URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/springWebapp/src/main/resources/logging.properties?rev=1454493&view=auto ============================================================================== --- cxf/fediz/trunk/systests/springWebapp/src/main/resources/logging.properties (added) +++ cxf/fediz/trunk/systests/springWebapp/src/main/resources/logging.properties Fri Mar 8 18:43:14 2013 @@ -0,0 +1,53 @@ +############################################################ +# Default Logging Configuration File +# +# You can use a different file by specifying a filename +# with the java.util.logging.config.file system property. +# For example java -Djava.util.logging.config.file=myfile +############################################################ + +############################################################ +# Global properties +############################################################ + +# "handlers" specifies a comma separated list of log Handler +# classes. These handlers will be installed during VM startup. +# Note that these classes must be on the system classpath. +# By default we only configure a ConsoleHandler, which will only +# show messages at the WARNING and above levels. +handlers= java.util.logging.ConsoleHandler +#handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler + +# Default global logging level. +# This specifies which kinds of events are logged across +# all loggers. For any given facility this global level +# can be overridden by a facility specific level +# Note that the ConsoleHandler also has a separate level +# setting to limit messages printed to the console. +.level= FINEST + +############################################################ +# Handler specific properties. +# Describes specific configuration info for Handlers. +############################################################ + +# default file output is in user's home directory. +java.util.logging.FileHandler.pattern = %h/java%u.log +java.util.logging.FileHandler.limit = 50000 +java.util.logging.FileHandler.count = 1 +java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter + +# Limit the message that are printed on the console to WARNING and above. +java.util.logging.ConsoleHandler.level = FINEST +java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter + + +############################################################ +# Facility specific properties. +# Provides extra control for each logger. +############################################################ + +# For example, set the com.xyz.foo logger to only log SEVERE +# messages: +#com.xyz.foo.level = SEVERE +#org.apache.cxf.fediz.level = FINEST Added: cxf/fediz/trunk/systests/springWebapp/src/main/resources/stsstore.jks URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/springWebapp/src/main/resources/stsstore.jks?rev=1454493&view=auto ============================================================================== Files cxf/fediz/trunk/systests/springWebapp/src/main/resources/stsstore.jks (added) and cxf/fediz/trunk/systests/springWebapp/src/main/resources/stsstore.jks Fri Mar 8 18:43:14 2013 differ Propchange: cxf/fediz/trunk/systests/springWebapp/src/main/resources/stsstore.jks ------------------------------------------------------------------------------ svn:executable = * Added: cxf/fediz/trunk/systests/springWebapp/src/main/webapp/META-INF/context.xml URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/springWebapp/src/main/webapp/META-INF/context.xml?rev=1454493&view=auto ============================================================================== --- cxf/fediz/trunk/systests/springWebapp/src/main/webapp/META-INF/context.xml (added) +++ cxf/fediz/trunk/systests/springWebapp/src/main/webapp/META-INF/context.xml Fri Mar 8 18:43:14 2013 @@ -0,0 +1,3 @@ + + + Added: cxf/fediz/trunk/systests/springWebapp/src/main/webapp/WEB-INF/applicationContext-security.xml URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/springWebapp/src/main/webapp/WEB-INF/applicationContext-security.xml?rev=1454493&view=auto ============================================================================== --- cxf/fediz/trunk/systests/springWebapp/src/main/webapp/WEB-INF/applicationContext-security.xml (added) +++ cxf/fediz/trunk/systests/springWebapp/src/main/webapp/WEB-INF/applicationContext-security.xml Fri Mar 8 18:43:14 2013 @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Added: cxf/fediz/trunk/systests/springWebapp/src/main/webapp/WEB-INF/web.xml URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/springWebapp/src/main/webapp/WEB-INF/web.xml?rev=1454493&view=auto ============================================================================== --- cxf/fediz/trunk/systests/springWebapp/src/main/webapp/WEB-INF/web.xml (added) +++ cxf/fediz/trunk/systests/springWebapp/src/main/webapp/WEB-INF/web.xml Fri Mar 8 18:43:14 2013 @@ -0,0 +1,79 @@ + + + + WS Federation Spring Example + + WS Federation Spring Example + + + + + + contextConfigLocation + + /WEB-INF/applicationContext-security.xml + + + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + + + FederationFilter + org.apache.cxf.fediz.cxf.web.FederationFilter + + + + springSecurityFilterChain + /* + + + + FederationFilter + /secure/* + + + + + org.springframework.web.context.ContextLoaderListener + + + + FederationServlet + org.apache.cxf.fediz.example.FederationServlet + + + + FederationServlet + /secure/fedservlet + + + + FederationServlet + /secure/admin/fedservlet + + + + FederationServlet + /secure/user/fedservlet + + + + FederationServlet + /secure/manager/fedservlet + + + Added: cxf/fediz/trunk/systests/springWebapp/src/main/webapp/index.html URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/springWebapp/src/main/webapp/index.html?rev=1454493&view=auto ============================================================================== --- cxf/fediz/trunk/systests/springWebapp/src/main/webapp/index.html (added) +++ cxf/fediz/trunk/systests/springWebapp/src/main/webapp/index.html Fri Mar 8 18:43:14 2013 @@ -0,0 +1,25 @@ + + +WS Federation Tomcat Examples + + + +

+

Hello World

+

+ Added: cxf/fediz/trunk/systests/springWebapp/src/main/webapp/secure/test.html URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/springWebapp/src/main/webapp/secure/test.html?rev=1454493&view=auto ============================================================================== --- cxf/fediz/trunk/systests/springWebapp/src/main/webapp/secure/test.html (added) +++ cxf/fediz/trunk/systests/springWebapp/src/main/webapp/secure/test.html Fri Mar 8 18:43:14 2013 @@ -0,0 +1,25 @@ + + +WS Federation Tomcat Examples + + + +

+

Secure Test

+

+ Modified: cxf/fediz/trunk/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/AbstractTests.java URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/AbstractTests.java?rev=1454493&r1=1454492&r2=1454493&view=diff ============================================================================== --- cxf/fediz/trunk/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/AbstractTests.java (original) +++ cxf/fediz/trunk/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/AbstractTests.java Fri Mar 8 18:43:14 2013 @@ -25,8 +25,10 @@ import java.security.KeyStore; import java.util.ArrayList; import java.util.List; +import net.htmlparser.jericho.Element; import net.htmlparser.jericho.FormField; import net.htmlparser.jericho.FormFields; +import net.htmlparser.jericho.HTMLElementName; import net.htmlparser.jericho.Source; import org.apache.cxf.fediz.core.ClaimTypes; import org.apache.http.Consts; @@ -210,7 +212,7 @@ public abstract class AbstractTests { HttpResponse response = httpclient.execute(httpget); HttpEntity entity = response.getEntity(); - + System.out.println(response.getStatusLine()); if (entity != null) { System.out.println("Response content length: " + entity.getContentLength()); @@ -231,16 +233,25 @@ public abstract class AbstractTests { // change the conditions under which the request was issued. httpclient.setRedirectStrategy(new LaxRedirectStrategy()); - HttpPost httppost = new HttpPost(url); + Source source = new Source(EntityUtils.toString(entity)); List nvps = new ArrayList (); FormFields formFields = source.getFormFields(); + System.out.println(formFields.getDebugInfo()); + System.out.println(source.getFormControls().toString()); + + List forms = source.getAllElements(HTMLElementName.FORM); + Assert.assertEquals("Only one form expected but got " + forms.size(), 1, forms.size()); + String postUrl = forms.get(0).getAttributeValue("action"); + Assert.assertNotNull("Form field 'wa' not found", formFields.get("wa")); Assert.assertNotNull("Form field 'wresult' not found", formFields.get("wresult")); for (FormField formField : formFields) { nvps.add(new BasicNameValuePair(formField.getName(), formField.getValues().get(0))); } + + HttpPost httppost = new HttpPost(postUrl); httppost.setEntity(new UrlEncodedFormEntity(nvps, Consts.UTF_8)); response = httpclient.execute(httppost);