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