Author: alain_defrance
Date: 2011-02-22 06:10:24 -0500 (Tue, 22 Feb 2011)
New Revision: 5918
Added:
components/wci/trunk/test/core/src/main/java/org/gatein/wci/spi/TestController.java
components/wci/trunk/wci/src/main/java/org/gatein/wci/security/WCIController.java
Removed:
components/wci/trunk/wci/src/main/java/org/gatein/wci/authentication/AuthenticationResult.java
components/wci/trunk/wci/src/main/java/org/gatein/wci/authentication/GenericAuthenticationResult.java
components/wci/trunk/wci/src/main/java/org/gatein/wci/authentication/ProgrammaticAuthenticationResult.java
Modified:
components/wci/trunk/jboss/jboss6/src/main/java/org/gatein/wci/jboss/JB6ServletContainerContext.java
components/wci/trunk/jetty/src/main/java/org/gatein/wci/jetty/Jetty6ServletContainerContext.java
components/wci/trunk/test/core/src/main/java/org/gatein/wci/container/ServletContainerContextImpl.java
components/wci/trunk/test/core/src/main/java/org/gatein/wci/spi/SPIAuthenticationTestCase.java
components/wci/trunk/test/servers/jetty6/pom.xml
components/wci/trunk/test/servers/pom.xml
components/wci/trunk/tomcat/tomcat6/src/main/java/org/gatein/wci/tomcat/TC6ServletContainerContext.java
components/wci/trunk/tomcat/tomcat7/src/main/java/org/gatein/wci/tomcat/TC7ServletContainerContext.java
components/wci/trunk/wci/src/main/doc/wci-authentication.odp
components/wci/trunk/wci/src/main/doc/wci-authentication.pdf
components/wci/trunk/wci/src/main/java/org/gatein/wci/ServletContainer.java
components/wci/trunk/wci/src/main/java/org/gatein/wci/authentication/AuthenticationEvent.java
components/wci/trunk/wci/src/main/java/org/gatein/wci/authentication/GenericAuthentication.java
components/wci/trunk/wci/src/main/java/org/gatein/wci/authentication/TicketService.java
components/wci/trunk/wci/src/main/java/org/gatein/wci/impl/DefaultServletContainer.java
components/wci/trunk/wci/src/main/java/org/gatein/wci/impl/generic/GenericServletContainerContext.java
components/wci/trunk/wci/src/main/java/org/gatein/wci/spi/ServletContainerContext.java
Log:
GTNPORTAL-1808 : Move some code from gatein authentication (InitialeLoginServlet &
ErrorLoginServlet) to wci authentication (Create WCIController)
Modified:
components/wci/trunk/jboss/jboss6/src/main/java/org/gatein/wci/jboss/JB6ServletContainerContext.java
===================================================================
---
components/wci/trunk/jboss/jboss6/src/main/java/org/gatein/wci/jboss/JB6ServletContainerContext.java 2011-02-21
06:34:14 UTC (rev 5917)
+++
components/wci/trunk/jboss/jboss6/src/main/java/org/gatein/wci/jboss/JB6ServletContainerContext.java 2011-02-22
11:10:24 UTC (rev 5918)
@@ -35,10 +35,7 @@
import org.gatein.common.logging.Logger;
import org.gatein.common.logging.LoggerFactory;
import org.gatein.wci.RequestDispatchCallback;
-import org.gatein.wci.authentication.AuthenticationResult;
import org.gatein.wci.authentication.GenericAuthentication;
-import org.gatein.wci.authentication.GenericAuthenticationResult;
-import org.gatein.wci.authentication.ProgrammaticAuthenticationResult;
import org.gatein.wci.authentication.TicketService;
import org.gatein.wci.command.CommandDispatcher;
import org.gatein.wci.impl.DefaultServletContainerFactory;
@@ -78,6 +75,9 @@
/** . */
private Registration registration;
+ /** . */
+ private GenericAuthentication authentication = new GenericAuthentication();
+
public JB6ServletContainerContext(Engine engine)
{
this.engine = engine;
@@ -99,21 +99,30 @@
this.registration = null;
}
- public AuthenticationResult login(HttpServletRequest request, HttpServletResponse
response, String userName,
- String password, long validityMillis) throws ServletException
- {
+ public void login(HttpServletRequest request, HttpServletResponse response,
Credentials credentials, long validityMillis) throws ServletException, IOException
+ {
+ login(request, response, credentials, validityMillis, null);
+ }
+
+ public void login(HttpServletRequest request, HttpServletResponse response,
Credentials credentials, long validityMillis, String initialURI) throws ServletException,
IOException
+ {
+ if (initialURI == null)
+ {
+ initialURI = request.getRequestURI();
+ }
try
{
- request.login(userName, password);
+ request.login(credentials.getUsername(), credentials.getPassword());
+ response.sendRedirect(response.encodeRedirectURL(initialURI));
}
catch (ServletException se)
{
se.printStackTrace();
try
{
- String ticket = GenericAuthentication.TICKET_SERVICE.createTicket(new
Credentials(userName, password),
+ String ticket = GenericAuthentication.TICKET_SERVICE.createTicket(new
Credentials(credentials.getUsername(), credentials.getUsername()),
TicketService.DEFAULT_VALIDITY);
- String url = "j_security_check?j_username=" + userName +
"&j_password=" + ticket;
+ String url = "j_security_check?j_username=" +
credentials.getUsername() + "&j_password=" + ticket +
"&initialURI=" + initialURI;
url = response.encodeRedirectURL(url);
response.sendRedirect(url);
response.flushBuffer();
@@ -121,10 +130,8 @@
catch (Exception ignore)
{
}
- return null;
}
- return new ProgrammaticAuthenticationResult();
- }
+ }
public void logout(HttpServletRequest request, HttpServletResponse response) throws
ServletException
{
@@ -132,6 +139,11 @@
request.getSession().invalidate();
}
+ public String getContainerInfo()
+ {
+ return "JBossas/6.x";
+ }
+
public synchronized void containerEvent(ContainerEvent event)
{
if (event.getData() instanceof Host)
Modified:
components/wci/trunk/jetty/src/main/java/org/gatein/wci/jetty/Jetty6ServletContainerContext.java
===================================================================
---
components/wci/trunk/jetty/src/main/java/org/gatein/wci/jetty/Jetty6ServletContainerContext.java 2011-02-21
06:34:14 UTC (rev 5917)
+++
components/wci/trunk/jetty/src/main/java/org/gatein/wci/jetty/Jetty6ServletContainerContext.java 2011-02-22
11:10:24 UTC (rev 5918)
@@ -10,10 +10,10 @@
import javax.servlet.http.HttpServletResponse;
import org.gatein.wci.RequestDispatchCallback;
-import org.gatein.wci.authentication.AuthenticationResult;
import org.gatein.wci.authentication.GenericAuthentication;
import org.gatein.wci.command.CommandDispatcher;
import org.gatein.wci.impl.DefaultServletContainerFactory;
+import org.gatein.wci.security.Credentials;
import org.gatein.wci.spi.ServletContainerContext;
import org.mortbay.component.Container;
import org.mortbay.component.LifeCycle;
@@ -31,6 +31,9 @@
private Container container;
private Server server;
private ContextHandlerCollection chc;
+
+ /** . */
+ private GenericAuthentication authentication = new GenericAuthentication();
/** The monitored contexts. */
private final Set<String> monitoredContexts = new HashSet<String>();
@@ -49,7 +52,7 @@
HttpServletRequest request, HttpServletResponse response,
RequestDispatchCallback callback, Object handback)
throws ServletException, IOException
- {
+ {
return dispatcher.include(targetServletContext, request, response,
callback, handback);
}
@@ -62,17 +65,27 @@
this.registration = null;
}
- public AuthenticationResult login(HttpServletRequest request, HttpServletResponse
response, String userName, String password, long validityMillis)
+ public void login(HttpServletRequest request, HttpServletResponse response,
Credentials credentials, long validityMillis) throws IOException
{
- return GenericAuthentication.getInstance().login(userName, password, request,
response, validityMillis);
+ authentication.login(credentials, request, response, validityMillis, null);
}
- public void logout(HttpServletRequest request, HttpServletResponse response)
+ public void login(HttpServletRequest request, HttpServletResponse response,
Credentials credentials, long validityMillis, String initialURI) throws IOException
{
- GenericAuthentication.getInstance().logout(request, response);
+ authentication.login(credentials, request, response, validityMillis, initialURI);
}
- public void start()
+ public void logout(HttpServletRequest request, HttpServletResponse response) throws
ServletException
+ {
+ authentication.logout(request, response);
+ }
+
+ public String getContainerInfo()
+ {
+ return "Jetty/6.x";
+ }
+
+ public void start()
{
DefaultServletContainerFactory.registerContext(this);
Modified:
components/wci/trunk/test/core/src/main/java/org/gatein/wci/container/ServletContainerContextImpl.java
===================================================================
---
components/wci/trunk/test/core/src/main/java/org/gatein/wci/container/ServletContainerContextImpl.java 2011-02-21
06:34:14 UTC (rev 5917)
+++
components/wci/trunk/test/core/src/main/java/org/gatein/wci/container/ServletContainerContextImpl.java 2011-02-22
11:10:24 UTC (rev 5918)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.gatein.wci.container;
-import org.gatein.wci.authentication.AuthenticationResult;
+import org.gatein.wci.security.Credentials;
import org.gatein.wci.spi.ServletContainerContext;
import org.gatein.wci.RequestDispatchCallback;
@@ -61,13 +61,23 @@
this.registration = null;
}
- public AuthenticationResult login(HttpServletRequest request, HttpServletResponse
response, String userName, String password, long validityMillis)
+ public void login(HttpServletRequest request, HttpServletResponse response,
Credentials credentials, long validityMillis)
{
throw new UnsupportedOperationException();
-}
+ }
+ public void login(HttpServletRequest request, HttpServletResponse response,
Credentials credentials, long validityMillis, String initialURI)
+ {
+ throw new UnsupportedOperationException();
+ }
+
public void logout(HttpServletRequest request, HttpServletResponse response)
{
throw new UnsupportedOperationException();
}
+
+ public String getContainerInfo()
+ {
+ return "Impl";
+ }
}
Modified:
components/wci/trunk/test/core/src/main/java/org/gatein/wci/spi/SPIAuthenticationTestCase.java
===================================================================
---
components/wci/trunk/test/core/src/main/java/org/gatein/wci/spi/SPIAuthenticationTestCase.java 2011-02-21
06:34:14 UTC (rev 5917)
+++
components/wci/trunk/test/core/src/main/java/org/gatein/wci/spi/SPIAuthenticationTestCase.java 2011-02-22
11:10:24 UTC (rev 5918)
@@ -27,13 +27,11 @@
import org.gatein.wci.authentication.AuthenticationEvent;
import org.gatein.wci.authentication.AuthenticationException;
import org.gatein.wci.authentication.AuthenticationListener;
-import org.gatein.wci.authentication.AuthenticationResult;
import org.gatein.wci.authentication.GenericAuthentication;
-import org.gatein.wci.authentication.GenericAuthenticationResult;
-import org.gatein.wci.authentication.ProgrammaticAuthenticationResult;
import org.gatein.wci.authentication.TicketService;
import org.gatein.wci.security.Credentials;
import org.gatein.wci.impl.DefaultServletContainerFactory;
+import org.gatein.wci.security.WCIController;
import org.jboss.unit.Failure;
import org.jboss.unit.driver.DriverCommand;
import org.jboss.unit.driver.DriverResponse;
@@ -45,6 +43,8 @@
import javax.servlet.ServletException;
import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
/**
* @author <a href="mailto:alain.defrance@exoplatform.com">Alain
Defrance</a>
@@ -52,8 +52,6 @@
*/
public class SPIAuthenticationTestCase extends ServletTestCase
{
- private final String username = "foo";
- private final String password = "bar";
/** . */
private ServletContainer container;
@@ -62,100 +60,109 @@
private final Value v = new Value();
/** . */
- private AuthenticationResult result;
+ private WCIController wciController = new TestController();
@Override
public DriverResponse service(TestServlet testServlet, WebRequest req, WebResponse
resp) throws ServletException, IOException
{
+ Credentials credentials = wciController.getCredentials(req, resp);
+
if (getRequestCount() == 0)
{
+ assertEquals("/home", wciController.getInitialURI(req));
+ req.setAttribute("javax.servlet.forward.request_uri",
"/foo");
+ assertEquals("/foo", wciController.getInitialURI(req));
+
+ // Test Ticket Expiration
+ String expireTicket = GenericAuthentication.TICKET_SERVICE.createTicket(new
Credentials("foo", "bar"), 5);
+ boolean expired = false;
+ try
+ {
+ Thread.sleep(5);
+ GenericAuthentication.TICKET_SERVICE.validateTicket(expireTicket, true);
+ }
+ catch (InterruptedException ignore)
+ {
+ }
+ catch (AuthenticationException ae)
+ {
+ expired = true;
+ }
+ if (!expired) return new
FailureResponse(Failure.createAssertionFailure(""));
+
assertNull(req.getUserPrincipal());
container = DefaultServletContainerFactory.getInstance().getServletContainer();
container.addAuthenticationListener(new TestListener(v));
assertEquals("", v.value);
- result = container.login(req, resp, username, password,
TicketService.DEFAULT_VALIDITY);
- assertNotNull(result);
- if (result instanceof GenericAuthenticationResult)
+ container.login(req, resp, credentials, TicketService.DEFAULT_VALIDITY);
+
+ if ("Tomcat/7.x".equals(container.getContainerInfo()) ||
"JBossas/6.x".equals(container.getContainerInfo()))
{
- GenericAuthenticationResult gAuthentication = (GenericAuthenticationResult)
result;
- // Test Ticket Expiration
- GenericAuthentication.getInstance();
- String expireTicket = GenericAuthentication.TICKET_SERVICE.createTicket(new
Credentials("foo", "bar"), 5);
- boolean expired = false;
- try
- {
- Thread.sleep(5);
- GenericAuthentication.TICKET_SERVICE.validateTicket(expireTicket, true);
- }
- catch (InterruptedException ignore)
- {
- }
- catch (AuthenticationException ae)
- {
- expired = true;
- }
- if (!expired) return new
FailureResponse(Failure.createAssertionFailure(""));
-
-
+ assertEquals("login", v.value);
+ assertNotNull(req.getUserPrincipal());
+ assertTrue(req.isUserInRole("test"));
+ }
+ else
+ {
// Test Ticket Service
- Credentials srcCredentials = new Credentials(username, password);
- String ticket =
GenericAuthentication.TICKET_SERVICE.createTicket(srcCredentials,
TicketService.DEFAULT_VALIDITY);
+ String ticket =
GenericAuthentication.TICKET_SERVICE.createTicket(credentials,
TicketService.DEFAULT_VALIDITY);
Credentials resultCredentials =
GenericAuthentication.TICKET_SERVICE.validateTicket(ticket, false);
- assertEquals(srcCredentials.getUsername(), resultCredentials.getUsername());
- assertEquals(srcCredentials.getPassword(), resultCredentials.getPassword());
+ assertEquals(credentials.getUsername(), resultCredentials.getUsername());
+ assertEquals(credentials.getPassword(), resultCredentials.getPassword());
assertNotNull(GenericAuthentication.TICKET_SERVICE.validateTicket(ticket,
true));
assertNull(GenericAuthentication.TICKET_SERVICE.validateTicket(ticket,
true));
- // Test Generic login
- GenericAuthenticationResult gResult = (GenericAuthenticationResult) result;
- String t = gResult.getTicket();
- Credentials credentials =
GenericAuthentication.TICKET_SERVICE.validateTicket(t, true);
- assertNotNull(credentials);
- assertEquals("", v.value);
- gAuthentication.perform(req, resp);
-
// Test login Event
assertEquals("login", v.value);
assertTrue(resp.isCommitted());
-
}
- else if (result instanceof ProgrammaticAuthenticationResult)
- {
- assertEquals("login", v.value);
- assertNotNull(req.getUserPrincipal());
- assertTrue(req.isUserInRole("test"));
- }
//
- String url = resp.renderURL("/", null, null);
+ Map<String, String[]> params = new HashMap<String, String[]>();
+ params.put("initialURI", new String[]{"/bar"});
+ String url = resp.renderURL("/", params, null);
return new InvokeGetResponse(url);
}
else if (getRequestCount() == 1)
{
- if (result instanceof GenericAuthenticationResult)
+ assertEquals("/bar", wciController.getInitialURI(req));
+
+ if ("Tomcat/7.x".equals(container.getContainerInfo()) ||
"JBossas/6.x".equals(container.getContainerInfo()))
{
- // Test logout
- assertNotNull(req.getSession(false));
assertEquals("login", v.value);
+
container.logout(req, resp);
- assertNull(req.getSession(false));
- // Test logout Event
assertEquals("logout", v.value);
+ assertNull(req.getUserPrincipal());
}
- else if (result instanceof ProgrammaticAuthenticationResult)
+ else
{
+ // Test logout
+ assertNotNull(req.getSession(false));
assertEquals("login", v.value);
-
container.logout(req, resp);
+ assertNull(req.getSession(false));
+ // Test logout Event
assertEquals("logout", v.value);
- assertNull(req.getUserPrincipal());
}
+
+ String url = resp.renderURL("/", null, null);
+ return new InvokeGetResponse(url);
+ }
+ else if (getRequestCount() == 2)
+ {
+ assertEquals(
+ "/home/j_security_check?j_username=foo&j_password=bar",
+ wciController.getAuthURI(req, resp, credentials.getUsername(),
credentials.getPassword())
+ );
+ wciController.sendAuth(req, resp, credentials.getUsername(),
credentials.getPassword());
+ assertTrue(resp.isCommitted());
return new EndTestResponse();
}
- return new FailureResponse(Failure.createAssertionFailure(""));
+ return new FailureResponse(Failure.createAssertionFailure("End test
reached"));
}
@Override
Added:
components/wci/trunk/test/core/src/main/java/org/gatein/wci/spi/TestController.java
===================================================================
--- components/wci/trunk/test/core/src/main/java/org/gatein/wci/spi/TestController.java
(rev 0)
+++
components/wci/trunk/test/core/src/main/java/org/gatein/wci/spi/TestController.java 2011-02-22
11:10:24 UTC (rev 5918)
@@ -0,0 +1,57 @@
+/*
+* Copyright (C) 2003-2009 eXo Platform SAS.
+*
+* 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.wci.spi;
+
+import org.gatein.wci.security.Credentials;
+import org.gatein.wci.security.WCIController;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:alain.defrance@exoplatform.com">Alain
Defrance</a>
+ * @version $Revision$
+ */
+public class TestController extends WCIController
+{
+ @Override
+ public void showLoginForm(final HttpServletRequest req, final HttpServletResponse
resp) throws ServletException, IOException
+ {
+ }
+
+ @Override
+ public void showErrorLoginForm(final HttpServletRequest req, final HttpServletResponse
resp) throws ServletException, IOException
+ {
+ }
+
+ @Override
+ public Credentials getCredentials(final HttpServletRequest req, final
HttpServletResponse resp)
+ {
+ return new Credentials("foo", "bar");
+ }
+
+ @Override
+ public String getHomeURI(final HttpServletRequest req)
+ {
+ return "/home";
+ }
+}
Modified: components/wci/trunk/test/servers/jetty6/pom.xml
===================================================================
--- components/wci/trunk/test/servers/jetty6/pom.xml 2011-02-21 06:34:14 UTC (rev 5917)
+++ components/wci/trunk/test/servers/jetty6/pom.xml 2011-02-22 11:10:24 UTC (rev 5918)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.gatein.wci</groupId>
<artifactId>wci-test-server-parent</artifactId>
- <version>2.1.0-Beta01-SNAPSHOT</version>
+ <version>2.1.0-Alpha04-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>wci-test-jetty6</artifactId>
Modified: components/wci/trunk/test/servers/pom.xml
===================================================================
--- components/wci/trunk/test/servers/pom.xml 2011-02-21 06:34:14 UTC (rev 5917)
+++ components/wci/trunk/test/servers/pom.xml 2011-02-22 11:10:24 UTC (rev 5918)
@@ -65,9 +65,9 @@
<modules>
<module>tomcat6</module>
<module>tomcat7</module>
- <module>jboss42</module>
<module>jboss51</module>
<module>jboss6</module>
+ <module>jetty6</module>
</modules>
</profile>
<profile>
@@ -77,7 +77,6 @@
<module>tomcat7</module>
<module>jboss42</module>
<module>jboss51</module>
- <module>jboss6</module>
<module>jetty6</module>
</modules>
</profile>
Modified:
components/wci/trunk/tomcat/tomcat6/src/main/java/org/gatein/wci/tomcat/TC6ServletContainerContext.java
===================================================================
---
components/wci/trunk/tomcat/tomcat6/src/main/java/org/gatein/wci/tomcat/TC6ServletContainerContext.java 2011-02-21
06:34:14 UTC (rev 5917)
+++
components/wci/trunk/tomcat/tomcat6/src/main/java/org/gatein/wci/tomcat/TC6ServletContainerContext.java 2011-02-22
11:10:24 UTC (rev 5918)
@@ -34,10 +34,10 @@
import org.gatein.common.logging.Logger;
import org.gatein.common.logging.LoggerFactory;
import org.gatein.wci.RequestDispatchCallback;
-import org.gatein.wci.authentication.AuthenticationResult;
import org.gatein.wci.authentication.GenericAuthentication;
import org.gatein.wci.command.CommandDispatcher;
import org.gatein.wci.impl.DefaultServletContainerFactory;
+import org.gatein.wci.security.Credentials;
import org.gatein.wci.spi.ServletContainerContext;
import org.apache.catalina.core.StandardContext;
@@ -74,6 +74,9 @@
/** . */
private Registration registration;
+ /** . */
+ private GenericAuthentication authentication = new GenericAuthentication();
+
public TC6ServletContainerContext(Engine engine)
{
this.engine = engine;
@@ -99,16 +102,26 @@
this.registration = null;
}
- public AuthenticationResult login(HttpServletRequest request, HttpServletResponse
response, String userName, String password, long validityMillis)
+ public void login(HttpServletRequest request, HttpServletResponse response,
Credentials credentials, long validityMillis) throws IOException
{
- return GenericAuthentication.getInstance().login(userName, password, request,
response, validityMillis);
+ authentication.login(credentials, request, response, validityMillis);
}
- public void logout(HttpServletRequest request, HttpServletResponse response)
+ public void login(HttpServletRequest request, HttpServletResponse response,
Credentials credentials, long validityMillis, String initialURI) throws IOException
{
- GenericAuthentication.getInstance().logout(request, response);
+ authentication.login(credentials, request, response, validityMillis, initialURI);
}
+ public void logout(HttpServletRequest request, HttpServletResponse response) throws
ServletException
+ {
+ authentication.logout(request, response);
+ }
+
+ public String getContainerInfo()
+ {
+ return "Tomcat/6.x";
+ }
+
public synchronized void containerEvent(ContainerEvent event)
{
if (event.getData() instanceof Host)
Modified:
components/wci/trunk/tomcat/tomcat7/src/main/java/org/gatein/wci/tomcat/TC7ServletContainerContext.java
===================================================================
---
components/wci/trunk/tomcat/tomcat7/src/main/java/org/gatein/wci/tomcat/TC7ServletContainerContext.java 2011-02-21
06:34:14 UTC (rev 5917)
+++
components/wci/trunk/tomcat/tomcat7/src/main/java/org/gatein/wci/tomcat/TC7ServletContainerContext.java 2011-02-22
11:10:24 UTC (rev 5918)
@@ -36,10 +36,7 @@
import org.gatein.common.logging.Logger;
import org.gatein.common.logging.LoggerFactory;
import org.gatein.wci.RequestDispatchCallback;
-import org.gatein.wci.authentication.AuthenticationResult;
import org.gatein.wci.authentication.GenericAuthentication;
-import org.gatein.wci.authentication.GenericAuthenticationResult;
-import org.gatein.wci.authentication.ProgrammaticAuthenticationResult;
import org.gatein.wci.authentication.TicketService;
import org.gatein.wci.command.CommandDispatcher;
import org.gatein.wci.impl.DefaultServletContainerFactory;
@@ -104,18 +101,28 @@
this.registration = null;
}
- public AuthenticationResult login(HttpServletRequest request, HttpServletResponse
response, String userName, String password, long validityMillis) throws ServletException
+ public void login(HttpServletRequest request, HttpServletResponse response,
Credentials credentials, long validityMillis) throws ServletException, IOException
{
+ login(request, response, credentials, validityMillis, null);
+ }
+
+ public void login(HttpServletRequest request, HttpServletResponse response,
Credentials credentials, long validityMillis, String initialURI) throws ServletException,
IOException
+ {
+ if (initialURI == null)
+ {
+ initialURI = request.getRequestURI();
+ }
try
{
- request.login(userName, password);
+ request.login(credentials.getUsername(), credentials.getPassword());
+ response.sendRedirect(response.encodeRedirectURL(initialURI));
}
catch (ServletException se)
{
try
{
- String ticket = GenericAuthentication.TICKET_SERVICE.createTicket(new
Credentials(userName, password), TicketService.DEFAULT_VALIDITY);
- String url = "j_security_check?j_username=" + userName +
"&j_password=" + ticket;
+ String ticket = GenericAuthentication.TICKET_SERVICE.createTicket(new
Credentials(credentials.getUsername(), credentials.getPassword()),
TicketService.DEFAULT_VALIDITY);
+ String url = "j_security_check?j_username=" +
credentials.getUsername() + "&j_password=" + ticket +
"&initialURI=" + initialURI;
url = response.encodeRedirectURL(url);
response.sendRedirect(url);
response.flushBuffer();
@@ -123,9 +130,7 @@
catch (Exception ignore)
{
}
- return null;
}
- return new ProgrammaticAuthenticationResult();
}
public void logout(HttpServletRequest request, HttpServletResponse response) throws
ServletException
@@ -134,8 +139,13 @@
request.getSession().invalidate();
}
- public synchronized void containerEvent(ContainerEvent event)
+ public String getContainerInfo()
{
+ return "Tomcat/7.x";
+ }
+
+ public synchronized void containerEvent(ContainerEvent event)
+ {
if (event.getData() instanceof Host)
{
Host host = (Host)event.getData();
Modified: components/wci/trunk/wci/src/main/doc/wci-authentication.odp
===================================================================
(Binary files differ)
Modified: components/wci/trunk/wci/src/main/doc/wci-authentication.pdf
===================================================================
(Binary files differ)
Modified: components/wci/trunk/wci/src/main/java/org/gatein/wci/ServletContainer.java
===================================================================
--- components/wci/trunk/wci/src/main/java/org/gatein/wci/ServletContainer.java 2011-02-21
06:34:14 UTC (rev 5917)
+++ components/wci/trunk/wci/src/main/java/org/gatein/wci/ServletContainer.java 2011-02-22
11:10:24 UTC (rev 5918)
@@ -23,7 +23,7 @@
package org.gatein.wci;
import org.gatein.wci.authentication.AuthenticationListener;
-import org.gatein.wci.authentication.AuthenticationResult;
+import org.gatein.wci.security.Credentials;
import org.gatein.wci.spi.ServletContainerContext;
import javax.servlet.ServletContext;
@@ -99,17 +99,25 @@
*
* @param request the request valid in the current servlet context
* @param response the response valid in the current servlet context
- * @param userName the username which try to login
- * @param password the password of the username
+ * @param credentials the credentials which try to authenticate
*/
- AuthenticationResult login(HttpServletRequest request, HttpServletResponse response,
String userName, String password, long validityMillis) throws ServletException;
+ void login(HttpServletRequest request, HttpServletResponse response, Credentials
credentials, long validityMillis) throws ServletException, IOException;
/**
* Authentication support.
*
* @param request the request valid in the current servlet context
* @param response the response valid in the current servlet context
+ * @param credentials the credentials which try to authenticate
*/
+ void login(HttpServletRequest request, HttpServletResponse response, Credentials
credentials, long validityMillis, String initialURI) throws ServletException,
IOException;
+
+ /**
+ * 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) throws
ServletException;
/**
@@ -125,4 +133,16 @@
* @param listener AuthenticationListener to remove
*/
void removeAuthenticationlistener(AuthenticationListener listener);
+
+ /**
+ * Returns the name and version of the servlet container in which the
+ * context is running.
+ *
+ * <P>
+ * The form of the returned string is
<code>containername/versionnumber</code>.
+ *
+ *
+ * @return the string containing at least name and version number
+ */
+ public String getContainerInfo();
}
Modified:
components/wci/trunk/wci/src/main/java/org/gatein/wci/authentication/AuthenticationEvent.java
===================================================================
---
components/wci/trunk/wci/src/main/java/org/gatein/wci/authentication/AuthenticationEvent.java 2011-02-21
06:34:14 UTC (rev 5917)
+++
components/wci/trunk/wci/src/main/java/org/gatein/wci/authentication/AuthenticationEvent.java 2011-02-22
11:10:24 UTC (rev 5918)
@@ -19,7 +19,9 @@
package org.gatein.wci.authentication;
+import org.gatein.wci.ServletContainer;
import org.gatein.wci.security.Credentials;
+import org.gatein.wci.spi.ServletContainerContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -33,8 +35,9 @@
private final HttpServletRequest request;
private final HttpServletResponse response;
private final Credentials credentials;
+ private final ServletContainerContext containerContext;
- public AuthenticationEvent(HttpServletRequest request, HttpServletResponse response)
+ public AuthenticationEvent(HttpServletRequest request, HttpServletResponse response,
ServletContainerContext containerContext)
{
if (request == null)
@@ -47,12 +50,18 @@
throw new IllegalArgumentException("response is null");
}
+ if (containerContext == null)
+ {
+ throw new IllegalArgumentException("containerContext is null");
+ }
+
this.request = request;
this.response = response;
this.credentials = null;
+ this.containerContext = containerContext;
}
- public AuthenticationEvent(HttpServletRequest request, HttpServletResponse response,
Credentials credentials)
+ public AuthenticationEvent(HttpServletRequest request, HttpServletResponse response,
Credentials credentials, ServletContainerContext containerContext)
{
if (request == null)
@@ -70,9 +79,15 @@
throw new IllegalArgumentException("credentials is null");
}
+ if (containerContext == null)
+ {
+ throw new IllegalArgumentException("container is null");
+ }
+
this.request = request;
this.response = response;
this.credentials = credentials;
+ this.containerContext = containerContext;
}
public HttpServletRequest getRequest()
@@ -89,4 +104,9 @@
{
return credentials;
}
+
+ public ServletContainerContext getContainerContext()
+ {
+ return containerContext;
+ }
}
Deleted:
components/wci/trunk/wci/src/main/java/org/gatein/wci/authentication/AuthenticationResult.java
===================================================================
---
components/wci/trunk/wci/src/main/java/org/gatein/wci/authentication/AuthenticationResult.java 2011-02-21
06:34:14 UTC (rev 5917)
+++
components/wci/trunk/wci/src/main/java/org/gatein/wci/authentication/AuthenticationResult.java 2011-02-22
11:10:24 UTC (rev 5918)
@@ -1,28 +0,0 @@
-/*
-* Copyright (C) 2003-2009 eXo Platform SAS.
-*
-* 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.wci.authentication;
-
-/**
- * @author <a href="mailto:alain.defrance@exoplatform.com">Alain
Defrance</a>
- * @version $Revision$
- */
-public abstract class AuthenticationResult
-{
-}
Modified:
components/wci/trunk/wci/src/main/java/org/gatein/wci/authentication/GenericAuthentication.java
===================================================================
---
components/wci/trunk/wci/src/main/java/org/gatein/wci/authentication/GenericAuthentication.java 2011-02-21
06:34:14 UTC (rev 5917)
+++
components/wci/trunk/wci/src/main/java/org/gatein/wci/authentication/GenericAuthentication.java 2011-02-22
11:10:24 UTC (rev 5918)
@@ -19,10 +19,13 @@
package org.gatein.wci.authentication;
+import org.gatein.wci.impl.DefaultServletContainer;
+import org.gatein.wci.impl.DefaultServletContainerFactory;
import org.gatein.wci.security.Credentials;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
/**
* @author <a href="mailto:alain.defrance@exoplatform.com">Alain
Defrance</a>
@@ -31,23 +34,29 @@
public class GenericAuthentication
{
public static final TicketService TICKET_SERVICE = new TicketService();
- private static final GenericAuthentication GENERIC_AUTHENTICATION = new
GenericAuthentication();
- private GenericAuthentication() {}
+ public void login(Credentials credentials, HttpServletRequest request,
HttpServletResponse response, long validityMillis) throws IOException
+ {
+ login(credentials, request, response, validityMillis, null);
+ }
- public AuthenticationResult login(String login, String password, HttpServletRequest
request, HttpServletResponse response, long validityMillis)
+ public void login(Credentials credentials, HttpServletRequest request,
HttpServletResponse response, long validityMillis, String initialURI) throws IOException
{
- String ticket = TICKET_SERVICE.createTicket(new Credentials(login, password),
validityMillis);
+ String ticket = TICKET_SERVICE.createTicket(new
Credentials(credentials.getUsername(), credentials.getPassword()), validityMillis);
- return new GenericAuthenticationResult(login, ticket);
+ request.getSession().removeAttribute(Credentials.CREDENTIALS);
+
+ if (initialURI == null) {
+ initialURI = request.getRequestURI();
+ }
+ String url = "j_security_check?j_username=" + credentials.getUsername() +
"&j_password=" + ticket + "&initialURI=" + initialURI;
+ url = response.encodeRedirectURL(url);
+ response.sendRedirect(url);
+ response.flushBuffer();
}
public void logout(HttpServletRequest request, HttpServletResponse response)
{
request.getSession().invalidate();
}
-
- public static GenericAuthentication getInstance() {
- return GENERIC_AUTHENTICATION;
- }
}
\ No newline at end of file
Deleted:
components/wci/trunk/wci/src/main/java/org/gatein/wci/authentication/GenericAuthenticationResult.java
===================================================================
---
components/wci/trunk/wci/src/main/java/org/gatein/wci/authentication/GenericAuthenticationResult.java 2011-02-21
06:34:14 UTC (rev 5917)
+++
components/wci/trunk/wci/src/main/java/org/gatein/wci/authentication/GenericAuthenticationResult.java 2011-02-22
11:10:24 UTC (rev 5918)
@@ -1,61 +0,0 @@
-/*
-* Copyright (C) 2003-2009 eXo Platform SAS.
-*
-* 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.wci.authentication;
-
-import org.gatein.wci.impl.DefaultServletContainer;
-import org.gatein.wci.impl.DefaultServletContainerFactory;
-import org.gatein.wci.security.Credentials;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
-/**
- * @author <a href="mailto:alain.defrance@exoplatform.com">Alain
Defrance</a>
- * @version $Revision$
- */
-public class GenericAuthenticationResult extends AuthenticationResult {
- private String username;
- private String ticket;
-
- public GenericAuthenticationResult(String username, String ticket) {
- this.username = username;
- this.ticket = ticket;
- }
-
- public String getTicket() {
- return ticket;
- }
-
- public void perform(HttpServletRequest req, HttpServletResponse resp) throws
IOException
- {
- req.getSession().removeAttribute(Credentials.CREDENTIALS);
- String url = "j_security_check?j_username=" + username +
"&j_password=" + ticket;
- url = resp.encodeRedirectURL(url);
- resp.sendRedirect(url);
- resp.flushBuffer();
-
- Object o = DefaultServletContainerFactory.getInstance().getServletContainer();
- if (o instanceof DefaultServletContainer)
- {
- ((DefaultServletContainer)o).fireEvent(DefaultServletContainer.EventType.LOGIN,
new AuthenticationEvent(req, resp, new Credentials(username, ticket)));
- }
- }
-}
Deleted:
components/wci/trunk/wci/src/main/java/org/gatein/wci/authentication/ProgrammaticAuthenticationResult.java
===================================================================
---
components/wci/trunk/wci/src/main/java/org/gatein/wci/authentication/ProgrammaticAuthenticationResult.java 2011-02-21
06:34:14 UTC (rev 5917)
+++
components/wci/trunk/wci/src/main/java/org/gatein/wci/authentication/ProgrammaticAuthenticationResult.java 2011-02-22
11:10:24 UTC (rev 5918)
@@ -1,27 +0,0 @@
-/*
-* Copyright (C) 2003-2009 eXo Platform SAS.
-*
-* 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.wci.authentication;
-
-/**
- * @author <a href="mailto:alain.defrance@exoplatform.com">Alain
Defrance</a>
- * @version $Revision$
- */
-public class ProgrammaticAuthenticationResult extends AuthenticationResult {
-}
Modified:
components/wci/trunk/wci/src/main/java/org/gatein/wci/authentication/TicketService.java
===================================================================
---
components/wci/trunk/wci/src/main/java/org/gatein/wci/authentication/TicketService.java 2011-02-21
06:34:14 UTC (rev 5917)
+++
components/wci/trunk/wci/src/main/java/org/gatein/wci/authentication/TicketService.java 2011-02-22
11:10:24 UTC (rev 5918)
@@ -44,7 +44,7 @@
}
if (credentials == null)
{
- throw new NullPointerException();
+ throw new IllegalArgumentException("credentials is null");
}
String tokenId = nextTicketId();
long expirationTimeMillis = System.currentTimeMillis() + validityMillis;
Modified:
components/wci/trunk/wci/src/main/java/org/gatein/wci/impl/DefaultServletContainer.java
===================================================================
---
components/wci/trunk/wci/src/main/java/org/gatein/wci/impl/DefaultServletContainer.java 2011-02-21
06:34:14 UTC (rev 5917)
+++
components/wci/trunk/wci/src/main/java/org/gatein/wci/impl/DefaultServletContainer.java 2011-02-22
11:10:24 UTC (rev 5918)
@@ -24,8 +24,6 @@
import org.gatein.wci.authentication.AuthenticationEvent;
import org.gatein.wci.authentication.AuthenticationListener;
-import org.gatein.wci.authentication.AuthenticationResult;
-import org.gatein.wci.authentication.GenericAuthenticationResult;
import org.gatein.wci.security.Credentials;
import org.gatein.wci.spi.ServletContainerContext;
import org.gatein.wci.spi.WebAppContext;
@@ -99,17 +97,18 @@
}
/** . */
- public AuthenticationResult login(HttpServletRequest request, HttpServletResponse
response, String userName, String password, long validityMillis) throws ServletException
+ public void login(HttpServletRequest request, HttpServletResponse response,
Credentials credentials, long validityMillis) throws ServletException, IOException
{
- AuthenticationResult result = registration.context.login(request, response,
userName, password, validityMillis);
+ login(request, response, credentials, validityMillis, null);
+ }
+ /** . */
+ public void login(HttpServletRequest request, HttpServletResponse response,
Credentials credentials, long validityMillis, String initialURI) throws ServletException,
IOException
+ {
+ registration.context.login(request, response, credentials, validityMillis,
initialURI);
+
//
- if (!(result instanceof GenericAuthenticationResult))
- {
- fireEvent(EventType.LOGIN, new AuthenticationEvent(request, response, new
Credentials(userName, password)));
- }
-
- return result;
+ fireEvent(EventType.LOGIN, new AuthenticationEvent(request, response, credentials,
registration.context));
}
public void logout(HttpServletRequest request, HttpServletResponse response) throws
ServletException
@@ -117,7 +116,7 @@
registration.context.logout(request, response);
//
- fireEvent(EventType.LOGOUT, new AuthenticationEvent(request, response));
+ fireEvent(EventType.LOGOUT, new AuthenticationEvent(request, response,
registration.context));
}
public void addAuthenticationListener(AuthenticationListener listener) {
@@ -136,6 +135,11 @@
authenticationListeners.remove(listener);
}
+ public String getContainerInfo()
+ {
+ return registration.context.getContainerInfo();
+ }
+
public WebExecutor getExecutor(HttpServletRequest request, HttpServletResponse
response)
{
throw new NotYetImplemented();
Modified:
components/wci/trunk/wci/src/main/java/org/gatein/wci/impl/generic/GenericServletContainerContext.java
===================================================================
---
components/wci/trunk/wci/src/main/java/org/gatein/wci/impl/generic/GenericServletContainerContext.java 2011-02-21
06:34:14 UTC (rev 5917)
+++
components/wci/trunk/wci/src/main/java/org/gatein/wci/impl/generic/GenericServletContainerContext.java 2011-02-22
11:10:24 UTC (rev 5918)
@@ -23,9 +23,9 @@
package org.gatein.wci.impl.generic;
import org.gatein.wci.RequestDispatchCallback;
-import org.gatein.wci.authentication.AuthenticationResult;
import org.gatein.wci.authentication.GenericAuthentication;
import org.gatein.wci.impl.DefaultServletContainerFactory;
+import org.gatein.wci.security.Credentials;
import org.gatein.wci.spi.ServletContainerContext;
import org.gatein.wci.command.CommandDispatcher;
@@ -54,6 +54,9 @@
private static GenericServletContainerContext instance;
private static HashMap<ServletContext, String> requestDispatchMap = new
HashMap<ServletContext, String>();
+
+ /** . */
+ private GenericAuthentication authentication = new GenericAuthentication();
public static GenericServletContainerContext getInstance()
{
@@ -99,7 +102,6 @@
}
/** . */
- //private final CommandDispatcher dispatcher = new
CommandDispatcher("/gateinservlet");
public Object include(
ServletContext targetServletContext,
@@ -130,15 +132,26 @@
this.registration = null;
}
- public AuthenticationResult login(HttpServletRequest request, HttpServletResponse
response, String userName, String password, long validityMillis)
+ public void login(HttpServletRequest request, HttpServletResponse response,
Credentials credentials, long validityMillis) throws IOException
{
- return GenericAuthentication.getInstance().login(userName, password, request,
response, validityMillis);
+ authentication.login(credentials, request, response, validityMillis);
}
- public void logout(HttpServletRequest request, HttpServletResponse response)
+ public void login(HttpServletRequest request, HttpServletResponse response,
Credentials credentials, long validityMillis, String initialURI) throws IOException
{
- GenericAuthentication.getInstance().logout(request, response);
+ authentication.login(credentials, request, response, validityMillis, initialURI);
}
+
+ public void logout(HttpServletRequest request, HttpServletResponse response) throws
ServletException
+ {
+ authentication.logout(request, response);
+ }
+
+ public String getContainerInfo()
+ {
+ return "Generic";
+ }
+
//
public void contextInitialized(ServletContextEvent servletContextEvent)
Added: components/wci/trunk/wci/src/main/java/org/gatein/wci/security/WCIController.java
===================================================================
--- components/wci/trunk/wci/src/main/java/org/gatein/wci/security/WCIController.java
(rev 0)
+++
components/wci/trunk/wci/src/main/java/org/gatein/wci/security/WCIController.java 2011-02-22
11:10:24 UTC (rev 5918)
@@ -0,0 +1,67 @@
+/*
+* Copyright (C) 2003-2009 eXo Platform SAS.
+*
+* 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.wci.security;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:alain.defrance@exoplatform.com">Alain
Defrance</a>
+ * @version $Revision$
+ */
+public abstract class WCIController
+{
+ public void sendAuth(HttpServletRequest req, HttpServletResponse resp, String
jUsername, String jPassword) throws IOException
+ {
+ resp.sendRedirect(getAuthURI(req, resp, jUsername, jPassword));
+ }
+
+ public String getInitialURI(HttpServletRequest req)
+ {
+ String initialURI = req.getParameter("initialURI");
+ if (initialURI == null)
+ {
+ initialURI =
(String)req.getAttribute("javax.servlet.forward.request_uri");
+ }
+ if (initialURI == null)
+ {
+ initialURI = getHomeURI(req);
+ }
+ return initialURI;
+ }
+
+ public String getAuthURI(HttpServletRequest req, HttpServletResponse resp, String
jUsername, String jPassword)
+ {
+ String initialURI = getInitialURI(req);
+ if (!initialURI.endsWith("/"))
+ {
+ initialURI += "/";
+ }
+ String url = initialURI + "j_security_check?j_username=" + jUsername +
"&j_password=" + jPassword;
+ return resp.encodeRedirectURL(url);
+ }
+
+ abstract public void showLoginForm(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException;
+ abstract public void showErrorLoginForm(HttpServletRequest req, HttpServletResponse
resp) throws ServletException, IOException;
+ abstract public Credentials getCredentials (HttpServletRequest req,
HttpServletResponse resp);
+ abstract public String getHomeURI(HttpServletRequest req);
+}
Modified:
components/wci/trunk/wci/src/main/java/org/gatein/wci/spi/ServletContainerContext.java
===================================================================
---
components/wci/trunk/wci/src/main/java/org/gatein/wci/spi/ServletContainerContext.java 2011-02-21
06:34:14 UTC (rev 5917)
+++
components/wci/trunk/wci/src/main/java/org/gatein/wci/spi/ServletContainerContext.java 2011-02-22
11:10:24 UTC (rev 5918)
@@ -30,7 +30,7 @@
import javax.servlet.http.HttpServletResponse;
import org.gatein.wci.RequestDispatchCallback;
-import org.gatein.wci.authentication.AuthenticationResult;
+import org.gatein.wci.security.Credentials;
/**
* Defines the service provider interface for a servlet container. It is an attempt to
abstract the non
@@ -80,19 +80,41 @@
*
* @param request the request valid in the current servlet context
* @param response the response valid in the current servlet context
- * @param userName the username which try to login
- * @param password the password of the username
+ * @param credentials the credentials which try to authenticate
+ * @param validityMillis the validity of the authentication
*/
- AuthenticationResult login(HttpServletRequest request, HttpServletResponse response,
String userName, String password, long validityMillis) throws ServletException;
+ void login(HttpServletRequest request, HttpServletResponse response, Credentials
credentials, long validityMillis) throws ServletException, IOException;
/**
* Authentication support.
*
* @param request the request valid in the current servlet context
* @param response the response valid in the current servlet context
+ * @param credentials the credentials which try to authenticate
+ * @param validityMillis the validity of the authentication
*/
+ void login(HttpServletRequest request, HttpServletResponse response, Credentials
credentials, long validityMillis, String initialURI) throws ServletException,
IOException;
+
+ /**
+ * 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) throws
ServletException;
+ /**
+ * Returns the name and version of the servlet container in which the
+ * context is running.
+ *
+ * <P>
+ * The form of the returned string is
<code>containername/versionnumber</code>.
+ *
+ *
+ * @return the string containing at least name and version number
+ */
+ public String getContainerInfo();
+
/**
* The callback interface that a servlet container context can obtain from its
registration against
* the <code>org.jboss.portal.web.ServletContainer</code> singleton.