Search in sources :

Example 1 with LdapConfiguration

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

the class ConfigurationRegistryReader method readLdapConfiguration.

private LdapConfiguration readLdapConfiguration(String prefix, Registry registry) {
    LdapConfiguration value = new LdapConfiguration();
    // String hostName = registry.getString( prefix + "hostName", value.getHostName() );
    List<String> hostNameList = registry.getList(prefix + "hostName");
    String hostName = value.getHostName();
    if (hostNameList != null && !hostNameList.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0, size = hostNameList.size(); i < size; i++) {
            sb.append(hostNameList.get(i));
            if (i < size - 1) {
                sb.append(',');
            }
        }
        hostName = sb.toString();
    }
    value.setHostName(hostName);
    int port = registry.getInt(prefix + "port", value.getPort());
    value.setPort(port);
    boolean ssl = registry.getBoolean(prefix + "ssl", value.isSsl());
    value.setSsl(ssl);
    // String baseDn = registry.getString( prefix + "baseDn", value.getBaseDn() );
    List<String> baseDnList = registry.getList(prefix + "baseDn");
    String baseDn = value.getBaseDn();
    if (baseDnList != null && !baseDnList.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0, size = baseDnList.size(); i < size; i++) {
            sb.append(baseDnList.get(i));
            if (i < size - 1) {
                sb.append(',');
            }
        }
        baseDn = sb.toString();
    }
    value.setBaseDn(baseDn);
    // String baseGroupsDn = registry.getString( prefix + "baseGroupsDn", value.getBaseGroupsDn() );
    List<String> baseGroupsDnList = registry.getList(prefix + "baseGroupsDn");
    String baseGroupsDn = value.getBaseGroupsDn();
    if (baseGroupsDnList != null && !baseGroupsDnList.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0, size = baseGroupsDnList.size(); i < size; i++) {
            sb.append(baseGroupsDnList.get(i));
            if (i < size - 1) {
                sb.append(',');
            }
        }
        baseGroupsDn = sb.toString();
    }
    value.setBaseGroupsDn(baseGroupsDn);
    // String contextFactory = registry.getString( prefix + "contextFactory", value.getContextFactory() );
    List<String> contextFactoryList = registry.getList(prefix + "contextFactory");
    String contextFactory = value.getContextFactory();
    if (contextFactoryList != null && !contextFactoryList.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0, size = contextFactoryList.size(); i < size; i++) {
            sb.append(contextFactoryList.get(i));
            if (i < size - 1) {
                sb.append(',');
            }
        }
        contextFactory = sb.toString();
    }
    value.setContextFactory(contextFactory);
    // String bindDn = registry.getString( prefix + "bindDn", value.getBindDn() );
    List<String> bindDnList = registry.getList(prefix + "bindDn");
    String bindDn = value.getBindDn();
    if (bindDnList != null && !bindDnList.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0, size = bindDnList.size(); i < size; i++) {
            sb.append(bindDnList.get(i));
            if (i < size - 1) {
                sb.append(',');
            }
        }
        bindDn = sb.toString();
    }
    value.setBindDn(bindDn);
    // String password = registry.getString( prefix + "password", value.getPassword() );
    List<String> passwordList = registry.getList(prefix + "password");
    String password = value.getPassword();
    if (passwordList != null && !passwordList.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0, size = passwordList.size(); i < size; i++) {
            sb.append(passwordList.get(i));
            if (i < size - 1) {
                sb.append(',');
            }
        }
        password = sb.toString();
    }
    value.setPassword(password);
    // String authenticationMethod = registry.getString( prefix + "authenticationMethod", value.getAuthenticationMethod() );
    List<String> authenticationMethodList = registry.getList(prefix + "authenticationMethod");
    String authenticationMethod = value.getAuthenticationMethod();
    if (authenticationMethodList != null && !authenticationMethodList.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0, size = authenticationMethodList.size(); i < size; i++) {
            sb.append(authenticationMethodList.get(i));
            if (i < size - 1) {
                sb.append(',');
            }
        }
        authenticationMethod = sb.toString();
    }
    value.setAuthenticationMethod(authenticationMethod);
    boolean bindAuthenticatorEnabled = registry.getBoolean(prefix + "bindAuthenticatorEnabled", value.isBindAuthenticatorEnabled());
    value.setBindAuthenticatorEnabled(bindAuthenticatorEnabled);
    boolean writable = registry.getBoolean(prefix + "writable", value.isWritable());
    value.setWritable(writable);
    boolean useRoleNameAsGroup = registry.getBoolean(prefix + "useRoleNameAsGroup", value.isUseRoleNameAsGroup());
    value.setUseRoleNameAsGroup(useRoleNameAsGroup);
    java.util.Map extraProperties = registry.getProperties(prefix + "extraProperties");
    value.setExtraProperties(extraProperties);
    return value;
}
Also used : LdapConfiguration(org.apache.archiva.configuration.model.LdapConfiguration)

Example 2 with LdapConfiguration

use of org.apache.archiva.configuration.model.LdapConfiguration 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

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