1
2
3
4
5
6
7
8
9
10
11
12
13
14 package waffle.spring;
15
16 import org.springframework.security.core.GrantedAuthority;
17 import org.springframework.security.core.authority.SimpleGrantedAuthority;
18
19 import waffle.windows.auth.WindowsAccount;
20
21
22
23
24
25
26
27
28
29
30 public class FqnGrantedAuthorityFactory implements GrantedAuthorityFactory {
31
32
33 private final String prefix;
34
35
36 private final boolean convertToUpperCase;
37
38
39
40
41
42
43
44
45
46 public FqnGrantedAuthorityFactory(final String newPrefix, final boolean newConvertToUpperCase) {
47 this.prefix = newPrefix;
48 this.convertToUpperCase = newConvertToUpperCase;
49 }
50
51
52
53
54 @Override
55 public GrantedAuthority createGrantedAuthority(final WindowsAccount windowsAccount) {
56
57 String grantedAuthorityString = windowsAccount.getFqn();
58
59 if (this.prefix != null) {
60 grantedAuthorityString = this.prefix + grantedAuthorityString;
61 }
62
63 if (this.convertToUpperCase) {
64 grantedAuthorityString = grantedAuthorityString.toUpperCase();
65 }
66
67 return new SimpleGrantedAuthority(grantedAuthorityString);
68 }
69 }