Search in sources :

Example 1 with ConfigurationException

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

the class OpenIdService method loadOpenIdConfiguration.

private void loadOpenIdConfiguration() {
    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.xdi.oxauth.client.OpenIdConfigurationClient) ConfigurationException(org.xdi.util.exception.ConfigurationException) OpenIdConfigurationResponse(org.xdi.oxauth.client.OpenIdConfigurationResponse)

Example 2 with ConfigurationException

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

the class OpenIdClient method loadOpenIdConfiguration.

private void loadOpenIdConfiguration() {
    String openIdProvider = appConfiguration.getOpenIdProviderUrl();
    if (StringHelper.isEmpty(openIdProvider)) {
        throw new ConfigurationException("OpenIdProvider Url is invalid");
    }
    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");
    }
    logger.info("Successfully loaded oxAuth configuration");
    this.openIdConfiguration = response;
}
Also used : OpenIdConfigurationClient(org.xdi.oxauth.client.OpenIdConfigurationClient) ConfigurationException(org.xdi.util.exception.ConfigurationException) OpenIdConfigurationResponse(org.xdi.oxauth.client.OpenIdConfigurationResponse)

Example 3 with ConfigurationException

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

the class OpenIdClient method registerOpenIdClient.

private RegisterResponse registerOpenIdClient() {
    logger.info("Registering OpenId client");
    String clientName = this.appConfiguration.getApplicationName() + " client";
    RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, clientName, Arrays.asList(this.appConfiguration.getOpenIdRedirectUrl()));
    registerRequest.setRequestObjectSigningAlg(SignatureAlgorithm.RS256);
    registerRequest.setTokenEndpointAuthMethod(AuthenticationMethod.CLIENT_SECRET_BASIC);
    RegisterClient registerClient = new RegisterClient(openIdConfiguration.getRegistrationEndpoint());
    registerClient.setRequest(registerRequest);
    RegisterResponse response = registerClient.exec();
    if ((response == null) || (response.getStatus() != 200)) {
        throw new ConfigurationException("Failed to register new client");
    }
    return response;
}
Also used : RegisterRequest(org.xdi.oxauth.client.RegisterRequest) RegisterResponse(org.xdi.oxauth.client.RegisterResponse) ConfigurationException(org.xdi.util.exception.ConfigurationException) RegisterClient(org.xdi.oxauth.client.RegisterClient)

Example 4 with ConfigurationException

use of org.xdi.util.exception.ConfigurationException 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

ConfigurationException (org.xdi.util.exception.ConfigurationException)4 OpenIdConfigurationClient (org.xdi.oxauth.client.OpenIdConfigurationClient)2 OpenIdConfigurationResponse (org.xdi.oxauth.client.OpenIdConfigurationResponse)2 File (java.io.File)1 BaseMappingException (org.gluu.persist.exception.mapping.BaseMappingException)1 RegisterClient (org.xdi.oxauth.client.RegisterClient)1 RegisterRequest (org.xdi.oxauth.client.RegisterRequest)1 RegisterResponse (org.xdi.oxauth.client.RegisterResponse)1 FileConfiguration (org.xdi.util.properties.FileConfiguration)1