Author: sohil.shah(a)jboss.com
Date: 2009-11-14 07:30:59 -0500 (Sat, 14 Nov 2009)
New Revision: 13815
Added:
jbossexo/modules/sso/trunk/auth-callback/.settings/
jbossexo/modules/sso/trunk/auth-callback/.settings/org.eclipse.jdt.core.prefs
jbossexo/modules/sso/trunk/auth-callback/target/
jbossexo/modules/sso/trunk/auth-callback/target/classes/
jbossexo/modules/sso/trunk/auth-callback/target/classes/conf/
jbossexo/modules/sso/trunk/auth-callback/target/classes/conf/portal/
jbossexo/modules/sso/trunk/auth-callback/target/classes/conf/portal/configuration.xml
jbossexo/modules/sso/trunk/auth-callback/target/classes/org/
jbossexo/modules/sso/trunk/auth-callback/target/classes/org/gatein/
jbossexo/modules/sso/trunk/auth-callback/target/classes/org/gatein/sso/
jbossexo/modules/sso/trunk/auth-callback/target/classes/org/gatein/sso/authentication/
jbossexo/modules/sso/trunk/auth-callback/target/classes/org/gatein/sso/authentication/callback/
jbossexo/modules/sso/trunk/auth-callback/target/classes/org/gatein/sso/authentication/callback/AuthenticationHandler.class
jbossexo/modules/sso/trunk/auth-callback/target/test-classes/
Modified:
jbossexo/modules/sso/trunk/.classpath
jbossexo/modules/sso/trunk/auth-callback/.classpath
jbossexo/modules/sso/trunk/auth-callback/pom.xml
jbossexo/modules/sso/trunk/auth-callback/src/main/java/org/gatein/sso/authentication/callback/AuthenticationHandler.java
jbossexo/modules/sso/trunk/gatein-cas/src/test/java/org/gatein/sso/cas/server/TestAuthenticationPlugin.java
jbossexo/modules/sso/trunk/pom.xml
Log:
successful sso callback baseline
Modified: jbossexo/modules/sso/trunk/.classpath
===================================================================
--- jbossexo/modules/sso/trunk/.classpath 2009-11-13 19:16:04 UTC (rev 13814)
+++ jbossexo/modules/sso/trunk/.classpath 2009-11-14 12:30:59 UTC (rev 13815)
@@ -8,7 +8,10 @@
<classpathentry kind="var"
path="M2_REPO/org/jasig/cas/cas-server-core/3.3.4/cas-server-core-3.3.4.jar"
sourcepath="M2_REPO/org/jasig/cas/cas-server-core/3.3.4/cas-server-core-3.3.4-sources.jar"/>
<classpathentry kind="var"
path="M2_REPO/apache-log4j/log4j/1.2.14/log4j-1.2.14.jar"
sourcepath="M2_REPO/apache-log4j/log4j/1.2.14/log4j-1.2.14-sources.jar"/>
<classpathentry kind="var"
path="M2_REPO/org/exoplatform/ws/exo.ws.rest.core/2.1.0-Beta02/exo.ws.rest.core-2.1.0-Beta02.jar"
sourcepath="M2_REPO/org/exoplatform/ws/exo.ws.rest.core/2.1.0-Beta02/exo.ws.rest.core-2.1.0-Beta02-sources.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/org/exoplatform/core/exo.core.component.security.core/2.3.0-Beta02/exo.core.component.security.core-2.3.0-Beta02.jar"
sourcepath="M2_REPO/org/exoplatform/core/exo.core.component.security.core/2.3.0-Beta02/exo.core.component.security.core-2.3.0-Beta02-sources.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/org/exoplatform/kernel/exo.kernel.container/2.2.0-Beta02/exo.kernel.container-2.2.0-Beta02.jar"
sourcepath="M2_REPO/org/exoplatform/kernel/exo.kernel.container/2.2.0-Beta02/exo.kernel.container-2.2.0-Beta02-sources.jar"/>
<classpathentry kind="var"
path="M2_REPO/javax/ws/rs/jsr311-api/1.0/jsr311-api-1.0.jar"
sourcepath="M2_REPO/javax/ws/rs/jsr311-api/1.0/jsr311-api-1.0-sources.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/picocontainer/picocontainer/1.1/picocontainer-1.1.jar"/>
<classpathentry kind="var"
path="M2_REPO/commons-httpclient/commons-httpclient/3.1/commons-httpclient-3.1.jar"/>
<classpathentry kind="con"
path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
<classpathentry kind="output" path="bin"/>
Modified: jbossexo/modules/sso/trunk/auth-callback/.classpath
===================================================================
--- jbossexo/modules/sso/trunk/auth-callback/.classpath 2009-11-13 19:16:04 UTC (rev
13814)
+++ jbossexo/modules/sso/trunk/auth-callback/.classpath 2009-11-14 12:30:59 UTC (rev
13815)
@@ -21,6 +21,7 @@
<classpathentry kind="var"
path="M2_REPO/commons-io/commons-io/1.3.2/commons-io-1.3.2.jar"
sourcepath="M2_REPO/commons-io/commons-io/1.3.2/commons-io-1.3.2-sources.jar"/>
<classpathentry kind="var"
path="M2_REPO/commons-lang/commons-lang/2.3/commons-lang-2.3.jar"
sourcepath="M2_REPO/commons-lang/commons-lang/2.3/commons-lang-2.3-sources.jar"/>
<classpathentry kind="var"
path="M2_REPO/commons-logging/commons-logging/1.0.3/commons-logging-1.0.3.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/org/exoplatform/core/exo.core.component.security.core/2.3.0-Beta02/exo.core.component.security.core-2.3.0-Beta02.jar"
sourcepath="M2_REPO/org/exoplatform/core/exo.core.component.security.core/2.3.0-Beta02/exo.core.component.security.core-2.3.0-Beta02-sources.jar"/>
<classpathentry kind="var"
path="M2_REPO/org/exoplatform/core/exo.core.component.xml-processing/2.3.0-Beta02/exo.core.component.xml-processing-2.3.0-Beta02.jar"
sourcepath="M2_REPO/org/exoplatform/core/exo.core.component.xml-processing/2.3.0-Beta02/exo.core.component.xml-processing-2.3.0-Beta02-sources.jar"/>
<classpathentry kind="var"
path="M2_REPO/org/exoplatform/kernel/exo.kernel.commons/2.2.0-Beta02/exo.kernel.commons-2.2.0-Beta02.jar"
sourcepath="M2_REPO/org/exoplatform/kernel/exo.kernel.commons/2.2.0-Beta02/exo.kernel.commons-2.2.0-Beta02-sources.jar"/>
<classpathentry kind="var"
path="M2_REPO/org/exoplatform/kernel/exo.kernel.component.common/2.2.0-Beta02/exo.kernel.component.common-2.2.0-Beta02.jar"
sourcepath="M2_REPO/org/exoplatform/kernel/exo.kernel.component.common/2.2.0-Beta02/exo.kernel.component.common-2.2.0-Beta02-sources.jar"/>
@@ -37,7 +38,7 @@
<classpathentry kind="var"
path="M2_REPO/jotm/jotm/2.0.10/jotm-2.0.10.jar"/>
<classpathentry kind="var"
path="M2_REPO/jotm/jotm_jrmp_stubs/2.0.10/jotm_jrmp_stubs-2.0.10.jar"/>
<classpathentry kind="var"
path="M2_REPO/jtidy/jtidy/4aug2000r7-dev/jtidy-4aug2000r7-dev.jar"
sourcepath="M2_REPO/jtidy/jtidy/4aug2000r7-dev/jtidy-4aug2000r7-dev-sources.jar"/>
- <classpathentry kind="var"
path="M2_REPO/junit/junit/3.8.2/junit-3.8.2.jar"
sourcepath="M2_REPO/junit/junit/3.8.2/junit-3.8.2-sources.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"
sourcepath="M2_REPO/junit/junit/3.8.1/junit-3.8.1-sources.jar"/>
<classpathentry kind="var"
path="M2_REPO/apache-log4j/log4j/1.2.14/log4j-1.2.14.jar"
sourcepath="M2_REPO/apache-log4j/log4j/1.2.14/log4j-1.2.14-sources.jar"/>
<classpathentry kind="var"
path="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14.jar"
sourcepath="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14-sources.jar"/>
<classpathentry kind="var"
path="M2_REPO/picocontainer/picocontainer/1.1/picocontainer-1.1.jar"/>
Added: jbossexo/modules/sso/trunk/auth-callback/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- jbossexo/modules/sso/trunk/auth-callback/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
jbossexo/modules/sso/trunk/auth-callback/.settings/org.eclipse.jdt.core.prefs 2009-11-14
12:30:59 UTC (rev 13815)
@@ -0,0 +1,5 @@
+#Fri Nov 13 14:29:00 CST 2009
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
Modified: jbossexo/modules/sso/trunk/auth-callback/pom.xml
===================================================================
--- jbossexo/modules/sso/trunk/auth-callback/pom.xml 2009-11-13 19:16:04 UTC (rev 13814)
+++ jbossexo/modules/sso/trunk/auth-callback/pom.xml 2009-11-14 12:30:59 UTC (rev 13815)
@@ -19,7 +19,11 @@
<dependency>
<groupId>org.exoplatform.ws</groupId>
<artifactId>exo.ws.rest.core</artifactId>
- </dependency>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.core</groupId>
+ <artifactId>exo.core.component.security.core</artifactId>
+ </dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
Modified:
jbossexo/modules/sso/trunk/auth-callback/src/main/java/org/gatein/sso/authentication/callback/AuthenticationHandler.java
===================================================================
---
jbossexo/modules/sso/trunk/auth-callback/src/main/java/org/gatein/sso/authentication/callback/AuthenticationHandler.java 2009-11-13
19:16:04 UTC (rev 13814)
+++
jbossexo/modules/sso/trunk/auth-callback/src/main/java/org/gatein/sso/authentication/callback/AuthenticationHandler.java 2009-11-14
12:30:59 UTC (rev 13815)
@@ -23,12 +23,24 @@
import org.apache.log4j.Logger;
+import javax.security.auth.login.LoginException;
+
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.container.RootContainer;
+
+import org.exoplatform.services.security.Authenticator;
+import org.exoplatform.services.security.Credential;
+import org.exoplatform.services.security.Identity;
+import org.exoplatform.services.security.PasswordCredential;
+import org.exoplatform.services.security.UsernameCredential;
+
import org.exoplatform.services.rest.resource.ResourceContainer;
/**
@@ -41,7 +53,7 @@
@Path("/sso/authcallback")
public class AuthenticationHandler implements ResourceContainer
{
- private static Logger log = Logger.getLogger(AuthenticationHandler.class);
+ private static Logger log = Logger.getLogger(AuthenticationHandler.class);
@GET
@Path("/auth/{1}/{2}")
@@ -49,16 +61,42 @@
{MediaType.TEXT_PLAIN})
public String authenticate(@PathParam("1") String username,
@PathParam("2") String password)
{
- log.info("---------------------------------------");
- log.info("Username="+username);
- log.info("Password="+password);
- log.info("---------------------------------------");
-
- if(username.equals("root") && password.equals("gtn"))
- {
- return ""+Boolean.TRUE;
- }
-
- return ""+Boolean.FALSE;
+ try
+ {
+ log.info("---------------------------------------");
+ log.info("Username: "+username);
+ log.info("Password: "+password);
+
+ ExoContainer container = this.getContainer();
+ Authenticator authenticator = (Authenticator)
getContainer().getComponentInstanceOfType(Authenticator.class);
+
+ Credential[] credentials = new Credential[] { new UsernameCredential(username),
+ new PasswordCredential(password) };
+
+ try
+ {
+ authenticator.validateUser(credentials);
+ return ""+Boolean.TRUE;
+ }
+ catch(LoginException le)
+ {
+ return ""+Boolean.FALSE;
+ }
+ }
+ catch(Exception e)
+ {
+ log.error(this, e);
+ throw new RuntimeException(e);
+ }
}
+
+ private ExoContainer getContainer() throws Exception
+ {
+ ExoContainer container = ExoContainerContext.getCurrentContainer();
+ if (container instanceof RootContainer)
+ {
+ container = RootContainer.getInstance().getPortalContainer("portal");
+ }
+ return container;
+ }
}
Added:
jbossexo/modules/sso/trunk/auth-callback/target/classes/conf/portal/configuration.xml
===================================================================
--- jbossexo/modules/sso/trunk/auth-callback/target/classes/conf/portal/configuration.xml
(rev 0)
+++
jbossexo/modules/sso/trunk/auth-callback/target/classes/conf/portal/configuration.xml 2009-11-14
12:30:59 UTC (rev 13815)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd
http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
+
xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
+ <component>
+ <type>org.gatein.sso.authentication.callback.AuthenticationHandler</type>
+ </component>
+</configuration>
\ No newline at end of file
Added:
jbossexo/modules/sso/trunk/auth-callback/target/classes/org/gatein/sso/authentication/callback/AuthenticationHandler.class
===================================================================
(Binary files differ)
Property changes on:
jbossexo/modules/sso/trunk/auth-callback/target/classes/org/gatein/sso/authentication/callback/AuthenticationHandler.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified:
jbossexo/modules/sso/trunk/gatein-cas/src/test/java/org/gatein/sso/cas/server/TestAuthenticationPlugin.java
===================================================================
---
jbossexo/modules/sso/trunk/gatein-cas/src/test/java/org/gatein/sso/cas/server/TestAuthenticationPlugin.java 2009-11-13
19:16:04 UTC (rev 13814)
+++
jbossexo/modules/sso/trunk/gatein-cas/src/test/java/org/gatein/sso/cas/server/TestAuthenticationPlugin.java 2009-11-14
12:30:59 UTC (rev 13815)
@@ -48,17 +48,21 @@
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------
public void testAuthenticationCallback() throws Exception
{
+ //Unsuccessful login scenario
UsernamePasswordCredentials credentials = new UsernamePasswordCredentials();
credentials.setUsername("root");
- credentials.setPassword("gtn");
+ credentials.setPassword("blah");
boolean authResult = this.authPlugin.authenticate(credentials);
- assertTrue("Login should have succeeded!!", authResult);
+ assertFalse("Login should *not* have succeeded!!", authResult);
+
+ //Successful login scenario
credentials = new UsernamePasswordCredentials();
credentials.setUsername("root");
- credentials.setPassword("blah");
+ credentials.setPassword("gtn");
+
authResult = this.authPlugin.authenticate(credentials);
- assertFalse("Login should *not* have succeeded!!", authResult);
+ assertTrue("Login should have succeeded!!", authResult);
}
}
Modified: jbossexo/modules/sso/trunk/pom.xml
===================================================================
--- jbossexo/modules/sso/trunk/pom.xml 2009-11-13 19:16:04 UTC (rev 13814)
+++ jbossexo/modules/sso/trunk/pom.xml 2009-11-14 12:30:59 UTC (rev 13815)
@@ -35,6 +35,7 @@
<version.cas>3.3.4</version.cas>
<!-- exo -->
+
<org.exoplatform.core.version>2.3.0-Beta02</org.exoplatform.core.version>
<org.exoplatform.ws.version>2.1.0-Beta02</org.exoplatform.ws.version>
<!-- JAX-RS jsr-311 -->
@@ -88,6 +89,11 @@
<groupId>org.exoplatform.ws</groupId>
<artifactId>exo.ws.rest.core</artifactId>
<version>${org.exoplatform.ws.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.core</groupId>
+ <artifactId>exo.core.component.security.core</artifactId>
+ <version>${org.exoplatform.core.version}</version>
</dependency>
</dependencies>
</dependencyManagement>