use of com.blackducksoftware.integration.hub.alert.datasource.entity.global.GlobalHubConfigEntity in project hub-alert by blackducksoftware.
the class ObjectTransformerTest method testTransformGlobalModels.
@Test
public void testTransformGlobalModels() throws Exception {
final ObjectTransformer objectTransformer = new ObjectTransformer();
final MockGlobalHubRestModel globalHubMockUtils = new MockGlobalHubRestModel();
final MockGlobalHubEntity mockGlobalHubEntity = new MockGlobalHubEntity();
final GlobalHubConfigRestModel restModel = globalHubMockUtils.createGlobalRestModel();
final GlobalHubConfigEntity configEntity = mockGlobalHubEntity.createGlobalEntity();
final GlobalHubConfigEntity transformedConfigEntity = objectTransformer.configRestModelToDatabaseEntity(restModel, GlobalHubConfigEntity.class);
final GlobalHubConfigRestModel transformedConfigRestModel = objectTransformer.databaseEntityToConfigRestModel(configEntity, GlobalHubConfigRestModel.class);
assertNull(transformedConfigRestModel.getHubAlwaysTrustCertificate());
assertEquals(restModel.getHubApiKey(), transformedConfigRestModel.getHubApiKey());
assertNull(transformedConfigRestModel.getHubProxyHost());
assertNull(transformedConfigRestModel.getHubProxyPassword());
assertNull(transformedConfigRestModel.getHubProxyPort());
assertNull(transformedConfigRestModel.getHubProxyUsername());
assertEquals(restModel.getHubTimeout(), transformedConfigRestModel.getHubTimeout());
assertNull(transformedConfigRestModel.getHubUrl());
assertEquals(restModel.getId(), transformedConfigRestModel.getId());
assertEquals(configEntity.getHubApiKey(), transformedConfigEntity.getHubApiKey());
assertEquals(configEntity.getHubTimeout(), transformedConfigEntity.getHubTimeout());
assertEquals(configEntity.getId(), transformedConfigEntity.getId());
}
use of com.blackducksoftware.integration.hub.alert.datasource.entity.global.GlobalHubConfigEntity in project hub-alert by blackducksoftware.
the class StartupManager method logConfiguration.
public void logConfiguration() {
final GlobalHubConfigEntity globalHubConfig = globalProperties.getHubConfig();
final boolean authenticatedProxy = StringUtils.isNotBlank(globalProperties.getHubProxyPassword());
logger.info("----------------------------------------");
logger.info("Alert Configuration: ");
logger.info("Logging level: {}", loggingLevel);
logger.info("Hub URL: {}", globalProperties.getHubUrl());
logger.info("Hub Proxy Host: {}", globalProperties.getHubProxyHost());
logger.info("Hub Proxy Port: {}", globalProperties.getHubProxyPort());
logger.info("Hub Proxy Authenticated: {}", authenticatedProxy);
logger.info("Hub Proxy User: {}", globalProperties.getHubProxyUsername());
if (globalHubConfig != null) {
logger.info("Hub API Token: **********");
logger.info("Hub Timeout: {}", globalHubConfig.getHubTimeout());
}
logger.info("----------------------------------------");
}
use of com.blackducksoftware.integration.hub.alert.datasource.entity.global.GlobalHubConfigEntity in project hub-alert by blackducksoftware.
the class GlobalHubRepositoryWrapper method encryptSensitiveData.
@Override
public GlobalHubConfigEntity encryptSensitiveData(final GlobalHubConfigEntity entity) throws EncryptionException {
String hubApiKey = entity.getHubApiKey();
if (StringUtils.isBlank(hubApiKey)) {
return entity;
} else {
final Integer hubTimeout = entity.getHubTimeout();
hubApiKey = PasswordEncrypter.encrypt(hubApiKey);
final GlobalHubConfigEntity newEntity = new GlobalHubConfigEntity(hubTimeout, hubApiKey);
newEntity.setId(entity.getId());
return newEntity;
}
}
Aggregations