Search in sources :

Example 1 with FileConfiguration

use of org.xdi.util.properties.FileConfiguration in project oxAuth by GluuFederation.

the class ConfigurationFactory method loadCryptoConfigurationSalt.

public void loadCryptoConfigurationSalt() {
    try {
        FileConfiguration cryptoConfiguration = createFileConfiguration(saltFilePath, true);
        this.cryptoConfigurationSalt = cryptoConfiguration.getString("encodeSalt");
    } catch (Exception ex) {
        log.error("Failed to load configuration from {}", ex, saltFilePath);
        throw new ConfigurationException("Failed to load configuration from " + saltFilePath, ex);
    }
}
Also used : FileConfiguration(org.xdi.util.properties.FileConfiguration) ConfigurationException(org.xdi.exception.ConfigurationException) ConfigurationException(org.xdi.exception.ConfigurationException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) LdapMappingException(org.gluu.site.ldap.persistence.exception.LdapMappingException) IOException(java.io.IOException) JsonParseException(org.codehaus.jackson.JsonParseException)

Example 2 with FileConfiguration

use of org.xdi.util.properties.FileConfiguration in project oxTrust by GluuFederation.

the class ManagePersonAuthenticationAction method testLdapConnection.

public String testLdapConnection() {
    try {
        FileConfiguration configuration = new FileConfiguration(ConfigurationFactory.LDAP_PROPERTIES_FILE);
        if (!configuration.isLoaded()) {
            configuration = new FileConfiguration(ConfigurationFactory.LDAP_DEFAULT_PROPERTIES_FILE);
        }
        Properties properties = configuration.getProperties();
        properties.setProperty("bindDN", this.ldapConfig.getBindDN());
        properties.setProperty("bindPassword", this.ldapConfig.getBindPassword());
        properties.setProperty("servers", buildServersString(this.ldapConfig.getServers()));
        properties.setProperty("useSSL", Boolean.toString(this.ldapConfig.isUseSSL()));
        LDAPConnectionProvider connectionProvider = new LDAPConnectionProvider(PropertiesDecrypter.decryptProperties(properties, configurationFactory.getCryptoConfigurationSalt()));
        if (connectionProvider.isConnected()) {
            connectionProvider.closeConnectionPool();
            return OxTrustConstants.RESULT_SUCCESS;
        }
        connectionProvider.closeConnectionPool();
        return OxTrustConstants.RESULT_FAILURE;
    } catch (Exception ex) {
        log.error("Could not connect to LDAP", ex);
        return OxTrustConstants.RESULT_FAILURE;
    }
}
Also used : FileConfiguration(org.xdi.util.properties.FileConfiguration) Properties(java.util.Properties) LDAPConnectionProvider(org.gluu.site.ldap.LDAPConnectionProvider) EncryptionException(org.xdi.util.security.StringEncrypter.EncryptionException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) LdapMappingException(org.gluu.site.ldap.persistence.exception.LdapMappingException) IOException(java.io.IOException) JsonGenerationException(org.codehaus.jackson.JsonGenerationException) JsonParseException(org.codehaus.jackson.JsonParseException)

Example 3 with FileConfiguration

use of org.xdi.util.properties.FileConfiguration in project oxTrust by GluuFederation.

the class Configuration method loadLdapConfiguration.

private FileConfiguration loadLdapConfiguration() {
    String ldapConfigurationFileName = getLdapConfigurationFileName();
    FileConfiguration fileConfiguration = loadLdapConfiguration(ldapConfigurationFileName, false);
    if (fileConfiguration == null) {
        ldapConfigurationFileName = getDefaultLdapConfigurationFileName();
        fileConfiguration = loadLdapConfiguration(ldapConfigurationFileName, true);
    }
    return fileConfiguration;
}
Also used : FileConfiguration(org.xdi.util.properties.FileConfiguration)

Example 4 with FileConfiguration

use of org.xdi.util.properties.FileConfiguration in project oxTrust by GluuFederation.

the class PassportService method getConfigurationDn.

private String getConfigurationDn() {
    FileConfiguration fc = configurationFactory.getLdapConfiguration();
    String configurationDn = fc.getString("oxpassport_ConfigurationEntryDN");
    return configurationDn;
}
Also used : FileConfiguration(org.xdi.util.properties.FileConfiguration)

Example 5 with FileConfiguration

use of org.xdi.util.properties.FileConfiguration in project oxAuth by GluuFederation.

the class Manual method init.

@BeforeClass
public void init() {
    final FileConfiguration fileConfiguration = new FileConfiguration(LDAP_FILE_PATH);
    final Properties props = PropertiesDecrypter.decryptProperties(fileConfiguration.getProperties(), "passoword");
    final LDAPConnectionProvider connectionProvider = new LDAPConnectionProvider(props);
    MANAGER = new LdapEntryManager(new OperationsFacade(connectionProvider));
}
Also used : FileConfiguration(org.xdi.util.properties.FileConfiguration) LdapEntryManager(org.gluu.site.ldap.persistence.LdapEntryManager) OperationsFacade(org.gluu.site.ldap.OperationsFacade) Properties(java.util.Properties) LDAPConnectionProvider(org.gluu.site.ldap.LDAPConnectionProvider) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

FileConfiguration (org.xdi.util.properties.FileConfiguration)12 LdapMappingException (org.gluu.site.ldap.persistence.exception.LdapMappingException)6 ConfigurationException (org.xdi.exception.ConfigurationException)4 IOException (java.io.IOException)3 Properties (java.util.Properties)3 JsonParseException (org.codehaus.jackson.JsonParseException)3 JsonMappingException (org.codehaus.jackson.map.JsonMappingException)3 File (java.io.File)2 LDAPConnectionProvider (org.gluu.site.ldap.LDAPConnectionProvider)2 BeforeClass (org.testng.annotations.BeforeClass)2 JsonGenerationException (org.codehaus.jackson.JsonGenerationException)1 OperationsFacade (org.gluu.site.ldap.OperationsFacade)1 LdapEntryManager (org.gluu.site.ldap.persistence.LdapEntryManager)1 BeforeClass (org.junit.BeforeClass)1 ConfigurationException (org.xdi.util.exception.ConfigurationException)1 EncryptionException (org.xdi.util.security.StringEncrypter.EncryptionException)1