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");
}
}
}
}
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);
}
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;
}
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;
}
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;
}
Aggregations