Search in sources :

Example 6 with LdapGroupMapping

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);
    }
}
Also used : LdapGroupMapping(org.apache.archiva.admin.model.beans.LdapGroupMapping) RedbackRuntimeConfiguration(org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException) MappingException(org.apache.archiva.redback.common.ldap.MappingException)

Example 7 with LdapGroupMapping

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);
    }
}
Also used : LdapGroupMapping(org.apache.archiva.admin.model.beans.LdapGroupMapping) RedbackRuntimeConfiguration(org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException) MappingException(org.apache.archiva.redback.common.ldap.MappingException)

Example 8 with LdapGroupMapping

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;
}
Also used : LdapGroupMapping(org.apache.archiva.admin.model.beans.LdapGroupMapping) ArrayList(java.util.ArrayList) LdapConfiguration(org.apache.archiva.admin.model.beans.LdapConfiguration) RedbackRuntimeConfiguration(org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration) CacheConfiguration(org.apache.archiva.admin.model.beans.CacheConfiguration)

Aggregations

LdapGroupMapping (org.apache.archiva.admin.model.beans.LdapGroupMapping)8 RedbackRuntimeConfiguration (org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration)7 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)6 MappingException (org.apache.archiva.redback.common.ldap.MappingException)5 ArrayList (java.util.ArrayList)4 CacheConfiguration (org.apache.archiva.admin.model.beans.CacheConfiguration)3 LdapConfiguration (org.apache.archiva.admin.model.beans.LdapConfiguration)3 HashMap (java.util.HashMap)2 Collection (java.util.Collection)1 List (java.util.List)1 Map (java.util.Map)1 PostConstruct (javax.annotation.PostConstruct)1 UserConfigurationException (org.apache.archiva.redback.configuration.UserConfigurationException)1