Project

General

Profile

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
    public final String ANONYMOUS_USER = "ROLE_ANONYMOUS";
10
    public final String REGISTERED_USER = "REGISTERED_USER";
11

    
12
    private String mapType(String type, boolean communityMap) {
13
        if(type.equals("organization")) {
14
            type = "institution";
15
        } else if(type.equals("ri") && communityMap) {
16
            type = "community";
17
        }
18
        return type;
19
    }
20

    
21
    /**
22
     * Type = FUNDER | COMMUNITY | INSTITUTION | PROJECT
23
     *
24
     * */
25
    public String curator(String type) {
26
        return "CURATOR_" + mapType(type, true).toUpperCase();
27
    }
28

    
29
    /**
30
     * Type = FUNDER | COMMUNITY | INSTITUTION | PROJECT
31
     *
32
     * Id = EE, EGI, etc
33
     * */
34
    public String manager(String type, String id) {
35
        return mapType(type, true).toUpperCase() + "_" + id.toUpperCase() + "_MANAGER";
36
    }
37

    
38
    /**
39
     * Type = FUNDER | COMMUNITY | RI | INSTITUTION | PROJECT
40
     *
41
     * Id = EE, EGI, etc
42
     * */
43
    public String member(String type, String id) {
44
        return mapType(type, false).toUpperCase() + "_" + id.toUpperCase();
45
    }
46

    
47
    public boolean isCommunity(String type) {
48
        return mapType(type, false).equals("community");
49
    }
50
}
(2-2/9)