[jboss-cvs] jboss-seam/src/main/org/jboss/seam/security/filter ...
Shane Bryzak
Shane_Bryzak at symantec.com
Tue Aug 1 01:03:34 EDT 2006
User: sbryzak2
Date: 06/08/01 01:03:34
Modified: src/main/org/jboss/seam/security/filter
SeamSecurityFilter.java
Log:
initial logout() support
Revision Changes Path
1.4 +29 -14 jboss-seam/src/main/org/jboss/seam/security/filter/SeamSecurityFilter.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: SeamSecurityFilter.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/security/filter/SeamSecurityFilter.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- SeamSecurityFilter.java 1 Aug 2006 02:04:54 -0000 1.3
+++ SeamSecurityFilter.java 1 Aug 2006 05:03:34 -0000 1.4
@@ -38,12 +38,25 @@
// private static final String CONFIG_RESOURCE = "/WEB-INF/seam-security.xml";
+ private AuthenticationContext authContext;
+ private Authenticator authenticator;
+
public void init(FilterConfig config)
throws ServletException
{
servletContext = config.getServletContext();
- SecurityConfig.instance().setApplicationContext( new WebApplicationContext(servletContext));
+ Context appContext = new WebApplicationContext(servletContext);
+ SecurityConfig.instance().setApplicationContext(appContext);
+
+ authContext = ((AuthenticationContext) appContext.get(
+ "org.jboss.seam.security.AuthenticationContext"));
+
+ authenticator = (Authenticator) appContext.get(
+ "org.jboss.seam.security.Authenticator");
+
+ if (authenticator == null)
+ throw new ServletException("No Authenticator configured.");
// try
// {
@@ -77,29 +90,26 @@
HttpServletRequest hRequest = (HttpServletRequest) request;
HttpServletResponse hResponse = (HttpServletResponse) response;
- Authentication authentication = (Authentication)new WebSessionContext(
- ContextAdaptor.getSession(hRequest.getSession())).get(
+ Context sessionContext = new WebSessionContext(
+ ContextAdaptor.getSession(hRequest.getSession()));
+
+ Authentication authentication = (Authentication)sessionContext.get(
"org.jboss.seam.security.Authentication");
+
if (authentication != null)
{
- Context appContext = new WebApplicationContext(servletContext);
-
- Authenticator authenticator = (Authenticator) appContext.get(
- "org.jboss.seam.security.Authenticator");
- if (authenticator == null)
- throw new ServletException("No Authenticator configured.");
-
try
{
- ((AuthenticationContext) appContext.get("org.jboss.seam.security.AuthenticationContext"))
- .setAuthentication(authenticator.authenticate(authentication));
+ authContext.setAuthentication(authenticator.authenticate(authentication));
}
catch (AuthenticationException ex)
{
- throw new ServletException("Authentication Failed", ex);
+ authContext.setAuthentication(null);
}
}
+ else
+ authContext.setAuthentication(null);
try
{
@@ -126,9 +136,14 @@
cause = cause.getCause();
}
}
-
throw new ServletException(e);
}
+ finally
+ {
+ if (authentication != null)
+ authenticator.unauthenticate(authentication);
+ authContext.setAuthentication(null);
+ }
}
public void destroy()
More information about the jboss-cvs-commits
mailing list