|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| package org.acegisecurity.context; |
|
16 |
| |
|
17 |
| import org.acegisecurity.Authentication; |
|
18 |
| |
|
19 |
| |
|
20 |
| |
|
21 |
| |
|
22 |
| |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| public class SecurityContextImpl implements SecurityContext { |
|
31 |
| private Authentication authentication; |
|
32 |
| |
|
33 |
187
| public void setAuthentication(Authentication authentication) {
|
|
34 |
187
| this.authentication = authentication;
|
|
35 |
| } |
|
36 |
| |
|
37 |
207
| public Authentication getAuthentication() {
|
|
38 |
207
| return authentication;
|
|
39 |
| } |
|
40 |
| |
|
41 |
6
| public boolean equals(Object obj) {
|
|
42 |
6
| if (obj instanceof SecurityContextImpl) {
|
|
43 |
6
| SecurityContextImpl test = (SecurityContextImpl) obj;
|
|
44 |
| |
|
45 |
6
| if ((this.getAuthentication() == null) &&
|
|
46 |
| (test.getAuthentication() == null)) { |
|
47 |
5
| return true;
|
|
48 |
| } |
|
49 |
| |
|
50 |
1
| if ((this.getAuthentication() != null) &&
|
|
51 |
| (test.getAuthentication() != null) && |
|
52 |
| this.getAuthentication().equals(test.getAuthentication())) { |
|
53 |
0
| return true;
|
|
54 |
| } |
|
55 |
| } |
|
56 |
| |
|
57 |
1
| return false;
|
|
58 |
| } |
|
59 |
| |
|
60 |
2
| public String toString() {
|
|
61 |
2
| StringBuffer sb = new StringBuffer();
|
|
62 |
2
| sb.append(super.toString());
|
|
63 |
| |
|
64 |
2
| if (this.authentication == null) {
|
|
65 |
0
| sb.append(": Null authentication");
|
|
66 |
| } else { |
|
67 |
2
| sb.append(": Authentication: " + this.authentication);
|
|
68 |
| } |
|
69 |
| |
|
70 |
2
| return sb.toString();
|
|
71 |
| } |
|
72 |
| |
|
73 |
11
| public int hashCode() {
|
|
74 |
11
| if (this.authentication == null) {
|
|
75 |
3
| return -1;
|
|
76 |
| } else { |
|
77 |
8
| return this.authentication.hashCode();
|
|
78 |
| } |
|
79 |
| } |
|
80 |
| } |