Search in sources :

Example 1 with GluuAppliance

use of org.xdi.oxauth.model.appliance.GluuAppliance in project oxAuth by GluuFederation.

the class AppInitializer method loadAppliance.

private GluuAppliance loadAppliance(LdapEntryManager localLdapEntryManager, String... ldapReturnAttributes) {
    String baseDn = configurationFactory.getBaseDn().getAppliance();
    String applianceInum = configurationFactory.getAppConfiguration().getApplianceInum();
    if (StringHelper.isEmpty(baseDn) || StringHelper.isEmpty(applianceInum)) {
        return null;
    }
    String applianceDn = String.format("inum=%s,%s", applianceInum, baseDn);
    GluuAppliance appliance = null;
    try {
        appliance = localLdapEntryManager.find(GluuAppliance.class, applianceDn, ldapReturnAttributes);
    } catch (LdapMappingException ex) {
        log.error("Failed to load appliance entry from Ldap", ex);
        return null;
    }
    return appliance;
}
Also used : GluuAppliance(org.xdi.oxauth.model.appliance.GluuAppliance) LdapMappingException(org.gluu.site.ldap.persistence.exception.LdapMappingException)

Example 2 with GluuAppliance

use of org.xdi.oxauth.model.appliance.GluuAppliance in project oxAuth by GluuFederation.

the class AppInitializer method setDefaultAuthenticationMethod.

private void setDefaultAuthenticationMethod(LdapEntryManager localLdapEntryManager) {
    GluuAppliance appliance = loadAppliance(localLdapEntryManager, "oxAuthenticationMode");
    authenticationMode = null;
    if (appliance != null) {
        this.authenticationMode = new AuthenticationMode(appliance.getAuthenticationMode());
    }
    authenticationModeInstance.destroy(authenticationModeInstance.get());
}
Also used : AuthenticationMode(org.xdi.oxauth.model.auth.AuthenticationMode) GluuAppliance(org.xdi.oxauth.model.appliance.GluuAppliance)

Example 3 with GluuAppliance

use of org.xdi.oxauth.model.appliance.GluuAppliance in project oxAuth by GluuFederation.

the class LdapCustomAuthenticationConfigurationService method getCustomAuthenticationConfigurations.

public List<CustomAuthenticationConfiguration> getCustomAuthenticationConfigurations() {
    GluuAppliance gluuAppliance = applianceService.getAppliance();
    List<String> configurationJsons = gluuAppliance.getOxIDPAuthentication();
    List<CustomAuthenticationConfiguration> customAuthenticationConfigurations = new ArrayList<CustomAuthenticationConfiguration>();
    if (configurationJsons == null) {
        return customAuthenticationConfigurations;
    }
    for (String configurationJson : configurationJsons) {
        oxIDPAuthConf configuration;
        try {
            configuration = (oxIDPAuthConf) jsonToObject(configurationJson, oxIDPAuthConf.class);
            if (configuration.getEnabled() && configuration.getType().equalsIgnoreCase("customAuthentication")) {
                CustomAuthenticationConfiguration customAuthenticationConfiguration = mapCustomAuthentication(configuration);
                customAuthenticationConfigurations.add(customAuthenticationConfiguration);
            }
        } catch (Exception ex) {
            log.error("Failed to create object by json: '{}'", ex, configurationJson);
        }
    }
    return customAuthenticationConfigurations;
}
Also used : GluuAppliance(org.xdi.oxauth.model.appliance.GluuAppliance) ArrayList(java.util.ArrayList) CustomAuthenticationConfiguration(org.xdi.model.config.CustomAuthenticationConfiguration) org.xdi.oxauth.model.config.oxIDPAuthConf(org.xdi.oxauth.model.config.oxIDPAuthConf)

Example 4 with GluuAppliance

use of org.xdi.oxauth.model.appliance.GluuAppliance in project oxAuth by GluuFederation.

the class AppInitializer method loadLdapIdpAuthConfigs.

private List<oxIDPAuthConf> loadLdapIdpAuthConfigs(LdapEntryManager localLdapEntryManager) {
    GluuAppliance appliance = loadAppliance(localLdapEntryManager, "oxIDPAuthentication");
    if ((appliance == null) || (appliance.getOxIDPAuthentication() == null)) {
        return null;
    }
    List<oxIDPAuthConf> configurations = new ArrayList<oxIDPAuthConf>();
    for (String configurationJson : appliance.getOxIDPAuthentication()) {
        try {
            oxIDPAuthConf configuration = (oxIDPAuthConf) jsonToObject(configurationJson, oxIDPAuthConf.class);
            if (configuration.getType().equalsIgnoreCase("ldap") || configuration.getType().equalsIgnoreCase("auth")) {
                configurations.add(configuration);
            }
        } catch (Exception ex) {
            log.error("Failed to create object by json: '{}'", ex, configurationJson);
        }
    }
    return configurations;
}
Also used : GluuAppliance(org.xdi.oxauth.model.appliance.GluuAppliance) ArrayList(java.util.ArrayList) org.xdi.oxauth.model.config.oxIDPAuthConf(org.xdi.oxauth.model.config.oxIDPAuthConf) ConfigurationException(org.xdi.exception.ConfigurationException) LdapMappingException(org.gluu.site.ldap.persistence.exception.LdapMappingException) EncryptionException(org.xdi.util.security.StringEncrypter.EncryptionException)

Example 5 with GluuAppliance

use of org.xdi.oxauth.model.appliance.GluuAppliance in project oxAuth by GluuFederation.

the class ApplicationFactory method getSmtpConfiguration.

@Produces
@ApplicationScoped
public SmtpConfiguration getSmtpConfiguration() {
    GluuAppliance appliance = applianceService.getAppliance();
    SmtpConfiguration smtpConfiguration = appliance.getSmtpConfiguration();
    if (smtpConfiguration == null) {
        return null;
    }
    String password = smtpConfiguration.getPassword();
    if (StringHelper.isNotEmpty(password)) {
        try {
            smtpConfiguration.setPasswordDecrypted(encryptionService.decrypt(password));
        } catch (EncryptionException ex) {
            log.error("Failed to decript SMTP user password", ex);
        }
    }
    return smtpConfiguration;
}
Also used : GluuAppliance(org.xdi.oxauth.model.appliance.GluuAppliance) SmtpConfiguration(org.xdi.model.SmtpConfiguration) EncryptionException(org.xdi.util.security.StringEncrypter.EncryptionException) Produces(javax.enterprise.inject.Produces) ApplicationScoped(javax.enterprise.context.ApplicationScoped)

Aggregations

GluuAppliance (org.xdi.oxauth.model.appliance.GluuAppliance)5 ArrayList (java.util.ArrayList)2 LdapMappingException (org.gluu.site.ldap.persistence.exception.LdapMappingException)2 org.xdi.oxauth.model.config.oxIDPAuthConf (org.xdi.oxauth.model.config.oxIDPAuthConf)2 EncryptionException (org.xdi.util.security.StringEncrypter.EncryptionException)2 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 Produces (javax.enterprise.inject.Produces)1 ConfigurationException (org.xdi.exception.ConfigurationException)1 SmtpConfiguration (org.xdi.model.SmtpConfiguration)1 CustomAuthenticationConfiguration (org.xdi.model.config.CustomAuthenticationConfiguration)1 AuthenticationMode (org.xdi.oxauth.model.auth.AuthenticationMode)1