KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > blandware > atleap > webapp > acegi > CustomAuthenticationProcessingFilter


1 /*
2  * Copyright 2004 Blandware (http://www.blandware.com)
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package com.blandware.atleap.webapp.acegi;
17
18 import org.acegisecurity.Authentication;
19 import org.acegisecurity.ui.webapp.AuthenticationProcessingFilter;
20
21 import javax.servlet.http.HttpServletRequest JavaDoc;
22 import javax.servlet.http.HttpServletResponse JavaDoc;
23 import javax.servlet.http.HttpSession JavaDoc;
24 import java.io.IOException JavaDoc;
25
26 /**
27  * <p>This class provides abilities to redirect into url from saved request</p>
28  * <p><a HREF="CustomAuthenticationProcessingFilter.java.htm"><i>View Source</i></a></p>
29  *
30  * @author Andrey Grebnev <a HREF="mailto:andrey.grebnev@blandware.com">&lt;andrey.grebnev@blandware.com&gt;</a>
31  * @version $Revision: 1.4 $ $Date: 2006/03/09 16:46:03 $
32  * @web.filter name="authenticationProcessingFilter"
33  */

34 public class CustomAuthenticationProcessingFilter extends AuthenticationProcessingFilter {
35
36     /**
37      * Overridden method in order to set target url
38      *
39      * @param request Request
40      * @param response Response
41      * @param authResult Authentication result
42      * @throws IOException
43      */

44     protected void successfulAuthentication(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response, Authentication authResult) throws IOException JavaDoc {
45         HttpSession JavaDoc session = request.getSession(false);
46         if (session != null) {
47             SavedRequest savedRequest = (SavedRequest)session.getAttribute(CustomExceptionTranslationFilter.SAVED_REQUEST_SESSION_ATTRIBUTE);
48             if (savedRequest != null) {
49                 session.setAttribute(ACEGI_SECURITY_TARGET_URL_KEY, savedRequest.getRequestURL());
50             }
51         }
52         super.successfulAuthentication(request, response, authResult);
53     }
54 }
55
Popular Tags