aboutsummaryrefslogtreecommitdiffstats
path: root/profiles/http/src/main/java/org/onap
diff options
context:
space:
mode:
Diffstat (limited to 'profiles/http/src/main/java/org/onap')
-rw-r--r--profiles/http/src/main/java/org/onap/cli/fw/http/auth/OnapCommandHttpAuthClient.java11
-rw-r--r--profiles/http/src/main/java/org/onap/cli/fw/http/connect/OnapHttpConnection.java20
-rw-r--r--profiles/http/src/main/java/org/onap/cli/fw/http/schema/OnapCommandSchemaHttpLoader.java2
3 files changed, 20 insertions, 13 deletions
diff --git a/profiles/http/src/main/java/org/onap/cli/fw/http/auth/OnapCommandHttpAuthClient.java b/profiles/http/src/main/java/org/onap/cli/fw/http/auth/OnapCommandHttpAuthClient.java
index e5f17bec..075c1304 100644
--- a/profiles/http/src/main/java/org/onap/cli/fw/http/auth/OnapCommandHttpAuthClient.java
+++ b/profiles/http/src/main/java/org/onap/cli/fw/http/auth/OnapCommandHttpAuthClient.java
@@ -32,6 +32,10 @@ import org.onap.cli.fw.http.schema.OnapCommandSchemaHttpLoader;
import org.onap.cli.fw.output.OnapCommandResultAttribute;
import org.onap.cli.fw.registrar.OnapCommandRegistrar;
import org.onap.cli.fw.utils.OnapCommandUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import org.onap.cli.fw.http.error.OnapCommandLoginFailed;
/**
* Oclip Auth client helps to do login and logout.
@@ -39,6 +43,7 @@ import org.onap.cli.fw.utils.OnapCommandUtils;
*/
public class OnapCommandHttpAuthClient {
+ private static Logger logger = LoggerFactory.getLogger(OnapCommandHttpAuthClient.class); //NOSONAR
private OnapHttpCommand cmd = null;
private OnapHttpConnection http = null;
@@ -98,7 +103,11 @@ public class OnapCommandHttpAuthClient {
logout.execute();
- this.http.close();
+ try {
+ this.http.close();
+ } catch (IOException e) {
+ throw new OnapCommandLoginFailed("Exception when closing httpclient");
+ }
}
/**
diff --git a/profiles/http/src/main/java/org/onap/cli/fw/http/connect/OnapHttpConnection.java b/profiles/http/src/main/java/org/onap/cli/fw/http/connect/OnapHttpConnection.java
index 732e6c0a..95ad7266 100644
--- a/profiles/http/src/main/java/org/onap/cli/fw/http/connect/OnapHttpConnection.java
+++ b/profiles/http/src/main/java/org/onap/cli/fw/http/connect/OnapHttpConnection.java
@@ -38,7 +38,6 @@ import org.apache.http.HttpResponse;
import org.apache.http.annotation.Contract;
import org.apache.http.annotation.ThreadingBehavior;
import org.apache.http.client.CookieStore;
-import org.apache.http.client.HttpClient;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
@@ -47,14 +46,11 @@ import org.apache.http.client.methods.HttpPatch;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.methods.HttpRequestBase;
-import org.apache.http.client.protocol.ClientContext;
import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.HttpClientConnectionManager;
import org.apache.http.conn.socket.ConnectionSocketFactory;
-import org.apache.http.conn.ssl.AllowAllHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
-import org.apache.http.conn.ssl.X509HostnameVerifier;
import org.apache.http.cookie.Cookie;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
@@ -71,7 +67,10 @@ import org.onap.cli.fw.http.conf.OnapCommandHttpConstants;
import org.onap.cli.fw.http.error.OnapCommandHttpFailure;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
+import org.apache.http.client.protocol.HttpClientContext;
+import org.apache.http.conn.ssl.NoopHostnameVerifier;
+import org.apache.http.impl.client.CloseableHttpClient;
+import javax.net.ssl.HostnameVerifier;
/**
* Helps to make http connection.<br>
*/
@@ -79,7 +78,7 @@ public class OnapHttpConnection {
private static Logger log = LoggerFactory.getLogger(OnapHttpConnection.class);
- private HttpClient httpClient = null;
+ private CloseableHttpClient httpClient = null;
Map<String, String> mapCommonHeaders = new HashMap<> ();
@@ -108,7 +107,7 @@ public class OnapHttpConnection {
SSLContext sslContext = SSLContext.getInstance(OnapCommandHttpConstants.SSLCONTEST_TLS);
sslContext.init(null, new TrustManager[] { new TrustAllX509TrustManager() },
new java.security.SecureRandom());
- X509HostnameVerifier hostnameVerifier = new AllowAllHostnameVerifier();
+ HostnameVerifier hostnameVerifier = new NoopHostnameVerifier();
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder
.<ConnectionSocketFactory>create()
.register("https", new SSLConnectionSocketFactory(sslContext, hostnameVerifier)).build();
@@ -320,7 +319,7 @@ public class OnapHttpConnection {
CookieStore cookieStore = new BasicCookieStore();
updateInputFromCookies(input, cookieStore);
HttpContext localContext = new BasicHttpContext();
- localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
+ localContext.setAttribute(HttpClientContext.COOKIE_STORE, cookieStore);
this.initHttpClient(input.getUri().startsWith("https"));
@@ -337,11 +336,10 @@ public class OnapHttpConnection {
return result;
}
- @SuppressWarnings("deprecation")
- public void close() {
+ public void close() throws IOException {
this.mapCommonHeaders.clear();
if (this.httpClient != null) {
- this.httpClient.getConnectionManager().shutdown();
+ this.httpClient.close();
}
}
diff --git a/profiles/http/src/main/java/org/onap/cli/fw/http/schema/OnapCommandSchemaHttpLoader.java b/profiles/http/src/main/java/org/onap/cli/fw/http/schema/OnapCommandSchemaHttpLoader.java
index e7a643ad..35501208 100644
--- a/profiles/http/src/main/java/org/onap/cli/fw/http/schema/OnapCommandSchemaHttpLoader.java
+++ b/profiles/http/src/main/java/org/onap/cli/fw/http/schema/OnapCommandSchemaHttpLoader.java
@@ -246,7 +246,7 @@ public class OnapCommandSchemaHttpLoader {
validateHttpSccessCodes(errorList, (List<Object>) valMap.get(key1));
}
List<String> list = (ArrayList) valMap.get(key1);
- cmd.setSuccessStatusCodes(list.stream().map(s -> Integer.parseInt(s)).collect(Collectors.toList()));
+ cmd.setSuccessStatusCodes(list.stream().map(Integer::parseInt).collect(Collectors.toList()));
break;
case OnapCommandHttpConstants.RESULT_MAP: