/** * 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]); }
private Set<SimpleGrantedAuthority> mapAuthority(final GrantedAuthority ldapRoleAuthority) { final Set<SimpleGrantedAuthority> authorities = roleMappings.entrySet().stream() .filter(roleMapEntry -> ldapRoleAuthority.getAuthority().equalsIgnoreCase(roleMapEntry.getValue().getAuthority())) .map(roleMapEntry -> new SimpleGrantedAuthority(this.rolePrefix + roleMapEntry.getKey().getKey())).collect(Collectors.toSet()); return authorities; }
logger.warn("Received an empty permission from {}", roleProviderUri); } else { final CoreSecurityRoles securityRole = CoreSecurityRoles.fromKey(permission.toUpperCase()); if (securityRole == null) { logger.warn("Invalid role {} provided by {}", permission, roleProviderUri);
rolesToPopulate = CoreSecurityRoles.getAllRolesAsStringArray();
/** * 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); } } }