Revision 60300
Added by Konstantinos Triantafyllou about 3 years ago
AuthorizationService.java | ||
---|---|---|
19 | 19 |
public final String REGISTERED_USER = "REGISTERED_USER"; |
20 | 20 |
|
21 | 21 |
|
22 |
private String mapType(String type) { |
|
23 |
if(type.equals("organization")) { |
|
22 |
private String mapType(String type, boolean communityMap) {
|
|
23 |
if (type.equals("organization")) {
|
|
24 | 24 |
type = "institution"; |
25 |
} |
|
26 |
if(type.equals("ri")) { |
|
25 |
} else if (type.equals("ri") && communityMap) { |
|
27 | 26 |
type = "community"; |
28 | 27 |
} |
29 | 28 |
return type; |
... | ... | |
31 | 30 |
|
32 | 31 |
/** |
33 | 32 |
* Type = FUNDER | COMMUNITY | INSTITUTION | PROJECT |
34 |
* |
|
35 |
* */ |
|
33 |
*/ |
|
36 | 34 |
public String curator(String type) { |
37 |
return "CURATOR_"+mapType(type).toUpperCase();
|
|
35 |
return "CURATOR_" + mapType(type, true).toUpperCase();
|
|
38 | 36 |
} |
39 | 37 |
|
40 | 38 |
/** |
41 | 39 |
* Type = FUNDER | COMMUNITY | INSTITUTION | PROJECT |
42 |
* |
|
40 |
* <p>
|
|
43 | 41 |
* Id = EE, EGI, etc |
44 |
* */
|
|
42 |
*/ |
|
45 | 43 |
public String manager(String type, String id) { |
46 |
return mapType(type).toUpperCase() + "_" + id.toUpperCase() + "_MANAGER"; |
|
44 |
return mapType(type, true).toUpperCase() + "_" + id.toUpperCase() + "_MANAGER";
|
|
47 | 45 |
} |
48 | 46 |
|
49 | 47 |
/** |
50 |
* Type = FUNDER | COMMUNITY | INSTITUTION | PROJECT |
|
51 |
* |
|
48 |
* Type = FUNDER | COMMUNITY | RI | INSTITUTION | PROJECT
|
|
49 |
* <p>
|
|
52 | 50 |
* Id = EE, EGI, etc |
53 |
* */
|
|
51 |
*/ |
|
54 | 52 |
public String member(String type, String id) { |
55 |
return mapType(type).toUpperCase() + "_" + id.toUpperCase(); |
|
53 |
return mapType(type, false).toUpperCase() + "_" + id.toUpperCase();
|
|
56 | 54 |
} |
57 | 55 |
|
58 | 56 |
public List<String> getRoles() { |
59 | 57 |
Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); |
60 |
if(authentication != null) { |
|
58 |
if (authentication != null) {
|
|
61 | 59 |
List<GrantedAuthority> authorities = (List<GrantedAuthority>) authentication.getAuthorities(); |
62 |
if(authorities != null) { |
|
60 |
if (authorities != null) {
|
|
63 | 61 |
List<String> roles = new ArrayList<>(); |
64 | 62 |
authorities.forEach((authority) -> { |
65 | 63 |
roles.add(authority.getAuthority()); |
... | ... | |
72 | 70 |
|
73 | 71 |
public String getAaiId() { |
74 | 72 |
Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); |
75 |
if(authentication != null) { |
|
73 |
if (authentication != null) {
|
|
76 | 74 |
User user = (User) authentication.getPrincipal(); |
77 | 75 |
return user.getPassword(); |
78 | 76 |
} |
Also available in: Unified diff
[Authorization-Library | Trunk]: Authorization Service add boolean communityMap on mapType