[jboss-svn-commits] JBL Code SVN: r21052 - in labs/jbossesb/workspace/dbevenius/security/product: etc/schemas/xml and 4 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Jul 16 05:16:44 EDT 2008
Author: beve
Date: 2008-07-16 05:16:43 -0400 (Wed, 16 Jul 2008)
New Revision: 21052
Added:
labs/jbossesb/workspace/dbevenius/security/product/rosetta/src/org/jboss/soa/esb/services/security/
labs/jbossesb/workspace/dbevenius/security/product/rosetta/src/org/jboss/soa/esb/services/security/SecurityService.java
labs/jbossesb/workspace/dbevenius/security/product/rosetta/src/org/jboss/soa/esb/services/security/SecurityServiceImpl.java
labs/jbossesb/workspace/dbevenius/security/product/rosetta/tests/src/org/jboss/soa/esb/services/security/
labs/jbossesb/workspace/dbevenius/security/product/rosetta/tests/src/org/jboss/soa/esb/services/security/SecurityServiceImplUnitTest.java
labs/jbossesb/workspace/dbevenius/security/product/rosetta/tests/src/org/jboss/soa/esb/services/security/TestLoginModule.java
labs/jbossesb/workspace/dbevenius/security/product/rosetta/tests/src/org/jboss/soa/esb/services/security/TestPrincipal.java
labs/jbossesb/workspace/dbevenius/security/product/rosetta/tests/src/org/jboss/soa/esb/services/security/jaas-test.config
Modified:
labs/jbossesb/workspace/dbevenius/security/product/.classpath
labs/jbossesb/workspace/dbevenius/security/product/.project
labs/jbossesb/workspace/dbevenius/security/product/etc/schemas/xml/jbossesb-1.0.1.xsd
Log:
First checkin. Mainly to share the code.
Modified: labs/jbossesb/workspace/dbevenius/security/product/.classpath
===================================================================
--- labs/jbossesb/workspace/dbevenius/security/product/.classpath 2008-07-16 07:43:58 UTC (rev 21051)
+++ labs/jbossesb/workspace/dbevenius/security/product/.classpath 2008-07-16 09:16:43 UTC (rev 21052)
@@ -18,7 +18,6 @@
<classpathentry kind="lib" path="lib/ext/jbossall-client.jar"/>
<classpathentry kind="lib" path="lib/ext/jboss-system.jar"/>
<classpathentry kind="lib" path="lib/ext/jbossts-common.jar"/>
- <classpathentry kind="lib" path="lib/ext/jsch-0.1.jar"/>
<classpathentry kind="lib" path="lib/ext/juddi-2.0rc5.jar"/>
<classpathentry kind="lib" path="lib/ext/juddi-client-2.0rc5.jar"/>
<classpathentry kind="lib" path="lib/ext/junit-4.1.jar"/>
@@ -37,7 +36,6 @@
<classpathentry kind="lib" path="lib/ext/xstream-1.2.2.jar"/>
<classpathentry kind="lib" path="lib/ext/jboss.jar"/>
<classpathentry kind="lib" path="lib/ext/commons-io-1.3.jar"/>
- <classpathentry kind="lib" path="lib/ext/edtftpj-1.5.4.jar"/>
<classpathentry kind="lib" path="ftp/lib/backport-util-concurrent-2.2.jar"/>
<classpathentry kind="lib" path="ftp/lib/ftplet-api-1.0-incubator-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="ftp/lib/ftpserver-admin-gui-1.0-incubator-SNAPSHOT.jar"/>
@@ -69,10 +67,13 @@
<classpathentry kind="lib" path="lib/ext/jakarta-oro-2.0.8.jar"/>
<classpathentry kind="lib" path="lib/ext/commons-ssl-0.3.4.jar"/>
<classpathentry kind="lib" path="services/jbrules/lib/ext/antlr-runtime-3.0.jar"/>
- <classpathentry kind="lib" path="lib/ext/mvel14-1.2rc4rv908.jar"/>
<classpathentry kind="lib" path="lib/ext/quartz-1.5.2.jar"/>
<classpathentry kind="lib" path="lib/ext/jaxr-api-1.0rc1.jar"/>
<classpathentry kind="lib" path="lib/ext/jboss-jaxb-intros.jar"/>
<classpathentry kind="lib" path="lib/ext/scout-1.0rc1.jar"/>
+ <classpathentry kind="lib" path="lib/ext/commons-net-2.0.0-652071.jar"/>
+ <classpathentry kind="lib" path="lib/ext/h2.jar"/>
+ <classpathentry kind="lib" path="lib/ext/mvel-1.3.1-java1.4.jar"/>
+ <classpathentry kind="lib" path="lib/ext/jsch-0.1.38.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified: labs/jbossesb/workspace/dbevenius/security/product/.project
===================================================================
--- labs/jbossesb/workspace/dbevenius/security/product/.project 2008-07-16 07:43:58 UTC (rev 21051)
+++ labs/jbossesb/workspace/dbevenius/security/product/.project 2008-07-16 09:16:43 UTC (rev 21052)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>JBossESB</name>
+ <name>JBossESB-security</name>
<comment></comment>
<projects>
</projects>
Modified: labs/jbossesb/workspace/dbevenius/security/product/etc/schemas/xml/jbossesb-1.0.1.xsd
===================================================================
--- labs/jbossesb/workspace/dbevenius/security/product/etc/schemas/xml/jbossesb-1.0.1.xsd 2008-07-16 07:43:58 UTC (rev 21051)
+++ labs/jbossesb/workspace/dbevenius/security/product/etc/schemas/xml/jbossesb-1.0.1.xsd 2008-07-16 09:16:43 UTC (rev 21052)
@@ -261,12 +261,12 @@
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
+ <xsd:element maxOccurs="1" minOccurs="0" ref="jesb:security" />
<xsd:element maxOccurs="unbounded" minOccurs="0"
ref="jesb:property" />
<xsd:element maxOccurs="1" minOccurs="0"
ref="jesb:listeners" />
- <xsd:element maxOccurs="1" minOccurs="0"
- ref="jesb:actions" />
+ <xsd:element maxOccurs="1" minOccurs="0" ref="jesb:actions" />
</xsd:sequence>
<xsd:attribute name="category" type="xsd:string"
use="required">
@@ -385,6 +385,31 @@
</xsd:attribute>
</xsd:complexType>
</xsd:element>
+
+ <xsd:element name="security">
+ <xsd:annotation>
+ <xsd:documentation xml:lang="en">
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element maxOccurs="unbounded" minOccurs="0" ref="jesb:property" />
+ </xsd:sequence>
+ <xsd:attribute name="runAs" type="xsd:string" use="optional">
+ <xsd:annotation>
+ <xsd:documentation xml:lang="en">
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="useCallerIdentity" type="xsd:string" use="optional">
+ <xsd:annotation>
+ <xsd:documentation xml:lang="en">
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ </xsd:complexType>
+ </xsd:element>
+
<!-- 88888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
Listener base types.
Added: labs/jbossesb/workspace/dbevenius/security/product/rosetta/src/org/jboss/soa/esb/services/security/SecurityService.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/security/product/rosetta/src/org/jboss/soa/esb/services/security/SecurityService.java (rev 0)
+++ labs/jbossesb/workspace/dbevenius/security/product/rosetta/src/org/jboss/soa/esb/services/security/SecurityService.java 2008-07-16 09:16:43 UTC (rev 21052)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, 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;
+
+import java.security.PrivilegedAction;
+
+import javax.security.auth.Subject;
+import javax.security.auth.login.LoginException;
+
+/**
+ *
+ * @author <a href="mailto:dbevenius at redhat.com">Daniel Bevenius</a>
+ *
+ */
+public interface SecurityService
+{
+ <T> T runAsSubject( Subject subject, PrivilegedAction<T> action );
+
+ void login( final String configurationName, final Subject subject ) throws LoginException;
+}
Added: labs/jbossesb/workspace/dbevenius/security/product/rosetta/src/org/jboss/soa/esb/services/security/SecurityServiceImpl.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/security/product/rosetta/src/org/jboss/soa/esb/services/security/SecurityServiceImpl.java (rev 0)
+++ labs/jbossesb/workspace/dbevenius/security/product/rosetta/src/org/jboss/soa/esb/services/security/SecurityServiceImpl.java 2008-07-16 09:16:43 UTC (rev 21052)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, 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;
+
+import java.security.PrivilegedAction;
+
+import javax.security.auth.Subject;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+
+/**
+ * Concreate impl of a SecurityService in JBoss ESB
+ * <p/>
+ *
+ * @author <a href="mailto:dbevenius at redhat.com">Daniel Bevenius</a>
+ * @Since 4.4
+ */
+public class SecurityServiceImpl implements SecurityService
+{
+ /**
+ * Will run the priviledged action with a fresh ActionControlContext
+ */
+ @SuppressWarnings("unchecked")
+ public <T> T runAsSubject( final Subject subject, final PrivilegedAction<T> action )
+ {
+ return (T) Subject.doAsPrivileged( subject , action, null);
+ }
+
+ public void login( final String configurationName, final Subject subject ) throws LoginException
+ {
+ LoginContext loginContext = new LoginContext( configurationName, subject, null, null );
+ loginContext.login();
+ }
+
+}
Added: labs/jbossesb/workspace/dbevenius/security/product/rosetta/tests/src/org/jboss/soa/esb/services/security/SecurityServiceImplUnitTest.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/security/product/rosetta/tests/src/org/jboss/soa/esb/services/security/SecurityServiceImplUnitTest.java (rev 0)
+++ labs/jbossesb/workspace/dbevenius/security/product/rosetta/tests/src/org/jboss/soa/esb/services/security/SecurityServiceImplUnitTest.java 2008-07-16 09:16:43 UTC (rev 21052)
@@ -0,0 +1,133 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, 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;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.File;
+import java.security.Principal;
+import java.security.PrivilegedAction;
+import java.util.Set;
+
+import javax.security.auth.Subject;
+import javax.security.auth.login.FailedLoginException;
+import javax.security.auth.login.LoginException;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Unit test for {@link SecurityServiceImpl}
+ * <p/>
+ *
+ * @author <a href="mailto:dbevenius at redhat.com">Daniel Bevenius</a>
+ * @since 4.4
+ */
+public class SecurityServiceImplUnitTest
+{
+ private SecurityService service = new SecurityServiceImpl();
+ private Subject subject = new Subject();
+
+ private static String policyConfig;
+
+ @Test
+ public void runAsSubject()
+ {
+ subject.getPrincipals().add( new MockPrincipal( "danbev") );
+
+ String name = service.runAsSubject( subject, new Action() );
+ assertEquals( "somestring", name );
+ }
+
+ @Test
+ public void loginSuccess() throws LoginException
+ {
+ System.setProperty("java.security.auth.login.config", policyConfig );
+ service.login( "SuccessfulLogin", subject );
+ Set<TestPrincipal> principals = subject.getPrincipals( TestPrincipal.class );
+ assertEquals( 1, principals.size() );
+ assertEquals( "test", principals.iterator().next().getName() );
+ }
+
+ @Test ( expected = FailedLoginException.class )
+ public void loginFailure() throws LoginException
+ {
+ System.setProperty("java.security.auth.login.config", policyConfig );
+ service.login( "FailureLogin", subject );
+ }
+
+ @BeforeClass
+ public static void setup()
+ {
+ //TODO: clean this upp and don't use a path
+ final String fs = File.separator;
+ StringBuilder sb = new StringBuilder();
+ sb.append( "bin" ).append( fs );
+ sb.append( "org" ).append( fs );
+ sb.append( "jboss" ).append( fs );
+ sb.append( "soa" ).append( fs );
+ sb.append( "esb" ).append( fs );
+ sb.append( "services" ).append( fs );
+ sb.append( "security" ).append( fs );
+ sb.append( "jaas-test.config" );
+ policyConfig = sb.toString();
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new JUnit4TestAdapter( SecurityServiceImplUnitTest.class );
+ }
+
+ private class Action implements PrivilegedAction<String>
+ {
+ public String run()
+ {
+ System.out.println("Running action...");
+ return "somestring";
+ }
+ }
+
+ private class MockPrincipal implements Principal
+ {
+ String name;
+
+ public MockPrincipal(String name)
+ {
+ super();
+ this.name = name;
+ }
+
+ public MockPrincipal()
+ {
+ super();
+ }
+
+
+ public String getName()
+ {
+ return null;
+ }
+
+ }
+
+}
Added: labs/jbossesb/workspace/dbevenius/security/product/rosetta/tests/src/org/jboss/soa/esb/services/security/TestLoginModule.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/security/product/rosetta/tests/src/org/jboss/soa/esb/services/security/TestLoginModule.java (rev 0)
+++ labs/jbossesb/workspace/dbevenius/security/product/rosetta/tests/src/org/jboss/soa/esb/services/security/TestLoginModule.java 2008-07-16 09:16:43 UTC (rev 21052)
@@ -0,0 +1,123 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, 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;
+
+import java.util.Map;
+
+import javax.security.auth.Subject;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.login.FailedLoginException;
+import javax.security.auth.login.LoginException;
+import javax.security.auth.spi.LoginModule;
+
+/**
+ * LoginModule intended for testing perposes. <p/>
+ *
+ * @author <a href="mailto:dbevenius at redhat.com">Daniel Bevenius</a>
+ */
+public class TestLoginModule implements LoginModule
+{
+ private Subject subject;
+
+ // the authentication status
+ private boolean succeeded = false;
+
+ private boolean commitSucceeded = false;
+
+ private String username = "test";
+
+ private TestPrincipal principal;
+
+ private static boolean forceLogin;
+
+ public void initialize( final Subject subject, final CallbackHandler callbackHandler, final Map<String,?> sharedState, final Map<String,?> options )
+ {
+ this.subject = subject;
+ forceLogin = "true".equalsIgnoreCase( (String) options.get( "forceLogin" ) );
+ }
+
+ public boolean login() throws LoginException
+ {
+ if ( forceLogin )
+ {
+ succeeded = true;
+ return true;
+ }
+ else
+ {
+ succeeded = false;
+ throw new FailedLoginException( "Login failed" );
+ }
+ }
+
+ public boolean commit() throws LoginException
+ {
+ if (succeeded == false)
+ {
+ return false;
+ }
+ else
+ {
+ principal = new TestPrincipal( username );
+ if ( !subject.getPrincipals().contains( principal ) )
+ {
+ subject.getPrincipals().add( principal );
+ }
+
+ // in any case, clean out state
+ username = null;
+
+ commitSucceeded = true;
+ return true;
+ }
+ }
+
+ public boolean abort() throws LoginException
+ {
+ if (succeeded == false)
+ {
+ return false;
+ }
+ else if ( succeeded == true && commitSucceeded == false)
+ {
+ // login succeeded but overall authentication failed
+ succeeded = false;
+ username = null;
+ principal = null;
+ }
+ else
+ {
+ logout();
+ }
+ return true;
+ }
+
+ public boolean logout() throws LoginException
+ {
+
+ subject.getPrincipals().remove( principal );
+ succeeded = false;
+ succeeded = commitSucceeded;
+ username = null;
+ principal = null;
+ return true;
+ }
+}
Added: labs/jbossesb/workspace/dbevenius/security/product/rosetta/tests/src/org/jboss/soa/esb/services/security/TestPrincipal.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/security/product/rosetta/tests/src/org/jboss/soa/esb/services/security/TestPrincipal.java (rev 0)
+++ labs/jbossesb/workspace/dbevenius/security/product/rosetta/tests/src/org/jboss/soa/esb/services/security/TestPrincipal.java 2008-07-16 09:16:43 UTC (rev 21052)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, 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;
+
+import java.security.Principal;
+
+import org.jboss.internal.soa.esb.assertion.AssertArgument;
+
+/**
+ * Principal intented for use in test. </p>
+ *
+ * @author <a href="mailto:dbevenius at redhat.com">Daniel Bevenius</a>
+ */
+public class TestPrincipal implements Principal, java.io.Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * @serial
+ */
+ private String name;
+
+ public TestPrincipal(String name)
+ {
+ AssertArgument.isNotNull( name, "name" );
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+}
Added: labs/jbossesb/workspace/dbevenius/security/product/rosetta/tests/src/org/jboss/soa/esb/services/security/jaas-test.config
===================================================================
--- labs/jbossesb/workspace/dbevenius/security/product/rosetta/tests/src/org/jboss/soa/esb/services/security/jaas-test.config (rev 0)
+++ labs/jbossesb/workspace/dbevenius/security/product/rosetta/tests/src/org/jboss/soa/esb/services/security/jaas-test.config 2008-07-16 09:16:43 UTC (rev 21052)
@@ -0,0 +1,6 @@
+SuccessfulLogin {
+ org.jboss.soa.esb.services.security.TestLoginModule required forceLogin=true;
+};
+FailureLogin {
+ org.jboss.soa.esb.services.security.TestLoginModule required forceLogin=false;
+};
\ No newline at end of file
More information about the jboss-svn-commits
mailing list