diff options
author | Martin Stockhammer <martin_s@apache.org> | 2020-07-07 06:52:37 +0200 |
---|---|---|
committer | Martin Stockhammer <martin_s@apache.org> | 2020-07-07 06:52:58 +0200 |
commit | dcf4c111e57a5a996869918667b1566b0bbe8d46 (patch) | |
tree | a56094ff0c37e29be4c39a4ecaa669264fcb98fe /archiva-modules | |
parent | 12827812ac1fa78cbc0ae377a8241c831ade9cd4 (diff) | |
download | archiva-dcf4c111e57a5a996869918667b1566b0bbe8d46.tar.gz archiva-dcf4c111e57a5a996869918667b1566b0bbe8d46.zip |
Adapting to redback LDAP group mapping change
Diffstat (limited to 'archiva-modules')
-rw-r--r-- | archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaLdapRoleMapperConfiguration.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaLdapRoleMapperConfiguration.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaLdapRoleMapperConfiguration.java index e16800390..34d33c0da 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaLdapRoleMapperConfiguration.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaLdapRoleMapperConfiguration.java @@ -36,6 +36,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; /** * @author Olivier Lamy @@ -152,6 +153,34 @@ public class ArchivaLdapRoleMapperConfiguration } @Override + public Collection<String> getLdapGroupMapping( final String groupName ) throws MappingException + { + try + { + RedbackRuntimeConfiguration redbackRuntimeConfiguration = + redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration(); + + List<LdapGroupMapping> ldapGroupMappings = redbackRuntimeConfiguration.getLdapGroupMappings(); + + if ( ldapGroupMappings == null ) + { + return Collections.EMPTY_LIST; + } + + Optional<LdapGroupMapping> result = ldapGroupMappings.stream( ).filter( mapping -> mapping.getGroup( ).equals( groupName ) ).findFirst( ); + if (result.isPresent()) { + return result.get( ).getRoleNames( ); + } else { + throw new MappingException( "Group " + groupName + " not found" ); + } + } + catch ( RepositoryAdminException e ) + { + throw new MappingException( e.getMessage(), e ); + } + } + + @Override public void setLdapGroupMappings( Map<String, List<String>> mappings ) throws MappingException { |