use of com.blackducksoftware.integration.exception.EncryptionException in project hub-fortify-ssc-integration-service by blackducksoftware.
the class RestConnectionHelper method getRestConnection.
/**
* Get the Hub REST connection
*
* @param serverConfig
* @param logLevel
* @return
*/
private static CredentialsRestConnection getRestConnection(final HubServerConfig serverConfig, final LogLevel logLevel) {
CredentialsRestConnection restConnection;
try {
final ProxyInfo proxyInfo = getProxyInfo(serverConfig);
restConnection = new CredentialsRestConnection(new PrintStreamIntLogger(System.out, logLevel), serverConfig.getHubUrl(), serverConfig.getGlobalCredentials().getUsername(), serverConfig.getGlobalCredentials().getDecryptedPassword(), serverConfig.getTimeout(), proxyInfo, new UriCombiner());
} catch (final IllegalArgumentException e) {
e.printStackTrace();
throw new RuntimeException(e);
} catch (final EncryptionException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
return restConnection;
}
use of com.blackducksoftware.integration.exception.EncryptionException in project hub-alert by blackducksoftware.
the class AuditEntryRepositoryWrapperTest method testFindFirstByCommonConfigIdOrderByTimeLastSentDesc.
@Test
public void testFindFirstByCommonConfigIdOrderByTimeLastSentDesc() throws IOException {
final MockAuditEntryEntity mockAuditEntryEntity = new MockAuditEntryEntity();
final AuditEntryRepository repository = Mockito.mock(AuditEntryRepository.class);
Mockito.when(repository.findFirstByCommonConfigIdOrderByTimeLastSentDesc(Mockito.anyLong())).thenReturn(mockAuditEntryEntity.createEntity());
final AuditEntryRepositoryWrapper auditEntryRepositoryWrapper = new AuditEntryRepositoryWrapper(repository) {
@Override
public AuditEntryEntity decryptSensitiveData(final AuditEntryEntity entity) throws EncryptionException {
throw new EncryptionException();
}
};
final AuditEntryEntity actual = auditEntryRepositoryWrapper.findFirstByCommonConfigIdOrderByTimeLastSentDesc(1L);
assertNull(actual);
assertTrue(outputLogger.isLineContainingText("Error finding common distribution config"));
}
use of com.blackducksoftware.integration.exception.EncryptionException in project hub-alert by blackducksoftware.
the class ConfiguredProjectsRepositoryWrapperTest method testFindByProjectName.
@Test
public void testFindByProjectName() throws IOException {
final ProjectMockUtils projectMockUtils = new ProjectMockUtils();
final ConfiguredProjectsRepository repository = Mockito.mock(ConfiguredProjectsRepository.class);
Mockito.when(repository.findByProjectName(Mockito.anyString())).thenReturn(projectMockUtils.getProjectOneEntity());
final ConfiguredProjectsRepositoryWrapper configuredProjectsRepositoryWrapper = new ConfiguredProjectsRepositoryWrapper(repository) {
@Override
public ConfiguredProjectEntity decryptSensitiveData(final ConfiguredProjectEntity entity) throws EncryptionException {
throw new EncryptionException();
}
};
final ConfiguredProjectEntity actual = configuredProjectsRepositoryWrapper.findByProjectName("any");
assertNull(actual);
assertTrue(outputLogger.isLineContainingText("Error finding common distribution config"));
}
use of com.blackducksoftware.integration.exception.EncryptionException in project hub-alert by blackducksoftware.
the class RepositoryWrapperTest method getExceptionThrowingRepositoryWrapper.
@SuppressWarnings("unchecked")
public W getExceptionThrowingRepositoryWrapper() throws EncryptionException {
final R repository = getMockedRepository();
final W wrapper = getRepositoryObjectWrapper(repository);
final W wrapperSpy = Mockito.spy(wrapper);
Mockito.doThrow(new EncryptionException()).when(wrapperSpy).decryptSensitiveData((E) Mockito.any(DatabaseEntity.class));
Mockito.doThrow(new EncryptionException()).when(wrapperSpy).encryptSensitiveData((E) Mockito.any(DatabaseEntity.class));
return wrapperSpy;
}
use of com.blackducksoftware.integration.exception.EncryptionException in project hub-detect by blackducksoftware.
the class HubServiceWrapper method init.
public void init() throws IntegrationException, DetectUserFriendlyException {
try {
slf4jIntLogger = new Slf4jIntLogger(logger);
hubServerConfig = createHubServerConfig(slf4jIntLogger);
hubServicesFactory = createHubServicesFactory(slf4jIntLogger, hubServerConfig);
} catch (IllegalStateException | EncryptionException e) {
throw new DetectUserFriendlyException(String.format("Not able to initialize Hub connection: %s", e.getMessage()), e, ExitCodeType.FAILURE_HUB_CONNECTIVITY);
}
final HubService hubService = createHubService();
final CurrentVersionView currentVersion = hubService.getResponse(ApiDiscovery.CURRENT_VERSION_LINK_RESPONSE);
logger.info(String.format("Successfully connected to Hub (version %s)!", currentVersion.version));
detectPhoneHomeManager.init(createPhoneHomeService());
detectPhoneHomeManager.startPhoneHome();
}
Aggregations