1
|
package eu.dnetlib.openaire.usermanagement.utils;
|
2
|
|
3
|
import org.springframework.stereotype.Component;
|
4
|
|
5
|
@Component("AuthorizationService")
|
6
|
public class AuthorizationService {
|
7
|
|
8
|
public final String PORTAL_ADMIN = "PORTAL_ADMINISTRATOR";
|
9
|
|
10
|
private String mapType(String type) {
|
11
|
if(type.equals("organization")) {
|
12
|
type = "institution";
|
13
|
}
|
14
|
if(type.equals("ri")) {
|
15
|
type = "community";
|
16
|
}
|
17
|
return type;
|
18
|
}
|
19
|
|
20
|
/**
|
21
|
* Type = FUNDER | COMMUNITY | INSTITUTION | PROJECT
|
22
|
*
|
23
|
* */
|
24
|
public String curator(String type) {
|
25
|
return "CURATOR_" + mapType(type).toUpperCase();
|
26
|
}
|
27
|
|
28
|
/**
|
29
|
* Type = FUNDER | COMMUNITY | INSTITUTION | PROJECT
|
30
|
*
|
31
|
* Id = EE, EGI, etc
|
32
|
* */
|
33
|
public String manager(String type, String id) {
|
34
|
return mapType(type).toUpperCase() + "_" + id.toUpperCase() + "_MANAGER";
|
35
|
}
|
36
|
|
37
|
/**
|
38
|
* Type = FUNDER | COMMUNITY | INSTITUTION | PROJECT
|
39
|
*
|
40
|
* Id = EE, EGI, etc
|
41
|
* */
|
42
|
public String member(String type, String id) {
|
43
|
return mapType(type).toUpperCase() + "_" + id.toUpperCase();
|
44
|
}
|
45
|
|
46
|
public boolean isCommunity(String type) {
|
47
|
return mapType(type).equals("community");
|
48
|
}
|
49
|
}
|