|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| package org.acegisecurity.ui.cas; |
|
17 |
| |
|
18 |
| import org.acegisecurity.AuthenticationException; |
|
19 |
| import org.acegisecurity.intercept.web.AuthenticationEntryPoint; |
|
20 |
| |
|
21 |
| import org.springframework.beans.factory.InitializingBean; |
|
22 |
| import org.springframework.util.Assert; |
|
23 |
| |
|
24 |
| import java.io.IOException; |
|
25 |
| |
|
26 |
| import java.net.URLEncoder; |
|
27 |
| |
|
28 |
| import javax.servlet.ServletException; |
|
29 |
| import javax.servlet.ServletRequest; |
|
30 |
| import javax.servlet.ServletResponse; |
|
31 |
| import javax.servlet.http.HttpServletResponse; |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
| |
|
37 |
| |
|
38 |
| |
|
39 |
| |
|
40 |
| |
|
41 |
| |
|
42 |
| |
|
43 |
| |
|
44 |
| |
|
45 |
| |
|
46 |
| |
|
47 |
| |
|
48 |
| |
|
49 |
| |
|
50 |
| |
|
51 |
| public class CasProcessingFilterEntryPoint implements AuthenticationEntryPoint, |
|
52 |
| InitializingBean { |
|
53 |
| |
|
54 |
| |
|
55 |
| private ServiceProperties serviceProperties; |
|
56 |
| private String loginUrl; |
|
57 |
| |
|
58 |
| |
|
59 |
| |
|
60 |
4
| public void setLoginUrl(String loginUrl) {
|
|
61 |
4
| this.loginUrl = loginUrl;
|
|
62 |
| } |
|
63 |
| |
|
64 |
| |
|
65 |
| |
|
66 |
| |
|
67 |
| |
|
68 |
| |
|
69 |
| |
|
70 |
1
| public String getLoginUrl() {
|
|
71 |
1
| return loginUrl;
|
|
72 |
| } |
|
73 |
| |
|
74 |
4
| public void setServiceProperties(ServiceProperties serviceProperties) {
|
|
75 |
4
| this.serviceProperties = serviceProperties;
|
|
76 |
| } |
|
77 |
| |
|
78 |
1
| public ServiceProperties getServiceProperties() {
|
|
79 |
1
| return serviceProperties;
|
|
80 |
| } |
|
81 |
| |
|
82 |
4
| public void afterPropertiesSet() throws Exception {
|
|
83 |
4
| Assert.hasLength(loginUrl, "loginUrl must be specified");
|
|
84 |
3
| Assert.notNull(serviceProperties, "serviceProperties must be specified");
|
|
85 |
| } |
|
86 |
| |
|
87 |
2
| public void commence(ServletRequest request, ServletResponse response,
|
|
88 |
| AuthenticationException authenticationException) |
|
89 |
| throws IOException, ServletException { |
|
90 |
2
| String url;
|
|
91 |
| |
|
92 |
2
| if (serviceProperties.isSendRenew()) {
|
|
93 |
1
| url = loginUrl + "?renew=true" + "&service="
|
|
94 |
| + serviceProperties.getService(); |
|
95 |
| } else { |
|
96 |
1
| url = loginUrl + "?service="
|
|
97 |
| + URLEncoder.encode(serviceProperties.getService(), "UTF-8"); |
|
98 |
| } |
|
99 |
| |
|
100 |
2
| ((HttpServletResponse) response).sendRedirect(url);
|
|
101 |
| } |
|
102 |
| } |