Search in sources :

Example 6 with RedbackRuntimeConfiguration

use of org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration in project archiva by apache.

the class RedbackRuntimeConfigurationServiceTest method update.

@Test
public void update() throws Exception {
    RedbackRuntimeConfiguration redbackRuntimeConfiguration = getRedbackRuntimeConfigurationService().getRedbackRuntimeConfiguration();
    assertEquals("jpa", redbackRuntimeConfiguration.getUserManagerImpls().get(0));
    redbackRuntimeConfiguration.setUserManagerImpls(Arrays.asList("foo"));
    getRedbackRuntimeConfigurationService().updateRedbackRuntimeConfiguration(redbackRuntimeConfiguration);
    redbackRuntimeConfiguration = getRedbackRuntimeConfigurationService().getRedbackRuntimeConfiguration();
    assertEquals("foo", redbackRuntimeConfiguration.getUserManagerImpls().get(0));
}
Also used : RedbackRuntimeConfiguration(org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration) Test(org.junit.Test)

Example 7 with RedbackRuntimeConfiguration

use of org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration 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);
    }
}
Also used : LdapGroupMapping(org.apache.archiva.admin.model.beans.LdapGroupMapping) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) RedbackRuntimeConfiguration(org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException) HashMap(java.util.HashMap) Map(java.util.Map) MappingException(org.apache.archiva.redback.common.ldap.MappingException)

Example 8 with RedbackRuntimeConfiguration

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

Example 9 with RedbackRuntimeConfiguration

use of org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration 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);
    }
}
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 10 with RedbackRuntimeConfiguration

use of org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration 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)

Aggregations

RedbackRuntimeConfiguration (org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration)18 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)14 LdapGroupMapping (org.apache.archiva.admin.model.beans.LdapGroupMapping)7 MappingException (org.apache.archiva.redback.common.ldap.MappingException)5 ArrayList (java.util.ArrayList)3 CacheConfiguration (org.apache.archiva.admin.model.beans.CacheConfiguration)3 LdapConfiguration (org.apache.archiva.admin.model.beans.LdapConfiguration)3 HashMap (java.util.HashMap)2 Test (org.junit.Test)2 SimpleDateFormat (java.text.SimpleDateFormat)1 Collection (java.util.Collection)1 Date (java.util.Date)1 List (java.util.List)1 Locale (java.util.Locale)1 Map (java.util.Map)1 PostConstruct (javax.annotation.PostConstruct)1 ArchivaConfiguration (org.apache.archiva.configuration.ArchivaConfiguration)1 Configuration (org.apache.archiva.configuration.Configuration)1 IndeterminateConfigurationException (org.apache.archiva.configuration.IndeterminateConfigurationException)1 RegistryException (org.apache.archiva.redback.components.registry.RegistryException)1