use of org.gluu.oxtrust.model.GluuAppliance in project oxTrust by GluuFederation.
the class ConfigureLogViewerAction method updateAppliance.
private void updateAppliance() {
GluuAppliance updateAppliance = applianceService.getAppliance();
try {
updateAppliance.setOxLogViewerConfig(jsonService.objectToJson(logViewerConfiguration));
updateAppliance.setOxLogConfigLocation(oxTrustLogConfigLocation);
applianceService.updateAppliance(updateAppliance);
loggerService.updateLoggerConfigLocation();
} catch (Exception ex) {
log.error("Failed to save log viewer configuration '{}'", ex);
}
}
use of org.gluu.oxtrust.model.GluuAppliance in project oxTrust by GluuFederation.
the class ManageCertificateAction method updateTrustCertificates.
private boolean updateTrustCertificates() {
try {
// Reload entry to include latest changes
GluuAppliance tmpAppliance = applianceService.getAppliance();
TrustStoreConfiguration currTrustStoreConfiguration = tmpAppliance.getTrustStoreConfiguration();
List<TrustStoreCertificate> currTrustStoreCertificates = tmpAppliance.getTrustStoreCertificates();
if (currTrustStoreCertificates == null) {
currTrustStoreCertificates = new ArrayList<TrustStoreCertificate>(0);
}
if (!trustStoreConfiguration.equals(currTrustStoreConfiguration) || !trustStoreCertificates.equals(currTrustStoreCertificates)) {
this.wereAnyChanges = true;
}
tmpAppliance.setTrustStoreConfiguration(trustStoreConfiguration);
if (trustStoreCertificates.size() == 0) {
tmpAppliance.setTrustStoreCertificates(null);
} else {
tmpAppliance.setTrustStoreCertificates(trustStoreCertificates);
}
applianceService.updateAppliance(tmpAppliance);
} catch (BaseMappingException ex) {
log.error("Failed to update appliance configuration", ex);
facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to update appliance");
return false;
}
return true;
}
use of org.gluu.oxtrust.model.GluuAppliance in project oxTrust by GluuFederation.
the class PasswordReminderAction method requestReminderImpl.
public String requestReminderImpl() throws Exception {
if (enabled()) {
FacesContext facesContext = FacesContext.getCurrentInstance();
if (facesContext == null) {
return OxTrustConstants.RESULT_FAILURE;
}
ExternalContext externalContext = facesContext.getExternalContext();
if (externalContext == null) {
return OxTrustConstants.RESULT_FAILURE;
}
HttpServletRequest httpServletRequest = (HttpServletRequest) externalContext.getRequest();
GluuCustomPerson person = new GluuCustomPerson();
person.setMail(email);
List<GluuCustomPerson> matchedPersons = personService.findPersons(person, 0);
if (matchedPersons != null && matchedPersons.size() > 0) {
GluuAppliance appliance = applianceService.getAppliance();
OrganizationalUnit requests = new OrganizationalUnit();
requests.setOu("resetPasswordRequests");
requests.setDn("ou=resetPasswordRequests," + appliance.getDn());
if (!ldapEntryManager.contains(requests)) {
ldapEntryManager.persist(requests);
}
PasswordResetRequest request = new PasswordResetRequest();
do {
request.setCreationDate(Calendar.getInstance().getTime());
request.setPersonInum(matchedPersons.get(0).getInum());
request.setOxGuid(StringHelper.getRandomString(16));
request.setBaseDn("oxGuid=" + request.getOxGuid() + ", ou=resetPasswordRequests," + appliance.getDn());
} while (ldapEntryManager.contains(request));
rendererParameters.setParameter("givenName", matchedPersons.get(0).getGivenName());
rendererParameters.setParameter("organizationName", organizationService.getOrganization().getDisplayName());
rendererParameters.setParameter("resetLink", appConfiguration.getApplianceUrl() + httpServletRequest.getContextPath() + "/resetPassword/" + request.getOxGuid());
String subj = facesMessages.evalResourceAsString("#{msg['mail.reset.found.message.subject']}");
String messagePlain = facesMessages.evalResourceAsString("#{msg['mail.reset.found.message.plain.body']}");
String messageHtml = facesMessages.evalResourceAsString("#{msg['mail.reset.found.message.html.body']}");
// rendererParameters.setParameter("mail_body", messageHtml);
// String mailHtml = renderService.renderView("/WEB-INF/mail/reset_password.xhtml");
mailService.sendMail(email, null, subj, messagePlain, messageHtml);
ldapEntryManager.persist(request);
} else {
GluuAppliance appliance = applianceService.getAppliance();
SmtpConfiguration smtpConfiguration = appliance.getSmtpConfiguration();
rendererParameters.setParameter("organizationName", organizationService.getOrganization().getDisplayName());
String fromName = smtpConfiguration.getFromName();
if (fromName == null) {
fromName = String.format("%1$s identity server", organizationService.getOrganization().getDisplayName());
}
String subj = facesMessages.evalResourceAsString("#{msg['mail.reset.not_found.message.subject']}");
String messagePlain = facesMessages.evalResourceAsString("#{msg['mail.reset.not_found.message.plain.body']}");
String messageHtml = facesMessages.evalResourceAsString("#{msg['mail.reset.not_found.message.html.body']}");
// rendererParameters.setParameter("mail_body", messageHtml);
// String mailHtml = renderService.renderView("/WEB-INF/mail/reset_password.xhtml");
mailService.sendMail(null, fromName, email, null, subj, messagePlain, messageHtml);
}
return OxTrustConstants.RESULT_SUCCESS;
}
return OxTrustConstants.RESULT_FAILURE;
}
use of org.gluu.oxtrust.model.GluuAppliance in project oxTrust by GluuFederation.
the class PasswordReminderAction method enabled.
public boolean enabled() {
GluuAppliance appliance = applianceService.getAppliance();
SmtpConfiguration smtpConfiguration = appliance.getSmtpConfiguration();
boolean valid = smtpConfiguration != null && smtpConfiguration.getHost() != null && smtpConfiguration.getPort() != 0 && ((!smtpConfiguration.isRequiresAuthentication()) || (smtpConfiguration.getUserName() != null && smtpConfiguration.getPassword() != null)) && appliance.getPasswordResetAllowed() != null && appliance.getPasswordResetAllowed().isBooleanValue();
if (valid) {
if (recaptchaService.isEnabled()) {
valid = recaptchaService.verifyRecaptchaResponse();
if (!valid)
facesMessages.add(FacesMessage.SEVERITY_ERROR, "Please check your input and CAPTCHA answer.");
}
} else {
facesMessages.add(FacesMessage.SEVERITY_ERROR, "Sorry the Password Reminder functionality is not enabled.Please contact to administrator.");
}
return valid;
}
use of org.gluu.oxtrust.model.GluuAppliance in project oxTrust by GluuFederation.
the class PasswordResetAction method start.
public String start() throws ParseException {
GluuAppliance appliance = applianceService.getAppliance();
this.request = ldapEntryManager.find(PasswordResetRequest.class, "oxGuid=" + this.guid + ",ou=resetPasswordRequests," + appliance.getDn());
Calendar requestCalendarExpiry = Calendar.getInstance();
Calendar currentCalendar = Calendar.getInstance();
if (request != null) {
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy");
requestCalendarExpiry.setTime(request.getCreationDate());
requestCalendarExpiry.add(Calendar.HOUR, 2);
}
GluuCustomPerson person = personService.getPersonByInum(request.getPersonInum());
GluuCustomAttribute question = null;
if (person != null) {
question = person.getGluuCustomAttribute("secretQuestion");
}
if (request != null && requestCalendarExpiry.after(currentCalendar)) {
if (question != null) {
securityQuestion = question.getValue();
}
return OxTrustConstants.RESULT_SUCCESS;
} else {
facesMessages.add(FacesMessage.SEVERITY_ERROR, "Your link is not valid or your user is not allowed to perform a password reset. If you want to initiate a reset password procedure please fill this form.");
conversationService.endConversation();
return OxTrustConstants.RESULT_FAILURE;
}
}
Aggregations