|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| package org.acegisecurity.runas; |
|
17 |
| |
|
18 |
| import org.acegisecurity.GrantedAuthority; |
|
19 |
| import org.acegisecurity.providers.AbstractAuthenticationToken; |
|
20 |
| |
|
21 |
| |
|
22 |
| |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| public class RunAsUserToken extends AbstractAuthenticationToken { |
|
30 |
| |
|
31 |
| |
|
32 |
| private Class originalAuthentication; |
|
33 |
| private Object credentials; |
|
34 |
| private Object principal; |
|
35 |
| private GrantedAuthority[] authorities; |
|
36 |
| private int keyHash; |
|
37 |
| private boolean authenticated; |
|
38 |
| |
|
39 |
| |
|
40 |
| |
|
41 |
7
| public RunAsUserToken(String key, Object principal, Object credentials,
|
|
42 |
| GrantedAuthority[] authorities, Class originalAuthentication) { |
|
43 |
7
| super();
|
|
44 |
7
| this.keyHash = key.hashCode();
|
|
45 |
7
| this.authorities = authorities;
|
|
46 |
7
| this.principal = principal;
|
|
47 |
7
| this.credentials = credentials;
|
|
48 |
7
| this.originalAuthentication = originalAuthentication;
|
|
49 |
7
| this.authenticated = true;
|
|
50 |
| } |
|
51 |
| |
|
52 |
1
| protected RunAsUserToken() {
|
|
53 |
1
| throw new IllegalArgumentException("Cannot use default constructor");
|
|
54 |
| } |
|
55 |
| |
|
56 |
| |
|
57 |
| |
|
58 |
1
| public void setAuthenticated(boolean isAuthenticated) {
|
|
59 |
1
| this.authenticated = isAuthenticated;
|
|
60 |
| } |
|
61 |
| |
|
62 |
3
| public boolean isAuthenticated() {
|
|
63 |
3
| return this.authenticated;
|
|
64 |
| } |
|
65 |
| |
|
66 |
12
| public GrantedAuthority[] getAuthorities() {
|
|
67 |
12
| return this.authorities;
|
|
68 |
| } |
|
69 |
| |
|
70 |
3
| public Object getCredentials() {
|
|
71 |
3
| return this.credentials;
|
|
72 |
| } |
|
73 |
| |
|
74 |
6
| public int getKeyHash() {
|
|
75 |
6
| return this.keyHash;
|
|
76 |
| } |
|
77 |
| |
|
78 |
1
| public Class getOriginalAuthentication() {
|
|
79 |
1
| return this.originalAuthentication;
|
|
80 |
| } |
|
81 |
| |
|
82 |
4
| public Object getPrincipal() {
|
|
83 |
4
| return this.principal;
|
|
84 |
| } |
|
85 |
| |
|
86 |
1
| public String toString() {
|
|
87 |
1
| StringBuffer sb = new StringBuffer(super.toString());
|
|
88 |
1
| sb.append("; Original Class: " + this.originalAuthentication.getName());
|
|
89 |
| |
|
90 |
1
| return sb.toString();
|
|
91 |
| } |
|
92 |
| } |