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;
}
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");
}
}
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;
}
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;
}
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;
}
Aggregations