Search in sources :

Example 31 with GluuConfiguration

use of org.gluu.oxtrust.model.GluuConfiguration in project oxTrust by GluuFederation.

the class PasswordReminderAction method enabled.

public boolean enabled() {
    GluuConfiguration configuration = configurationService.getConfiguration();
    SmtpConfiguration smtpConfiguration = configuration.getSmtpConfiguration();
    boolean valid = smtpConfiguration != null && smtpConfiguration.isValid() && configurationService.getConfiguration().isPasswordResetAllowed();
    if (valid) {
        passwordResetIsEnable = true;
        if (recaptchaService.isEnabled() && getAuthenticationRecaptchaEnabled()) {
            valid = recaptchaService.verifyRecaptchaResponse();
            if (!valid) {
                facesMessages.add(FacesMessage.SEVERITY_ERROR, facesMessages.evalResourceAsString("#{msgs['person.passwordreset.catch.checkInputAndCaptcha']}"));
            }
        }
    } else {
        facesMessages.add(FacesMessage.SEVERITY_ERROR, facesMessages.evalResourceAsString("#{msgs['person.passwordreset.notActivate']}"));
    }
    return valid;
}
Also used : SmtpConfiguration(org.gluu.model.SmtpConfiguration) GluuConfiguration(org.gluu.oxtrust.model.GluuConfiguration)

Example 32 with GluuConfiguration

use of org.gluu.oxtrust.model.GluuConfiguration in project oxTrust by GluuFederation.

the class Authenticator method oAuthLogin.

/**
 * Main entry point for oAuth authentication.
 *
 * @throws IOException
 *
 * @throws Exception
 */
public boolean oAuthLogin() throws IOException, Exception {
    Client client = ClientBuilder.newClient();
    WebTarget target = client.target(getAuthorizationUrl());
    String clientId = appConfiguration.getOxAuthClientId();
    String scope = appConfiguration.getOxAuthClientScope();
    String responseType = "code";
    String nonce = UUID.randomUUID().toString();
    String state = UUID.randomUUID().toString();
    target = target.queryParam(OxTrustConstants.OXAUTH_CLIENT_ID, clientId);
    target = target.queryParam(OxTrustConstants.OXAUTH_REDIRECT_URI, appConfiguration.getLoginRedirectUrl());
    target = target.queryParam(OxTrustConstants.OXAUTH_RESPONSE_TYPE, responseType);
    target = target.queryParam(OxTrustConstants.OXAUTH_SCOPE, scope);
    target = target.queryParam(OxTrustConstants.OXAUTH_NONCE, nonce);
    target = target.queryParam(OxTrustConstants.OXAUTH_STATE, state);
    // Store state and nonce
    identity.getSessionMap().put(OxTrustConstants.OXAUTH_NONCE, nonce);
    identity.getSessionMap().put(OxTrustConstants.OXAUTH_STATE, state);
    GluuConfiguration configuration = configurationService.getConfiguration(new String[] { "oxTrustAuthenticationMode" });
    String acrValues = configuration.getOxTrustAuthenticationMode();
    if (StringHelper.isNotEmpty(acrValues)) {
        target = target.queryParam(OxTrustConstants.OXAUTH_ACR_VALUES, acrValues);
        // Store authentication method
        identity.getSessionMap().put(OxTrustConstants.OXAUTH_ACR_VALUES, acrValues);
    }
    facesService.redirectToExternalURL(target.getUri().toString().replaceAll("%2B", "+"));
    return true;
}
Also used : WebTarget(javax.ws.rs.client.WebTarget) UserInfoClient(org.gluu.oxauth.client.UserInfoClient) Client(javax.ws.rs.client.Client) TokenClient(org.gluu.oxauth.client.TokenClient) GluuConfiguration(org.gluu.oxtrust.model.GluuConfiguration)

Aggregations

GluuConfiguration (org.gluu.oxtrust.model.GluuConfiguration)32 Date (java.util.Date)8 IOException (java.io.IOException)6 BasePersistenceException (org.gluu.persist.exception.BasePersistenceException)6 Operation (io.swagger.v3.oas.annotations.Operation)5 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)5 ProtectedApi (org.gluu.oxtrust.service.filter.ProtectedApi)5 TrustStoreCertificate (org.gluu.oxtrust.model.cert.TrustStoreCertificate)4 Parameters (org.testng.annotations.Parameters)3 Test (org.testng.annotations.Test)3 X509Certificate (java.security.cert.X509Certificate)2 ArrayList (java.util.ArrayList)2 GET (javax.ws.rs.GET)2 PUT (javax.ws.rs.PUT)2 AppConfiguration (org.gluu.config.oxtrust.AppConfiguration)2 SmtpConfiguration (org.gluu.model.SmtpConfiguration)2 GluuOxTrustStat (org.gluu.oxtrust.model.GluuOxTrustStat)2 TrustStoreConfiguration (org.gluu.oxtrust.model.cert.TrustStoreConfiguration)2 X509CertificateShortInfo (org.gluu.oxtrust.util.X509CertificateShortInfo)2 File (java.io.File)1