From ab432ac822108ccd622e6d009d0e73bb9bffe673 Mon Sep 17 00:00:00 2001 From: Nils Behlen <29949516+nilsbehlen@users.noreply.github.com> Date: Mon, 4 Mar 2024 11:01:19 +0100 Subject: [PATCH 1/2] http timeouts, v1.2.2 --- pom.xml | 2 +- src/main/java/org/privacyidea/Endpoint.java | 31 ++++++------------- src/main/java/org/privacyidea/PIConfig.java | 1 + .../java/org/privacyidea/PrivacyIDEA.java | 13 ++++++++ .../org/privacyidea/TestGetTokenInfo.java | 1 + 5 files changed, 25 insertions(+), 23 deletions(-) diff --git a/pom.xml b/pom.xml index fb9784a..a80f601 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 org.privacyidea privacyidea-java-client - 1.2.1 + 1.2.2 jar UTF-8 diff --git a/src/main/java/org/privacyidea/Endpoint.java b/src/main/java/org/privacyidea/Endpoint.java index 87b9f3c..26eb880 100644 --- a/src/main/java/org/privacyidea/Endpoint.java +++ b/src/main/java/org/privacyidea/Endpoint.java @@ -73,6 +73,10 @@ public java.security.cert.X509Certificate[] getAcceptedIssuers() this.piconfig = privacyIDEA.configuration(); OkHttpClient.Builder builder = new OkHttpClient.Builder(); + builder.connectTimeout(piconfig.httpTimeoutMs, TimeUnit.MILLISECONDS) + .writeTimeout(piconfig.httpTimeoutMs, TimeUnit.MILLISECONDS) + .readTimeout(piconfig.httpTimeoutMs, TimeUnit.MILLISECONDS); + if (!this.piconfig.doSSLVerify) { // Trust all certs and verify every host @@ -108,7 +112,7 @@ void sendRequestAsync(String endpoint, Map params, Map params, Map params, Map { - try - { - String encValue = URLEncoder.encode(value, StandardCharsets.UTF_8.toString()); - urlBuilder.addQueryParameter(key, encValue); - } - catch (UnsupportedEncodingException e) - { - e.printStackTrace(); - } + String encValue = URLEncoder.encode(value, StandardCharsets.UTF_8); + urlBuilder.addQueryParameter(key, encValue); }); } @@ -168,14 +162,7 @@ void sendRequestAsync(String endpoint, Map params, Map Date: Mon, 4 Mar 2024 12:21:02 +0100 Subject: [PATCH 2/2] replace stringbuilder with string --- src/main/java/org/privacyidea/Endpoint.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/org/privacyidea/Endpoint.java b/src/main/java/org/privacyidea/Endpoint.java index 26eb880..b4658a5 100644 --- a/src/main/java/org/privacyidea/Endpoint.java +++ b/src/main/java/org/privacyidea/Endpoint.java @@ -122,9 +122,7 @@ void sendRequestAsync(String endpoint, Map params, Map