Search in sources :

Example 1 with LdapGroupMapping

use of org.apache.archiva.configuration.model.LdapGroupMapping in project archiva by apache.

the class ConfigurationRegistryReader method readLdapGroupMapping.

private LdapGroupMapping readLdapGroupMapping(String prefix, Registry registry) {
    LdapGroupMapping value = new LdapGroupMapping();
    // String group = registry.getString( prefix + "group", value.getGroup() );
    List<String> groupList = registry.getList(prefix + "group");
    String group = value.getGroup();
    if (groupList != null && !groupList.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0, size = groupList.size(); i < size; i++) {
            sb.append(groupList.get(i));
            if (i < size - 1) {
                sb.append(',');
            }
        }
        group = sb.toString();
    }
    value.setGroup(group);
    java.util.List roleNames = new java.util.ArrayList();
    roleNames.addAll(registry.getList(prefix + "roleNames.roleName"));
    value.setRoleNames(roleNames);
    return value;
}
Also used : List(java.util.List) LdapGroupMapping(org.apache.archiva.configuration.model.LdapGroupMapping)

Example 2 with LdapGroupMapping

use of org.apache.archiva.configuration.model.LdapGroupMapping in project archiva by apache.

the class ConfigurationRegistryWriter method writeRedbackRuntimeConfiguration.

private void writeRedbackRuntimeConfiguration(String prefix, RedbackRuntimeConfiguration value, Registry registry) {
    if (value != null) {
        String migratedFromRedbackConfiguration = "migratedFromRedbackConfiguration";
        registry.setBoolean(prefix + migratedFromRedbackConfiguration, value.isMigratedFromRedbackConfiguration());
        if (value.getUserManagerImpls() != null && value.getUserManagerImpls().size() > 0) {
            registry.removeSubset(prefix + "userManagerImpls");
            int count = 0;
            for (Iterator iter = value.getUserManagerImpls().iterator(); iter.hasNext(); count++) {
                String name = "userManagerImpls.userManagerImpl(" + count + ")";
                String userManagerImpl = (String) iter.next();
                registry.setString(prefix + name, userManagerImpl);
            }
        }
        if (value.getRbacManagerImpls() != null && value.getRbacManagerImpls().size() > 0) {
            registry.removeSubset(prefix + "rbacManagerImpls");
            int count = 0;
            for (Iterator iter = value.getRbacManagerImpls().iterator(); iter.hasNext(); count++) {
                String name = "rbacManagerImpls.rbacManagerImpl(" + count + ")";
                String rbacManagerImpl = (String) iter.next();
                registry.setString(prefix + name, rbacManagerImpl);
            }
        }
        if (value.getLdapConfiguration() != null) {
            writeLdapConfiguration(prefix + "ldapConfiguration.", value.getLdapConfiguration(), registry);
        }
        if (value.getLdapGroupMappings() != null && value.getLdapGroupMappings().size() > 0) {
            registry.removeSubset(prefix + "ldapGroupMappings");
            int count = 0;
            for (Iterator iter = value.getLdapGroupMappings().iterator(); iter.hasNext(); count++) {
                String name = "ldapGroupMappings.ldapGroupMapping(" + count + ")";
                LdapGroupMapping o = (LdapGroupMapping) iter.next();
                writeLdapGroupMapping(prefix + name + ".", o, registry);
            }
        }
        if (value.getConfigurationProperties() != null && value.getConfigurationProperties().size() > 0) {
            registry.removeSubset(prefix + "configurationProperties");
            for (Iterator iter = value.getConfigurationProperties().keySet().iterator(); iter.hasNext(); ) {
                String key = (String) iter.next();
                String v = (String) value.getConfigurationProperties().get(key);
                registry.setString(prefix + "configurationProperties." + key, v);
            }
        }
        String useUsersCache = "useUsersCache";
        registry.setBoolean(prefix + useUsersCache, value.isUseUsersCache());
        if (value.getUsersCacheConfiguration() != null) {
            writeCacheConfiguration(prefix + "usersCacheConfiguration.", value.getUsersCacheConfiguration(), registry);
        }
    }
}
Also used : LdapGroupMapping(org.apache.archiva.configuration.model.LdapGroupMapping) Iterator(java.util.Iterator)

Example 3 with LdapGroupMapping

use of org.apache.archiva.configuration.model.LdapGroupMapping in project archiva by apache.

the class ConfigurationRegistryReader method readRedbackRuntimeConfiguration.

private RedbackRuntimeConfiguration readRedbackRuntimeConfiguration(String prefix, Registry registry) {
    RedbackRuntimeConfiguration value = new RedbackRuntimeConfiguration();
    boolean migratedFromRedbackConfiguration = registry.getBoolean(prefix + "migratedFromRedbackConfiguration", value.isMigratedFromRedbackConfiguration());
    value.setMigratedFromRedbackConfiguration(migratedFromRedbackConfiguration);
    java.util.List userManagerImpls = new java.util.ArrayList();
    userManagerImpls.addAll(registry.getList(prefix + "userManagerImpls.userManagerImpl"));
    value.setUserManagerImpls(userManagerImpls);
    java.util.List rbacManagerImpls = new java.util.ArrayList();
    rbacManagerImpls.addAll(registry.getList(prefix + "rbacManagerImpls.rbacManagerImpl"));
    value.setRbacManagerImpls(rbacManagerImpls);
    LdapConfiguration ldapConfiguration = readLdapConfiguration(prefix + "ldapConfiguration.", registry);
    value.setLdapConfiguration(ldapConfiguration);
    java.util.List ldapGroupMappings = new java.util.ArrayList();
    List ldapGroupMappingsSubsets = registry.getSubsetList(prefix + "ldapGroupMappings.ldapGroupMapping");
    for (Iterator i = ldapGroupMappingsSubsets.iterator(); i.hasNext(); ) {
        LdapGroupMapping v = readLdapGroupMapping("", (Registry) i.next());
        ldapGroupMappings.add(v);
    }
    value.setLdapGroupMappings(ldapGroupMappings);
    java.util.Map configurationProperties = registry.getProperties(prefix + "configurationProperties");
    value.setConfigurationProperties(configurationProperties);
    boolean useUsersCache = registry.getBoolean(prefix + "useUsersCache", value.isUseUsersCache());
    value.setUseUsersCache(useUsersCache);
    CacheConfiguration usersCacheConfiguration = readCacheConfiguration(prefix + "usersCacheConfiguration.", registry);
    value.setUsersCacheConfiguration(usersCacheConfiguration);
    return value;
}
Also used : List(java.util.List) LdapGroupMapping(org.apache.archiva.configuration.model.LdapGroupMapping) Iterator(java.util.Iterator) LdapConfiguration(org.apache.archiva.configuration.model.LdapConfiguration) List(java.util.List) RedbackRuntimeConfiguration(org.apache.archiva.configuration.model.RedbackRuntimeConfiguration) CacheConfiguration(org.apache.archiva.configuration.model.CacheConfiguration)

Aggregations

LdapGroupMapping (org.apache.archiva.configuration.model.LdapGroupMapping)3 Iterator (java.util.Iterator)2 List (java.util.List)2 CacheConfiguration (org.apache.archiva.configuration.model.CacheConfiguration)1 LdapConfiguration (org.apache.archiva.configuration.model.LdapConfiguration)1 RedbackRuntimeConfiguration (org.apache.archiva.configuration.model.RedbackRuntimeConfiguration)1