Author: sohil.shah(a)jboss.com
Date: 2009-12-16 01:45:42 -0500 (Wed, 16 Dec 2009)
New Revision: 1024
Added:
components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/josso/GateInAgentRequest.java
components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/josso/GateInLocalSession.java
components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/josso/GateInSSOAgent.java
components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/josso/LocalSessionImpl.java
components/sso/trunk/packaging/josso/src/main/config/gatein/portal.war/WEB-INF/classes/
components/sso/trunk/packaging/josso/src/main/config/gatein/portal.war/WEB-INF/classes/josso-agent-config.xml
Modified:
components/sso/trunk/agent/pom.xml
components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/GenericSSOAgent.java
components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/josso/JOSSOAgent.java
components/sso/trunk/gatein-josso-plugin/pom.xml
components/sso/trunk/gatein-josso-plugin/src/main/java/org/gatein/sso/josso/plugin/GateinIdentityPlugin.java
components/sso/trunk/packaging/josso/pom.xml
Log:
JOSSO 1.8 (end-to-end)
Modified: components/sso/trunk/agent/pom.xml
===================================================================
--- components/sso/trunk/agent/pom.xml 2009-12-16 06:15:40 UTC (rev 1023)
+++ components/sso/trunk/agent/pom.xml 2009-12-16 06:45:42 UTC (rev 1024)
@@ -75,6 +75,21 @@
<skip>true</skip>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.xbean</groupId>
+ <artifactId>maven-xbean-plugin</artifactId>
+ <version>${version.xbean}</version>
+ <executions>
+ <execution>
+ <configuration>
+
<namespace>urn:org:josso:agent:generic-servlet</namespace>
+ </configuration>
+ <goals>
+ <goal>mapping</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
Modified:
components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/GenericSSOAgent.java
===================================================================
---
components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/GenericSSOAgent.java 2009-12-16
06:15:40 UTC (rev 1023)
+++
components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/GenericSSOAgent.java 2009-12-16
06:45:42 UTC (rev 1024)
@@ -63,7 +63,7 @@
{
try
{
- this.processSSOToken(req);
+ this.processSSOToken(req,resp);
super.doGet(req, resp);
}
catch(Exception e)
@@ -80,7 +80,7 @@
this.doGet(req, resp);
}
- private void processSSOToken(HttpServletRequest httpRequest) throws Exception
+ private void processSSOToken(HttpServletRequest httpRequest, HttpServletResponse
httpResponse) throws Exception
{
String ticket = httpRequest.getParameter("ticket");
String jossoAssertion = httpRequest.getParameter("josso_assertion_id");
@@ -91,8 +91,8 @@
}
else if (jossoAssertion != null && jossoAssertion.trim().length() > 0)
{
- //TODO: fix the JOSSO Agent. This will need to the new client side JOSSO stack that
can run on 5.1.0.GA
- JOSSOAgent.getInstance(this.ssoServerUrl).validateTicket(httpRequest);
+ //the JOSSO Agent. This will need to the new client side JOSSO stack that can run on
5.1.0.GA
+ JOSSOAgent.getInstance().validateTicket(httpRequest,httpResponse);
}
else
{
Added:
components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/josso/GateInAgentRequest.java
===================================================================
---
components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/josso/GateInAgentRequest.java
(rev 0)
+++
components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/josso/GateInAgentRequest.java 2009-12-16
06:45:42 UTC (rev 1024)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * 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.gatein.sso.agent.josso;
+
+import org.josso.agent.LocalSession;
+
+import org.josso.agent.http.HttpSSOAgentRequest;
+import org.josso.agent.http.JOSSOSecurityContext;
+
+/**
+ *
+ * @author <a href="mailto:sgonzalez@josso.org">Sebastian Gonzalez
Oyuela</a>
+ */
+public class GateInAgentRequest extends HttpSSOAgentRequest
+{
+ private JOSSOSecurityContext ctx;
+
+ public GateInAgentRequest(int action, String sessionId, LocalSession session,
+ String assertionId)
+ {
+ super(action, sessionId, session, assertionId);
+ }
+
+ public GateInAgentRequest(int action, String sessionId, LocalSession session)
+ {
+ super(action, sessionId, session);
+ }
+
+ public void setSecurityContext(JOSSOSecurityContext ctx)
+ {
+ this.ctx = ctx;
+ }
+
+ public JOSSOSecurityContext getSecurityContext()
+ {
+ return this.ctx;
+ }
+
+}
Added:
components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/josso/GateInLocalSession.java
===================================================================
---
components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/josso/GateInLocalSession.java
(rev 0)
+++
components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/josso/GateInLocalSession.java 2009-12-16
06:45:42 UTC (rev 1024)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * 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.gatein.sso.agent.josso;
+
+import javax.servlet.http.HttpSession;
+import org.josso.agent.http.JOSSOSecurityContext;
+import org.josso.agent.http.WebAccessControlUtil;
+
+/**
+ *
+ * @author <a href="mailto:sgonzalez@josso.org">Sebastian Gonzalez
Oyuela</a>
+ */
+public class GateInLocalSession extends LocalSessionImpl
+{
+
+ public GateInLocalSession(HttpSession httpSession)
+ {
+ super();
+
+ setWrapped(httpSession);
+ setMaxInactiveInterval(httpSession.getMaxInactiveInterval());
+
+ }
+
+ public void setSecurityContext(JOSSOSecurityContext ctx)
+ {
+ HttpSession session = (HttpSession) getWrapped();
+ session.setAttribute(WebAccessControlUtil.KEY_JOSSO_SECURITY_CONTEXT, ctx);
+ }
+}
Added:
components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/josso/GateInSSOAgent.java
===================================================================
---
components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/josso/GateInSSOAgent.java
(rev 0)
+++
components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/josso/GateInSSOAgent.java 2009-12-16
06:45:42 UTC (rev 1024)
@@ -0,0 +1,69 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* 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.gatein.sso.agent.josso;
+
+import org.apache.log4j.Logger;
+
+import org.josso.agent.SSOAgentRequest;
+import org.josso.agent.http.HttpSSOAgent;
+
+import java.security.Principal;
+
+/**
+ *
+ * @org.apache.xbean.XBean element="agent"
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public class GateInSSOAgent extends HttpSSOAgent
+{
+
+ private static final Logger log = Logger.getLogger(GateInSSOAgent.class);
+
+ protected Principal authenticate(SSOAgentRequest request)
+ {
+ try
+ {
+ String ssoSessionId = request.getSessionId();
+ return this.getSSOIdentityManager().findUserInSession(ssoSessionId);
+ }
+ catch(Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ protected boolean isAuthenticationAlwaysRequired()
+ {
+ return true;
+ }
+
+ protected void log(String message)
+ {
+ log.debug(message);
+ }
+
+ protected void log(String message, Throwable throwable)
+ {
+ log.debug(message, throwable);
+ }
+}
Modified:
components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/josso/JOSSOAgent.java
===================================================================
---
components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/josso/JOSSOAgent.java 2009-12-16
06:15:40 UTC (rev 1023)
+++
components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/josso/JOSSOAgent.java 2009-12-16
06:45:42 UTC (rev 1024)
@@ -22,22 +22,19 @@
package org.gatein.sso.agent.josso;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.exoplatform.web.security.Credentials;
import org.gatein.sso.agent.GenericSSOAgent;
-import org.josso.agent.SSOAgent;
+
import org.josso.agent.Lookup;
import org.josso.agent.SSOAgentRequest;
import org.josso.agent.SingleSignOnEntry;
+import org.josso.agent.http.HttpSSOAgent;
-import org.josso.servlet.agent.GenericServletSSOAgentRequest;
-import org.josso.servlet.agent.GenericServletLocalSession;
-
/**
- * TODO: This is broken. This will need a JBoss 5.1.0.GA based JOSSO client stack
- *
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
*/
public class JOSSOAgent
@@ -45,14 +42,27 @@
private static Logger log = Logger.getLogger(Logger.class);
private static JOSSOAgent singleton;
- private String serverUrl = null;
+ private HttpSSOAgent httpAgent;
- private JOSSOAgent(String serverUrl)
+ private JOSSOAgent()
{
- this.serverUrl = serverUrl;
+ try
+ {
+ //Initializing the JOSSO Agent
+ Lookup lookup = Lookup.getInstance();
+ lookup.init("josso-agent-config.xml");
+
+ this.httpAgent = (HttpSSOAgent) lookup.lookupSSOAgent();
+ this.httpAgent.start();
+ }
+ catch(Exception e)
+ {
+ log.error(this, e);
+ throw new RuntimeException(e);
+ }
}
- public static JOSSOAgent getInstance(String serverUrl)
+ public static JOSSOAgent getInstance()
{
if(JOSSOAgent.singleton == null)
{
@@ -60,22 +70,49 @@
{
if(JOSSOAgent.singleton == null)
{
- JOSSOAgent.singleton = new JOSSOAgent(serverUrl);
+ JOSSOAgent.singleton = new JOSSOAgent();
}
}
}
return JOSSOAgent.singleton;
}
- public void validateTicket(HttpServletRequest httpRequest) throws Exception
+ public void validateTicket(HttpServletRequest httpRequest,HttpServletResponse
httpResponse) throws Exception
{
String ticket = httpRequest.getParameter("josso_assertion_id");
- log.info("Trying to validate the following Ticket: "+ticket);
+ log.debug("Trying to validate the following Ticket: "+ticket);
- //TODO: Use the JOSSO Client Library to validate the token and extract the subject that
was authenticated
+ //Use the JOSSO Client Library to validate the token and extract the subject that was
authenticated
+ SSOAgentRequest agentRequest = this.doMakeSSOAgentRequest(SSOAgentRequest.ACTION_RELAY,
+ null, ticket, httpRequest, httpResponse);
- //Just do a hack login for now...to cutoff the infinite redirects
- Credentials credentials = new Credentials("demo", "");
- httpRequest.getSession().setAttribute(GenericSSOAgent.CREDENTIALS, credentials);
+ SingleSignOnEntry entry = this.httpAgent.processRequest(agentRequest);
+
+ if(entry != null)
+ {
+ String sessionId = agentRequest.getSessionId();
+ String assertionId = agentRequest.getAssertionId();
+ String principal = entry.principal.getName();
+
+ log.debug("-----------------------------------------------------------");
+ log.debug("SessionId: "+sessionId);
+ log.debug("AssertionId: "+assertionId);
+ log.debug("Principal: "+principal);
+ log.debug("-----------------------------------------------------------");
+
+ Credentials credentials = new Credentials(principal, "");
+ httpRequest.getSession().setAttribute(GenericSSOAgent.CREDENTIALS, credentials);
+ }
}
+
+ protected SSOAgentRequest doMakeSSOAgentRequest(int action, String sessionId, String
assertionId,
+ HttpServletRequest hreq,
HttpServletResponse hres)
+ {
+ GateInAgentRequest r = new GateInAgentRequest(action, sessionId, new
GateInLocalSession(hreq.getSession()), assertionId);
+ r.setRequest(hreq);
+ r.setResponse(hres);
+
+ return r;
+
+ }
}
Added:
components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/josso/LocalSessionImpl.java
===================================================================
---
components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/josso/LocalSessionImpl.java
(rev 0)
+++
components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/josso/LocalSessionImpl.java 2009-12-16
06:45:42 UTC (rev 1024)
@@ -0,0 +1,120 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * 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.gatein.sso.agent.josso;
+
+import org.josso.agent.LocalSession;
+import org.josso.agent.LocalSessionEvent;
+import org.josso.agent.LocalSessionListener;
+
+import javax.servlet.http.HttpSession;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ *
+ * @author <a href="mailto:sgonzalez@josso.org">Sebastian Gonzalez
Oyuela</a>
+ */
+public class LocalSessionImpl implements LocalSession
+{
+
+ /**
+ * The session event listeners for this Session.
+ */
+ private transient ArrayList _listeners = new ArrayList();
+ private long _creationTime;
+
+ private String _id;
+
+ private long _lastAccessedTime;
+
+ private int _maxInactiveInterval;
+
+ private Object _wrapped;
+
+ public LocalSessionImpl()
+ {
+ }
+
+ public long getCreationTime()
+ {
+ return _creationTime;
+ }
+
+ public String getId()
+ {
+ return _id;
+ }
+
+ public long getLastAccessedTime()
+ {
+ return _lastAccessedTime;
+ }
+
+ public void setMaxInactiveInterval(int i)
+ {
+ _maxInactiveInterval = i;
+ }
+
+ public int getMaxInactiveInterval()
+ {
+ return _maxInactiveInterval;
+ }
+
+ public void expire()
+ {
+
+ Iterator i = _listeners.iterator();
+ while (i.hasNext())
+ {
+ LocalSessionListener listener = (LocalSessionListener) i.next();
+
+ listener.localSessionEvent(new LocalSessionEvent(this,
+ LocalSession.LOCAL_SESSION_DESTROYED_EVENT, null));
+ }
+ }
+
+ public void addSessionListener(LocalSessionListener sessionListener)
+ {
+ _listeners.add(sessionListener);
+ }
+
+ public void removeSessionListener(LocalSessionListener sessionListener)
+ {
+ _listeners.remove(sessionListener);
+ }
+
+ public void exipre()
+ {
+ ((HttpSession) _wrapped).invalidate();
+ }
+
+ public void setWrapped(Object wrapped)
+ {
+ _wrapped = wrapped;
+ }
+
+ public Object getWrapped()
+ {
+ return _wrapped;
+ }
+}
Modified: components/sso/trunk/gatein-josso-plugin/pom.xml
===================================================================
--- components/sso/trunk/gatein-josso-plugin/pom.xml 2009-12-16 06:15:40 UTC (rev 1023)
+++ components/sso/trunk/gatein-josso-plugin/pom.xml 2009-12-16 06:45:42 UTC (rev 1024)
@@ -23,7 +23,11 @@
<dependency>
<groupId>org.josso</groupId>
<artifactId>josso-basic-authscheme</artifactId>
- </dependency>
+ </dependency>
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ </dependency>
</dependencies>
<build>
Modified:
components/sso/trunk/gatein-josso-plugin/src/main/java/org/gatein/sso/josso/plugin/GateinIdentityPlugin.java
===================================================================
---
components/sso/trunk/gatein-josso-plugin/src/main/java/org/gatein/sso/josso/plugin/GateinIdentityPlugin.java 2009-12-16
06:15:40 UTC (rev 1023)
+++
components/sso/trunk/gatein-josso-plugin/src/main/java/org/gatein/sso/josso/plugin/GateinIdentityPlugin.java 2009-12-16
06:45:42 UTC (rev 1024)
@@ -22,36 +22,36 @@
******************************************************************************/
package org.gatein.sso.josso.plugin;
+import java.io.InputStream;
+import java.util.Properties;
+
import org.apache.log4j.Logger;
-import org.josso.gateway.SSONameValuePair;
import org.josso.gateway.identity.exceptions.NoSuchUserException;
import org.josso.gateway.identity.exceptions.SSOIdentityException;
import org.josso.gateway.identity.service.BaseRole;
-import org.josso.gateway.identity.service.BaseRoleImpl;
import org.josso.gateway.identity.service.BaseUser;
import org.josso.gateway.identity.service.BaseUserImpl;
import org.josso.gateway.identity.service.store.UserKey;
-import org.josso.gateway.identity.service.store.SimpleUserKey;
import org.josso.gateway.identity.service.store.IdentityStore;
import org.josso.auth.Credential;
import org.josso.auth.CredentialKey;
import org.josso.auth.CredentialProvider;
import org.josso.auth.scheme.AuthenticationScheme;
-import org.josso.auth.scheme.UsernameCredential;
-import org.josso.auth.scheme.PasswordCredential;
import org.josso.auth.BindableCredentialStore;
import org.josso.auth.exceptions.SSOAuthenticationException;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.GetMethod;
+
/**
* @org.apache.xbean.XBean element="gatein-store"
*
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
*
*/
-public class GateinIdentityPlugin implements IdentityStore,
- BindableCredentialStore
+public class GateinIdentityPlugin implements BindableCredentialStore,IdentityStore
{
private static Logger log = Logger.getLogger(GateinIdentityPlugin.class);
@@ -67,9 +67,17 @@
*/
public GateinIdentityPlugin()
{
+ InputStream is = null;
try
{
- // TODO: readin GateIn configuration from WEB-INF/gatein.properties
+ ///Load the GateIn properties
+ Properties properties = new Properties();
+ is =
Thread.currentThread().getContextClassLoader().getResourceAsStream("gatein.properties");
+ properties.load(is);
+
+ this.gateInHost = properties.getProperty("host");
+ this.gateInPort = properties.getProperty("port");
+ this.gateInContext = properties.getProperty("context");
log
.info("-------------------------------------------------------------------");
@@ -87,6 +95,13 @@
throw new RuntimeException(
"GateIn Identity Plugin registration failed....");
}
+ finally
+ {
+ if(is != null)
+ {
+ try{is.close();}catch(Exception e){}
+ }
+ }
}
public void setAuthenticationScheme(AuthenticationScheme authenticationScheme)
@@ -128,15 +143,12 @@
//
implementation------------------------------------------------------------------------------------------------------------------------
public boolean userExists(UserKey userKey) throws SSOIdentityException
{
- log.info("User: "+userKey+" exists....");
return true;
}
public BaseRole[] findRolesByUserKey(UserKey userKey)
throws SSOIdentityException
{
- log.info("Loading Roles for..."+userKey);
-
return null;
}
@@ -145,11 +157,6 @@
{
BaseUser user = new BaseUserImpl();
user.setName(userKey.toString());
- user.addProperty("password", "");
-
- log.info("Loading
User................................................................");
- log.info("User:"+user.getName());
-
return user;
}
// ---------------CredentialStore
@@ -157,30 +164,68 @@
public Credential[] loadCredentials(CredentialKey credentialKey,
CredentialProvider credentialProvider) throws SSOIdentityException
{
- log.info("Loading Credentials using the new
method................................................................");
- return loadCredentials(credentialKey);
+ return null;
}
public Credential[] loadCredentials(CredentialKey credentialKey) throws
SSOIdentityException
{
- // Get the User corresponding to this credentialKey
- BaseUser user = this.loadUser((SimpleUserKey) credentialKey);
- SSONameValuePair[] properties = user.getProperties();
- String password = properties[0].getValue();
-
- log.info("Loading Credentials
for................................................................");
- log.info("User:"+user.getName());
- log.info("Password:"+password);
- return new Credential[] { new UsernameCredential(user.getName()),new
PasswordCredential(password) };
+ return null;
}
public boolean bind(String username, String password)
throws SSOAuthenticationException
{
- // return this.portalIdentityService.authenticate(username, password);
- log.info("Performing Authentication........................");
- log.info("Username: "+username);
- log.info("Password: "+password);
- return true;
+ try
+ {
+ // return this.portalIdentityService.authenticate(username, password);
+ log.debug("Performing Authentication........................");
+ log.debug("Username: "+username);
+ log.debug("Password: "+password);
+
+ StringBuilder urlBuffer = new StringBuilder();
+ urlBuffer.append("http://" + this.gateInHost + ":" +
this.gateInPort + "/"
+ + this.gateInContext + "/rest/sso/authcallback/auth/" + username +
"/"
+ + password);
+
+ boolean success = this.executeRemoteCall(urlBuffer.toString());
+
+ return success;
+ }
+ catch(Exception e)
+ {
+ throw new SSOAuthenticationException(e);
+ }
}
+ //------------------------------------------------------------------------------------------------------------------------------------------
+ private boolean executeRemoteCall(String authUrl) throws Exception
+ {
+ HttpClient client = new HttpClient();
+ GetMethod method = null;
+ try
+ {
+ method = new GetMethod(authUrl);
+
+ int status = client.executeMethod(method);
+ String response = method.getResponseBodyAsString();
+
+ switch (status)
+ {
+ case 200:
+ if (response.equals(Boolean.TRUE.toString()))
+ {
+ return true;
+ }
+ break;
+ }
+
+ return false;
+ }
+ finally
+ {
+ if (method != null)
+ {
+ method.releaseConnection();
+ }
+ }
+ }
}
Modified: components/sso/trunk/packaging/josso/pom.xml
===================================================================
--- components/sso/trunk/packaging/josso/pom.xml 2009-12-16 06:15:40 UTC (rev 1023)
+++ components/sso/trunk/packaging/josso/pom.xml 2009-12-16 06:45:42 UTC (rev 1024)
@@ -109,11 +109,7 @@
overwrite="true"/>
<!-- Deploy JOSSO Agent dependencies -->
- <!--
- <copy
file="${settings.localRepository}/opensso/openssoclientsdk/${version.opensso}/openssoclientsdk-${version.opensso}.jar"
- todir="${gatein.location}/deploy/gatein.ear/lib"
- overwrite="true"/>
- -->
+
</tasks>
</configuration>
<goals>
@@ -165,7 +161,13 @@
<!-- copy thirdparty dependency -->
<copy
tofile="${basedir}/target/plugin/webapps/josso/WEB-INF/lib/log4j.jar"
file="${settings.localRepository}/apache-log4j/log4j/${version.log4j}/log4j-${version.log4j}.jar"
- overwrite="true"/>
+ overwrite="true"/>
+ <copy
tofile="${basedir}/target/plugin/webapps/josso/WEB-INF/lib/commons-httpclient.jar"
+
file="${settings.localRepository}/commons-httpclient/commons-httpclient/${version.commons-httpclient}/commons-httpclient-${version.commons-httpclient}.jar"
+ overwrite="true"/>
+ <copy
tofile="${basedir}/target/plugin/webapps/josso/WEB-INF/lib/commons-logging.jar"
+
file="${settings.localRepository}/commons-logging/commons-logging/${version.commons-logging}/commons-logging-${version.commons-logging}.jar"
+ overwrite="true"/>
</tasks>
</configuration>
<goals>
Added:
components/sso/trunk/packaging/josso/src/main/config/gatein/portal.war/WEB-INF/classes/josso-agent-config.xml
===================================================================
---
components/sso/trunk/packaging/josso/src/main/config/gatein/portal.war/WEB-INF/classes/josso-agent-config.xml
(rev 0)
+++
components/sso/trunk/packaging/josso/src/main/config/gatein/portal.war/WEB-INF/classes/josso-agent-config.xml 2009-12-16
06:45:42 UTC (rev 1024)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<s:beans
xmlns:s="http://www.springframework.org/schema/beans"
+ xmlns:gen-svlt="urn:org:josso:agent:generic-servlet"
+ xmlns:agent="urn:org:josso:agent:core"
+ xmlns:protocol="urn:org:josso:protocol:client"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+<gen-svlt:agent name="josso-tomcat60-agent"
sessionAccessMinInterval="1000">
+
+
<gatewayLoginUrl>http://localhost:8888/josso/signon/login.do</gatewayLoginUrl>
+
<gatewayLogoutUrl>http://localhost:8888/josso/signon/logout.do</gatewayLogoutUrl>
+
+ <gatewayServiceLocator>
+ <protocol:ws-service-locator endpoint="localhost:8888"/>
+ </gatewayServiceLocator>
+ <configuration>
+ <agent:agent-configuration>
+ <agent:partner-apps>
+ <agent:partner-app id="portal"
context="/portal"/>
+ </agent:partner-apps>
+ </agent:agent-configuration>
+ </configuration>
+ <parametersBuilders>
+ <agent:vhost-parameters-builder/>
+ <agent:appctx-parameters-builder/>
+ </parametersBuilders>
+ </gen-svlt:agent>
+</s:beans>
\ No newline at end of file