/** * Helper class that will return all role names as a string array. * * @return Never null */ public static String[] getAllRolesAsStringArray() { return Arrays.stream(CoreSecurityRoles.values()).map(CoreSecurityRoles::getKey) .toArray(size -> new String[size]); }
public static CoreSecurityRoles fromKey(String role) { Assert.hasText(role, "Parameter role must not be null or empty."); for (CoreSecurityRoles roleType : CoreSecurityRoles.values()) { if (roleType.getKey().equals(role)) { return roleType; } } return null; }
/** * The returned {@link List} of {@link GrantedAuthority}s contains all roles from * {@link CoreSecurityRoles}. The roles are prefixed with the value specified in * {@link GrantedAuthorityDefaults}. * * * @param map Must not be null. Is only used for logging */ @Override public List<GrantedAuthority> extractAuthorities(Map<String, Object> map) { Assert.notNull(map, "The map argument must not be null."); final List<String> rolesAsStrings = new ArrayList<>(); final List<GrantedAuthority> grantedAuthorities = Stream.of(CoreSecurityRoles.values()) .map(roleEnum -> { final String roleName = SecurityConfigUtils.ROLE_PREFIX + roleEnum.getKey(); rolesAsStrings.add(roleName); return new SimpleGrantedAuthority(roleName); }) .collect(Collectors.toList()); logger.info("Adding ALL roles {} to user {}", StringUtils.collectionToCommaDelimitedString(rolesAsStrings), map); return grantedAuthorities; } }
/** * The returned {@link List} of {@link GrantedAuthority}s contains all roles from * {@link CoreSecurityRoles}. The roles are prefixed with the value specified in * {@link GrantedAuthorityDefaults}. * * @param map Must not be null. Is only used for logging */ @Override public List<GrantedAuthority> extractAuthorities(Map<String, Object> map) { Assert.notNull(map, "The map argument must not be null."); if (cloudFoundrySecurityService.isSpaceDeveloper()) { final List<String> rolesAsStrings = new ArrayList<>(); final List<GrantedAuthority> grantedAuthorities = Stream.of(CoreSecurityRoles.values()) .map(roleEnum -> { final String roleName = SecurityConfigUtils.ROLE_PREFIX + roleEnum.getKey(); rolesAsStrings.add(roleName); return new SimpleGrantedAuthority(roleName); }) .collect(Collectors.toList()); logger.info("Adding ALL roles {} to Cloud Foundry Space Developer user {}", StringUtils.collectionToCommaDelimitedString(rolesAsStrings), map); return grantedAuthorities; } else { return new ArrayList<>(0); } } }
/** * The returned {@link List} of {@link GrantedAuthority}s contains all roles from * {@link CoreSecurityRoles}. The roles are prefixed with the value specified in * {@link GrantedAuthorityDefaults}. * * @param map Must not be null. Is only used for logging */ @Override public List<GrantedAuthority> extractAuthorities(Map<String, Object> map) { Assert.notNull(map, "The map argument must not be null."); if (cloudFoundrySecurityService.isSpaceDeveloper()) { final List<String> rolesAsStrings = new ArrayList<>(); final List<GrantedAuthority> grantedAuthorities = Stream.of(CoreSecurityRoles.values()) .map(roleEnum -> { final String roleName = SecurityConfigUtils.ROLE_PREFIX + roleEnum.getKey(); rolesAsStrings.add(roleName); return new SimpleGrantedAuthority(roleName); }) .collect(Collectors.toList()); logger.info("Adding ALL roles {} to Cloud Foundry Space Developer user {}", StringUtils.collectionToCommaDelimitedString(rolesAsStrings), map); return grantedAuthorities; } else { return new ArrayList<>(0); } } }
/** * The returned {@link List} of {@link GrantedAuthority}s contains all roles from * {@link CoreSecurityRoles}. The roles are prefixed with the value specified in * {@link GrantedAuthorityDefaults}. * * @param map Must not be null. Is only used for logging */ @Override public List<GrantedAuthority> extractAuthorities(Map<String, Object> map) { Assert.notNull(map, "The map argument must not be null."); if (cloudFoundrySecurityService.isSpaceDeveloper()) { final List<String> rolesAsStrings = new ArrayList<>(); final List<GrantedAuthority> grantedAuthorities = Stream.of(CoreSecurityRoles.values()) .map(roleEnum -> { final String roleName = SecurityConfigUtils.ROLE_PREFIX + roleEnum.getKey(); rolesAsStrings.add(roleName); return new SimpleGrantedAuthority(roleName); }) .collect(Collectors.toList()); logger.info("Adding ALL roles {} to Cloud Foundry Space Developer user {}", StringUtils.collectionToCommaDelimitedString(rolesAsStrings), map); return grantedAuthorities; } else { return new ArrayList<>(0); } } }
for (CoreSecurityRoles coreRole : CoreSecurityRoles.values()) {