Search in sources :

Example 1 with SmtpConfiguration

use of org.gluu.model.SmtpConfiguration in project oxAuth by GluuFederation.

the class ApplicationFactory method getSmtpConfiguration.

@Produces
@RequestScoped
public SmtpConfiguration getSmtpConfiguration() {
    GluuConfiguration configuration = configurationService.getConfiguration();
    SmtpConfiguration smtpConfiguration = configuration.getSmtpConfiguration();
    if (smtpConfiguration == null) {
        return new SmtpConfiguration();
    }
    configurationService.decryptSmtpPassword(smtpConfiguration);
    return smtpConfiguration;
}
Also used : SmtpConfiguration(org.gluu.model.SmtpConfiguration) GluuConfiguration(org.oxauth.persistence.model.configuration.GluuConfiguration) Produces(javax.enterprise.inject.Produces) RequestScoped(javax.enterprise.context.RequestScoped)

Example 2 with SmtpConfiguration

use of org.gluu.model.SmtpConfiguration in project oxTrust by GluuFederation.

the class UpdateOrganizationAction method modifyApplliance.

private String modifyApplliance() {
    if (this.configuration != null) {
        return OxTrustConstants.RESULT_SUCCESS;
    }
    try {
        this.configuration = configurationService.getConfiguration();
        if (this.configuration == null) {
            return OxTrustConstants.RESULT_FAILURE;
        }
        this.smtpConfiguration = this.configuration.getSmtpConfiguration();
        if (this.smtpConfiguration == null) {
            this.smtpConfiguration = new SmtpConfiguration();
            this.configuration.setSmtpConfiguration(smtpConfiguration);
        }
        configurationService.decryptSmtpPassword(smtpConfiguration);
        return OxTrustConstants.RESULT_SUCCESS;
    } catch (Exception ex) {
        log.error("an error occured", ex);
        return OxTrustConstants.RESULT_FAILURE;
    }
}
Also used : SmtpConfiguration(org.gluu.model.SmtpConfiguration) BasePersistenceException(org.gluu.persist.exception.BasePersistenceException) IOException(java.io.IOException)

Example 3 with SmtpConfiguration

use of org.gluu.model.SmtpConfiguration in project oxTrust by GluuFederation.

the class ApplicationFactory method getSmtpConfiguration.

@Produces
@RequestScoped
public SmtpConfiguration getSmtpConfiguration() {
    GluuConfiguration configuration = configurationService.getConfiguration();
    SmtpConfiguration smtpConfiguration = configuration.getSmtpConfiguration();
    if (smtpConfiguration == null) {
        return new SmtpConfiguration();
    }
    configurationService.decryptSmtpPassword(smtpConfiguration);
    return smtpConfiguration;
}
Also used : SmtpConfiguration(org.gluu.model.SmtpConfiguration) GluuConfiguration(org.gluu.oxtrust.model.GluuConfiguration) Produces(javax.enterprise.inject.Produces) RequestScoped(javax.enterprise.context.RequestScoped)

Example 4 with SmtpConfiguration

use of org.gluu.model.SmtpConfiguration in project oxTrust by GluuFederation.

the class SmtpConfigurationWebResource method testSmtpConfiguration.

@GET
@Path(ApiConstants.TEST)
@Operation(summary = "Test smtp configuration", description = "Test smtp configuration")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = SmtpConfiguration.class)), description = Constants.RESULT_SUCCESS), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { READ_ACCESS })
public Response testSmtpConfiguration() {
    try {
        SmtpConfiguration smtpConfiguration = configurationService.getConfiguration().getSmtpConfiguration();
        String password = encryptionService.decrypt(smtpConfiguration.getPassword());
        smtpConfiguration.setPasswordDecrypted(password);
        boolean result = mailService.sendMail(smtpConfiguration, smtpConfiguration.getFromEmailAddress(), smtpConfiguration.getFromName(), smtpConfiguration.getFromEmailAddress(), null, "SMTP Configuration verification", "Mail to test smtp configuration", "Mail to test smtp configuration");
        return Response.ok(result ? true : false).build();
    } catch (Exception e) {
        log(logger, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : SmtpConfiguration(org.gluu.model.SmtpConfiguration) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 5 with SmtpConfiguration

use of org.gluu.model.SmtpConfiguration 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)

Aggregations

SmtpConfiguration (org.gluu.model.SmtpConfiguration)7 IOException (java.io.IOException)2 RequestScoped (javax.enterprise.context.RequestScoped)2 Produces (javax.enterprise.inject.Produces)2 GluuConfiguration (org.gluu.oxtrust.model.GluuConfiguration)2 Operation (io.swagger.v3.oas.annotations.Operation)1 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)1 HttpEntity (org.apache.http.HttpEntity)1 HttpResponse (org.apache.http.HttpResponse)1 ParseException (org.apache.http.ParseException)1 HttpPut (org.apache.http.client.methods.HttpPut)1 ByteArrayEntity (org.apache.http.entity.ByteArrayEntity)1 ProtectedApi (org.gluu.oxtrust.service.filter.ProtectedApi)1 BasePersistenceException (org.gluu.persist.exception.BasePersistenceException)1 Test (org.junit.Test)1 GluuConfiguration (org.oxauth.persistence.model.configuration.GluuConfiguration)1