Author: alain_defrance
Date: 2010-09-30 10:01:44 -0400 (Thu, 30 Sep 2010)
New Revision: 4443
Modified:
components/wci/branches/adf/jetty/src/main/java/org/gatein/wci/jetty/Jetty6ServletContainerContext.java
components/wci/branches/adf/test/core/src/main/java/org/gatein/wci/container/ServletContainerContextImpl.java
components/wci/branches/adf/tomcat6/src/main/java/org/gatein/wci/tomcat/TC6ServletContainerContext.java
components/wci/branches/adf/tomcat7/src/main/java/org/gatein/wci/tomcat/TC7ServletContainerContext.java
components/wci/branches/adf/wci/src/main/java/org/gatein/wci/ServletContainer.java
components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/Authentication.java
components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/GenericAuthentication.java
components/wci/branches/adf/wci/src/main/java/org/gatein/wci/impl/DefaultServletContainer.java
components/wci/branches/adf/wci/src/main/java/org/gatein/wci/impl/generic/GenericServletContainerContext.java
components/wci/branches/adf/wci/src/main/java/org/gatein/wci/spi/ServletContainerContext.java
Log:
logout feature added
Modified:
components/wci/branches/adf/jetty/src/main/java/org/gatein/wci/jetty/Jetty6ServletContainerContext.java
===================================================================
---
components/wci/branches/adf/jetty/src/main/java/org/gatein/wci/jetty/Jetty6ServletContainerContext.java 2010-09-30
12:12:57 UTC (rev 4442)
+++
components/wci/branches/adf/jetty/src/main/java/org/gatein/wci/jetty/Jetty6ServletContainerContext.java 2010-09-30
14:01:44 UTC (rev 4443)
@@ -66,7 +66,11 @@
return GenericAuthentication.getInstance().login(userName, password.toCharArray());
}
+ public void logout(HttpServletRequest request, HttpServletResponse response) {
+ GenericAuthentication.getInstance().logout(request, response);
+ }
+
public void start()
{
DefaultServletContainerFactory.registerContext(this);
Modified:
components/wci/branches/adf/test/core/src/main/java/org/gatein/wci/container/ServletContainerContextImpl.java
===================================================================
---
components/wci/branches/adf/test/core/src/main/java/org/gatein/wci/container/ServletContainerContextImpl.java 2010-09-30
12:12:57 UTC (rev 4442)
+++
components/wci/branches/adf/test/core/src/main/java/org/gatein/wci/container/ServletContainerContextImpl.java 2010-09-30
14:01:44 UTC (rev 4443)
@@ -66,4 +66,9 @@
{
return GenericAuthentication.getInstance().login(userName,
password.toCharArray());
}
+
+ public void logout(HttpServletRequest request, HttpServletResponse response)
+ {
+ GenericAuthentication.getInstance().logout(request, response);
+ }
}
Modified:
components/wci/branches/adf/tomcat6/src/main/java/org/gatein/wci/tomcat/TC6ServletContainerContext.java
===================================================================
---
components/wci/branches/adf/tomcat6/src/main/java/org/gatein/wci/tomcat/TC6ServletContainerContext.java 2010-09-30
12:12:57 UTC (rev 4442)
+++
components/wci/branches/adf/tomcat6/src/main/java/org/gatein/wci/tomcat/TC6ServletContainerContext.java 2010-09-30
14:01:44 UTC (rev 4443)
@@ -104,6 +104,11 @@
return GenericAuthentication.getInstance().login(userName,
password.toCharArray());
}
+ public void logout(HttpServletRequest request, HttpServletResponse response)
+ {
+ GenericAuthentication.getInstance().logout(request, response);
+ }
+
public synchronized void containerEvent(ContainerEvent event)
{
if (event.getData() instanceof Host)
Modified:
components/wci/branches/adf/tomcat7/src/main/java/org/gatein/wci/tomcat/TC7ServletContainerContext.java
===================================================================
---
components/wci/branches/adf/tomcat7/src/main/java/org/gatein/wci/tomcat/TC7ServletContainerContext.java 2010-09-30
12:12:57 UTC (rev 4442)
+++
components/wci/branches/adf/tomcat7/src/main/java/org/gatein/wci/tomcat/TC7ServletContainerContext.java 2010-09-30
14:01:44 UTC (rev 4443)
@@ -100,15 +100,31 @@
this.registration = null;
}
- public AuthenticationResult login(HttpServletRequest request, HttpServletResponse
response, String userName, String password) {
- try {
- request.login(userName, password);
- } catch (ServletException e) {
- e.printStackTrace();
- }
- return new ProgrammaticAuthenticationResult();
- }
+ public AuthenticationResult login(HttpServletRequest request, HttpServletResponse
response, String userName, String password)
+ {
+ try
+ {
+ request.login(userName, password);
+ }
+ catch (ServletException e)
+ {
+ e.printStackTrace(); // TODO : manage correctly this exception.
+ }
+ return new ProgrammaticAuthenticationResult();
+ }
+ public void logout(HttpServletRequest request, HttpServletResponse response)
+ {
+ try
+ {
+ request.logout();
+ }
+ catch (ServletException e)
+ {
+ e.printStackTrace(); // TODO : manage correctly this exception.
+ }
+ }
+
public synchronized void containerEvent(ContainerEvent event)
{
if (event.getData() instanceof Host)
Modified:
components/wci/branches/adf/wci/src/main/java/org/gatein/wci/ServletContainer.java
===================================================================
---
components/wci/branches/adf/wci/src/main/java/org/gatein/wci/ServletContainer.java 2010-09-30
12:12:57 UTC (rev 4442)
+++
components/wci/branches/adf/wci/src/main/java/org/gatein/wci/ServletContainer.java 2010-09-30
14:01:44 UTC (rev 4443)
@@ -102,4 +102,12 @@
* @param password the password of the username
*/
AuthenticationResult login(HttpServletRequest request, HttpServletResponse response,
String userName, String password);
+
+ /**
+ * Authentication support.
+ *
+ * @param request the request valid in the current servlet context
+ * @param response the response valid in the current servlet context
+ */
+ void logout(HttpServletRequest request, HttpServletResponse response);
}
Modified:
components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/Authentication.java
===================================================================
---
components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/Authentication.java 2010-09-30
12:12:57 UTC (rev 4442)
+++
components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/Authentication.java 2010-09-30
14:01:44 UTC (rev 4443)
@@ -19,6 +19,9 @@
package org.gatein.wci.authentication;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
/**
* @author <a href="mailto:alain.defrance@exoplatform.com">Alain
Defrance</a>
* @version $Revision$
@@ -26,6 +29,6 @@
public interface Authentication
{
public AuthenticationResult login(String login, char[] password);
- public void logout();
+ public void logout(HttpServletRequest request, HttpServletResponse response);
public void addAuthenticationListener(AuthenticationListener listener);
}
Modified:
components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/GenericAuthentication.java
===================================================================
---
components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/GenericAuthentication.java 2010-09-30
12:12:57 UTC (rev 4442)
+++
components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/GenericAuthentication.java 2010-09-30
14:01:44 UTC (rev 4443)
@@ -19,6 +19,9 @@
package org.gatein.wci.authentication;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
/**
* @author <a href="mailto:alain.defrance@exoplatform.com">Alain
Defrance</a>
* @version $Revision$
@@ -32,15 +35,16 @@
public AuthenticationResult login(String login, char[] password)
{
- String ticket = TICKET_SERVICE.createTicket(new WCICredentials(login, new
String(password)));
+ String ticket = TICKET_SERVICE.createTicket(new WCICredentials(login, new
String(password)));
- fireEvent(EventType.LOGIN, new AuthenticationEvent(login, password));
- return new GenericAuthenticationResult(ticket);
+ fireEvent(EventType.LOGIN, new AuthenticationEvent(login, password));
+ return new GenericAuthenticationResult(ticket);
}
- public void logout()
+ public void logout(HttpServletRequest request, HttpServletResponse response)
{
- fireEvent(EventType.LOGOUT, new AuthenticationEvent("", new char[1]));
+ request.getSession().invalidate();
+ fireEvent(EventType.LOGOUT, new AuthenticationEvent("", new char[1]));
}
public static GenericAuthentication getInstance() {
Modified:
components/wci/branches/adf/wci/src/main/java/org/gatein/wci/impl/DefaultServletContainer.java
===================================================================
---
components/wci/branches/adf/wci/src/main/java/org/gatein/wci/impl/DefaultServletContainer.java 2010-09-30
12:12:57 UTC (rev 4442)
+++
components/wci/branches/adf/wci/src/main/java/org/gatein/wci/impl/DefaultServletContainer.java 2010-09-30
14:01:44 UTC (rev 4443)
@@ -95,6 +95,10 @@
return registration.context.login(request, response, userName, password);
}
+ public void logout(HttpServletRequest request, HttpServletResponse response) {
+ registration.context.logout(request, response);
+ }
+
public WebExecutor getExecutor(HttpServletRequest request, HttpServletResponse
response)
{
throw new NotYetImplemented();
Modified:
components/wci/branches/adf/wci/src/main/java/org/gatein/wci/impl/generic/GenericServletContainerContext.java
===================================================================
---
components/wci/branches/adf/wci/src/main/java/org/gatein/wci/impl/generic/GenericServletContainerContext.java 2010-09-30
12:12:57 UTC (rev 4442)
+++
components/wci/branches/adf/wci/src/main/java/org/gatein/wci/impl/generic/GenericServletContainerContext.java 2010-09-30
14:01:44 UTC (rev 4443)
@@ -135,6 +135,11 @@
return GenericAuthentication.getInstance().login(userName,
password.toCharArray());
}
+ public void logout(HttpServletRequest request, HttpServletResponse response)
+ {
+ GenericAuthentication.getInstance().logout(request, response);
+ }
+
//
public void contextInitialized(ServletContextEvent servletContextEvent)
Modified:
components/wci/branches/adf/wci/src/main/java/org/gatein/wci/spi/ServletContainerContext.java
===================================================================
---
components/wci/branches/adf/wci/src/main/java/org/gatein/wci/spi/ServletContainerContext.java 2010-09-30
12:12:57 UTC (rev 4442)
+++
components/wci/branches/adf/wci/src/main/java/org/gatein/wci/spi/ServletContainerContext.java 2010-09-30
14:01:44 UTC (rev 4443)
@@ -85,6 +85,14 @@
AuthenticationResult login(HttpServletRequest request, HttpServletResponse response,
String userName, String password);
/**
+ * Authentication support.
+ *
+ * @param request the request valid in the current servlet context
+ * @param response the response valid in the current servlet context
+ */
+ void logout(HttpServletRequest request, HttpServletResponse response);
+
+ /**
* The callback interface that a servlet container context can obtain from its
registration against
* the <code>org.jboss.portal.web.ServletContainer</code> singleton.
*/