use of org.apache.archiva.redback.common.ldap.MappingException in project archiva by apache.
the class ArchivaLdapRoleMapperConfiguration method setLdapGroupMappings.
@Override
public void setLdapGroupMappings(Map<String, List<String>> mappings) throws MappingException {
try {
RedbackRuntimeConfiguration redbackRuntimeConfiguration = redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration();
List<LdapGroupMapping> ldapGroupMappings = new ArrayList<>(mappings.size());
for (Map.Entry<String, List<String>> entry : mappings.entrySet()) {
ldapGroupMappings.add(new LdapGroupMapping(entry.getKey(), entry.getValue()));
}
redbackRuntimeConfiguration.setLdapGroupMappings(ldapGroupMappings);
redbackRuntimeConfigurationAdmin.updateRedbackRuntimeConfiguration(redbackRuntimeConfiguration);
} catch (RepositoryAdminException e) {
throw new MappingException(e.getMessage(), e);
}
}
use of org.apache.archiva.redback.common.ldap.MappingException in project archiva by apache.
the class ArchivaLdapRoleMapperConfiguration method getLdapGroupMappings.
@Override
public Map<String, Collection<String>> getLdapGroupMappings() throws MappingException {
try {
RedbackRuntimeConfiguration redbackRuntimeConfiguration = redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration();
List<LdapGroupMapping> ldapGroupMappings = redbackRuntimeConfiguration.getLdapGroupMappings();
if (ldapGroupMappings == null) {
return Collections.emptyMap();
}
Map<String, Collection<String>> res = new HashMap<>(ldapGroupMappings.size());
for (LdapGroupMapping ldapGroupMapping : ldapGroupMappings) {
res.put(ldapGroupMapping.getGroup(), ldapGroupMapping.getRoleNames());
}
return res;
} catch (RepositoryAdminException e) {
throw new MappingException(e.getMessage(), e);
}
}
use of org.apache.archiva.redback.common.ldap.MappingException in project archiva by apache.
the class ArchivaLdapRoleMapperConfiguration method updateLdapMapping.
@Override
public void updateLdapMapping(String ldapGroup, List<String> roles) throws MappingException {
try {
RedbackRuntimeConfiguration redbackRuntimeConfiguration = redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration();
LdapGroupMapping ldapGroupMapping = new LdapGroupMapping(ldapGroup);
int idx = redbackRuntimeConfiguration.getLdapGroupMappings().indexOf(ldapGroupMapping);
if (idx > -1) {
logger.debug("updateLdapMapping ldapGroup: {}, roles: {}", ldapGroup, roles);
ldapGroupMapping = redbackRuntimeConfiguration.getLdapGroupMappings().get(idx);
ldapGroupMapping.setRoleNames(roles);
}
redbackRuntimeConfigurationAdmin.updateRedbackRuntimeConfiguration(redbackRuntimeConfiguration);
} catch (RepositoryAdminException e) {
throw new MappingException(e.getMessage(), e);
}
}
use of org.apache.archiva.redback.common.ldap.MappingException 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.redback.common.ldap.MappingException 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);
}
}
Aggregations