Search in sources :

Example 1 with CAConnectorConfig

use of de.trustable.ca3s.core.domain.CAConnectorConfig in project ca3sCore by kuehne-trustable-de.

the class CertBundleScheduler method retrieveCertificates.

@Scheduled(fixedDelay = 60000)
public void retrieveCertificates() {
    for (CAConnectorConfig caConfigDao : caConfigRepo.findAll()) {
        if (caConfigDao.isActive() && caConfigDao.isDefaultCA()) {
            if (CAStatus.Active.equals(caConnAd.getStatus(caConfigDao))) {
                if (timedRenewalCertMapHolder.getCertMap().getBundleFactory() == null) {
                    timedRenewalCertMapHolder.getCertMap().setBundleFactory(new Ca3sBundleFactory(caConfigDao, caConnAd, certUtil, certificateRepository, dnSuffix, sans, persist));
                    LOG.info("Ca3sBundleFactory registered for TLS certificate production");
                }
            } else {
                LOG.info("CA default connector not active");
            }
        }
    }
}
Also used : Ca3sBundleFactory(de.trustable.ca3s.core.security.provider.Ca3sBundleFactory) CAConnectorConfig(de.trustable.ca3s.core.domain.CAConnectorConfig) Scheduled(org.springframework.scheduling.annotation.Scheduled)

Example 2 with CAConnectorConfig

use of de.trustable.ca3s.core.domain.CAConnectorConfig in project ca3sCore by kuehne-trustable-de.

the class CAConnectorConfigResourceIT method updateCAConnectorConfig.

@Test
@Transactional
public void updateCAConnectorConfig() throws Exception {
    // Initialize the database
    cAConnectorConfigService.save(cAConnectorConfig);
    int databaseSizeBeforeUpdate = cAConnectorConfigRepository.findAll().size();
    // Update the cAConnectorConfig
    CAConnectorConfig updatedCAConnectorConfig = cAConnectorConfigRepository.findById(cAConnectorConfig.getId()).get();
    // Disconnect from session so that the updates on updatedCAConnectorConfig are not directly saved in db
    em.detach(updatedCAConnectorConfig);
    updatedCAConnectorConfig.name(UPDATED_NAME).caConnectorType(UPDATED_CA_CONNECTOR_TYPE).caUrl(UPDATED_CA_URL).pollingOffset(UPDATED_POLLING_OFFSET).defaultCA(UPDATED_DEFAULT_CA).active(UPDATED_ACTIVE).selector(UPDATED_SELECTOR).interval(UPDATED_INTERVAL).plainSecret(UPDATED_PLAIN_SECRET);
    restCAConnectorConfigMockMvc.perform(put("/api/ca-connector-configs").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedCAConnectorConfig))).andExpect(status().isOk());
    // Validate the CAConnectorConfig in the database
    List<CAConnectorConfig> cAConnectorConfigList = cAConnectorConfigRepository.findAll();
    assertThat(cAConnectorConfigList).hasSize(databaseSizeBeforeUpdate);
    CAConnectorConfig testCAConnectorConfig = cAConnectorConfigList.get(cAConnectorConfigList.size() - 1);
    assertThat(testCAConnectorConfig.getName()).isEqualTo(UPDATED_NAME);
    assertThat(testCAConnectorConfig.getCaConnectorType()).isEqualTo(UPDATED_CA_CONNECTOR_TYPE);
    assertThat(testCAConnectorConfig.getCaUrl()).isEqualTo(UPDATED_CA_URL);
    assertThat(testCAConnectorConfig.getPollingOffset()).isEqualTo(UPDATED_POLLING_OFFSET);
    assertThat(testCAConnectorConfig.isDefaultCA()).isEqualTo(UPDATED_DEFAULT_CA);
    assertThat(testCAConnectorConfig.isActive()).isEqualTo(UPDATED_ACTIVE);
    assertThat(testCAConnectorConfig.getSelector()).isEqualTo(UPDATED_SELECTOR);
    assertThat(testCAConnectorConfig.getInterval()).isEqualTo(UPDATED_INTERVAL);
    assertThat(testCAConnectorConfig.getPlainSecret()).isEqualTo(CAConnectorConfigResource.PLAIN_SECRET_PLACEHOLDER);
}
Also used : CAConnectorConfig(de.trustable.ca3s.core.domain.CAConnectorConfig) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with CAConnectorConfig

use of de.trustable.ca3s.core.domain.CAConnectorConfig in project ca3sCore by kuehne-trustable-de.

the class CaConfigTestConfiguration method getInternalTestCAC.

@Bean
CAConnectorConfig getInternalTestCAC() {
    Optional<CAConnectorConfig> existingConfigOpt = cacRepo.findById(CONFIG_ID);
    if (existingConfigOpt.isPresent()) {
        LOGGER.debug("CAConnectorConfig for 'Internal' already present");
        return existingConfigOpt.get();
    }
    CAConnectorConfig newCAC = new CAConnectorConfig();
    newCAC.setId(CONFIG_ID);
    newCAC.setName("InternalTestCA");
    newCAC.setCaConnectorType(CAConnectorType.INTERNAL);
    newCAC.setDefaultCA(true);
    newCAC.setActive(true);
    cacRepo.save(newCAC);
    LOGGER.debug("CAConnectorConfig for 'Internal' created");
    return newCAC;
}
Also used : CAConnectorConfig(de.trustable.ca3s.core.domain.CAConnectorConfig) Bean(org.springframework.context.annotation.Bean)

Example 4 with CAConnectorConfig

use of de.trustable.ca3s.core.domain.CAConnectorConfig in project ca3sCore by kuehne-trustable-de.

the class PipelineTestConfiguration method internalTestCAC.

public CAConnectorConfig internalTestCAC() {
    CAConnectorConfig exampleCCC = new CAConnectorConfig();
    exampleCCC.setName(INTERNAL_TEST_CA);
    Example<CAConnectorConfig> example = Example.of(exampleCCC);
    List<CAConnectorConfig> existingConfigList = cacRepo.findAll(example);
    if (!existingConfigList.isEmpty()) {
        LOGGER.info("CAConnectorConfig for 'Internal' already present");
        return existingConfigList.get(0);
    }
    CAConnectorConfig newCAC = new CAConnectorConfig();
    // newCAC.setId(CONFIG_ID);
    newCAC.setName(INTERNAL_TEST_CA);
    newCAC.setCaConnectorType(CAConnectorType.INTERNAL);
    newCAC.setDefaultCA(true);
    newCAC.setActive(true);
    cacRepo.save(newCAC);
    LOGGER.info("CAConnectorConfig for 'Internal' created");
    return newCAC;
}
Also used : CAConnectorConfig(de.trustable.ca3s.core.domain.CAConnectorConfig)

Example 5 with CAConnectorConfig

use of de.trustable.ca3s.core.domain.CAConnectorConfig in project ca3sCore by kuehne-trustable-de.

the class ConfigUtil method getDefaultConfig.

public CAConnectorConfig getDefaultConfig() {
    CAConnectorConfig caConfigDefault = null;
    for (CAConnectorConfig caConfig : caccRepo.findAll()) {
        LOG.debug("checking CA configuration {}, default {}", caConfig.getName(), caConfig.isDefaultCA());
        if (caConfig.isDefaultCA() && caConfig.isActive()) {
            caConfigDefault = caConfig;
            LOG.debug("default CA configuration {}, default {}", caConfig.getName(), caConfig.isDefaultCA());
            break;
        }
    }
    if (caConfigDefault == null) {
        LOG.error("no default and active CA configured");
    }
    return caConfigDefault;
}
Also used : CAConnectorConfig(de.trustable.ca3s.core.domain.CAConnectorConfig)

Aggregations

CAConnectorConfig (de.trustable.ca3s.core.domain.CAConnectorConfig)13 Transactional (org.springframework.transaction.annotation.Transactional)4 Test (org.junit.jupiter.api.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 CSR (de.trustable.ca3s.core.domain.CSR)2 Certificate (de.trustable.ca3s.core.domain.Certificate)2 ProtectedContent (de.trustable.ca3s.core.domain.ProtectedContent)2 BadRequestAlertException (de.trustable.ca3s.core.web.rest.errors.BadRequestAlertException)2 CsrAttribute (de.trustable.ca3s.core.domain.CsrAttribute)1 ImportInfo (de.trustable.ca3s.core.schedule.ImportInfo)1 Ca3sBundleFactory (de.trustable.ca3s.core.security.provider.Ca3sBundleFactory)1 CAConnectorStatus (de.trustable.ca3s.core.service.dto.CAConnectorStatus)1 CAStatus (de.trustable.ca3s.core.service.dto.CAStatus)1 BpmnCheckResult (de.trustable.ca3s.core.web.rest.data.BpmnCheckResult)1 File (java.io.File)1 IOException (java.io.IOException)1 URI (java.net.URI)1 GeneralSecurityException (java.security.GeneralSecurityException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1