use of org.apache.archiva.admin.model.beans.LdapGroupMapping in project archiva by apache.
the class ArchivaLdapRoleMapperConfiguration method addLdapMapping.
@Override
public void addLdapMapping(String ldapGroup, List<String> roles) throws MappingException {
logger.debug("addLdapMapping ldapGroup: {}, roles: {}", ldapGroup, roles);
// TODO check if already exist first
try {
RedbackRuntimeConfiguration redbackRuntimeConfiguration = redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration();
boolean added = redbackRuntimeConfiguration.getLdapGroupMappings().add(new LdapGroupMapping(ldapGroup, roles));
logger.debug("addLdapMapping ldapGroup: {}, roles: {}, added: {}", ldapGroup, roles, added);
redbackRuntimeConfigurationAdmin.updateRedbackRuntimeConfiguration(redbackRuntimeConfiguration);
} catch (RepositoryAdminException e) {
throw new MappingException(e.getMessage(), e);
}
}
use of org.apache.archiva.admin.model.beans.LdapGroupMapping in project archiva by apache.
the class ArchivaLdapRoleMapperConfiguration method removeLdapMapping.
@Override
public void removeLdapMapping(String group) throws MappingException {
try {
RedbackRuntimeConfiguration redbackRuntimeConfiguration = redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration();
boolean removed = redbackRuntimeConfiguration.getLdapGroupMappings().remove(new LdapGroupMapping(group));
redbackRuntimeConfigurationAdmin.updateRedbackRuntimeConfiguration(redbackRuntimeConfiguration);
logger.debug("removeLdapMapping ldapGroup: {}, removed: {}", group, removed);
} catch (RepositoryAdminException e) {
throw new MappingException(e.getMessage(), e);
}
}
use of org.apache.archiva.admin.model.beans.LdapGroupMapping in project archiva by apache.
the class DefaultRedbackRuntimeConfigurationAdmin method build.
private RedbackRuntimeConfiguration build(org.apache.archiva.configuration.RedbackRuntimeConfiguration runtimeConfiguration) {
RedbackRuntimeConfiguration redbackRuntimeConfiguration = getModelMapper().map(runtimeConfiguration, RedbackRuntimeConfiguration.class);
if (runtimeConfiguration.getLdapConfiguration() != null) {
redbackRuntimeConfiguration.setLdapConfiguration(getModelMapper().map(runtimeConfiguration.getLdapConfiguration(), LdapConfiguration.class));
}
if (runtimeConfiguration.getUsersCacheConfiguration() != null) {
redbackRuntimeConfiguration.setUsersCacheConfiguration(getModelMapper().map(runtimeConfiguration.getUsersCacheConfiguration(), CacheConfiguration.class));
}
if (redbackRuntimeConfiguration.getLdapConfiguration() == null) {
// prevent NPE
redbackRuntimeConfiguration.setLdapConfiguration(new LdapConfiguration());
}
if (redbackRuntimeConfiguration.getUsersCacheConfiguration() == null) {
redbackRuntimeConfiguration.setUsersCacheConfiguration(new CacheConfiguration());
}
List<org.apache.archiva.configuration.LdapGroupMapping> mappings = runtimeConfiguration.getLdapGroupMappings();
if (mappings != null && mappings.size() > 0) {
List<LdapGroupMapping> ldapGroupMappings = new ArrayList<>(mappings.size());
for (org.apache.archiva.configuration.LdapGroupMapping mapping : mappings) {
ldapGroupMappings.add(new LdapGroupMapping(mapping.getGroup(), mapping.getRoleNames()));
}
redbackRuntimeConfiguration.setLdapGroupMappings(ldapGroupMappings);
}
cleanupProperties(redbackRuntimeConfiguration);
return redbackRuntimeConfiguration;
}
Aggregations