| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
package org.acegisecurity.providers.cas; |
| 17 |
|
|
| 18 |
|
import org.acegisecurity.GrantedAuthority; |
| 19 |
|
|
| 20 |
|
import org.acegisecurity.providers.AbstractAuthenticationToken; |
| 21 |
|
|
| 22 |
|
import org.acegisecurity.userdetails.UserDetails; |
| 23 |
|
|
| 24 |
|
import java.io.Serializable; |
| 25 |
|
|
| 26 |
|
import java.util.List; |
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
public class CasAuthenticationToken extends AbstractAuthenticationToken implements Serializable { |
| 36 |
|
|
| 37 |
|
|
| 38 |
|
private static final long serialVersionUID = 1L; |
| 39 |
|
private final List proxyList; |
| 40 |
|
private final Object credentials; |
| 41 |
|
private final Object principal; |
| 42 |
|
private final String proxyGrantingTicketIou; |
| 43 |
|
private final UserDetails userDetails; |
| 44 |
|
private final int keyHash; |
| 45 |
|
|
| 46 |
|
|
| 47 |
|
|
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| 54 |
|
|
| 55 |
|
|
| 56 |
|
|
| 57 |
|
|
| 58 |
|
|
| 59 |
|
|
| 60 |
|
|
| 61 |
|
|
| 62 |
|
|
| 63 |
|
|
| 64 |
|
|
| 65 |
|
|
| 66 |
|
|
| 67 |
|
|
| 68 |
|
public CasAuthenticationToken(final String key, final Object principal, final Object credentials, |
| 69 |
|
final GrantedAuthority[] authorities, final UserDetails userDetails, final List proxyList, |
| 70 |
|
final String proxyGrantingTicketIou) { |
| 71 |
29 |
super(authorities); |
| 72 |
|
|
| 73 |
28 |
if ((key == null) || ("".equals(key)) || (principal == null) || "".equals(principal) || (credentials == null) |
| 74 |
|
|| "".equals(credentials) || (authorities == null) || (userDetails == null) || (proxyList == null) |
| 75 |
|
|| (proxyGrantingTicketIou == null)) { |
| 76 |
7 |
throw new IllegalArgumentException("Cannot pass null or empty values to constructor"); |
| 77 |
|
} |
| 78 |
|
|
| 79 |
21 |
this.keyHash = key.hashCode(); |
| 80 |
21 |
this.principal = principal; |
| 81 |
21 |
this.credentials = credentials; |
| 82 |
21 |
this.userDetails = userDetails; |
| 83 |
21 |
this.proxyList = proxyList; |
| 84 |
21 |
this.proxyGrantingTicketIou = proxyGrantingTicketIou; |
| 85 |
21 |
setAuthenticated(true); |
| 86 |
21 |
} |
| 87 |
|
|
| 88 |
|
|
| 89 |
|
|
| 90 |
|
public boolean equals(final Object obj) { |
| 91 |
8 |
if (!super.equals(obj)) { |
| 92 |
2 |
return false; |
| 93 |
|
} |
| 94 |
|
|
| 95 |
6 |
if (obj instanceof CasAuthenticationToken) { |
| 96 |
6 |
CasAuthenticationToken test = (CasAuthenticationToken) obj; |
| 97 |
|
|
| 98 |
|
|
| 99 |
6 |
if (!this.getProxyGrantingTicketIou().equals(test.getProxyGrantingTicketIou())) { |
| 100 |
1 |
return false; |
| 101 |
|
} |
| 102 |
|
|
| 103 |
|
|
| 104 |
5 |
if (!this.getProxyList().equals(test.getProxyList())) { |
| 105 |
1 |
return false; |
| 106 |
|
} |
| 107 |
|
|
| 108 |
4 |
if (this.getKeyHash() != test.getKeyHash()) { |
| 109 |
1 |
return false; |
| 110 |
|
} |
| 111 |
|
|
| 112 |
3 |
return true; |
| 113 |
|
} |
| 114 |
|
|
| 115 |
0 |
return false; |
| 116 |
|
} |
| 117 |
|
|
| 118 |
|
public Object getCredentials() { |
| 119 |
23 |
return this.credentials; |
| 120 |
|
} |
| 121 |
|
|
| 122 |
|
public int getKeyHash() { |
| 123 |
12 |
return this.keyHash; |
| 124 |
|
} |
| 125 |
|
|
| 126 |
|
public Object getPrincipal() { |
| 127 |
22 |
return this.principal; |
| 128 |
|
} |
| 129 |
|
|
| 130 |
|
|
| 131 |
|
|
| 132 |
|
|
| 133 |
|
|
| 134 |
|
|
| 135 |
|
|
| 136 |
|
public String getProxyGrantingTicketIou() { |
| 137 |
14 |
return proxyGrantingTicketIou; |
| 138 |
|
} |
| 139 |
|
|
| 140 |
|
public List getProxyList() { |
| 141 |
12 |
return proxyList; |
| 142 |
|
} |
| 143 |
|
|
| 144 |
|
public UserDetails getUserDetails() { |
| 145 |
1 |
return userDetails; |
| 146 |
|
} |
| 147 |
|
|
| 148 |
|
public String toString() { |
| 149 |
1 |
StringBuffer sb = new StringBuffer(); |
| 150 |
1 |
sb.append(super.toString()); |
| 151 |
1 |
sb.append("; Credentials (Service/Proxy Ticket): ").append(this.credentials); |
| 152 |
1 |
sb.append("; Proxy-Granting Ticket IOU: ").append(this.proxyGrantingTicketIou); |
| 153 |
1 |
sb.append("; Proxy List: ").append(this.proxyList); |
| 154 |
|
|
| 155 |
1 |
return (sb.toString()); |
| 156 |
|
} |
| 157 |
|
} |