use of org.gluu.oxtrust.model.GluuAppliance in project oxTrust by GluuFederation.
the class BaseScimWebService method getAuthorizedUser.
protected boolean getAuthorizedUser() {
try {
GluuCustomPerson authUser = identity.getUser();
if (authUser == null) {
return false;
}
GluuAppliance appliance = applianceService.getAppliance();
if (appliance == null) {
return false;
}
if (!(GluuBoolean.TRUE.equals(appliance.getScimEnabled()) || GluuBoolean.ENABLED.equals(appliance.getScimEnabled()))) {
return false;
}
return true;
} catch (Exception ex) {
log.error("Exception: ", ex);
return false;
}
}
use of org.gluu.oxtrust.model.GluuAppliance in project oxTrust by GluuFederation.
the class ScimConfigureAction method init.
public String init() {
if (isInitialized) {
return OxTrustConstants.RESULT_SUCCESS;
}
GluuAppliance appliance = applianceService.getAppliance();
if ((appliance.getScimEnabled() == null) || !appliance.getScimEnabled().isBooleanValue()) {
return OxTrustConstants.RESULT_DISABLED;
}
this.isInitialized = true;
return OxTrustConstants.RESULT_SUCCESS;
}
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 (LdapMappingException 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 requestReminder.
public String requestReminder() 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));
String subj = String.format("Password reset was requested at %1$s identity server", organizationService.getOrganization().getDisplayName());
MailUtils mail = new MailUtils(appliance.getSmtpHost(), appliance.getSmtpPort(), appliance.isRequiresSsl(), appliance.isRequiresAuthentication(), appliance.getSmtpUserName(), applianceService.getDecryptedSmtpPassword(appliance));
mail.sendMail(appliance.getSmtpFromName() + " <" + appliance.getSmtpFromEmailAddress() + ">", email, subj, String.format(MESSAGE_FOUND, matchedPersons.get(0).getGivenName(), organizationService.getOrganization().getDisplayName(), appConfiguration.getApplianceUrl() + httpServletRequest.getContextPath() + "/resetPassword/" + request.getOxGuid()));
ldapEntryManager.persist(request);
} else {
GluuAppliance appliance = applianceService.getAppliance();
String subj = String.format("Password reset was requested at %1$s identity server", organizationService.getOrganization().getDisplayName());
MailUtils mail = new MailUtils(appliance.getSmtpHost(), appliance.getSmtpPort(), appliance.isRequiresSsl(), appliance.isRequiresAuthentication(), appliance.getSmtpUserName(), applianceService.getDecryptedSmtpPassword(appliance));
String fromName = appliance.getSmtpFromName();
if (fromName == null) {
fromName = String.format("%1$s identity server", organizationService.getOrganization().getDisplayName());
}
mail.sendMail(fromName + " <" + appliance.getSmtpFromEmailAddress() + ">", email, subj, String.format(MESSAGE_NOT_FOUND, organizationService.getOrganization().getDisplayName()));
}
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();
boolean valid = appliance.getSmtpHost() != null && appliance.getSmtpPort() != null && ((!appliance.isRequiresAuthentication()) || (appliance.getSmtpUserName() != null && applianceService.getDecryptedSmtpPassword(appliance) != 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;
}
Aggregations