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