Search in sources :

Example 1 with PhoneHomeRequestBody

use of com.blackducksoftware.integration.phonehome.PhoneHomeRequestBody in project hub-alert by blackducksoftware.

the class DailyItemReader method phoneHome.

private PhoneHomeResponse phoneHome() {
    final String productVersion = globalProperties.getProductVersion();
    if (!GlobalProperties.PRODUCT_VERSION_UNKNOWN.equals(productVersion)) {
        final HubServicesFactory hubServicesFactory = globalProperties.createHubServicesFactoryAndLogErrors(logger);
        final PhoneHomeService phoneHomeService = hubServicesFactory.createPhoneHomeService();
        final PhoneHomeRequestBodyBuilder phoneHomeRequestBodyBuilder = phoneHomeService.createInitialPhoneHomeRequestBodyBuilder(ThirdPartyName.ALERT, productVersion, productVersion);
        final PhoneHomeRequestBody phoneHomeRequestBody = phoneHomeRequestBodyBuilder.build();
        return phoneHomeService.startPhoneHome(phoneHomeRequestBody);
    } else {
        return null;
    }
}
Also used : PhoneHomeRequestBody(com.blackducksoftware.integration.phonehome.PhoneHomeRequestBody) PhoneHomeRequestBodyBuilder(com.blackducksoftware.integration.phonehome.PhoneHomeRequestBodyBuilder) HubServicesFactory(com.blackducksoftware.integration.hub.service.HubServicesFactory) PhoneHomeService(com.blackducksoftware.integration.hub.service.PhoneHomeService)

Example 2 with PhoneHomeRequestBody

use of com.blackducksoftware.integration.phonehome.PhoneHomeRequestBody in project hub-detect by blackducksoftware.

the class DetectPhoneHomeManager method performPhoneHome.

private void performPhoneHome(final Set<BomToolType> applicableBomToolTypes) {
    endPhoneHome();
    // TODO When we begin to phone home in offline mode, we should re-address this section
    if (null != phoneHomeService) {
        final PhoneHomeRequestBodyBuilder phoneHomeRequestBodyBuilder = createBuilder();
        if (applicableBomToolTypes != null) {
            final String applicableBomToolsString = StringUtils.join(applicableBomToolTypes, ", ");
            phoneHomeRequestBodyBuilder.addToMetaDataMap("bomToolTypes", applicableBomToolsString);
        }
        final PhoneHomeRequestBody phoneHomeRequestBody = phoneHomeRequestBodyBuilder.build();
        phoneHomeResponse = phoneHomeService.startPhoneHome(phoneHomeRequestBody);
    }
}
Also used : PhoneHomeRequestBody(com.blackducksoftware.integration.phonehome.PhoneHomeRequestBody) PhoneHomeRequestBodyBuilder(com.blackducksoftware.integration.phonehome.PhoneHomeRequestBodyBuilder)

Example 3 with PhoneHomeRequestBody

use of com.blackducksoftware.integration.phonehome.PhoneHomeRequestBody in project hub-docker-inspector by blackducksoftware.

the class HubClient method phoneHomeNoHubConnection.

private void phoneHomeNoHubConnection(final String dockerEngineVersion) {
    try {
        final IntLogger intLogger = new Slf4jIntLogger(logger);
        final ProxyInfo proxyInfo = new ProxyInfo(config.getHubProxyHost(), Integer.parseInt(config.getHubProxyPort()), new Credentials(config.getHubProxyUsername(), config.getHubProxyPassword()), null, null, null);
        final boolean alwaysTrustServerCertificate = config.isHubAlwaysTrustCert();
        final PhoneHomeClient phClient = new PhoneHomeClient(intLogger, 15, proxyInfo, alwaysTrustServerCertificate);
        final Map<String, String> infoMap = new HashMap<>();
        infoMap.put("blackDuckName", BlackDuckName.HUB.getName());
        infoMap.put("blackDuckVersion", "None");
        infoMap.put("thirdPartyName", THIRD_PARTY_NAME_DOCKER);
        infoMap.put("thirdPartyVersion", dockerEngineVersion);
        infoMap.put("pluginVersion", programVersion.getProgramVersion());
        if (!StringUtils.isBlank(config.getCallerName())) {
            infoMap.put(PHONE_HOME_METADATA_NAME_CALLER_NAME, config.getCallerName());
        }
        if (!StringUtils.isBlank(config.getCallerVersion())) {
            infoMap.put(PHONE_HOME_METADATA_NAME_CALLER_VERSION, config.getCallerVersion());
        }
        final PhoneHomeRequestBody phoneHomeRequestBody = new PhoneHomeRequestBody("None", "Integrations", infoMap);
        phClient.postPhoneHomeRequest(phoneHomeRequestBody, new CIEnvironmentVariables());
    } catch (final Throwable t) {
        logger.debug(String.format("Unable to phone home: %s", t.getMessage()));
    }
}
Also used : PhoneHomeRequestBody(com.blackducksoftware.integration.phonehome.PhoneHomeRequestBody) ProxyInfo(com.blackducksoftware.integration.hub.proxy.ProxyInfo) PhoneHomeClient(com.blackducksoftware.integration.phonehome.PhoneHomeClient) Slf4jIntLogger(com.blackducksoftware.integration.log.Slf4jIntLogger) HashMap(java.util.HashMap) IntLogger(com.blackducksoftware.integration.log.IntLogger) Slf4jIntLogger(com.blackducksoftware.integration.log.Slf4jIntLogger) Credentials(com.blackducksoftware.integration.hub.Credentials) CIEnvironmentVariables(com.blackducksoftware.integration.util.CIEnvironmentVariables)

Example 4 with PhoneHomeRequestBody

use of com.blackducksoftware.integration.phonehome.PhoneHomeRequestBody in project hub-docker-inspector by blackducksoftware.

the class HubClient method phoneHomeHubConnection.

private void phoneHomeHubConnection(final String dockerEngineVersion) throws IOException, EncryptionException {
    final RestConnection restConnection = createRestConnection();
    final HubServicesFactory hubServicesFactory = new HubServicesFactory(restConnection);
    final PhoneHomeService phoner = hubServicesFactory.createPhoneHomeService();
    final PhoneHomeRequestBodyBuilder phoneHomeRequestBodyBuilder = phoner.createInitialPhoneHomeRequestBodyBuilder(THIRD_PARTY_NAME_DOCKER, dockerEngineVersion, programVersion.getProgramVersion());
    phoneHomeRequestBodyBuilder.setBlackDuckName(BlackDuckName.HUB);
    if (!StringUtils.isBlank(config.getCallerName())) {
        phoneHomeRequestBodyBuilder.addToMetaDataMap(PHONE_HOME_METADATA_NAME_CALLER_NAME, config.getCallerName());
    }
    if (!StringUtils.isBlank(config.getCallerVersion())) {
        phoneHomeRequestBodyBuilder.addToMetaDataMap(PHONE_HOME_METADATA_NAME_CALLER_VERSION, config.getCallerVersion());
    }
    final PhoneHomeRequestBody phoneHomeRequestBody = phoneHomeRequestBodyBuilder.buildObject();
    phoner.phoneHome(phoneHomeRequestBody);
    logger.trace("Attempt to phone home completed");
}
Also used : PhoneHomeRequestBody(com.blackducksoftware.integration.phonehome.PhoneHomeRequestBody) PhoneHomeRequestBodyBuilder(com.blackducksoftware.integration.phonehome.PhoneHomeRequestBodyBuilder) RestConnection(com.blackducksoftware.integration.hub.rest.RestConnection) HubServicesFactory(com.blackducksoftware.integration.hub.service.HubServicesFactory) PhoneHomeService(com.blackducksoftware.integration.hub.service.PhoneHomeService)

Aggregations

PhoneHomeRequestBody (com.blackducksoftware.integration.phonehome.PhoneHomeRequestBody)4 PhoneHomeRequestBodyBuilder (com.blackducksoftware.integration.phonehome.PhoneHomeRequestBodyBuilder)3 HubServicesFactory (com.blackducksoftware.integration.hub.service.HubServicesFactory)2 PhoneHomeService (com.blackducksoftware.integration.hub.service.PhoneHomeService)2 Credentials (com.blackducksoftware.integration.hub.Credentials)1 ProxyInfo (com.blackducksoftware.integration.hub.proxy.ProxyInfo)1 RestConnection (com.blackducksoftware.integration.hub.rest.RestConnection)1 IntLogger (com.blackducksoftware.integration.log.IntLogger)1 Slf4jIntLogger (com.blackducksoftware.integration.log.Slf4jIntLogger)1 PhoneHomeClient (com.blackducksoftware.integration.phonehome.PhoneHomeClient)1 CIEnvironmentVariables (com.blackducksoftware.integration.util.CIEnvironmentVariables)1 HashMap (java.util.HashMap)1