Search in sources :

Example 1 with ConfigurationException

use of org.gluu.util.exception.ConfigurationException in project oxCore by GluuFederation.

the class ConfigurationFactory method loadCacheConfiguration.

private CacheConfiguration loadCacheConfiguration() {
    SharedConfigurationEntry sharedConfigurationEntry = persistenceEntryManager.find(SharedConfigurationEntry.class, SHARED_CONFIGURATION_DN);
    if (sharedConfigurationEntry == null) {
        LOG.error("Failed to load share configuration from DB. Please fix it!!!.");
        throw new ConfigurationException("Failed to load shared configuration from DB.");
    }
    CacheConfiguration cacheConfiguration = sharedConfigurationEntry.getCacheConfiguration();
    if (cacheConfiguration == null || cacheConfiguration.getCacheProviderType() == null) {
        LOG.error("Failed to read cache configuration from DB. Please check configuration oxCacheConfiguration attribute " + "that must contain cache configuration JSON represented by CacheConfiguration.class. Shared configuration DN: " + SHARED_CONFIGURATION_DN);
        LOG.info("Creating fallback IN-MEMORY cache configuration ... ");
        cacheConfiguration = new CacheConfiguration();
        cacheConfiguration.setInMemoryConfiguration(new InMemoryConfiguration());
        LOG.info("IN-MEMORY cache configuration is created.");
    }
    LOG.info("Cache configuration: " + cacheConfiguration);
    return cacheConfiguration;
}
Also used : InMemoryConfiguration(org.gluu.service.cache.InMemoryConfiguration) ConfigurationException(org.gluu.util.exception.ConfigurationException) SharedConfigurationEntry(org.gluu.conf.model.SharedConfigurationEntry) CacheConfiguration(org.gluu.service.cache.CacheConfiguration)

Example 2 with ConfigurationException

use of org.gluu.util.exception.ConfigurationException in project oxCore by GluuFederation.

the class ConfigurationFactory method create.

private void create() {
    this.persistanceFactoryService = new StandalonePersistanceFactoryService();
    this.persistenceConfiguration = persistanceFactoryService.loadPersistenceConfiguration(getDefaultConfigurationFileName());
    this.baseConfiguration = loadBaseConfiguration();
    this.confDir = confDir();
    this.saltFilePath = confDir + SALT_FILE_NAME;
    this.cryptoConfigurationSalt = loadCryptoConfigurationSalt();
    this.stringEncrypter = createStringEncrypter();
    this.persistenceEntryManager = createPersistenceEntryManager();
    if (!createFromDb()) {
        LOG.error("Failed to load configuration from DB. Please fix it!!!.");
        throw new ConfigurationException("Failed to load configuration from DB.");
    } else {
        this.loaded = true;
        LOG.info("Configuration loaded successfully.");
    }
    this.cacheConfiguration = loadCacheConfiguration();
}
Also used : ConfigurationException(org.gluu.util.exception.ConfigurationException) StandalonePersistanceFactoryService(org.gluu.persist.service.StandalonePersistanceFactoryService)

Example 3 with ConfigurationException

use of org.gluu.util.exception.ConfigurationException in project oxCore by GluuFederation.

the class ConfigurationFactory method preparePersistanceProperties.

protected Properties preparePersistanceProperties() {
    FileConfiguration persistenceConfig = persistenceConfiguration.getConfiguration();
    Properties connectionProperties = (Properties) persistenceConfig.getProperties();
    Properties decryptedConnectionProperties;
    try {
        decryptedConnectionProperties = PropertiesDecrypter.decryptAllProperties(StringEncrypter.defaultInstance(), connectionProperties, this.cryptoConfigurationSalt);
    } catch (EncryptionException ex) {
        throw new ConfigurationException("Failed to decript configuration properties", ex);
    }
    return decryptedConnectionProperties;
}
Also used : FileConfiguration(org.gluu.orm.util.properties.FileConfiguration) ConfigurationException(org.gluu.util.exception.ConfigurationException) EncryptionException(org.gluu.util.security.StringEncrypter.EncryptionException) Properties(java.util.Properties)

Example 4 with ConfigurationException

use of org.gluu.util.exception.ConfigurationException in project oxTrust by GluuFederation.

the class OpenIdClient method initInternal.

protected void initInternal() {
    this.clientId = appConfiguration.getOpenIdClientId();
    this.clientSecret = appConfiguration.getOpenIdClientPassword();
    if (StringHelper.isNotEmpty(this.clientSecret)) {
        try {
            StringEncrypter stringEncrypter = StringEncrypter.instance(this.configuration.getCryptoConfigurationSalt());
            this.clientSecret = stringEncrypter.decrypt(this.clientSecret);
        } catch (EncryptionException ex) {
            logger.warn("Assuming that client password is not encrypted!");
        }
    }
    this.preRegisteredClient = StringHelper.isNotEmpty(this.clientId) && StringHelper.isNotEmpty(this.clientSecret);
    try {
        loadOpenIdConfiguration();
    } catch (IOException ex) {
        throw new ConfigurationException("Failed to load oxAuth configuration");
    }
}
Also used : ConfigurationException(org.gluu.util.exception.ConfigurationException) EncryptionException(org.gluu.util.security.StringEncrypter.EncryptionException) IOException(java.io.IOException) StringEncrypter(org.gluu.util.security.StringEncrypter)

Example 5 with ConfigurationException

use of org.gluu.util.exception.ConfigurationException in project oxTrust by GluuFederation.

the class OpenIdService method loadOpenIdConfiguration.

private void loadOpenIdConfiguration() throws IOException {
    String openIdProvider = appConfiguration.getOxAuthIssuer();
    if (StringHelper.isEmpty(openIdProvider)) {
        throw new ConfigurationException("OpenIdProvider Url is invalid");
    }
    openIdProvider = openIdProvider + "/.well-known/openid-configuration";
    final OpenIdConfigurationClient openIdConfigurationClient = new OpenIdConfigurationClient(openIdProvider);
    final OpenIdConfigurationResponse response = openIdConfigurationClient.execOpenIdConfiguration();
    if ((response == null) || (response.getStatus() != 200)) {
        throw new ConfigurationException("Failed to load oxAuth configuration");
    }
    log.info("Successfully loaded oxAuth configuration");
    this.openIdConfiguration = response;
}
Also used : OpenIdConfigurationClient(org.gluu.oxauth.client.OpenIdConfigurationClient) ConfigurationException(org.gluu.util.exception.ConfigurationException) OpenIdConfigurationResponse(org.gluu.oxauth.client.OpenIdConfigurationResponse)

Aggregations

ConfigurationException (org.gluu.util.exception.ConfigurationException)7 OpenIdConfigurationClient (org.gluu.oxauth.client.OpenIdConfigurationClient)2 OpenIdConfigurationResponse (org.gluu.oxauth.client.OpenIdConfigurationResponse)2 EncryptionException (org.gluu.util.security.StringEncrypter.EncryptionException)2 IOException (java.io.IOException)1 Properties (java.util.Properties)1 SharedConfigurationEntry (org.gluu.conf.model.SharedConfigurationEntry)1 FileConfiguration (org.gluu.orm.util.properties.FileConfiguration)1 RegisterClient (org.gluu.oxauth.client.RegisterClient)1 RegisterRequest (org.gluu.oxauth.client.RegisterRequest)1 RegisterResponse (org.gluu.oxauth.client.RegisterResponse)1 StandalonePersistanceFactoryService (org.gluu.persist.service.StandalonePersistanceFactoryService)1 CacheConfiguration (org.gluu.service.cache.CacheConfiguration)1 InMemoryConfiguration (org.gluu.service.cache.InMemoryConfiguration)1 StringEncrypter (org.gluu.util.security.StringEncrypter)1