Search in sources :

Example 1 with SmtpConfiguration

use of io.jans.model.SmtpConfiguration in project jans by JanssenProject.

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(io.jans.model.SmtpConfiguration) GluuConfiguration(io.jans.as.persistence.model.configuration.GluuConfiguration) Produces(javax.enterprise.inject.Produces) RequestScoped(javax.enterprise.context.RequestScoped)

Example 2 with SmtpConfiguration

use of io.jans.model.SmtpConfiguration in project jans by JanssenProject.

the class ConfigSmtpResource method removeSmtpConfiguration.

@DELETE
@ProtectedApi(scopes = { ApiAccessConstants.SMTP_DELETE_ACCESS })
public Response removeSmtpConfiguration() {
    GluuConfiguration configurationUpdate = configurationService.getConfiguration();
    configurationUpdate.setSmtpConfiguration(new SmtpConfiguration());
    configurationService.updateConfiguration(configurationUpdate);
    return Response.noContent().build();
}
Also used : SmtpConfiguration(io.jans.model.SmtpConfiguration) GluuConfiguration(io.jans.as.persistence.model.configuration.GluuConfiguration) ProtectedApi(io.jans.configapi.core.rest.ProtectedApi)

Example 3 with SmtpConfiguration

use of io.jans.model.SmtpConfiguration in project jans by JanssenProject.

the class ConfigSmtpResource method getSmtpServerConfiguration.

@GET
@ProtectedApi(scopes = { ApiAccessConstants.SMTP_READ_ACCESS })
public Response getSmtpServerConfiguration() {
    SmtpConfiguration smtpConfiguration = configurationService.getConfiguration().getSmtpConfiguration();
    log.debug("getSmtpServerConfiguration() - smtpConfiguration = " + smtpConfiguration + "\n\n");
    return Response.ok(Objects.requireNonNullElseGet(smtpConfiguration, SmtpConfiguration::new)).build();
}
Also used : SmtpConfiguration(io.jans.model.SmtpConfiguration) ProtectedApi(io.jans.configapi.core.rest.ProtectedApi)

Example 4 with SmtpConfiguration

use of io.jans.model.SmtpConfiguration in project jans by JanssenProject.

the class ConfigSmtpResource method testSmtpConfiguration.

@POST
@Path(ApiConstants.TEST)
@ProtectedApi(scopes = { ApiAccessConstants.SMTP_READ_ACCESS })
public Response testSmtpConfiguration() throws EncryptionException {
    log.debug("\n ConfigSmtpResource::testSmtpConfiguration() - 1 - \n\n");
    SmtpConfiguration smtpConfiguration = configurationService.getConfiguration().getSmtpConfiguration();
    log.debug("\n ConfigSmtpResource::testSmtpConfiguration() - 1 - smtpConfiguration = " + smtpConfiguration + "\n\n");
    smtpConfiguration.setPasswordDecrypted(encryptionService.decrypt(smtpConfiguration.getPassword()));
    boolean status = mailService.sendMail(smtpConfiguration, smtpConfiguration.getFromEmailAddress(), smtpConfiguration.getFromName(), smtpConfiguration.getFromEmailAddress(), null, "SMTP Configuration verification", "Mail to test smtp configuration", "Mail to test smtp configuration");
    log.debug("\n ConfigSmtpResource::testSmtpConfiguration() - 2 - status = " + status + "\n\n");
    return Response.ok(status).build();
}
Also used : SmtpConfiguration(io.jans.model.SmtpConfiguration) ProtectedApi(io.jans.configapi.core.rest.ProtectedApi)

Example 5 with SmtpConfiguration

use of io.jans.model.SmtpConfiguration in project jans by JanssenProject.

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(io.jans.model.SmtpConfiguration) GluuConfiguration(io.jans.scim.model.GluuConfiguration) Produces(javax.enterprise.inject.Produces) RequestScoped(javax.enterprise.context.RequestScoped)

Aggregations

SmtpConfiguration (io.jans.model.SmtpConfiguration)5 ProtectedApi (io.jans.configapi.core.rest.ProtectedApi)3 GluuConfiguration (io.jans.as.persistence.model.configuration.GluuConfiguration)2 RequestScoped (javax.enterprise.context.RequestScoped)2 Produces (javax.enterprise.inject.Produces)2 GluuConfiguration (io.jans.scim.model.GluuConfiguration)1