[jboss-svn-commits] JBL Code SVN: r29443 - in labs/jbossesb/workspace/dbevenius/saml_support/product: install and 8 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Sep 23 10:09:52 EDT 2009


Author: beve
Date: 2009-09-23 10:09:51 -0400 (Wed, 23 Sep 2009)
New Revision: 29443

Removed:
   labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/WSTrustClientConfig.java
   labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/WSTrustClientFactory.java
   labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/JBossSTSSAML20SecurityHandler.java
   labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/JBossSTSSecurityHandler.java
   labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/jboss-sts-client.properties
   labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/login/WSTrustClientConfigUnitTest.java
   labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/ws/JBossSTSSAML20SecurityHandlerUnitTest.java
   labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/ws/jboss-sts-client.properties
Modified:
   labs/jbossesb/workspace/dbevenius/saml_support/product/.classpath
   labs/jbossesb/workspace/dbevenius/saml_support/product/install/build.xml
   labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/actions/security/JBossSTSAction.java
   labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/JBossSTSLoginModule.java
   labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/login/JBossSTSLoginModuleUnitTest.java
   labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/src/org/jboss/soa/esb/samples/quickstart/securitysaml/webservice/handlerchain.xml
   labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/war/resources/WEB-INF/web.xml
Log:
Now using the handler that were moved to jboss identity.
Fixed undeploy so that the identity jars are removed from the servers.


Modified: labs/jbossesb/workspace/dbevenius/saml_support/product/.classpath
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/.classpath	2009-09-23 13:06:42 UTC (rev 29442)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/.classpath	2009-09-23 14:09:51 UTC (rev 29443)
@@ -135,10 +135,10 @@
 	<classpathentry kind="lib" path="lib/ext/milyn-commons-1.3-20090908.105925-1.jar"/>
 	<classpathentry kind="lib" path="build/lib/jboss-identity-bindings-1.0.0.beta2.jar"/>
 	<classpathentry kind="lib" path="build/lib/jboss-identity-bindings-jboss-1.0.0.beta2.jar"/>
-	<classpathentry kind="lib" path="build/lib/jboss-identity-fed-api-1.0.0.beta2.jar"/>
 	<classpathentry kind="lib" path="build/lib/jboss-identity-fed-core-1.0.0.beta2.jar"/>
 	<classpathentry kind="lib" path="build/lib/jboss-identity-fed-model-1.0.0.beta2.jar"/>
 	<classpathentry kind="lib" path="build/lib/jboss-identity-xmlsec-model-1.0.0.beta2.jar"/>
 	<classpathentry kind="lib" path="build/lib/freemarker-2.3.11.jar"/>
+	<classpathentry kind="lib" path="lib/ext/jboss-identity-fed-api-1.0.0.beta2-SNAPSHOT.jar"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>

Modified: labs/jbossesb/workspace/dbevenius/saml_support/product/install/build.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/install/build.xml	2009-09-23 13:06:42 UTC (rev 29442)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/install/build.xml	2009-09-23 14:09:51 UTC (rev 29443)
@@ -175,6 +175,11 @@
 	                <include name="xmlsec-*.jar"/>
 	            </fileset>
 	        </copy>
+			<!-- Just here utnil we get a beta3 relaease in maven -->
+			<copy overwrite="true"
+				file="${product.dir}/lib/ext/jboss-identity-fed-api-1.0.0.beta2-SNAPSHOT.jar"  
+				tofile="${server.lib.dir}/jboss-identity-fed-api-1.0.0.beta2.jar"/>
+		
 	        <copy file="${org.jboss.esb.dist.lib}/jbossws-native-core-3.0.5.GA.jar" tofile="${deploy.dir}/jbossws.sar/jbossws-core.jar"/>
 	        <copy file="${org.jboss.esb.dist.lib}/jbossws-common-1.0.8.GA.jar" tofile="${server.lib.dir}/jbossws-common.jar"/>
 
@@ -264,11 +269,15 @@
 		</copy>
 		
 		<copy todir="${org.jboss.esb.server.home}/common/lib" overwrite="true">
-            <fileset dir="${org.jboss.esb.dist.lib}">
+            <fileset dir="${product.dir}/build/lib">
                 <include name="jboss-identity-*.jar"/>
                 <include name="xmlsec-*.jar"/>
             </fileset>
         </copy>
+		<!-- Just here utnil we get a beta3 relaease in maven -->
+		<copy overwrite="true"
+			file="${product.dir}/lib/ext/jboss-identity-fed-api-1.0.0.beta2-SNAPSHOT.jar"  
+			tofile="${org.jboss.esb.server.home}/common/lib/jboss-identity-fed-api-1.0.0.beta2.jar"/>
 		
 	            <property name="org.jboss.esb.server.home" value="${org.jboss.esb.server.home}"/>
 		
@@ -389,11 +398,25 @@
         <delete file="${deploy.dir}/jbas4-admin-console.war" quiet="true"/>
         <delete file="${deploy.dir}/jbas5-admin-console.war"  quiet="true" />
         <delete dir="${conf.dir}/action-templates.xml" quiet="true"/>
+        <delete quiet="false">
+			<fileset dir="${server.lib.dir}" >
+                <include name="jboss-identity-*.jar"/>
+                <include name="xmlsec-*.jar"/>
+            </fileset>
+        </delete>
     	<antcall target="undeploy.jbossas5"/>
     </target>
 	
 	<target name="undeploy.jbossas5" if="jbossas5" >
         <delete dir="${server.dir}/deployers/esb.deployer" quiet="true"/>
+		
+        <delete quiet="false">
+			<fileset dir="${org.jboss.esb.server.home}/common/lib" >
+                <include name="jboss-identity-*.jar"/>
+                <include name="xmlsec-*.jar"/>
+            </fileset>
+        </delete>
+		
     </target>
 
         <property name="org.jboss.esb.tomcat.55lib"

Modified: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/actions/security/JBossSTSAction.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/actions/security/JBossSTSAction.java	2009-09-23 13:06:42 UTC (rev 29442)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/actions/security/JBossSTSAction.java	2009-09-23 14:09:51 UTC (rev 29443)
@@ -24,6 +24,8 @@
 
 import org.apache.log4j.Logger;
 import org.jboss.identity.federation.api.wstrust.WSTrustClient;
+import org.jboss.identity.federation.api.wstrust.WSTrustClientConfig;
+import org.jboss.identity.federation.api.wstrust.WSTrustClientFactory;
 import org.jboss.identity.federation.core.exceptions.ParsingException;
 import org.jboss.identity.federation.core.wstrust.WSTrustException;
 import org.jboss.internal.soa.esb.assertion.AssertArgument;
@@ -40,8 +42,6 @@
 import org.jboss.soa.esb.services.security.auth.AuthenticationRequestImpl;
 import org.jboss.soa.esb.services.security.auth.login.SamlContext;
 import org.jboss.soa.esb.services.security.auth.login.SamlPrincipal;
-import org.jboss.soa.esb.services.security.auth.login.WSTrustClientConfig;
-import org.jboss.soa.esb.services.security.auth.login.WSTrustClientFactory;
 import org.w3c.dom.Element;
 
 

Modified: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/JBossSTSLoginModule.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/JBossSTSLoginModule.java	2009-09-23 13:06:42 UTC (rev 29442)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/JBossSTSLoginModule.java	2009-09-23 14:09:51 UTC (rev 29443)
@@ -34,11 +34,12 @@
 
 import org.apache.log4j.Logger;
 import org.jboss.identity.federation.api.wstrust.WSTrustClient;
+import org.jboss.identity.federation.api.wstrust.WSTrustClientConfig;
+import org.jboss.identity.federation.api.wstrust.WSTrustClientFactory;
 import org.jboss.identity.federation.core.exceptions.ParsingException;
 import org.jboss.identity.federation.core.wstrust.WSTrustException;
 import org.jboss.identity.federation.core.wstrust.plugins.saml.SAMLUtil;
 import org.jboss.identity.federation.saml.v2.assertion.AssertionType;
-import org.jboss.identity.federation.saml.v2.assertion.SubjectType;
 import org.jboss.security.auth.callback.ObjectCallback;
 import org.jboss.soa.esb.services.security.auth.AuthenticationRequest;
 import org.w3c.dom.Element;

Deleted: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/WSTrustClientConfig.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/WSTrustClientConfig.java	2009-09-23 13:06:42 UTC (rev 29442)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/WSTrustClientConfig.java	2009-09-23 14:09:51 UTC (rev 29443)
@@ -1,221 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
- * LLC, and individual contributors by the @authors tag. See the copyright.txt
- * in the distribution for a full listing of individual contributors.
- * 
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or (at your option)
- * any later version.
- * 
- * This software is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
- * details.
- * 
- * You should have received a copy of the GNU Lesser General Public License
- * along with this software; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
- * site: http://www.fsf.org.
- */
-package org.jboss.soa.esb.services.security.auth.login;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
-/**
- * 
- * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
- * 
- */
-public class WSTrustClientConfig
-{
-    public static final String DEFAULT_CONFIG_FILE = "jboss-sts-client.properties";
-    
-    public static final String SERVICE_NAME = "serviceName";
-    public static final String PORT_NAME = "portName";
-    public static final String ENDPOINT_ADDRESS = "endpointAddress";
-    public static final String USERNAME = "username";
-    public static final String PASSWORD = "password";
-    public static final String TOKEN_TYPE = "tokenType";
-
-
-    private String serviceName;
-    private String portName;
-    private String endpointAddress;
-    private String username;
-    private String password;
-
-    private WSTrustClientConfig(final Builder builder)
-    {
-        serviceName = builder.serviceName;
-        portName = builder.portName;
-        endpointAddress = builder.endpointAddress;
-        username = builder.username;
-        password = builder.password;
-    }
-
-    public String getServiceName()
-    {
-        return serviceName;
-    }
-
-    public String getPortName()
-    {
-        return portName;
-    }
-
-    public String getEndPointAddress()
-    {
-        return endpointAddress;
-    }
-
-    public String getUsername()
-    {
-        return username;
-    }
-
-    public String getPassword()
-    {
-        return password;
-    }
-
-    public String toString()
-    {
-        return getClass().getSimpleName() + "[serviceName=" + serviceName + ", portName=" + portName + ", endpointAddress=" + endpointAddress + "]";
-    }
-
-    public static class Builder
-    {
-        private String serviceName;
-        private String portName;
-        private String endpointAddress;
-        private String username;
-        private String password;
-
-        public Builder serviceName(final String serviceName)
-        {
-            this.serviceName = serviceName;
-            return this;
-        }
-
-        public Builder portName(final String portName)
-        {
-            this.portName = portName;
-            return this;
-        }
-
-        public Builder endpointAddress(final String address)
-        {
-            this.endpointAddress = address;
-            return this;
-        }
-
-        public Builder username(final String username)
-        {
-            this.username = username;
-            return this;
-        }
-
-        public Builder password(final String password)
-        {
-            this.password = password;
-            return this;
-        }
-
-        public WSTrustClientConfig build()
-        {
-            validate(this);
-            return new WSTrustClientConfig(this);
-        }
-
-        private void validate(Builder builder)
-        {
-            checkPropertyShowValue(serviceName, SERVICE_NAME);
-            checkPropertyShowValue(portName, PORT_NAME);
-            checkPropertyShowValue(endpointAddress, endpointAddress);
-            checkProperty(username, USERNAME);
-            checkProperty(password, PASSWORD);
-        }
-
-        private void checkPropertyShowValue(final String propertyName, final String propertyValue)
-        {
-            if (propertyValue == null || propertyValue.equals(""))
-                throw new IllegalArgumentException(propertyName + " property must not be null or empty was:" + propertyValue);
-        }
-
-        private void checkProperty(final String propertyName, final String propertyValue)
-        {
-            if (propertyValue == null || propertyValue.equals(""))
-                throw new IllegalArgumentException(propertyName + " property must not be null");
-        }
-
-        public WSTrustClientConfig build(final String configFile)
-        {
-            InputStream in = null;
-
-            try
-            {
-	            in = getResource(configFile);
-	            if (in == null)
-	            {
-	                throw new IllegalStateException("Could not find properties file " + configFile);
-	                
-	            }
-                final Properties properties = new Properties();
-                properties.load(in);
-                this.serviceName = properties.getProperty(SERVICE_NAME);
-                this.portName = properties.getProperty(PORT_NAME);
-                this.endpointAddress = properties.getProperty(ENDPOINT_ADDRESS);
-                this.username = properties.getProperty(USERNAME);
-                this.password = properties.getProperty(PASSWORD);
-            }
-            catch (IOException e)
-            {
-                throw new IllegalStateException("Could not load properties from " + configFile);
-            }
-            finally
-            {
-                try
-                {
-                    if (in != null)
-                        in.close();
-                }
-                catch (final IOException e)
-                {
-                    e.printStackTrace();
-                }
-            }
-
-            validate(this);
-            return new WSTrustClientConfig(this);
-        }
-    }
-
-    private static InputStream getResource(String resource) throws IOException
-    {
-        // Try it as a File resource...
-        final File file = new File(resource);
-
-        if (file.exists() && !file.isDirectory())
-        {
-            return new FileInputStream(file);
-        }
-        // Try it as a classpath resource ...
-        final ClassLoader threadClassLoader = Thread.currentThread().getContextClassLoader() ;
-        if (threadClassLoader != null)
-        {
-            final InputStream is = threadClassLoader.getResourceAsStream(resource) ;
-            if (is != null)
-            {
-                return is ;
-            }
-        }
-        
-	    return  null;
-    }
-
-}

Deleted: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/WSTrustClientFactory.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/WSTrustClientFactory.java	2009-09-23 13:06:42 UTC (rev 29442)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/WSTrustClientFactory.java	2009-09-23 14:09:51 UTC (rev 29443)
@@ -1,49 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
- * LLC, and individual contributors by the @authors tag. See the copyright.txt
- * in the distribution for a full listing of individual contributors.
- * 
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or (at your option)
- * any later version.
- * 
- * This software is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
- * details.
- * 
- * You should have received a copy of the GNU Lesser General Public License
- * along with this software; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
- * site: http://www.fsf.org.
- */
-package org.jboss.soa.esb.services.security.auth.login;
-
-import org.jboss.identity.federation.api.wstrust.WSTrustClient;
-import org.jboss.identity.federation.api.wstrust.WSTrustClient.SecurityInfo;
-import org.jboss.identity.federation.core.exceptions.ParsingException;
-
-/**
- * Simple factory for creating {@link WSTrustClient}s.
- * 
- * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
- */
-public final class WSTrustClientFactory
-{
-    private static final WSTrustClientFactory INSTANCE = new WSTrustClientFactory();
-    
-    private WSTrustClientFactory()
-    {
-    }
-    
-    public static WSTrustClientFactory getInstance()
-    {
-        return INSTANCE;
-    }
-    
-    public WSTrustClient create(final WSTrustClientConfig c) throws ParsingException
-    {
-        return new WSTrustClient(c.getServiceName(), c.getPortName(), c.getEndPointAddress(),  new SecurityInfo(c.getUsername(), c.getPassword()));
-    }
-}

Deleted: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/JBossSTSSAML20SecurityHandler.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/JBossSTSSAML20SecurityHandler.java	2009-09-23 13:06:42 UTC (rev 29442)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/JBossSTSSAML20SecurityHandler.java	2009-09-23 14:09:51 UTC (rev 29443)
@@ -1,52 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
- * LLC, and individual contributors by the @authors tag. See the copyright.txt
- * in the distribution for a full listing of individual contributors.
- * 
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or (at your option)
- * any later version.
- * 
- * This software is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
- * details.
- * 
- * You should have received a copy of the GNU Lesser General Public License
- * along with this software; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
- * site: http://www.fsf.org.
- */
-package org.jboss.soa.esb.services.security.auth.ws;
-
-import javax.xml.namespace.QName;
-
-/**
- * 
- * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
- *
- */
-public class JBossSTSSAML20SecurityHandler extends JBossSTSSecurityHandler
-{
-    public static final String SECURITY_ELEMENT_NAME = "Security";
-    public static final String SECURITY_ELEMENT_NS =  "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
-    public static final QName SECURITY_QNAME = new QName(SECURITY_ELEMENT_NS, SECURITY_ELEMENT_NAME);
-    
-    public static final String SAML_TOKEN_NAME = "Assertion";
-    public static final String SAML_TOKEN_NS =  "urn:oasis:names:tc:SAML:2.0:assertion";
-    public static final QName SAML_TOKEN_QNAME = new QName(SAML_TOKEN_NS, SAML_TOKEN_NAME);
-    
-    @Override
-    public QName getSecurityElementQName()
-    {
-        return SECURITY_QNAME;
-    }
-
-    @Override
-    public QName getTokenElementQName()
-    {
-        return SAML_TOKEN_QNAME;
-    }
-
-}

Deleted: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/JBossSTSSecurityHandler.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/JBossSTSSecurityHandler.java	2009-09-23 13:06:42 UTC (rev 29442)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/JBossSTSSecurityHandler.java	2009-09-23 14:09:51 UTC (rev 29443)
@@ -1,216 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
- * LLC, and individual contributors by the @authors tag. See the copyright.txt
- * in the distribution for a full listing of individual contributors.
- * 
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or (at your option)
- * any later version.
- * 
- * This software is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
- * details.
- * 
- * You should have received a copy of the GNU Lesser General Public License
- * along with this software; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
- * site: http://www.fsf.org.
- */
-package org.jboss.soa.esb.services.security.auth.ws;
-
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.Set;
-
-//import javax.annotation.Resource;
-import javax.xml.namespace.QName;
-import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPHeader;
-import javax.xml.soap.SOAPHeaderElement;
-import javax.xml.ws.WebServiceException;
-import javax.xml.ws.handler.MessageContext;
-import javax.xml.ws.handler.soap.SOAPHandler;
-import javax.xml.ws.handler.soap.SOAPMessageContext;
-
-import org.apache.log4j.Logger;
-import org.jboss.identity.federation.api.wstrust.WSTrustClient;
-import org.jboss.identity.federation.core.exceptions.ParsingException;
-import org.jboss.identity.federation.core.wstrust.WSTrustException;
-import org.jboss.soa.esb.services.security.auth.login.WSTrustClientConfig;
-import org.jboss.soa.esb.services.security.auth.login.WSTrustClientFactory;
-import org.w3c.dom.Element;
-
-/**
- * JBossSTSSecurityHandler is a server-side JAX-WS SOAP Protocol handler that will extract 
- * a Security Token from the SOAP Security Header and validate the token with JBoss Security 
- * Token Service (STS)
- * <p/>
- * 
- * <h3>Concrete implementations</h3>
- * Subclasses a required to implement two methods:
- * <ul>
- * <li> {@link #getSecurityElementQName()} 
- *    This should return the qualified name of the security header. This lets us support 
- *    different versions. </li>
- *    
- * <li>{@link #getTokenElementQName()}
- *    This should return the qualified name of the security token element that should exist
- *    in the security header. This lets us support different tokens that can be validated
- *    with JBossSTS.</li>
- * </ul>
- * <p/>
- *    
- * <h3>Configuration</h3>
- * This class uses {@link WSTrustClient} to interact with JBossSTS. By default the configuration
- * properties are set in a file named {@link WSTrustClientConfig#DEFAULT_CONFIG_FILE}.
- * This can be overridden by specifying environment entries in a deployment descriptor. 
- * 
- * For example in web.xml:
- * <pre>{@code
- * <env-entry>
- *   <env-entry-name>JBossSTSClientConfig</env-entry-name>
- *   <env-entry-type>java.lang.String</env-entry-type>
- *   <env-entry-value>/jboss-sts-client.properties</env-entry-value>
- * </env-entry>
- * }</pre>
- * 
- * 
- * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
- */
-public abstract class JBossSTSSecurityHandler implements SOAPHandler<SOAPMessageContext>
-{
-    private Logger log = Logger.getLogger(JBossSTSSecurityHandler.class);
-    
-    /**
-     * The path to the jboss-sts-client.properties file.
-     */
-    private String configFile = WSTrustClientConfig.DEFAULT_CONFIG_FILE;
-    
-    /**
-     * Subclasses can return the QName of the Security header element in usage.
-     * 
-     * @return QName
-     */
-    public abstract QName getSecurityElementQName();
-    
-    /**
-     * Subclasses can return the QName of the Security Element that should be used 
-     * as the token for validation.
-     * 
-     * @return QName
-     */
-    public abstract QName getTokenElementQName();
-    
-    /**
-     * Will process in-bound messages and extract a security token from the SOAP Header. This token
-     * will then be validated using by calling JBossSTS.
-     * 
-     * @param messageContext The {@link SOAPMessageContext}.
-     */
-    public boolean handleMessage(final SOAPMessageContext messageContext)
-    {
-        if (isOutBound(messageContext))
-            return true;
-        
-        try
-        {
-            log.info("Using configFile : " + configFile);
-            final WSTrustClientConfig config = new WSTrustClientConfig.Builder().build(configFile);
-            final WSTrustClient wsTrustClient = createWSTrustClient(config);
-
-            final Element securityToken = extractSecurityToken(messageContext, getSecurityElementQName(), getTokenElementQName());
-            final boolean valid = wsTrustClient.validateToken(securityToken);
-            if (valid)
-            {
-                log.info("Succesfully validated Token : " + securityToken);
-                return true;
-            }
-            else
-            {
-                log.info("Could not validate token");
-                throw new WebServiceException("Could not validate security token "+ securityToken);
-            }
-        }
-        catch (final SOAPException e)
-        {
-            throw new WebServiceException(e.getMessage(), e);
-        }
-        catch (final WSTrustException e)
-        {
-            throw new WebServiceException(e.getMessage(), e);
-        }
-        catch (final ParsingException e)
-        {
-            throw new WebServiceException(e.getMessage(), e);
-        }
-    }
-    
-    private boolean isOutBound(final SOAPMessageContext messageContext)
-    {
-        return ((Boolean) messageContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY)).booleanValue();
-    }
-    
-    protected WSTrustClient createWSTrustClient(final WSTrustClientConfig config) throws ParsingException
-    {
-        return WSTrustClientFactory.getInstance().create(config);
-    }
-
-    private Element extractSecurityToken(final SOAPMessageContext messageContext, final QName securityQName, final QName tokenQName) throws SOAPException
-    {
-        final SOAPHeader soapHeader = messageContext.getMessage().getSOAPHeader();
-        final Iterator securityHeaders = soapHeader.getChildElements(securityQName);
-        while (securityHeaders.hasNext())
-        {
-            final SOAPHeaderElement elem = (SOAPHeaderElement) securityHeaders.next();
-            if (elem.getElementQName().equals(securityQName))
-            {
-                final Iterator childElements = elem.getChildElements(tokenQName);
-                while (childElements.hasNext())
-                {
-                    return (Element) childElements.next();
-                }
-            }
-        }
-        return null;
-    }
-
-    public Set<QName> getHeaders()
-    {
-        return Collections.singleton(getSecurityElementQName());
-    }
-
-    public boolean handleFault(final SOAPMessageContext messageContext)
-    {
-        return false;
-    }
-    /**
-     * No cleanup is done here.
-     */
-    public void close(final MessageContext messageContext)
-    {
-    }
-    
-    /**
-     * This setter enables the injection of the jboss-sts-client.properties file
-     * path.
-     *  
-     * @param configFile
-     */
-    
-    /*
-     * @Resource (name = "JBossSTSClientConfig")
-     * Commented out as this does not work with AS4.2.3
-     * with AS 5.1.0 this works as expected.
-     * 
-     * 
-     */
-    public void setConfigFile(final String configFile)
-    {
-        if (configFile != null)
-        {
-	        this.configFile = configFile;
-        }
-    }
-}

Deleted: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/jboss-sts-client.properties
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/jboss-sts-client.properties	2009-09-23 13:06:42 UTC (rev 29442)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/jboss-sts-client.properties	2009-09-23 14:09:51 UTC (rev 29443)
@@ -1,5 +0,0 @@
-serviceName=JBossSTS
-portName=JBossSTSPort
-endpointAddress=http://localhost:8080/jboss-sts/JBossSTS
-username=admin
-password=admin

Modified: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/login/JBossSTSLoginModuleUnitTest.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/login/JBossSTSLoginModuleUnitTest.java	2009-09-23 13:06:42 UTC (rev 29442)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/login/JBossSTSLoginModuleUnitTest.java	2009-09-23 14:09:51 UTC (rev 29443)
@@ -34,6 +34,7 @@
 import junit.framework.JUnit4TestAdapter;
 
 import org.jboss.identity.federation.api.wstrust.WSTrustClient;
+import org.jboss.identity.federation.api.wstrust.WSTrustClientConfig;
 import org.jboss.identity.federation.core.wstrust.plugins.saml.SAMLUtil;
 import org.jboss.identity.federation.saml.v2.assertion.AssertionType;
 import org.jboss.soa.esb.services.security.auth.AuthenticationRequest;
@@ -122,7 +123,7 @@
     private Map<String, String> allOptions()
     {
         final Map<String, String> options = new HashMap<String, String>();
-        options.put(JBossSTSLoginModule.STS_CONFIG_FILE, "jboss-sts-client.properties");
+        options.put(JBossSTSLoginModule.STS_CONFIG_FILE, "org/jboss/soa/esb/services/security/auth/login/jboss-sts-client.properties");
         return options;
     }
 

Deleted: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/login/WSTrustClientConfigUnitTest.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/login/WSTrustClientConfigUnitTest.java	2009-09-23 13:06:42 UTC (rev 29442)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/login/WSTrustClientConfigUnitTest.java	2009-09-23 14:09:51 UTC (rev 29443)
@@ -1,75 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
- * LLC, and individual contributors by the @authors tag. See the copyright.txt
- * in the distribution for a full listing of individual contributors.
- * 
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or (at your option)
- * any later version.
- * 
- * This software is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
- * details.
- * 
- * You should have received a copy of the GNU Lesser General Public License
- * along with this software; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
- * site: http://www.fsf.org.
- */
-package org.jboss.soa.esb.services.security.auth.login;
-
-import static org.junit.Assert.*;
-
-import org.jboss.soa.esb.services.security.auth.login.WSTrustClientConfig.Builder;
-import org.junit.Test;
-
-import junit.framework.JUnit4TestAdapter;
-
-/**
- * Unit test for {@link WSTrustClientConfig}.
- * 
- * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
- * 
- */
-public class WSTrustClientConfigUnitTest
-{
-    final String serviceName = "JBossSTS";
-    final String portName = "JBossSTSPort";
-    final String endpointAddress = "http://test:8080/JBossSTS";
-    final String username = "user1";
-    final String password = "pass1";
-    
-    @Test
-    public void build()
-    {
-        final Builder builder = new WSTrustClientConfig.Builder();
-        final WSTrustClientConfig config = builder.serviceName(serviceName).portName(portName).endpointAddress(endpointAddress).username(username).password(password).build();
-        assertAllProperties(config);
-    }
-    
-    @Test
-    public void buildFromConfigPropertiesFile()
-    {
-        final Builder builder = new WSTrustClientConfig.Builder();
-        WSTrustClientConfig config = builder.build(WSTrustClientConfig.DEFAULT_CONFIG_FILE);
-        assertAllProperties(config);
-    }
-    
-    private void assertAllProperties(final WSTrustClientConfig config)
-    {
-        assertEquals(serviceName, config.getServiceName());
-        assertEquals(portName, config.getPortName());
-        assertEquals(endpointAddress, config.getEndPointAddress());
-        assertEquals(username, config.getUsername());
-        assertEquals(password, config.getPassword());
-        
-    }
-    
-    public static junit.framework.Test suite()
-    {
-        return new JUnit4TestAdapter(WSTrustClientConfigUnitTest.class);
-    }
-
-}

Deleted: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/ws/JBossSTSSAML20SecurityHandlerUnitTest.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/ws/JBossSTSSAML20SecurityHandlerUnitTest.java	2009-09-23 13:06:42 UTC (rev 29442)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/ws/JBossSTSSAML20SecurityHandlerUnitTest.java	2009-09-23 14:09:51 UTC (rev 29443)
@@ -1,150 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
- * LLC, and individual contributors by the @authors tag. See the copyright.txt
- * in the distribution for a full listing of individual contributors.
- * 
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or (at your option)
- * any later version.
- * 
- * This software is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
- * details.
- * 
- * You should have received a copy of the GNU Lesser General Public License
- * along with this software; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
- * site: http://www.fsf.org.
- */
-package org.jboss.soa.esb.services.security.auth.ws;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import javax.xml.namespace.QName;
-import javax.xml.soap.MessageFactory;
-import javax.xml.soap.SOAPElement;
-import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPHeader;
-import javax.xml.soap.SOAPHeaderElement;
-import javax.xml.soap.SOAPMessage;
-import javax.xml.ws.WebServiceException;
-import javax.xml.ws.handler.MessageContext;
-import javax.xml.ws.handler.soap.SOAPMessageContext;
-
-import junit.framework.JUnit4TestAdapter;
-
-import org.jboss.identity.federation.api.wstrust.WSTrustClient;
-import org.jboss.identity.federation.core.exceptions.ParsingException;
-import org.jboss.soa.esb.services.security.auth.login.WSTrustClientConfig;
-import org.junit.Test;
-import org.w3c.dom.Element;
-
-/**
- * Unit test for {@link JBossSTSSecurityHandler}.
- * 
- * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
- * 
- */
-public class JBossSTSSAML20SecurityHandlerUnitTest
-{
-    @Test
-    public void handleMessageValidateOutbound() throws SOAPException
-    {
-        final SOAPMessageContext messageContext = mock(SOAPMessageContext.class);
-
-        // Set it to be an outbound message.
-        when(messageContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY)).thenReturn(true);
-
-        boolean result = new MockSAMLHandler().handleMessage(messageContext);
-        assertTrue(result);
-    }
-
-    @Test
-    public void handleMessageValidToken() throws Exception
-    {
-        final SOAPMessageContext messageContext = mock(SOAPMessageContext.class);
-        final SOAPMessage soapMessage = MessageFactory.newInstance().createMessage();
-        final SOAPHeader soapHeader = soapMessage.getSOAPHeader();
-        
-        final WSTrustClient client = mock(WSTrustClient.class);
-        when(client.validateToken((any(Element.class)))).thenReturn(true);
-        
-        final MockSAMLHandler samlHandler = new MockSAMLHandler(client);
-        
-        final QName securityQName = samlHandler.getSecurityElementQName();
-        final SOAPHeaderElement securityHeader = soapHeader.addHeaderElement(new QName(securityQName.getNamespaceURI(), securityQName.getLocalPart(), "wsse"));
-        soapHeader.addChildElement(securityHeader);
-        
-        final QName tokenElementQName = samlHandler.getTokenElementQName();
-        SOAPElement tokenElement = securityHeader.addChildElement(new QName(tokenElementQName.getNamespaceURI(), tokenElementQName.getLocalPart(), "saml"));
-        securityHeader.addChildElement(tokenElement);
-
-        // Set it to be an inbound message.
-        when(messageContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY)).thenReturn(false);
-        when(messageContext.getMessage()).thenReturn(soapMessage);
-        
-        boolean result = samlHandler.handleMessage(messageContext);
-        assertTrue(result);
-    }
-    
-    @Test (expected = WebServiceException.class)
-    public void handleMessageInValidToken() throws Exception
-    {
-        final SOAPMessageContext messageContext = mock(SOAPMessageContext.class);
-        final SOAPMessage soapMessage = MessageFactory.newInstance().createMessage();
-        final SOAPHeader soapHeader = soapMessage.getSOAPHeader();
-        
-        final WSTrustClient client = mock(WSTrustClient.class);
-        when(client.validateToken((any(Element.class)))).thenReturn(false);
-        
-        final MockSAMLHandler samlHandler = new MockSAMLHandler(client);
-        
-        final QName securityQName = samlHandler.getSecurityElementQName();
-        final SOAPHeaderElement securityHeader = soapHeader.addHeaderElement(new QName(securityQName.getNamespaceURI(), securityQName.getLocalPart(), "wsse"));
-        soapHeader.addChildElement(securityHeader);
-        
-        final QName tokenElementQName = samlHandler.getTokenElementQName();
-        SOAPElement tokenElement = securityHeader.addChildElement(new QName(tokenElementQName.getNamespaceURI(), tokenElementQName.getLocalPart(), "saml"));
-        securityHeader.addChildElement(tokenElement);
-
-        // Set it to be an inbound message.
-        when(messageContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY)).thenReturn(false);
-        when(messageContext.getMessage()).thenReturn(soapMessage);
-        
-        boolean result = samlHandler.handleMessage(messageContext);
-    }
-
-    private class MockSAMLHandler extends JBossSTSSAML20SecurityHandler
-    {
-        private WSTrustClient client;
-
-        public MockSAMLHandler()
-        {
-        }
-
-        public MockSAMLHandler(final WSTrustClient client)
-        {
-            this.client = client;
-
-        }
-
-        @Override
-        protected WSTrustClient createWSTrustClient(WSTrustClientConfig config) throws ParsingException
-        {
-            return client;
-        }
-
-    }
-
-    public static junit.framework.Test suite()
-    {
-        return new JUnit4TestAdapter(JBossSTSSAML20SecurityHandlerUnitTest.class);
-    }
-
-}

Deleted: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/ws/jboss-sts-client.properties
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/ws/jboss-sts-client.properties	2009-09-23 13:06:42 UTC (rev 29442)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/ws/jboss-sts-client.properties	2009-09-23 14:09:51 UTC (rev 29443)
@@ -1,5 +0,0 @@
-serviceName=JBossSTS
-portName=JBossSTSPort
-endpointAddress=http://localhost:8080/jboss-sts/JBossSTS
-username=admin
-password=admin

Modified: labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/src/org/jboss/soa/esb/samples/quickstart/securitysaml/webservice/handlerchain.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/src/org/jboss/soa/esb/samples/quickstart/securitysaml/webservice/handlerchain.xml	2009-09-23 13:06:42 UTC (rev 29442)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/src/org/jboss/soa/esb/samples/quickstart/securitysaml/webservice/handlerchain.xml	2009-09-23 14:09:51 UTC (rev 29443)
@@ -3,7 +3,7 @@
 	<jws:handler-chains>
 		<jws:handler-chain>
 			<jws:handler>
-				<jws:handler-class>org.jboss.soa.esb.services.security.auth.ws.JBossSTSSAML20SecurityHandler</jws:handler-class>
+				<jws:handler-class>org.jboss.identity.federation.api.wstrust.handlers.JBossSTSSaml20Handler</jws:handler-class>
 			</jws:handler>
 		</jws:handler-chain>
 	</jws:handler-chains>

Modified: labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/war/resources/WEB-INF/web.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/war/resources/WEB-INF/web.xml	2009-09-23 13:06:42 UTC (rev 29442)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/war/resources/WEB-INF/web.xml	2009-09-23 14:09:51 UTC (rev 29443)
@@ -15,12 +15,10 @@
         <url-pattern>/GoodbyeWorldWS</url-pattern>
     </servlet-mapping>
 
-	<!--
 	<env-entry>
-		<env-entry-name>configFile</env-entry-name>
+		<env-entry-name>JBossSTSClientConfig</env-entry-name>
 		<env-entry-type>java.lang.String</env-entry-type>
 		<env-entry-value>/jboss-sts-client.properties</env-entry-value>
 	</env-entry>
-	-->
 
 </web-app>



More information about the jboss-svn-commits mailing list