1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.rice.ksb.security.credentials;
18
19 import java.io.IOException;
20
21 import org.acegisecurity.context.SecurityContextHolder;
22 import org.acegisecurity.providers.cas.CasAuthenticationToken;
23 import org.acegisecurity.ui.cas.CasProcessingFilter;
24 import org.kuali.rice.core.security.credentials.Credentials;
25 import org.kuali.rice.core.security.credentials.CredentialsSource;
26
27 import edu.yale.its.tp.cas.proxy.ProxyTicketReceptor;
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44 public final class CasProxyTicketCredentialsSource implements CredentialsSource {
45
46 public Credentials getCredentials(final String serviceEndpoint) {
47 final String proxyGrantingTicketIou = ((CasAuthenticationToken) (SecurityContextHolder
48 .getContext()).getAuthentication()).getProxyGrantingTicketIou();
49 try {
50 final String proxyTicket = ProxyTicketReceptor.getProxyTicket(
51 proxyGrantingTicketIou, serviceEndpoint);
52 return new UsernamePasswordCredentials(
53 CasProcessingFilter.CAS_STATELESS_IDENTIFIER, proxyTicket);
54 } catch (final IOException e) {
55 return null;
56 }
57 }
58
59 public CredentialsType getSupportedCredentialsType() {
60 return CredentialsType.CAS;
61 }
62 }