[Authorization-Library | Trunk]: Authorization Service add boolean communityMap on mapType

master
parent cc70806ad2
commit 89e87dea27

@ -19,11 +19,10 @@ public class AuthorizationService {
public final String REGISTERED_USER = "REGISTERED_USER";
private String mapType(String type) {
if(type.equals("organization")) {
private String mapType(String type, boolean communityMap) {
if (type.equals("organization")) {
type = "institution";
}
if(type.equals("ri")) {
} else if (type.equals("ri") && communityMap) {
type = "community";
}
return type;
@ -31,35 +30,34 @@ public class AuthorizationService {
/**
* Type = FUNDER | COMMUNITY | INSTITUTION | PROJECT
*
* */
*/
public String curator(String type) {
return "CURATOR_"+mapType(type).toUpperCase();
return "CURATOR_" + mapType(type, true).toUpperCase();
}
/**
* Type = FUNDER | COMMUNITY | INSTITUTION | PROJECT
*
* <p>
* Id = EE, EGI, etc
* */
*/
public String manager(String type, String id) {
return mapType(type).toUpperCase() + "_" + id.toUpperCase() + "_MANAGER";
return mapType(type, true).toUpperCase() + "_" + id.toUpperCase() + "_MANAGER";
}
/**
* Type = FUNDER | COMMUNITY | INSTITUTION | PROJECT
*
* Type = FUNDER | COMMUNITY | RI | INSTITUTION | PROJECT
* <p>
* Id = EE, EGI, etc
* */
*/
public String member(String type, String id) {
return mapType(type).toUpperCase() + "_" + id.toUpperCase();
return mapType(type, false).toUpperCase() + "_" + id.toUpperCase();
}
public List<String> getRoles() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if(authentication != null) {
if (authentication != null) {
List<GrantedAuthority> authorities = (List<GrantedAuthority>) authentication.getAuthorities();
if(authorities != null) {
if (authorities != null) {
List<String> roles = new ArrayList<>();
authorities.forEach((authority) -> {
roles.add(authority.getAuthority());
@ -72,7 +70,7 @@ public class AuthorizationService {
public String getAaiId() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if(authentication != null) {
if (authentication != null) {
User user = (User) authentication.getPrincipal();
return user.getPassword();
}

Loading…
Cancel
Save