Skip to content
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

OWS-627: fix SSLHandshake in some cases #943

Merged
merged 2 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ private CompletableFuture<Resource> downloadFrom(final URL url) {
}

private Resource tryDownloading(final URL downloadFrom) throws IOException {
ensureRequestInterval();
DownloadDetails downloadDetails = null;
try (final CloseableConnection connection = getDownloadConnection(downloadFrom)) {
downloadDetails = getDownloadDetails(connection);
Expand All @@ -158,23 +159,33 @@ private Resource tryDownloading(final URL downloadFrom) throws IOException {
}
}

private void ensureRequestInterval() {
final int httpsRequestInterval = getTimeValue(ConfigurationConstants.KEY_HTTPCONNECTION_REQUEST_INTERVAL);
if (httpsRequestInterval > 0) {
try {
Thread.sleep(httpsRequestInterval);
} catch (InterruptedException ignored) {
}
}
}

private CloseableConnection getDownloadConnection(final URL location) throws IOException {
final Map<String, String> requestProperties = new HashMap<>();
requestProperties.put(ACCEPT_ENCODING_HEADER, PACK_200_OR_GZIP);
return ConnectionFactory.openConnection(location, HttpMethod.GET, requestProperties, getTimeoutValue(ConfigurationConstants.KEY_HTTPCONNECTION_CONNECT_TIMEOUT), getTimeoutValue(ConfigurationConstants.KEY_HTTPCONNECTION_READ_TIMEOUT));
return ConnectionFactory.openConnection(location, HttpMethod.GET, requestProperties, getTimeValue(ConfigurationConstants.KEY_HTTPCONNECTION_CONNECT_TIMEOUT), getTimeValue(ConfigurationConstants.KEY_HTTPCONNECTION_READ_TIMEOUT));
}

private int getTimeoutValue(final String key) {
int timeout = 0;
private int getTimeValue(final String key) {
int timeValue = 0;
final String value = JNLPRuntime.getConfiguration().getProperty(key);
if (value != null && value.trim().length() != 0) {
try {
timeout = Integer.valueOf(value);
timeValue = Integer.valueOf(value);
} catch (NumberFormatException e) {
LOG.error("Could not parse {} with value '{}' - reason {}", key, value, e.getMessage());
}
}
return timeout;
return timeValue;
}

private long tryDownloading(final DownloadDetails downloadDetails) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,4 +305,5 @@ public interface ConfigurationConstants {
*/
String KEY_HTTPCONNECTION_CONNECT_TIMEOUT = "deployment.connection.connectTimeout";
String KEY_HTTPCONNECTION_READ_TIMEOUT = "deployment.connection.readTimeout";
String KEY_HTTPCONNECTION_REQUEST_INTERVAL = "deployment.connection.request.interval";
}
16 changes: 16 additions & 0 deletions core/src/main/java/net/sourceforge/jnlp/runtime/JNLPRuntime.java
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,22 @@ public static LaunchHandler getDefaultLaunchHandler() {
return handler;
}

/**
* Returns the Security Dialog Message Handler.
* @return SecurityDialogMessageHandler
*/
public static SecurityDialogMessageHandler getSecurityDialogMessageHandler() {
return securityDialogMessageHandler;
}

/**
* Sets the Security Dialog Message Handler.
* @param securityDialogMessageHandler handler for Security Dialog messages
*/
public static void setSecurityDialogMessageHandler(final SecurityDialogMessageHandler securityDialogMessageHandler) {
JNLPRuntime.securityDialogMessageHandler = securityDialogMessageHandler;
}

/**
* Sets the default download indicator.
*
Expand Down
Loading