Search in sources :

Example 11 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)

Example 12 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 {}", fileName, ex);
            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) BaseMappingException(org.gluu.persist.exception.mapping.BaseMappingException)

Example 13 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 {}", this.saltFilePath, ex);
        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) BaseMappingException(org.gluu.persist.exception.mapping.BaseMappingException)

Example 14 with FileConfiguration

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

the class AppInitializer method createCentralLdapEntryManager.

@Produces
@ApplicationScoped
@Named(LDAP_CENTRAL_ENTRY_MANAGER_NAME)
@CentralLdap
public LdapEntryManager createCentralLdapEntryManager() {
    if (!((configurationFactory.getLdapCentralConfiguration() != null) && configurationFactory.getAppConfiguration().isUpdateApplianceStatus())) {
        return new LdapEntryManager();
    }
    FileConfiguration ldapCentralConfig = configurationFactory.getLdapCentralConfiguration();
    Properties centralConnectionProperties = (Properties) ldapCentralConfig.getProperties();
    EncryptionService securityService = encryptionServiceInstance.get();
    Properties decryptedCentralConnectionProperties = securityService.decryptProperties(centralConnectionProperties);
    LdapEntryManager centralLdapEntryManager = this.ldapEntryManagerFactory.createEntryManager(decryptedCentralConnectionProperties);
    log.info("Created {}: {}", new Object[] { LDAP_CENTRAL_ENTRY_MANAGER_NAME, centralLdapEntryManager.getOperationService() });
    return centralLdapEntryManager;
}
Also used : FileConfiguration(org.xdi.util.properties.FileConfiguration) LdapEntryManager(org.gluu.persist.ldap.impl.LdapEntryManager) Properties(java.util.Properties) Named(javax.inject.Named) Produces(javax.enterprise.inject.Produces) CentralLdap(org.gluu.oxtrust.service.cdi.event.CentralLdap) ApplicationScoped(javax.enterprise.context.ApplicationScoped)

Example 15 with FileConfiguration

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

the class Configuration method loadLdapConfiguration.

public FileConfiguration loadLdapConfiguration(String ldapConfigurationFileName, boolean mandatory) {
    try {
        if (StringHelper.isEmpty(ldapConfigurationFileName)) {
            if (mandatory) {
                throw new ConfigurationException("Failed to load Ldap configuration file!");
            } else {
                return null;
            }
        }
        String ldapConfigurationFilePath = DIR + ldapConfigurationFileName;
        FileConfiguration ldapConfiguration = new FileConfiguration(ldapConfigurationFilePath);
        if (ldapConfiguration.isLoaded()) {
            File ldapFile = new File(ldapConfigurationFilePath);
            if (ldapFile.exists()) {
                this.ldapFileLastModifiedTime = ldapFile.lastModified();
            }
            return ldapConfiguration;
        }
    } catch (Exception ex) {
        logger.error(ex.getMessage(), ex);
        throw new ConfigurationException("Failed to load Ldap configuration from " + ldapConfigurationFileName, ex);
    }
    if (mandatory) {
        throw new ConfigurationException("Failed to load Ldap configuration from " + ldapConfigurationFileName);
    }
    return null;
}
Also used : FileConfiguration(org.xdi.util.properties.FileConfiguration) ConfigurationException(org.xdi.util.exception.ConfigurationException) File(java.io.File) ConfigurationException(org.xdi.util.exception.ConfigurationException) BaseMappingException(org.gluu.persist.exception.mapping.BaseMappingException)

Aggregations

FileConfiguration (org.xdi.util.properties.FileConfiguration)15 Properties (java.util.Properties)6 IOException (java.io.IOException)4 JsonParseException (org.codehaus.jackson.JsonParseException)4 JsonMappingException (org.codehaus.jackson.map.JsonMappingException)4 BaseMappingException (org.gluu.persist.exception.mapping.BaseMappingException)4 ConfigurationException (org.xdi.exception.ConfigurationException)4 LdapMappingException (org.gluu.site.ldap.persistence.exception.LdapMappingException)3 File (java.io.File)2 ApplicationScoped (javax.enterprise.context.ApplicationScoped)2 Produces (javax.enterprise.inject.Produces)2 Named (javax.inject.Named)2 JsonGenerationException (org.codehaus.jackson.JsonGenerationException)2 LdapEntryManager (org.gluu.persist.ldap.impl.LdapEntryManager)2 LDAPConnectionProvider (org.gluu.site.ldap.LDAPConnectionProvider)2 BeforeClass (org.testng.annotations.BeforeClass)2 EncryptionException (org.xdi.util.security.StringEncrypter.EncryptionException)2 CentralLdap (org.gluu.oxtrust.service.cdi.event.CentralLdap)1 LdapConnectionProvider (org.gluu.persist.ldap.operation.impl.LdapConnectionProvider)1 OperationsFacade (org.gluu.site.ldap.OperationsFacade)1