use of org.gluu.oxtrust.model.GluuConfiguration in project oxTrust by GluuFederation.
the class ManageCertificateAction method updateTrustCertificates.
private boolean updateTrustCertificates() {
try {
GluuConfiguration tmpConfiguration = configurationService.getConfiguration();
TrustStoreConfiguration currTrustStoreConfiguration = tmpConfiguration.getTrustStoreConfiguration();
List<TrustStoreCertificate> currTrustStoreCertificates = tmpConfiguration.getTrustStoreCertificates();
if (currTrustStoreCertificates == null) {
currTrustStoreCertificates = new ArrayList<TrustStoreCertificate>(0);
}
if (!trustStoreConfiguration.equals(currTrustStoreConfiguration) || !trustStoreCertificates.equals(currTrustStoreCertificates)) {
this.wereAnyChanges = true;
}
tmpConfiguration.setTrustStoreConfiguration(trustStoreConfiguration);
if (trustStoreCertificates.size() == 0) {
tmpConfiguration.setTrustStoreCertificates(null);
} else {
tmpConfiguration.setTrustStoreCertificates(trustStoreCertificates);
}
configurationService.updateConfiguration(tmpConfiguration);
} catch (BasePersistenceException ex) {
log.error("Failed to update configuration configuration", ex);
facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to update configuration");
return false;
}
return true;
}
use of org.gluu.oxtrust.model.GluuConfiguration in project oxTrust by GluuFederation.
the class UpdateTrustRelationshipAction method updateReleasedAttributes.
public void updateReleasedAttributes(GluuSAMLTrustRelationship trustRelationship) {
List<String> releasedAttributes = new ArrayList<String>();
String mailMsgPlain = "";
String mailMsgHtml = "";
for (GluuCustomAttribute customAttribute : trustRelationship.getReleasedCustomAttributes()) {
if (customAttribute.isNew()) {
rendererParameters.setParameter("attributeName", customAttribute.getName());
rendererParameters.setParameter("attributeDisplayName", customAttribute.getMetadata().getDisplayName());
rendererParameters.setParameter("attributeValue", customAttribute.getValue());
mailMsgPlain += facesMessages.evalResourceAsString("#{msgs['mail.trust.released.attribute.plain']}");
mailMsgHtml += facesMessages.evalResourceAsString("#{msgs['mail.trust.released.attribute.html']}");
rendererParameters.reset();
customAttribute.setNew(false);
}
releasedAttributes.add(customAttribute.getMetadata().getDn());
}
// send email notification
if (!StringUtils.isEmpty(mailMsgPlain)) {
try {
GluuConfiguration configuration = configurationService.getConfiguration();
if (configuration.getContactEmail() == null || configuration.getContactEmail().isEmpty())
log.warn("Failed to send the 'Attributes released' notification email: unconfigured contact email");
else if (configuration.getSmtpConfiguration() == null || StringHelper.isEmpty(configuration.getSmtpConfiguration().getHost()))
log.warn("Failed to send the 'Attributes released' notification email: unconfigured SMTP server");
else {
String subj = facesMessages.evalResourceAsString("#{msgs['mail.trust.released.subject']}");
rendererParameters.setParameter("trustRelationshipName", trustRelationship.getDisplayName());
rendererParameters.setParameter("trustRelationshipInum", trustRelationship.getInum());
String preMsgPlain = facesMessages.evalResourceAsString("#{msgs['mail.trust.released.name.plain']}");
String preMsgHtml = facesMessages.evalResourceAsString("#{msgs['mail.trust.released.name.html']}");
boolean result = mailService.sendMail(configuration.getContactEmail(), null, subj, preMsgPlain + mailMsgPlain, preMsgHtml + mailMsgHtml);
if (!result) {
log.error("Failed to send the notification email");
}
}
} catch (Exception ex) {
log.error("Failed to send the notification email: ", ex);
}
}
if (!releasedAttributes.isEmpty()) {
trustRelationship.setReleasedAttributes(releasedAttributes);
} else {
trustRelationship.setReleasedAttributes(null);
}
}
use of org.gluu.oxtrust.model.GluuConfiguration in project oxTrust by GluuFederation.
the class UpdateOrganizationAction method updateConfiguration.
private void updateConfiguration() {
GluuConfiguration configurationUpdate = configurationService.getConfiguration();
configurationUpdate.setPasswordResetAllowed(configuration.isPasswordResetAllowed());
configurationUpdate.setPassportEnabled(configuration.isPassportEnabled());
configurationUpdate.setRadiusEnabled(configuration.isRadiusEnabled());
configurationUpdate.setScimEnabled(configuration.isScimEnabled());
configurationUpdate.setProfileManagment(configuration.isProfileManagment());
configurationUpdate.setConfigurationDnsServer(configuration.getConfigurationDnsServer());
configurationUpdate.setMaxLogSize(configuration.getMaxLogSize());
configurationUpdate.setContactEmail(configuration.getContactEmail());
configurationUpdate.setSamlEnabled(configuration.isSamlEnabled());
configurationUpdate.setSmtpConfiguration(smtpConfiguration);
configurationService.updateConfiguration(configurationUpdate);
}
use of org.gluu.oxtrust.model.GluuConfiguration in project oxTrust by GluuFederation.
the class AuthenticationMethodWebResource method updateAuthenticationMethod.
@PUT
@Operation(summary = "Update authentication methods", description = "Update authentication methods")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = AuthenticationMethod.class)), description = Constants.RESULT_SUCCESS), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response updateAuthenticationMethod(AuthenticationMethod method) {
log(logger, "Processing updateAuthenticationMethod()");
try {
Preconditions.checkNotNull(method, "Attempt to update null method");
GluuConfiguration configuration = configurationService.getConfiguration();
if (method.getDefaultAcr() != null || method.getOxtrustAcr() != null) {
configuration.setAuthenticationMode(method.getDefaultAcr());
configuration.setOxTrustAuthenticationMode(method.getOxtrustAcr());
configurationService.updateConfiguration(configuration);
configuration = configurationService.getConfiguration();
method.setDefaultAcr(configuration.getAuthenticationMode());
method.setOxtrustAcr(configuration.getOxTrustAuthenticationMode());
return Response.ok(method).build();
} else {
return Response.status(Response.Status.PRECONDITION_FAILED).build();
}
} catch (Exception e) {
log(logger, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
}
use of org.gluu.oxtrust.model.GluuConfiguration in project oxTrust by GluuFederation.
the class CertificatesWebResource method trustStoreCertificates.
private List<X509CertificateShortInfo> trustStoreCertificates() {
try {
trustStoreCertificates = new ArrayList<X509CertificateShortInfo>();
GluuConfiguration configuration = configurationService.getConfiguration();
List<TrustStoreCertificate> trustStoreCertificatesList = configuration.getTrustStoreCertificates();
if (trustStoreCertificatesList != null) {
for (TrustStoreCertificate trustStoreCertificate : trustStoreCertificatesList) {
try {
X509Certificate[] certs = SSLService.loadCertificates(trustStoreCertificate.getCertificate().getBytes());
for (X509Certificate cert : certs) {
X509CertificateShortInfo entry = new X509CertificateShortInfo(trustStoreCertificate.getName(), cert);
trustStoreCertificates.add(entry);
}
} catch (Exception e) {
logger.error("Certificate load exception", e);
}
}
}
} catch (Exception e) {
logger.error("Load trustStoreCertificates configuration exception", e);
}
return trustStoreCertificates;
}
Aggregations