01: /* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
02: *
03: * Licensed under the Apache License, Version 2.0 (the "License");
04: * you may not use this file except in compliance with the License.
05: * You may obtain a copy of the License at
06: *
07: * http://www.apache.org/licenses/LICENSE-2.0
08: *
09: * Unless required by applicable law or agreed to in writing, software
10: * distributed under the License is distributed on an "AS IS" BASIS,
11: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: * See the License for the specific language governing permissions and
13: * limitations under the License.
14: */
15:
16: package org.acegisecurity;
17:
18: import java.io.IOException;
19:
20: import javax.servlet.ServletException;
21: import javax.servlet.ServletRequest;
22: import javax.servlet.ServletResponse;
23: import javax.servlet.http.HttpServletRequest;
24: import javax.servlet.http.HttpServletResponse;
25:
26: import org.acegisecurity.ui.AuthenticationEntryPoint;
27: import org.springframework.core.Ordered;
28:
29: /**
30: * Performs a HTTP redirect to the constructor-indicated URL.
31: *
32: * @author Ben Alex
33: * @version $Id: MockAuthenticationEntryPoint.java 1823 2007-05-17 12:21:02Z vishalpuri $
34: */
35: public class MockAuthenticationEntryPoint implements
36: AuthenticationEntryPoint, Ordered {
37: //~ Instance fields ================================================================================================
38:
39: private String url;
40: private int order = Integer.MAX_VALUE; // ~ default
41:
42: //~ Constructors ===================================================================================================
43:
44: public int getOrder() {
45: return order;
46: }
47:
48: public void setOrder(int order) {
49: this .order = order;
50: }
51:
52: public MockAuthenticationEntryPoint(String url) {
53: this .url = url;
54: }
55:
56: private MockAuthenticationEntryPoint() {
57: super ();
58: }
59:
60: //~ Methods ========================================================================================================
61:
62: public void commence(ServletRequest request,
63: ServletResponse response,
64: AuthenticationException authenticationException)
65: throws IOException, ServletException {
66: ((HttpServletResponse) response)
67: .sendRedirect(((HttpServletRequest) request)
68: .getContextPath()
69: + url);
70: }
71: }
|