Search in sources :

Example 1 with FileConfiguration

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

the class ConnectionStatus method isUp.

public boolean isUp(LdapConnectionData ldapConnectionData) {
    FileConfiguration configuration = loadFileConfiguration();
    Properties properties = configuration.getProperties();
    properties.setProperty("bindDN", ldapConnectionData.getBindDN());
    properties.setProperty("bindPassword", ldapConnectionData.getBindPassword());
    properties.setProperty("servers", buildServersString(ldapConnectionData.getServers()));
    properties.setProperty("useSSL", Boolean.toString(ldapConnectionData.isUseSSL()));
    LdapConnectionProvider connectionProvider = new LdapConnectionProvider(PropertiesDecrypter.decryptProperties(properties, configurationFactory.getCryptoConfigurationSalt()));
    connectionProvider.create();
    if (connectionProvider.getConnectionPool() != null) {
        boolean isConnected = connectionProvider.isConnected();
        connectionProvider.closeConnectionPool();
        return isConnected;
    }
    return false;
}
Also used : FileConfiguration(org.gluu.util.properties.FileConfiguration) LdapConnectionProvider(org.gluu.persist.ldap.operation.impl.LdapConnectionProvider) Properties(java.util.Properties)

Example 2 with FileConfiguration

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

the class PassportService method getConfigurationDn.

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

Example 3 with FileConfiguration

use of org.gluu.util.properties.FileConfiguration in project oxTrust 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 {}", this.saltFilePath, ex);
        throw new ConfigurationException("Failed to load configuration from " + this.saltFilePath, ex);
    }
}
Also used : FileConfiguration(org.gluu.util.properties.FileConfiguration) ConfigurationException(org.gluu.exception.ConfigurationException) ConfigurationException(org.gluu.exception.ConfigurationException)

Example 4 with FileConfiguration

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

the class ConfigurationFactory method createFileConfiguration.

private FileConfiguration createFileConfiguration(String fileName, boolean isMandatory) {
    try {
        FileConfiguration fileConfiguration = new FileConfiguration(fileName);
        if (fileConfiguration.isLoaded()) {
            log.debug("########## fileName = " + fileConfiguration.getFileName());
            log.debug("########## oxtrust_ConfigurationEntryDN = " + fileConfiguration.getString("oxtrust_ConfigurationEntryDN"));
            return fileConfiguration;
        }
    } catch (Exception ex) {
        if (isMandatory) {
            log.error("Failed to load configuration from {}", fileName, ex);
            throw new ConfigurationException("Failed to load configuration from " + fileName, ex);
        }
    }
    return null;
}
Also used : FileConfiguration(org.gluu.util.properties.FileConfiguration) ConfigurationException(org.gluu.exception.ConfigurationException) ConfigurationException(org.gluu.exception.ConfigurationException)

Example 5 with FileConfiguration

use of org.gluu.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 {}", saltFilePath, ex);
        throw new ConfigurationException("Failed to load configuration from " + saltFilePath, ex);
    }
}
Also used : FileConfiguration(org.gluu.util.properties.FileConfiguration) ConfigurationException(org.gluu.exception.ConfigurationException) BasePersistenceException(org.gluu.persist.exception.BasePersistenceException) ConfigurationException(org.gluu.exception.ConfigurationException)

Aggregations

FileConfiguration (org.gluu.util.properties.FileConfiguration)6 ConfigurationException (org.gluu.exception.ConfigurationException)3 Properties (java.util.Properties)2 LdapConnectionProvider (org.gluu.persist.ldap.operation.impl.LdapConnectionProvider)2 BasePersistenceException (org.gluu.persist.exception.BasePersistenceException)1 LdapEntryManagerFactory (org.gluu.persist.ldap.impl.LdapEntryManagerFactory)1 BeforeClass (org.testng.annotations.BeforeClass)1