diff options
-rw-r--r-- | pom.xml | 2 | ||||
-rw-r--r-- | src/main/java/edu/kit/scc/dei/ecplean/ECPAuthenticatorBase.java | 19 |
2 files changed, 18 insertions, 3 deletions
@@ -43,7 +43,7 @@ <dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
- <version>[5.0,6.0)</version>
+ <version>[5.0,5.9999.9999]</version>
<scope>compile</scope>
</dependency>
<dependency>
diff --git a/src/main/java/edu/kit/scc/dei/ecplean/ECPAuthenticatorBase.java b/src/main/java/edu/kit/scc/dei/ecplean/ECPAuthenticatorBase.java index 454886f..9c549ea 100644 --- a/src/main/java/edu/kit/scc/dei/ecplean/ECPAuthenticatorBase.java +++ b/src/main/java/edu/kit/scc/dei/ecplean/ECPAuthenticatorBase.java @@ -4,6 +4,7 @@ import java.io.IOException; import java.io.StringReader;
import java.io.StringWriter;
import java.util.Observable;
+import java.util.concurrent.TimeUnit;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
@@ -23,10 +24,12 @@ import javax.xml.xpath.XPathFactory; import org.apache.hc.client5.http.auth.AuthenticationException;
import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.config.ConnectionConfig;
import org.apache.hc.client5.http.impl.auth.BasicScheme;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
-import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
+import org.apache.hc.client5.http.impl.io.BasicHttpClientConnectionManager;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.core5.http.HttpHeaders;
import org.apache.hc.core5.http.HttpHost;
@@ -55,7 +58,7 @@ public abstract class ECPAuthenticatorBase extends Observable { protected boolean retryWithoutAt;
public ECPAuthenticatorBase(CloseableHttpClient client) {
- this.client = client == null ? HttpClients.createSystem() : client;
+ this.client = client == null ? defaultClient() : client;
documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
@@ -72,6 +75,18 @@ public abstract class ECPAuthenticatorBase extends Observable { public ECPAuthenticatorBase() {
this(null);
}
+
+ private static CloseableHttpClient defaultClient() {
+ ConnectionConfig connConfig = ConnectionConfig.custom()
+ .setConnectTimeout(4000, TimeUnit.MILLISECONDS)
+ .setSocketTimeout(10000, TimeUnit.MILLISECONDS)
+ .build();
+ BasicHttpClientConnectionManager cm = new BasicHttpClientConnectionManager();
+ cm.setConnectionConfig(connConfig);
+ return HttpClientBuilder.create()
+ .setConnectionManager(cm)
+ .build();
+ }
private CloseableHttpResponse exec(Document idpRequest, String user, String pass)
throws ECPAuthenticationException {
|