Search in sources :

Example 1 with EncryptionException

use of org.gluu.util.security.StringEncrypter.EncryptionException 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 2 with EncryptionException

use of org.gluu.util.security.StringEncrypter.EncryptionException 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 3 with EncryptionException

use of org.gluu.util.security.StringEncrypter.EncryptionException in project oxTrust by GluuFederation.

the class Shibboleth3ConfService method prepareVelocityContext.

private VelocityContext prepareVelocityContext(HashMap<String, Object> trustParams, HashMap<String, Object> attrParams, HashMap<String, Object> casParams, HashMap<String, Object> attrResolverParams, String idpMetadataFolder) {
    VelocityContext context = new VelocityContext();
    context.put("StringHelper", StringHelper.class);
    context.put("salt", configurationFactory.getCryptoConfigurationSalt());
    context.put("trustParams", trustParams);
    context.put("attrParams", attrParams);
    context.put("casParams", casParams);
    context.put("resovlerParams", attrResolverParams);
    context.put("medataFolder", idpMetadataFolder);
    context.put("orgInum", StringHelper.removePunctuation("gluu"));
    context.put("orgSupportEmail", appConfiguration.getOrgSupportEmail());
    String idpUrl = appConfiguration.getIdpUrl();
    context.put("idpUrl", idpUrl);
    String idpHost = idpUrl.replaceAll(":[0-9]*$", "");
    context.put("idpHost", idpHost);
    String spUrl = appConfiguration.getApplicationUrl();
    context.put("spUrl", spUrl);
    String spHost = spUrl.replaceAll(":[0-9]*$", "").replaceAll("^.*?//", "");
    context.put("spHost", spHost);
    String gluuSPInum = configurationService.getConfiguration().getGluuSPTR();
    GluuSAMLTrustRelationship gluuSP = trustService.getRelationshipByInum(gluuSPInum);
    if (gluuSP == null) {
        gluuSP = new GluuSAMLTrustRelationship();
    }
    String gluuSPEntityId = gluuSP.getEntityId();
    context.put("gluuSPEntityId", gluuSPEntityId);
    // white spaces or comma
    String regx = "\\s*(=>|,|\\s)\\s*";
    String[] ldapUrls = appConfiguration.getIdpLdapServer().split(regx);
    String ldapUrl = "";
    if (ldapUrls != null) {
        for (String ldapServer : ldapUrls) {
            if (ldapUrl.length() > 1)
                ldapUrl = ldapUrl + " ";
            ldapUrl = ldapUrl + appConfiguration.getIdpLdapProtocol() + "://" + ldapServer;
        }
    } else {
        ldapUrl = appConfiguration.getIdpLdapProtocol() + "://" + appConfiguration.getIdpLdapServer();
    }
    context.put("ldapUrl", ldapUrl);
    context.put("bindDN", appConfiguration.getIdpBindDn());
    try {
        context.put("ldapPass", encryptionService.decrypt(appConfiguration.getIdpBindPassword()));
    } catch (EncryptionException e) {
        log.error("Failed to decrypt bindPassword", e);
        e.printStackTrace();
    }
    context.put("securityKey", appConfiguration.getIdpSecurityKey());
    context.put("securityCert", appConfiguration.getIdpSecurityCert());
    try {
        context.put("securityKeyPassword", encryptionService.decrypt(appConfiguration.getIdpSecurityKeyPassword()));
    } catch (EncryptionException e) {
        log.error("Failed to decrypt idp.securityKeyPassword", e);
        e.printStackTrace();
    }
    return context;
}
Also used : GluuSAMLTrustRelationship(org.gluu.oxtrust.model.GluuSAMLTrustRelationship) VelocityContext(org.apache.velocity.VelocityContext) EncryptionException(org.gluu.util.security.StringEncrypter.EncryptionException)

Example 4 with EncryptionException

use of org.gluu.util.security.StringEncrypter.EncryptionException in project oxTrust by GluuFederation.

the class Shibboleth3ConfService method generateIdpConfigurationFiles.

public boolean generateIdpConfigurationFiles() {
    if (appConfiguration.getShibboleth3IdpRootDir() == null) {
        throw new InvalidConfigurationException("Failed to update configuration due to undefined IDP root folder");
    }
    String idpConfFolder = getIdpConfDir();
    // Prepare data for files
    VelocityContext context = new VelocityContext();
    // white spaces or comma
    String regx = "\\s*(=>|,|\\s)\\s*";
    String[] ldapUrls = appConfiguration.getIdpLdapServer().split(regx);
    String ldapUrl = "";
    if (ldapUrls != null) {
        for (String ldapServer : ldapUrls) {
            if (ldapUrl.length() > 1) {
                ldapUrl = ldapUrl + " ";
            }
            ldapUrl = ldapUrl + appConfiguration.getIdpLdapProtocol() + "://" + ldapServer;
        }
    } else {
        ldapUrl = appConfiguration.getIdpLdapProtocol() + "://" + appConfiguration.getIdpLdapServer();
    }
    String host = ldapUrl;
    String base = appConfiguration.getBaseDN();
    String serviceUser = appConfiguration.getIdpBindDn();
    String serviceCredential = "";
    try {
        serviceCredential = encryptionService.decrypt(appConfiguration.getIdpBindPassword());
    } catch (EncryptionException e) {
        log.error("Failed to decrypt bindPassword", e);
        e.printStackTrace();
    }
    String userField = appConfiguration.getIdpUserFields();
    context.put("host", host);
    context.put("base", base);
    context.put("serviceUser", serviceUser);
    context.put("serviceCredential", serviceCredential);
    context.put("userField", userField);
    // Generate login.config
    String loginConfig = generateConfFile(SHIB3_IDP_LOGIN_CONFIG_FILE, context);
    boolean result = (loginConfig != null);
    // Write login.config
    result &= writeConfFile(idpConfFolder + SHIB3_IDP_LOGIN_CONFIG_FILE, loginConfig);
    return result;
}
Also used : VelocityContext(org.apache.velocity.VelocityContext) EncryptionException(org.gluu.util.security.StringEncrypter.EncryptionException) InvalidConfigurationException(org.gluu.util.exception.InvalidConfigurationException)

Example 5 with EncryptionException

use of org.gluu.util.security.StringEncrypter.EncryptionException in project oxTrust by GluuFederation.

the class JsonConfigurationAction method getProtectedOxAuthAppConfiguration.

private String getProtectedOxAuthAppConfiguration(String oxAuthAppConfiguration) {
    if (oxAuthAppConfiguration != null) {
        try {
            org.gluu.oxauth.model.configuration.AppConfiguration appConfiguration = jsonService.jsonToObject(oxAuthAppConfiguration, org.gluu.oxauth.model.configuration.AppConfiguration.class);
            // Add missing config if needed
            if (appConfiguration.getCibaEndUserNotificationConfig() == null) {
                appConfiguration.setCibaEndUserNotificationConfig(new CIBAEndUserNotificationConfig());
                appConfiguration.getCibaEndUserNotificationConfig().setNotificationKey("");
            }
            try {
                String decryptedKey = encryptionService.decrypt(appConfiguration.getCibaEndUserNotificationConfig().getNotificationKey());
                appConfiguration.getCibaEndUserNotificationConfig().setNotificationKey(decryptedKey);
            } catch (EncryptionException ex) {
                log.error("Failed to decrypt values in the oxAuth json configuration: '{}'", oxAuthAppConfiguration, ex);
                appConfiguration.getCibaEndUserNotificationConfig().setNotificationKey("");
            }
            return jsonService.objectToJson(appConfiguration);
        } catch (Exception e) {
            log.error("Problems processing oxAuth App configuration file: {}", oxAuthAppConfiguration, e);
            return null;
        }
    }
    return null;
}
Also used : EncryptionException(org.gluu.util.security.StringEncrypter.EncryptionException) CIBAEndUserNotificationConfig(org.gluu.oxauth.model.configuration.CIBAEndUserNotificationConfig) EncryptionException(org.gluu.util.security.StringEncrypter.EncryptionException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

EncryptionException (org.gluu.util.security.StringEncrypter.EncryptionException)9 VelocityContext (org.apache.velocity.VelocityContext)2 ConfigurationException (org.gluu.util.exception.ConfigurationException)2 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Properties (java.util.Properties)1 Cookie (javax.servlet.http.Cookie)1 HttpSession (javax.servlet.http.HttpSession)1 RelyingPartyContext (net.shibboleth.idp.profile.context.RelyingPartyContext)1 FileConfiguration (org.gluu.orm.util.properties.FileConfiguration)1 AuthorizationRequest (org.gluu.oxauth.client.AuthorizationRequest)1 TokenClient (org.gluu.oxauth.client.TokenClient)1 TokenResponse (org.gluu.oxauth.client.TokenResponse)1 UserInfoClient (org.gluu.oxauth.client.UserInfoClient)1 UserInfoResponse (org.gluu.oxauth.client.UserInfoResponse)1 JwtState (org.gluu.oxauth.client.model.JwtState)1 OAuthData (org.gluu.oxauth.client.session.OAuthData)1 ResponseType (org.gluu.oxauth.model.common.ResponseType)1 CIBAEndUserNotificationConfig (org.gluu.oxauth.model.configuration.CIBAEndUserNotificationConfig)1 OxAuthCryptoProvider (org.gluu.oxauth.model.crypto.OxAuthCryptoProvider)1