1
2
3
4
5
6
7
8
9
10
11
12
13
14 package waffle.shiro;
15
16 import java.io.Serializable;
17 import java.util.Collections;
18 import java.util.HashSet;
19 import java.util.Set;
20
21 import waffle.windows.auth.IWindowsAccount;
22 import waffle.windows.auth.IWindowsIdentity;
23
24
25
26
27 public class WaffleFqnPrincipal implements Serializable {
28
29
30 private static final long serialVersionUID = 1;
31
32
33 private final String fqn;
34
35
36 private final Set<String> groupFqns = new HashSet<String>();
37
38
39
40
41
42
43
44 WaffleFqnPrincipal(final IWindowsIdentity identity) {
45 this.fqn = identity.getFqn();
46 for (final IWindowsAccount group : identity.getGroups()) {
47 this.groupFqns.add(group.getFqn());
48 }
49 }
50
51
52
53
54
55
56 public String getFqn() {
57 return this.fqn;
58 }
59
60
61
62
63
64
65 public Set<String> getGroupFqns() {
66 return Collections.unmodifiableSet(this.groupFqns);
67 }
68
69
70
71
72 @Override
73 public boolean equals(final Object obj) {
74 if (obj instanceof WaffleFqnPrincipal) {
75 return this.fqn.equals(((WaffleFqnPrincipal) obj).fqn);
76 }
77 return false;
78 }
79
80
81
82
83 @Override
84 public int hashCode() {
85 return this.fqn.hashCode();
86 }
87
88
89
90
91 @Override
92 public String toString() {
93 final StringBuilder stringBuilder = new StringBuilder();
94 stringBuilder.append("{");
95 stringBuilder.append(this.getClass().getSimpleName());
96 stringBuilder.append(":");
97 stringBuilder.append(this.fqn);
98 stringBuilder.append("}");
99 return stringBuilder.toString();
100 }
101 }