Search in sources :

Example 26 with GluuConfiguration

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

the class SmtpConfigurationWebResource method updateSmtpConfiguration.

@PUT
@Operation(summary = "Update smtp configuration", description = "Update smtp configuration")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = SmtpConfiguration.class)), description = Constants.RESULT_SUCCESS), @ApiResponse(responseCode = "404", description = "Not found"), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response updateSmtpConfiguration(SmtpConfiguration smtpConfiguration) {
    try {
        Preconditions.checkNotNull(smtpConfiguration, "Attempt to update null smtpConfiguration");
        configurationService.encryptedSmtpPassword(smtpConfiguration);
        GluuConfiguration configurationUpdate = configurationService.getConfiguration();
        configurationUpdate.setSmtpConfiguration(smtpConfiguration);
        configurationService.updateConfiguration(configurationUpdate);
        return Response.ok(configurationService.getConfiguration().getSmtpConfiguration()).build();
    } catch (Exception e) {
        log(logger, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : GluuConfiguration(org.gluu.oxtrust.model.GluuConfiguration) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 27 with GluuConfiguration

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

the class JsonConfigurationService method saveDocumentStoreConfiguration.

public boolean saveDocumentStoreConfiguration(DocumentStoreConfiguration documentStoreConfiguration) {
    GluuConfiguration gluuConfiguration = configurationService.getConfiguration();
    gluuConfiguration.setDocumentStoreConfiguration(documentStoreConfiguration);
    configurationService.updateConfiguration(gluuConfiguration);
    return true;
}
Also used : GluuConfiguration(org.gluu.oxtrust.model.GluuConfiguration)

Example 28 with GluuConfiguration

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

the class CertificateManagementAction method updateTableView.

/**
 * Load and process certificate lists.
 *
 * Set highlight for obsolete certificates. Apply search pattern.
 */
private void updateTableView() {
    try {
        trustStoreCertificates = new ArrayList<X509CertificateShortInfo>();
        GluuConfiguration configuration = configurationService.getConfiguration();
        List<TrustStoreCertificate> trustStoreCertificatesList = configuration.getTrustStoreCertificates();
        if (trustStoreCertificatesList != null) {
            for (TrustStoreCertificate trustStoreCertificate : trustStoreCertificatesList) {
                try {
                    X509Certificate[] certs = SSLService.loadCertificates(trustStoreCertificate.getCertificate().getBytes());
                    for (X509Certificate cert : certs) {
                        X509CertificateShortInfo entry = new X509CertificateShortInfo(trustStoreCertificate.getName(), cert);
                        trustStoreCertificates.add(entry);
                    }
                } catch (Exception e) {
                    log.error("Certificate load exception", e);
                }
            }
        }
    } catch (Exception e) {
        log.error("Load trustStoreCertificates configuration exception", e);
    }
    try {
        // load internalCertificates
        internalCertificates = new ArrayList<X509CertificateShortInfo>();
        try {
            X509Certificate[] openDJCerts = SSLService.loadCertificates(new FileInputStream(OPENDJ_CERTIFICATE_FILE));
            for (X509Certificate openDJCert : openDJCerts) {
                internalCertificates.add(new X509CertificateShortInfo(OPENDJ_CERTIFICATE_FILE, "OpenDJ SSL", openDJCert));
            }
        } catch (Exception e) {
            log.warn("OPENDJ certificate load exception");
        }
        try {
            X509Certificate[] httpdCerts = SSLService.loadCertificates(new FileInputStream(HTTPD_CERTIFICATE_FILE));
            for (X509Certificate httpdCert : httpdCerts) {
                internalCertificates.add(new X509CertificateShortInfo(HTTPD_CERTIFICATE_FILE, "HTTPD SSL", httpdCert));
            }
        } catch (Exception e) {
            log.warn("HTTPD Certificate load exception");
        }
        try {
            X509Certificate[] idpSigingCerts = SSLService.loadCertificates(new FileInputStream(IDP_SIGNING_CERTIFICATE_FILE));
            for (X509Certificate idpSigingCert : idpSigingCerts) {
                internalCertificates.add(new X509CertificateShortInfo(IDP_SIGNING_CERTIFICATE_FILE, "IDP SIGNING", idpSigingCert));
            }
        } catch (Exception e) {
            log.warn("IDP SIGNING certificate load exception");
        }
        try {
            X509Certificate[] idpEncryptionCerts = SSLService.loadCertificates(new FileInputStream(IDP_ENCRYPT_CERTIFICATE_FILE));
            for (X509Certificate idpEncryptionCert : idpEncryptionCerts) {
                internalCertificates.add(new X509CertificateShortInfo(IDP_ENCRYPT_CERTIFICATE_FILE, "IDP ENCRYPTION", idpEncryptionCert));
            }
        } catch (Exception e) {
            log.warn("IDP ENCRYPTION certificate load exception");
        }
        try {
            X509Certificate[] idpEncryptionCerts = SSLService.loadCertificates(new FileInputStream(OPENLDAP_CERTIFICATE_FILE));
            for (X509Certificate idpEncryptionCert : idpEncryptionCerts) {
                internalCertificates.add(new X509CertificateShortInfo(OPENLDAP_CERTIFICATE_FILE, "OpenLDAP ENCRYPTION", idpEncryptionCert));
            }
        } catch (Exception e) {
            log.warn("OpenLDAP certificate load exception");
        }
    } catch (Exception e) {
        log.error("Load internalCertificates configuration exception", e);
    }
}
Also used : X509CertificateShortInfo(org.gluu.oxtrust.util.X509CertificateShortInfo) TrustStoreCertificate(org.gluu.oxtrust.model.cert.TrustStoreCertificate) GluuConfiguration(org.gluu.oxtrust.model.GluuConfiguration) X509Certificate(java.security.cert.X509Certificate) FileInputStream(java.io.FileInputStream)

Example 29 with GluuConfiguration

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

the class ConfigurationStatusAction method checkHealth.

public String checkHealth() {
    GluuConfiguration configuration = configurationService.getConfiguration();
    Date lastUpdateDateTime = configuration.getLastUpdate();
    long lastUpdate = 0;
    if (lastUpdateDateTime != null) {
        lastUpdate = lastUpdateDateTime.getTime();
    }
    long currentTime = System.currentTimeMillis();
    log.debug("lastUpdate: '{}', currentTime: '{}'", lastUpdate, currentTime);
    long timeSinceLastUpdate = (currentTime - lastUpdate) / 1000;
    if (timeSinceLastUpdate >= 0 && timeSinceLastUpdate < 100) {
        this.setHealth("OK");
    } else {
        this.setHealth("FAIL");
    }
    log.debug("Set status '{}'", this.getHealth());
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : GluuConfiguration(org.gluu.oxtrust.model.GluuConfiguration) Date(java.util.Date)

Example 30 with GluuConfiguration

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

the class ConfigureCacheRefreshAction method updateConfiguration.

private void updateConfiguration() {
    GluuConfiguration configuration = configurationService.getConfiguration();
    configuration.setVdsCacheRefreshEnabled(this.configuration.isVdsCacheRefreshEnabled());
    configuration.setVdsCacheRefreshPollingInterval(this.configuration.getVdsCacheRefreshPollingInterval());
    configuration.setCacheRefreshServerIpAddress(this.configuration.getCacheRefreshServerIpAddress());
    configurationService.updateConfiguration(configuration);
}
Also used : 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