Search in sources :

Example 26 with GluuAppliance

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;
    }
}
Also used : GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson) GluuAppliance(org.gluu.oxtrust.model.GluuAppliance)

Example 27 with GluuAppliance

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;
}
Also used : GluuAppliance(org.gluu.oxtrust.model.GluuAppliance)

Example 28 with GluuAppliance

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;
}
Also used : TrustStoreConfiguration(org.gluu.oxtrust.model.cert.TrustStoreConfiguration) GluuAppliance(org.gluu.oxtrust.model.GluuAppliance) TrustStoreCertificate(org.gluu.oxtrust.model.cert.TrustStoreCertificate) LdapMappingException(org.gluu.site.ldap.persistence.exception.LdapMappingException)

Example 29 with GluuAppliance

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;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) PasswordResetRequest(org.gluu.oxtrust.model.PasswordResetRequest) FacesContext(javax.faces.context.FacesContext) GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson) OrganizationalUnit(org.gluu.oxtrust.model.OrganizationalUnit) GluuAppliance(org.gluu.oxtrust.model.GluuAppliance) ExternalContext(javax.faces.context.ExternalContext) MailUtils(org.gluu.oxtrust.util.MailUtils)

Example 30 with GluuAppliance

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;
}
Also used : GluuAppliance(org.gluu.oxtrust.model.GluuAppliance)

Aggregations

GluuAppliance (org.gluu.oxtrust.model.GluuAppliance)36 Date (java.util.Date)8 LdapMappingException (org.gluu.site.ldap.persistence.exception.LdapMappingException)7 IOException (java.io.IOException)5 GluuCustomPerson (org.gluu.oxtrust.model.GluuCustomPerson)5 GluuCustomAttribute (org.gluu.oxtrust.model.GluuCustomAttribute)4 File (java.io.File)3 SimpleDateFormat (java.text.SimpleDateFormat)3 ArrayList (java.util.ArrayList)3 BaseTest (org.gluu.oxtrust.action.test.BaseTest)3 PasswordResetRequest (org.gluu.oxtrust.model.PasswordResetRequest)3 TrustStoreCertificate (org.gluu.oxtrust.model.cert.TrustStoreCertificate)3 Test (org.testng.annotations.Test)3 ParseException (java.text.ParseException)2 Calendar (java.util.Calendar)2 AuthenticationFailedException (javax.mail.AuthenticationFailedException)2 MessagingException (javax.mail.MessagingException)2 OxIDPAuthConf (org.gluu.oxtrust.model.OxIDPAuthConf)2 TrustStoreConfiguration (org.gluu.oxtrust.model.cert.TrustStoreConfiguration)2 MailUtils (org.gluu.oxtrust.util.MailUtils)2