aboutsummaryrefslogtreecommitdiffstats
path: root/aai-schema-abstraction
diff options
context:
space:
mode:
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>2025-01-06 11:34:17 +0100
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>2025-01-06 15:05:46 +0100
commit671edd133f4858b4b17663d109a23c80bbffa6b7 (patch)
treea9b05a6180b7c061b57c711b58f867281c3b4d52 /aai-schema-abstraction
parente0d6fcbfcdc38edd17b36050feead7314667f4a5 (diff)
Make aai-common agnostic of the embedded server (remove jetty-specific code)
- remove spring-boot-starter-[web,tomcat,jetty,jersey] in aai-rest - remove spring-boot-starter-web in aai-schema-ingest - remove keystore and certificate related leftovers - this prepares the move to tomcat for the spring boot 3 upgrade (details in the ticket) Issue-ID: AAI-4100 Change-Id: I04194c636f0548f7a832e430a40e48710ea4c00f Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
Diffstat (limited to 'aai-schema-abstraction')
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/JsonSchemaProvider.java4
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/SecureClientHttpRequestFactory.java116
2 files changed, 1 insertions, 119 deletions
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/JsonSchemaProvider.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/JsonSchemaProvider.java
index fba6e0fd..5647d6df 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/JsonSchemaProvider.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/JsonSchemaProvider.java
@@ -61,9 +61,7 @@ public class JsonSchemaProvider implements SchemaProvider {
public JsonSchemaProvider(JsonSchemaProviderConfig config) {
this.config = config;
- SecureClientHttpRequestFactory fac = new SecureClientHttpRequestFactory(config);
- fac.setBufferRequestBody(false);
- this.restTemplate = new RestTemplate(fac);
+ this.restTemplate = new RestTemplate();
}
@Override
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/SecureClientHttpRequestFactory.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/SecureClientHttpRequestFactory.java
deleted file mode 100644
index 3f17c9be..00000000
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/SecureClientHttpRequestFactory.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 European Software Marketing Ltd.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aai.schemaif.json;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.net.HttpURLConnection;
-import java.security.KeyStore;
-import java.security.cert.X509Certificate;
-
-import javax.net.ssl.HostnameVerifier;
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.KeyManagerFactory;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSession;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.X509TrustManager;
-
-import org.springframework.http.client.SimpleClientHttpRequestFactory;
-
-public class SecureClientHttpRequestFactory extends SimpleClientHttpRequestFactory {
-
- private static final String SSL_PROTOCOL = "TLS";
- private static final String KEYSTORE_ALGORITHM = "SunX509";
- private static final String KEYSTORE_TYPE = "PKCS12";
- private JsonSchemaProviderConfig config;
-
- public SecureClientHttpRequestFactory(JsonSchemaProviderConfig config) {
- super();
- this.config = config;
- }
-
- @Override
- protected void prepareConnection(final HttpURLConnection connection, final String httpMethod) throws IOException {
- if (connection instanceof HttpsURLConnection) {
- ((HttpsURLConnection) connection).setSSLSocketFactory(getSSLContext().getSocketFactory());
- ((HttpsURLConnection) connection).setHostnameVerifier(new HostnameVerifier() {
- @Override
- public boolean verify(String str, SSLSession sslSession) {
- return true;
- }
- });
- } else {
-
- throw new IOException();
- }
- super.prepareConnection(connection, httpMethod);
- }
-
- protected SSLContext getSSLContext() throws IOException {
- try {
- TrustManager[] trustAllCerts = null;
-
- // We aren't validating certificates, so create a trust manager that
- // does
- // not validate certificate chains.
- trustAllCerts = new TrustManager[] {new X509TrustManager() {
- public X509Certificate[] getAcceptedIssuers() {
- return null;
- }
-
- public void checkClientTrusted(X509Certificate[] certs, String authType) {
- }
-
- public void checkServerTrusted(X509Certificate[] certs, String authType) {
- }
- }};
-
- SSLContext ctx = SSLContext.getInstance(SSL_PROTOCOL);
- KeyManagerFactory kmf = KeyManagerFactory.getInstance(KEYSTORE_ALGORITHM);
- KeyStore ks = KeyStore.getInstance(KEYSTORE_TYPE);
-
- char[] pwd = null;
- if (config.getSchemaServiceCertPwd() != null) {
- pwd = config.getSchemaServiceCertPwd().toCharArray();
- }
-
- if (config.getSchemaServiceCertFile() != null) {
- try (FileInputStream fin = new FileInputStream(config.getSchemaServiceCertFile())) {
- // Load the keystore and initialize the key manager factory.
- ks.load(fin, pwd);
- kmf.init(ks, pwd);
-
- ctx.init(kmf.getKeyManagers(), trustAllCerts, null);
- }
- } else {
- ctx.init(null, trustAllCerts, null);
- }
-
- return ctx;
- } catch (Exception e) {
- throw new IOException("Problem with getting the SSL Context::" + e.getMessage(), e);
- }
-
- }
-
-}