Search in sources :

Example 6 with FileConfiguration

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

Example 7 with FileConfiguration

use of org.xdi.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 {}", ex, fileName);
            throw new ConfigurationException("Failed to load configuration from " + fileName, ex);
        }
    }
    return null;
}
Also used : FileConfiguration(org.xdi.util.properties.FileConfiguration) ConfigurationException(org.xdi.exception.ConfigurationException) ConfigurationException(org.xdi.exception.ConfigurationException) LdapMappingException(org.gluu.site.ldap.persistence.exception.LdapMappingException)

Example 8 with FileConfiguration

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

the class ConfigurationFactory method loadLdapConfiguration.

private String loadLdapConfiguration(String ldapFileName) {
    try {
        ldapConfiguration = new FileConfiguration(ldapFileName);
        File ldapFile = new File(ldapFileName);
        if (ldapFile.exists()) {
            this.ldapFileLastModifiedTime = ldapFile.lastModified();
        }
        return ldapFileName;
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        ldapConfiguration = null;
    }
    return null;
}
Also used : FileConfiguration(org.xdi.util.properties.FileConfiguration) File(java.io.File) 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 9 with FileConfiguration

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

the class AppInitializer method prepareAuthConnectionProperties.

private Properties prepareAuthConnectionProperties(GluuLdapConfiguration ldapAuthConfig) {
    FileConfiguration configuration = configurationFactory.getLdapConfiguration();
    Properties properties = (Properties) configuration.getProperties().clone();
    if (ldapAuthConfig != null) {
        properties.setProperty("servers", buildServersString(ldapAuthConfig.getServers()));
        String bindDn = ldapAuthConfig.getBindDN();
        if (StringHelper.isNotEmpty(bindDn)) {
            properties.setProperty("bindDN", bindDn);
            properties.setProperty("bindPassword", ldapAuthConfig.getBindPassword());
        }
        properties.setProperty("useSSL", Boolean.toString(ldapAuthConfig.isUseSSL()));
        properties.setProperty("maxconnections", Integer.toString(ldapAuthConfig.getMaxConnections()));
    }
    return properties;
}
Also used : FileConfiguration(org.xdi.util.properties.FileConfiguration) Properties(java.util.Properties)

Example 10 with FileConfiguration

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

the class ConfigurableTest method initTest.

/**
	 * Prepare configuration before tests execution
	 */
@BeforeClass
public static void initTest() {
    String propertiesFile = "./target/test-classes/testng.properties";
    testData = new FileConfiguration(propertiesFile);
}
Also used : FileConfiguration(org.xdi.util.properties.FileConfiguration) 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