|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| package org.acegisecurity.providers.cas.ticketvalidator; |
|
17 |
| |
|
18 |
| import edu.yale.its.tp.cas.client.ProxyTicketValidator; |
|
19 |
| |
|
20 |
| import org.acegisecurity.AuthenticationException; |
|
21 |
| import org.acegisecurity.AuthenticationServiceException; |
|
22 |
| import org.acegisecurity.BadCredentialsException; |
|
23 |
| import org.acegisecurity.providers.cas.TicketResponse; |
|
24 |
| |
|
25 |
| import org.apache.commons.logging.Log; |
|
26 |
| import org.apache.commons.logging.LogFactory; |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| public class CasProxyTicketValidator extends AbstractTicketValidator { |
|
36 |
| |
|
37 |
| |
|
38 |
| private static final Log logger = LogFactory.getLog(CasProxyTicketValidator.class); |
|
39 |
| |
|
40 |
| |
|
41 |
| |
|
42 |
| private String proxyCallbackUrl; |
|
43 |
| |
|
44 |
| |
|
45 |
| |
|
46 |
3
| public void setProxyCallbackUrl(String proxyCallbackUrl) {
|
|
47 |
3
| this.proxyCallbackUrl = proxyCallbackUrl;
|
|
48 |
| } |
|
49 |
| |
|
50 |
| |
|
51 |
| |
|
52 |
| |
|
53 |
| |
|
54 |
| |
|
55 |
| |
|
56 |
| |
|
57 |
| |
|
58 |
| |
|
59 |
| |
|
60 |
| |
|
61 |
| |
|
62 |
| |
|
63 |
| |
|
64 |
| |
|
65 |
| |
|
66 |
| |
|
67 |
| |
|
68 |
| |
|
69 |
| |
|
70 |
| |
|
71 |
| |
|
72 |
| |
|
73 |
1
| public String getProxyCallbackUrl() {
|
|
74 |
1
| return proxyCallbackUrl;
|
|
75 |
| } |
|
76 |
| |
|
77 |
3
| public TicketResponse confirmTicketValid(String serviceTicket)
|
|
78 |
| throws AuthenticationException { |
|
79 |
| |
|
80 |
3
| ProxyTicketValidator pv = new ProxyTicketValidator();
|
|
81 |
| |
|
82 |
3
| pv.setCasValidateUrl(super.getCasValidate());
|
|
83 |
3
| pv.setServiceTicket(serviceTicket);
|
|
84 |
3
| pv.setService(super.getServiceProperties().getService());
|
|
85 |
| |
|
86 |
3
| if (super.getServiceProperties().isSendRenew()) {
|
|
87 |
1
| logger.warn(
|
|
88 |
| "The current CAS ProxyTicketValidator does not support the 'renew' property. The ticket cannot be validated as having been issued by a 'renew' authentication. It is expected this will be corrected in a future version of CAS' ProxyTicketValidator."); |
|
89 |
| } |
|
90 |
| |
|
91 |
3
| if ((this.proxyCallbackUrl != null)
|
|
92 |
| && (!"".equals(this.proxyCallbackUrl))) { |
|
93 |
2
| pv.setProxyCallbackUrl(proxyCallbackUrl);
|
|
94 |
| } |
|
95 |
| |
|
96 |
3
| return validateNow(pv);
|
|
97 |
| } |
|
98 |
| |
|
99 |
| |
|
100 |
| |
|
101 |
| |
|
102 |
| |
|
103 |
| |
|
104 |
| |
|
105 |
| |
|
106 |
| |
|
107 |
| |
|
108 |
| |
|
109 |
| |
|
110 |
| |
|
111 |
0
| protected TicketResponse validateNow(ProxyTicketValidator pv)
|
|
112 |
| throws AuthenticationServiceException, BadCredentialsException { |
|
113 |
0
| try {
|
|
114 |
0
| pv.validate();
|
|
115 |
| } catch (Exception internalProxyTicketValidatorProblem) { |
|
116 |
0
| throw new AuthenticationServiceException(internalProxyTicketValidatorProblem
|
|
117 |
| .getMessage()); |
|
118 |
| } |
|
119 |
| |
|
120 |
0
| if (!pv.isAuthenticationSuccesful()) {
|
|
121 |
0
| throw new BadCredentialsException(pv.getErrorCode() + ": "
|
|
122 |
| + pv.getErrorMessage()); |
|
123 |
| } |
|
124 |
| |
|
125 |
0
| return new TicketResponse(pv.getUser(), pv.getProxyList(),
|
|
126 |
| pv.getPgtIou()); |
|
127 |
| } |
|
128 |
| } |