dnet-openaire-users/src/main/java/eu/dnetlib/openaire/usermanagement/utils/AuthorizationService.java

51 lines
1.4 KiB
Java

package eu.dnetlib.openaire.usermanagement.utils;
import org.springframework.stereotype.Component;
@Component("AuthorizationService")
public class AuthorizationService {
public final String PORTAL_ADMIN = "PORTAL_ADMINISTRATOR";
public final String ANONYMOUS_USER = "ROLE_ANONYMOUS";
public final String REGISTERED_USER = "REGISTERED_USER";
private String mapType(String type, boolean communityMap) {
if(type.equals("organization")) {
type = "institution";
} else if(type.equals("ri") && communityMap) {
type = "community";
}
return type;
}
/**
* Type = FUNDER | COMMUNITY | INSTITUTION | PROJECT
*
* */
public String curator(String type) {
return "CURATOR_" + mapType(type, true).toUpperCase();
}
/**
* Type = FUNDER | COMMUNITY | INSTITUTION | PROJECT
*
* Id = EE, EGI, etc
* */
public String manager(String type, String id) {
return mapType(type, true).toUpperCase() + "_" + id.toUpperCase() + "_MANAGER";
}
/**
* Type = FUNDER | COMMUNITY | RI | INSTITUTION | PROJECT
*
* Id = EE, EGI, etc
* */
public String member(String type, String id) {
return mapType(type, false).toUpperCase() + "_" + id.toUpperCase();
}
public boolean isCommunity(String type) {
return mapType(type, false).equals("community");
}
}