Skip to content

Use SSLContext when sending usage report #379

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
CreateSSLContext when sending usage report
  • Loading branch information
talarian1 committed Aug 1, 2023
commit 3be1e461f83818b58481531da1bbb64891ef6f20
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.http.conn.ssl.TrustAllStrategy;
import org.apache.http.ssl.SSLContextBuilder;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.Nullable;
import org.jfrog.build.extractor.clientConfiguration.ArtifactoryManagerBuilder;
Expand All @@ -38,6 +36,7 @@
import java.util.List;

import static com.jfrog.ide.common.ci.Utils.createAqlForBuildArtifacts;
import static com.jfrog.ide.common.utils.Utils.createSSLContext;
import static com.jfrog.ide.common.utils.XrayConnectionUtils.*;
import static com.jfrog.ide.idea.ui.configuration.ConfigVerificationUtils.DEFAULT_EXCLUSIONS;
import static com.jfrog.ide.idea.ui.configuration.Utils.clearText;
Expand Down Expand Up @@ -312,7 +311,6 @@ private void initLinks() {
initHyperlink(watchInstructions, "Create a <hyperlink>Watch</hyperlink> on JFrog Xray and assign your Policy and Project as resources to it.", "https://www.jfrog.com/confluence/display/JFROG/Configuring+Xray+Watches");
}

@SuppressWarnings("UnstableApiUsage")
private void initHyperlink(HyperlinkLabel label, String text, String link) {
label.setTextWithHyperlink(" " + text);
label.addHyperlinkListener(l -> BrowserUtil.browse(link));
Expand Down Expand Up @@ -403,9 +401,7 @@ private ArtifactoryManagerBuilder createArtifactoryManagerBuilder() throws KeySt
.setAccessToken(serverConfig.getAccessToken())
.setProxyConfiguration(serverConfig.getProxyConfForTargetUrl(urlStr))
.setLog(Logger.getInstance())
.setSslContext(serverConfig.isInsecureTls() ?
SSLContextBuilder.create().loadTrustMaterial(TrustAllStrategy.INSTANCE).build() :
serverConfig.getSslContext());
.setSslContext(createSSLContext(serverConfig));
}

private void loadConfig() {
Expand Down Expand Up @@ -462,18 +458,19 @@ private void updateConnectionDetailsTextFields() {

private void updatePolicyTextFields() {
switch (ObjectUtils.defaultIfNull(serverConfig.getPolicyType(), ServerConfig.PolicyType.VULNERABILITIES)) {
case WATCHES:
case WATCHES -> {
accordingToWatchesRadioButton.setSelected(true);
watches.setEnabled(true);
watches.setText(serverConfig.getWatches());
return;
case PROJECT:
}
case PROJECT -> {
accordingToProjectRadioButton.setSelected(true);
watches.setEnabled(false);
return;
case VULNERABILITIES:
}
case VULNERABILITIES -> {
allVulnerabilitiesRadioButton.setSelected(true);
watches.setEnabled(false);
}
}
}
}
10 changes: 8 additions & 2 deletions src/main/java/com/jfrog/ide/idea/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@
import java.net.URL;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.util.Collections;

import static com.jfrog.ide.common.utils.Utils.createSSLContext;

/**
* Created by romang on 5/8/17.
*/
Expand Down Expand Up @@ -70,8 +75,9 @@ public static void sendUsageReport(String techName) {
String pluginVersion = jfrogPlugin.getVersion();
UsageReporter usageReporter = new ClientIdUsageReporter(PRODUCT_ID + pluginVersion, featureIdArray, log);
try {
usageReporter.reportUsage(serverConfig.getArtifactoryUrl(), serverConfig.getUsername(), serverConfig.getPassword(), serverConfig.getAccessToken(), serverConfig.getProxyConfForTargetUrl(serverConfig.getArtifactoryUrl()), log);
} catch (IOException | RuntimeException e) {
usageReporter.reportUsage(serverConfig.getArtifactoryUrl(), serverConfig.getUsername(), serverConfig.getPassword(), serverConfig.getAccessToken(), serverConfig.getProxyConfForTargetUrl(serverConfig.getArtifactoryUrl()), createSSLContext(serverConfig), log);
} catch (IOException | RuntimeException | NoSuchAlgorithmException | KeyStoreException |
KeyManagementException e) {
log.debug("Usage report failed: " + ExceptionUtils.getRootCauseMessage(e));
}
log.debug("Usage report sent successfully.");
Expand Down