package eu.dnetlib.uoaauthorizationlibrary.security; import org.apache.log4j.Logger; import org.springframework.security.core.Authentication; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.User; import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.List; @Component(value = "AuthorizationService") public class AuthorizationService { private final Logger log = Logger.getLogger(this.getClass()); 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 List