Author: alain_defrance
Date: 2010-09-24 10:22:28 -0400 (Fri, 24 Sep 2010)
New Revision: 4384
Modified:
portal/branches/wci/component/web/security/pom.xml
portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/login/InitiateLoginServlet.java
portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/security/Credentials.java
portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/security/PortalLoginModule.java
portal/branches/wci/web/portal/src/main/webapp/WEB-INF/conf/common/autologin-configuration.xml
Log:
WCI login feature in progress
Modified: portal/branches/wci/component/web/security/pom.xml
===================================================================
--- portal/branches/wci/component/web/security/pom.xml 2010-09-24 14:16:26 UTC (rev 4383)
+++ portal/branches/wci/component/web/security/pom.xml 2010-09-24 14:22:28 UTC (rev 4384)
@@ -63,5 +63,9 @@
<artifactId>jboss-as-tomcat</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.gatein.wci</groupId>
+ <artifactId>wci-wci</artifactId>
+ </dependency>
</dependencies>
</project>
Modified:
portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/login/InitiateLoginServlet.java
===================================================================
---
portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/login/InitiateLoginServlet.java 2010-09-24
14:16:26 UTC (rev 4383)
+++
portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/login/InitiateLoginServlet.java 2010-09-24
14:22:28 UTC (rev 4384)
@@ -24,9 +24,11 @@
import org.exoplatform.web.security.Credentials;
import org.exoplatform.web.security.security.AbstractTokenService;
import org.exoplatform.web.security.security.CookieTokenService;
-import org.exoplatform.web.security.security.TransientTokenService;
import org.gatein.common.logging.Logger;
import org.gatein.common.logging.LoggerFactory;
+import org.gatein.wci.authentication.GenericAuthentication;
+import org.gatein.wci.authentication.TicketService;
+import org.gatein.wci.authentication.WCICredentials;
import java.io.IOException;
@@ -110,13 +112,13 @@
else
{
// We create a temporary token just for the login time
- TransientTokenService tokenService =
AbstractTokenService.getInstance(TransientTokenService.class);
- String token = tokenService.createToken(credentials);
+ TicketService ticketService = GenericAuthentication.TICKET_SERVICE;
+ String ticket = ticketService.createTicket(new
WCICredentials(credentials.getUsername(), credentials.getPassword()));
req.getSession().removeAttribute(InitiateLoginServlet.CREDENTIALS);
// Send authentication request
log.debug("Login initiated with credentials in session, performing
authentication");
- sendAuth(resp, credentials.getUsername(), token);
+ sendAuth(resp, credentials.getUsername(), ticket);
}
}
Modified:
portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/security/Credentials.java
===================================================================
---
portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/security/Credentials.java 2010-09-24
14:16:26 UTC (rev 4383)
+++
portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/security/Credentials.java 2010-09-24
14:22:28 UTC (rev 4384)
@@ -19,6 +19,8 @@
package org.exoplatform.web.security;
+import org.gatein.wci.authentication.WCICredentials;
+
import java.io.Serializable;
/**
@@ -59,6 +61,15 @@
this.password = password;
}
+ public Credentials(WCICredentials wciCredentials)
+ {
+ if (wciCredentials == null) {
+ throw new IllegalArgumentException("wciCredentials is null");
+ }
+ this.username = wciCredentials.getUsername();
+ this.password = wciCredentials.getPassword();
+ }
+
/**
* Returns the username.
*
Modified:
portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/security/PortalLoginModule.java
===================================================================
---
portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/security/PortalLoginModule.java 2010-09-24
14:16:26 UTC (rev 4383)
+++
portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/security/PortalLoginModule.java 2010-09-24
14:22:28 UTC (rev 4384)
@@ -25,7 +25,8 @@
import org.exoplatform.services.security.jaas.AbstractLoginModule;
import org.exoplatform.web.login.InitiateLoginServlet;
import org.exoplatform.web.security.security.CookieTokenService;
-import org.exoplatform.web.security.security.TransientTokenService;
+import org.gatein.wci.authentication.GenericAuthentication;
+import org.gatein.wci.authentication.WCICredentials;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.NameCallback;
@@ -99,42 +100,49 @@
callbackHandler.handle(callbacks);
String password = new String(((PasswordCallback)callbacks[1]).getPassword());
- ExoContainer container = getContainer();
- Object o =
-
((TransientTokenService)container.getComponentInstanceOfType(TransientTokenService.class)).validateToken(
- password, true);
- if (o == null)
- o =
+ GenericAuthentication authentication = new GenericAuthentication();
+ WCICredentials wciCredentials = authentication
+ .login(((NameCallback)callbacks[0]).getName(), password.toCharArray());
+ Credentials c = null;
+ if (wciCredentials != null)
+ {
+ c = new Credentials(wciCredentials);
+ }
+ else
+ {
+ ExoContainer container = getContainer();
+ Object o =
((CookieTokenService)container.getComponentInstanceOfType(CookieTokenService.class)).validateToken(
- password, false);
- //
+ password, false);
- // For clustered config check credentials stored and propagated in session. This
won't work in tomcat because
- // of lack of JACC PolicyContext so the code must be a bit defensive
- if (o == null && getContextMethod != null &&
password.startsWith(InitiateLoginServlet.COOKIE_NAME))
- {
- HttpServletRequest request;
- try
+ //
+ // For clustered config check credentials stored and propagated in session.
This won't work in tomcat because
+ // of lack of JACC PolicyContext so the code must be a bit defensive
+ if (o == null && getContextMethod != null &&
password.startsWith(InitiateLoginServlet.COOKIE_NAME))
{
- request = (HttpServletRequest)getContextMethod.invoke(null,
"javax.servlet.http.HttpServletRequest");
- o = request.getSession().getAttribute(AUTHENTICATED_CREDENTIALS);
+ HttpServletRequest request;
+ try
+ {
+ request = (HttpServletRequest)getContextMethod.invoke(null,
"javax.servlet.http.HttpServletRequest");
+ o = request.getSession().getAttribute(AUTHENTICATED_CREDENTIALS);
+ }
+ catch(Throwable e)
+ {
+ log.error(this,e);
+ log.error("LoginModule error. Turn off session credentials
checking with proper configuration option of " +
+ "LoginModule set to false");
+ }
+
}
- catch(Throwable e)
- {
- log.error(this,e);
- log.error("LoginModule error. Turn off session credentials checking
with proper configuration option of " +
- "LoginModule set to false");
- }
-
+ if (o instanceof Credentials) {
+ c = (Credentials) o;
+ }
}
- if (o instanceof Credentials)
+ if (c != null)
{
- Credentials wc = (Credentials)o;
-
- // Set shared state
- sharedState.put("javax.security.auth.login.name",
wc.getUsername());
- sharedState.put("javax.security.auth.login.password",
wc.getPassword());
+ sharedState.put("javax.security.auth.login.name", c.getUsername());
+ sharedState.put("javax.security.auth.login.password",
c.getPassword());
}
return true;
}
Modified:
portal/branches/wci/web/portal/src/main/webapp/WEB-INF/conf/common/autologin-configuration.xml
===================================================================
---
portal/branches/wci/web/portal/src/main/webapp/WEB-INF/conf/common/autologin-configuration.xml 2010-09-24
14:16:26 UTC (rev 4383)
+++
portal/branches/wci/web/portal/src/main/webapp/WEB-INF/conf/common/autologin-configuration.xml 2010-09-24
14:22:28 UTC (rev 4384)
@@ -39,7 +39,7 @@
</init-params>
</component>
- <component>
+ <!--<component>
<key>org.exoplatform.web.security.security.TransientTokenService</key>
<type>org.exoplatform.web.security.security.TransientTokenService</type>
<init-params>
@@ -50,7 +50,7 @@
<value>MINUTE</value>
</values-param>
</init-params>
- </component>
+ </component>-->
<external-component-plugins>
<target-component>org.exoplatform.commons.chromattic.ChromatticManager</target-component>
Show replies by date