Make aai-common agnostic of the embedded server (remove jetty-specific code) 52/139852/4
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>
Mon, 6 Jan 2025 10:34:17 +0000 (11:34 +0100)
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>
Mon, 6 Jan 2025 14:05:46 +0000 (15:05 +0100)
- 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>
31 files changed:
.gitignore
aai-core/.gitignore
aai-core/pom.xml
aai-core/src/main/java/org/onap/aai/prevalidation/ValidationServiceOneWayClient.java
aai-core/src/main/java/org/onap/aai/prevalidation/ValidationServiceRestClient.java
aai-core/src/main/java/org/onap/aai/util/HttpsAuthClient.java [deleted file]
aai-core/src/main/java/org/onap/aai/util/HttpsAuthExternalClient.java [deleted file]
aai-core/src/main/java/org/onap/aai/util/RestController.java [deleted file]
aai-core/src/main/java/org/onap/aai/util/RestControllerInterface.java [deleted file]
aai-core/src/test/resources/bundleconfig-local/aaf/cadi.properties [deleted file]
aai-core/src/test/resources/bundleconfig-local/aaf/org.onap.aai.props [deleted file]
aai-els-onap-logging/pom.xml
aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIApplicationConfig.java
aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIConstants.java
aai-els-onap-logging/src/test/java/org/onap/aai/util/AAIApplicationConfigTest.java
aai-els-onap-logging/src/test/resources/application.properties
aai-rest/pom.xml
aai-rest/src/main/java/org/onap/aai/restclient/AAIRestClient.java
aai-rest/src/main/java/org/onap/aai/restclient/JettyPasswordDecoder.java [deleted file]
aai-rest/src/main/java/org/onap/aai/restclient/NoAuthRestClient.java
aai-rest/src/main/java/org/onap/aai/restclient/OneWaySSLRestClient.java
aai-rest/src/main/java/org/onap/aai/restclient/PasswordDecoder.java [deleted file]
aai-rest/src/main/java/org/onap/aai/restclient/PropertyPasswordConfiguration.java [deleted file]
aai-rest/src/main/java/org/onap/aai/restclient/RestClient.java
aai-rest/src/main/java/org/onap/aai/restclient/TwoWaySSLRestClient.java
aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/JsonSchemaProvider.java
aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/SecureClientHttpRequestFactory.java [deleted file]
aai-schema-ingest/pom.xml
aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceOneWayClient.java
aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceRestClient.java
aai-schema-ingest/src/test/java/org/onap/aai/restclient/SchemaRestClientTest.java

index 42a9bdb..7d9fc07 100644 (file)
@@ -3,8 +3,6 @@
 target/
 **/logs/
 **/debug-logs/
-bundleconfig-local/etc/auth/aai-client-cert.p12
-bundleconfig-local/etc/auth/tomcat_keystore
 bundleconfig-local/etc/logback.xml
 /.pydevproject
 /bin/
index 2db7c68..87eaa08 100644 (file)
@@ -1,8 +1,6 @@
 .settings
 target/
 **/logs/
-bundleconfig-local/etc/auth/aai-client-cert.p12
-bundleconfig-local/etc/auth/tomcat_keystore
 bundleconfig-local/etc/oxm
 src/main/aai_schema
 bundleconfig-local/etc/logback.xml
index 3a993fe..37bc75a 100644 (file)
@@ -167,6 +167,10 @@ limitations under the License.
                        <artifactId>javax.json</artifactId>
                        <version>1.1.4</version>
                </dependency>
+               <dependency>
+                       <groupId>javax.servlet</groupId>
+                       <artifactId>javax.servlet-api</artifactId>
+               </dependency>
                <dependency>
                        <groupId>org.janusgraph</groupId>
                        <artifactId>janusgraph-core</artifactId>
@@ -349,6 +353,10 @@ limitations under the License.
                        <groupId>com.fasterxml.jackson.core</groupId>
                        <artifactId>jackson-databind</artifactId>
                </dependency>
+               <dependency>
+                       <groupId>com.fasterxml.jackson.datatype</groupId>
+                       <artifactId>jackson-datatype-jsr310</artifactId>
+               </dependency>
                <dependency>
                        <groupId>com.fasterxml.jackson.core</groupId>
                        <artifactId>jackson-annotations</artifactId>
index f72f6bc..e148cee 100644 (file)
@@ -36,12 +36,6 @@ public class ValidationServiceOneWayClient extends OneWaySSLRestClient {
     @Value("${validation.service.base.url}")
     private String baseUrl;
 
-    @Value("${validation.service.ssl.trust-store}")
-    private String truststorePath;
-
-    @Value("${validation.service.ssl.trust-store-password}")
-    private String truststorePassword;
-
     @Value("${validation.service.timeout-in-milliseconds}")
     private Integer timeout;
 
@@ -50,16 +44,6 @@ public class ValidationServiceOneWayClient extends OneWaySSLRestClient {
         return baseUrl;
     }
 
-    @Override
-    protected String getTruststorePath() {
-        return truststorePath;
-    }
-
-    @Override
-    protected char[] getTruststorePassword() {
-        return truststorePassword.toCharArray();
-    }
-
     @Override
     protected HttpComponentsClientHttpRequestFactory getHttpRequestFactory() throws Exception {
         HttpComponentsClientHttpRequestFactory requestFactory = super.getHttpRequestFactory();
index af28306..a1ca4b4 100644 (file)
@@ -38,18 +38,6 @@ public class ValidationServiceRestClient extends TwoWaySSLRestClient {
     @Value("${validation.service.base.url}")
     private String baseUrl;
 
-    @Value("${validation.service.ssl.key-store}")
-    private String keystorePath;
-
-    @Value("${validation.service.ssl.trust-store}")
-    private String truststorePath;
-
-    @Value("${validation.service.ssl.key-store-password}")
-    private String keystorePassword;
-
-    @Value("${validation.service.ssl.trust-store-password}")
-    private String truststorePassword;
-
     @Value("${validation.service.timeout-in-milliseconds}")
     private Integer timeout;
 
@@ -58,26 +46,6 @@ public class ValidationServiceRestClient extends TwoWaySSLRestClient {
         return baseUrl;
     }
 
-    @Override
-    protected String getKeystorePath() {
-        return keystorePath;
-    }
-
-    @Override
-    protected String getTruststorePath() {
-        return truststorePath;
-    }
-
-    @Override
-    protected char[] getKeystorePassword() {
-        return keystorePassword.toCharArray();
-    }
-
-    @Override
-    protected char[] getTruststorePassword() {
-        return truststorePassword.toCharArray();
-    }
-
     protected HttpComponentsClientHttpRequestFactory getHttpRequestFactory() throws Exception {
         HttpComponentsClientHttpRequestFactory requestFactory = super.getHttpRequestFactory();
         requestFactory.setConnectionRequestTimeout(timeout);
diff --git a/aai-core/src/main/java/org/onap/aai/util/HttpsAuthClient.java b/aai-core/src/main/java/org/onap/aai/util/HttpsAuthClient.java
deleted file mode 100644 (file)
index 2320159..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.util;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.security.KeyManagementException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.UnrecoverableKeyException;
-import java.security.cert.CertificateException;
-
-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.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.glassfish.jersey.client.ClientConfig;
-import org.onap.aai.aailog.filter.RestControllerClientRequestLoggingInterceptor;
-import org.onap.aai.aailog.filter.RestControllerClientResponseLoggingInterceptor;
-import org.onap.aai.exceptions.AAIException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class HttpsAuthClient {
-
-    private static final Logger logger = LoggerFactory.getLogger(HttpsAuthClient.class);
-
-    /**
-     * The main method.
-     *
-     * @param args the arguments
-     */
-    public static void main(String[] args) {
-        try {
-            String url = AAIConfig.get(AAIConstants.AAI_SERVER_URL) + "business/customers";
-            System.out.println("Making Jersey https call...");
-            Client client = HttpsAuthClient.getClient();
-
-            Response res = client.target(url)
-                    .request(MediaType.APPLICATION_JSON)
-                    .header("X-TransactionId", "PROV001")
-                    .header("X-FromAppId", "AAI").get();
-        } catch (KeyManagementException e) {
-            logger.debug("HttpsAuthClient KeyManagement error : {}", e.getMessage());
-        } catch (Exception e) {
-            logger.debug("HttpsAuthClient error : {}", e.getMessage());
-        }
-    }
-
-    /**
-     * Gets the client.
-     *
-     * @param truststorePath the truststore path
-     * @param truststorePassword the truststore password
-     * @param keystorePath the keystore path
-     * @param keystorePassword the keystore password
-     * @return the client
-     * @throws KeyManagementException the key management exception
-     */
-    public static Client getClient(String truststorePath, String truststorePassword, String keystorePath,
-            String keystorePassword) throws KeyManagementException, UnrecoverableKeyException, CertificateException,
-            NoSuchAlgorithmException, KeyStoreException, IOException {
-
-        ClientConfig config = new ClientConfig();
-        config.register(org.onap.aai.restcore.CustomJacksonJaxBJsonProvider.class);
-
-        SSLContext ctx = null;
-        try {
-            System.setProperty("javax.net.ssl.trustStore", truststorePath);
-            System.setProperty("javax.net.ssl.trustStorePassword", truststorePassword);
-            HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
-                public boolean verify(String string, SSLSession ssls) {
-                    return true;
-                }
-            });
-
-            ctx = SSLContext.getInstance("TLSv1.2");
-            KeyManagerFactory kmf = null;
-
-            try (FileInputStream fin = new FileInputStream(keystorePath)) {
-                kmf = KeyManagerFactory.getInstance("SunX509");
-                KeyStore ks = KeyStore.getInstance("PKCS12");
-                char[] pwd = keystorePassword.toCharArray();
-                ks.load(fin, pwd);
-                kmf.init(ks, pwd);
-            } catch (Exception e) {
-                System.out.println("Error setting up kmf: exiting " + e.getMessage());
-                throw e;
-            }
-
-            ctx.init(kmf.getKeyManagers(), null, null);
-            config.property("jersey.config.client.ssl.context", ctx);
-            config.property("jersey.config.client.hostname.verifier", (HostnameVerifier) (s, sslSession) -> true);
-        } catch (Exception e) {
-            System.out.println("Error setting up config: exiting " + e.getMessage());
-            throw e;
-        }
-
-        Client client = ClientBuilder.newClient(config);
-        client.register(new RestControllerClientRequestLoggingInterceptor());
-        client.register(new RestControllerClientResponseLoggingInterceptor());
-        // uncomment this line to get more logging for the request/response
-        // client.addFilter(new LoggingFilter(System.out));
-
-        return client;
-    }
-
-    /**
-     * Gets the client.
-     *
-     * @return the client
-     * @throws KeyManagementException the key management exception
-     */
-    public static Client getClient() throws KeyManagementException, AAIException, UnrecoverableKeyException,
-            CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException {
-        String truststorePath = null;
-        String truststorePassword = null;
-        String keystorePath = null;
-        String keystorePassword = null;
-        truststorePath = AAIConstants.AAI_HOME_ETC_AUTH + AAIConfig.get(AAIConstants.AAI_TRUSTSTORE_FILENAME);
-        truststorePassword = AAIConfig.get(AAIConstants.AAI_TRUSTSTORE_PASSWD);
-        keystorePath = AAIConstants.AAI_HOME_ETC_AUTH + AAIConfig.get(AAIConstants.AAI_KEYSTORE_FILENAME);
-        keystorePassword = AAIConfig.get(AAIConstants.AAI_KEYSTORE_PASSWD);
-        return getClient(truststorePath, truststorePassword, keystorePath, keystorePassword);
-    }
-
-}
diff --git a/aai-core/src/main/java/org/onap/aai/util/HttpsAuthExternalClient.java b/aai-core/src/main/java/org/onap/aai/util/HttpsAuthExternalClient.java
deleted file mode 100644 (file)
index 1ace66c..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.util;
-
-import java.io.FileInputStream;
-
-import org.glassfish.jersey.client.ClientConfig;
-import org.glassfish.jersey.SslConfigurator;
-
-import javax.net.ssl.HostnameVerifier;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSession;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-
-public class HttpsAuthExternalClient {
-
-    /**
-     * Gets the client.
-     *
-     * @param keystoreFileName the keystore file name
-     * @param keystorePassword the keystore password
-     * @return the client
-     * @throws Exception the exception
-     */
-    public static Client getClient(String keystoreFileName, String keystorePassword) throws Exception {
-
-        ClientConfig config = new ClientConfig();
-        config.register(org.onap.aai.restcore.CustomJacksonJaxBJsonProvider.class);
-
-        SSLContext sslContext = null;
-        String truststorePath = AAIConstants.AAI_HOME_ETC_AUTH + AAIConfig.get(AAIConstants.AAI_TRUSTSTORE_FILENAME);
-        try (FileInputStream tin = new FileInputStream(truststorePath)) {
-            String truststorePassword = AAIConfig.get(AAIConstants.AAI_TRUSTSTORE_PASSWD);
-            String keystorePath = AAIConstants.AAI_HOME_ETC_AUTH + keystoreFileName;
-
-            SslConfigurator sslConfig = SslConfigurator.newInstance()
-                    .trustStoreFile(truststorePath)
-                    .trustStorePassword(truststorePassword)
-                    .keyStoreFile(keystorePath)
-                    .keyStorePassword(keystorePassword);
-
-            sslContext = sslConfig.createSSLContext();
-
-            HostnameVerifier hostnameVerifier = new HostnameVerifier() {
-                @Override
-                public boolean verify(String s, SSLSession sslSession) {
-                    return true;
-                }
-            };
-
-            Client client = ClientBuilder.newBuilder()
-                    .withConfig(config)
-                    .sslContext(sslContext)
-                    .hostnameVerifier(hostnameVerifier)
-                    .build();
-
-            // Uncomment this line to get more logging for the request/response
-            // client.register(new
-            // LoggingFeature(Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME),
-            // Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 8192));
-
-            return client;
-        } catch (Exception e) {
-            throw e;
-        }
-    }
-
-}
diff --git a/aai-core/src/main/java/org/onap/aai/util/RestController.java b/aai-core/src/main/java/org/onap/aai/util/RestController.java
deleted file mode 100644 (file)
index b72b5af..0000000
+++ /dev/null
@@ -1,640 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.util;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.type.TypeFactory;
-
-import javax.ws.rs.client.Entity;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.security.KeyManagementException;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.UnrecoverableKeyException;
-import java.security.cert.CertificateException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-
-import javax.ws.rs.ClientErrorException;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.onap.aai.exceptions.AAIException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RestController implements RestControllerInterface {
-
-    private static final String TARGET_NAME = "AAI";
-    private static final Logger LOGGER = LoggerFactory.getLogger(RestController.class);
-
-    private static Client client = null;
-
-    private String restSrvrBaseURL;
-
-    private String overrideLocalHost = null;
-
-    // To do - Come up with helper function that will automatically
-    // generate the REST API path based on path parameter(s) and query parameter(s)!
-    public static final String REST_APIPATH_COMPLEXES = "cloud-infrastructure/complexes";
-    public static final String REST_APIPATH_COMPLEX = "cloud-infrastructure/complexes/complex/";
-    public static final String REST_APIPATH_PSERVERS = "cloud-infrastructure/pservers";
-    public static final String REST_APIPATH_PSERVER = "cloud-infrastructure/pservers/pserver/";
-    public static final String REST_APIPATH_PHYSICALLINKS = "network/physical-links/";
-    public static final String REST_APIPATH_PHYSICALLINK = "network/physical-links/physical-link/";
-    public static final String REST_APIPATH_PINTERFACES = "network/p-interfaces/";
-    public static final String REST_APIPATH_PINTERFACE = "network/p-interfaces/p-interface/";
-    public static final String REST_APIPATH_VPLSPES = "network/vpls-pes/";
-    public static final String REST_APIPATH_VPLSPE = "network/vpls-pes/vpls-pe/";
-    public static final String REST_APIPATH_UPDATE = "actions/update/";
-    public static final String REST_APIPATH_SEARCH = "search/nodes-query?search-node-type=";
-
-    public static final String REST_APIPATH_CLOUDREGION = "cloud-infrastructure/cloud-regions/cloud-region/";
-    public static final String REST_APIPATH_TENANT = "cloud-infrastructure/tenants/tenant/";
-    public static final String REST_APIPATH_VIRTUAL_DATA_CENTER = "cloud-infrastructure/virtual-data-centers/virtual-data-center/";
-    public static final String REST_APIPATH_VIRTUAL_DATA_CENTERS = "cloud-infrastructure/virtual-data-centers/";
-    public static final String REST_APIPATH_GENERIC_VNF = "network/generic-vnfs/generic-vnf/";
-    public static final String REST_APIPATH_GENERIC_VNFS = "network/generic-vnfs";
-    public static final String REST_APIPATH_L3_NETWORK = "network/l3-networks/l3-network/";
-    public static final String REST_APIPATH_L3_NETWORKS = "network/l3-networks";
-    public static final String REST_APIPATH_INSTANCE_GROUP = "network/instance-groups/instance-group";
-    public static final String REST_APIPATH_INSTANCE_GROUPS = "network/instance-groups";
-    public static final String REST_APIPATH_VFMODULE = "nodes/vf-modules/vf-module/";
-
-    public static final String REST_APIPATH_VCE = "network/vces/vce/";
-
-    public static final String REST_APIPATH_SERVICE = "service-design-and-creation/services/service/";
-    public static final String REST_APIPATH_LOGICALLINKS = "network/logical-links/";
-    public static final String REST_APIPATH_LOGICALLINK = "network/logical-links/logical-link/";
-
-    public RestController(String truststorePath, String truststorePassword, String keystorePath,
-            String keystorePassword) throws AAIException {
-        this.initRestClient(truststorePath, truststorePassword, keystorePath, keystorePassword);
-    }
-
-    /**
-     * Inits the rest client.
-     *
-     * @throws AAIException the AAI exception
-     */
-    public void initRestClient(String truststorePath, String truststorePassword, String keystorePath,
-            String keystorePassword) throws AAIException {
-        if (client == null) {
-            try {
-                client = getHttpsAuthClient(truststorePath, truststorePassword, keystorePath, keystorePassword);
-            } catch (KeyManagementException e) {
-                throw new AAIException("AAI_7117", "KeyManagementException in REST call to DB: " + e.toString());
-            } catch (Exception e) {
-                throw new AAIException("AAI_7117", " Exception in REST call to DB: " + e.toString());
-            }
-        }
-    }
-
-    public Client getHttpsAuthClient(String truststorePath, String truststorePassword, String keystorePath,
-            String keystorePassword) throws KeyManagementException, UnrecoverableKeyException, CertificateException,
-            NoSuchAlgorithmException, KeyStoreException, IOException {
-        return HttpsAuthClient.getClient(truststorePath, truststorePassword, keystorePath, keystorePassword);
-    }
-
-    public Client getHttpsAuthClient() throws KeyManagementException, UnrecoverableKeyException, CertificateException,
-            NoSuchAlgorithmException, KeyStoreException, IOException, AAIException {
-        return HttpsAuthClient.getClient();
-    }
-
-    /**
-     * Sets the rest srvr base URL.
-     *
-     * @param baseURL the base URL
-     * @throws AAIException the AAI exception
-     */
-    public void SetRestSrvrBaseURL(String baseURL) throws AAIException {
-        if (baseURL == null)
-            throw new AAIException("AAI_7117", "REST Server base URL cannot be null.");
-        restSrvrBaseURL = baseURL;
-    }
-
-    /**
-     * Gets the rest srvr base URL.
-     *
-     * @return the rest srvr base URL
-     */
-    public String getRestSrvrBaseURL() {
-        return restSrvrBaseURL;
-    }
-
-    public <T> void Get(T t, String sourceID, String transId, String path, RestObject<T> restObject, boolean oldserver)
-            throws AAIException {
-        Get(t, sourceID, transId, path, restObject, oldserver, AAIConstants.AAI_RESOURCES_PORT);
-    }
-
-    /**
-     * To do - optimization and automation. Also make it as generic as possible.
-     *
-     * @param <T> the generic type
-     * @param t the t
-     * @param sourceID the source ID
-     * @param transId the trans id
-     * @param path the path
-     * @param restObject the rest object
-     * @param oldserver the oldserver
-     * @throws AAIException the AAI exception
-     */
-    @SuppressWarnings("unchecked")
-    public <T> void Get(T t, String sourceID, String transId, String path, RestObject<T> restObject, boolean oldserver,
-            int port) throws AAIException {
-        String methodName = "Get";
-        String url = "";
-        transId += ":" + UUID.randomUUID().toString();
-
-        LOGGER.debug(methodName + " start");
-
-        restObject.set(t);
-
-        if (oldserver) {
-            url = AAIConfig.get(AAIConstants.AAI_OLDSERVER_URL) + path;
-        } else {
-            if (overrideLocalHost == null) {
-                overrideLocalHost = AAIConfig.get(AAIConstants.AAI_LOCAL_OVERRIDE,
-                        AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT);
-            }
-            if (AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT.equals(overrideLocalHost)) {
-                url = String.format(AAIConstants.AAI_LOCAL_REST, port,
-                        AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP)) + path;
-            } else {
-                url = String.format(AAIConstants.AAI_LOCAL_REST_OVERRIDE, overrideLocalHost,
-                        AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP)) + path;
-            }
-        }
-        LOGGER.debug(url + " for the get REST API");
-        Response response = client.target(url)
-                .request(MediaType.APPLICATION_JSON)
-                .header("X-TransactionId", transId)
-                .header("X-FromAppId", sourceID)
-                .header("Real-Time", "true")
-                .get();
-
-        // System.out.println("response.EntityInputSream()="+response.getEntityInputStream().toString());
-        // System.out.println("response.tostring()="+response.toString());
-
-        if (response.getStatus() == 200) {
-            // System.out.println(methodName + ": url=" + url);
-            T entity = response.readEntity((Class<T>) t.getClass());
-            restObject.set(entity);
-            restObject.set(t);
-            LOGGER.debug(methodName + "REST api GET was successfull!");
-        } else {
-            // System.out.println(methodName + ": url=" + url + " failed with status=" +
-            // response.getStatus());
-            throw new AAIException("AAI_7116", methodName + " with status=" + response.getStatus() + ", url=" + url);
-        }
-    }
-
-    /**
-     * To do - optimization and automation. Also make it as generic as possible.
-     *
-     * @param <T> the generic type
-     * @param t the t
-     * @param sourceID the source ID
-     * @param transId the trans id
-     * @param path the path
-     * @param restObject the rest object
-     * @param oldserver the oldserver
-     * @throws AAIException the AAI exception
-     */
-    @SuppressWarnings("unchecked")
-    public <T> void Get(T t, String sourceID, String transId, String path, RestObject<T> restObject, String apiVersion)
-            throws AAIException {
-        String methodName = "Get";
-        String url = "";
-        transId += ":" + UUID.randomUUID().toString();
-
-        LOGGER.debug(methodName + " start");
-
-        restObject.set(t);
-
-        url = AAIConfig.get(AAIConstants.AAI_SERVER_URL_BASE) + apiVersion + "/" + path;
-
-        LOGGER.debug(url + " for the get REST API");
-        Response response = client.target(url)
-                .request(MediaType.APPLICATION_JSON)
-                .header("X-TransactionId", transId)
-                .header("X-FromAppId", sourceID)
-                .header("Real-Time", "true")
-                .get();
-
-        // System.out.println("response.EntityInputSream()="+response.getEntityInputStream().toString());
-        // System.out.println("response.tostring()="+response.toString());
-
-        if (response.getStatus() == 200) {
-            // System.out.println(methodName + ": url=" + url);
-            T entity = response.readEntity((Class<T>) t.getClass());
-            restObject.set(entity);
-            LOGGER.debug(methodName + "REST api GET was successfull!");
-        } else {
-            // System.out.println(methodName + ": url=" + url + " failed with status=" +
-            // response.getStatus());
-            throw new AAIException("AAI_7116", methodName + " with status=" + response.getStatus() + ", url=" + url);
-        }
-    }
-
-    /**
-     * Map json to object list.
-     *
-     * @param <T> the generic type
-     * @param typeDef the type def
-     * @param json the json
-     * @param clazz the clazz
-     * @return the list
-     * @throws Exception the exception
-     */
-    private <T> List<T> mapJsonToObjectList(T typeDef, String json, Class<?> clazz) throws Exception {
-        List<T> list;
-        ObjectMapper mapper = new ObjectMapper();
-        System.out.println(json);
-        TypeFactory t = TypeFactory.defaultInstance();
-        list = mapper.readValue(json, t.constructCollectionType(ArrayList.class, clazz));
-
-        return list;
-    }
-
-    /**
-     * Put.
-     *
-     * @param <T> the generic type
-     * @param t the t
-     * @param sourceID the source ID
-     * @param transId the trans id
-     * @param path the path
-     * @throws AAIException the AAI exception
-     */
-    public <T> void Put(T t, String sourceID, String transId, String path) throws AAIException {
-        Put(t, sourceID, transId, path, false, AAIConstants.AAI_RESOURCES_PORT);
-    }
-
-    /**
-     * Put.
-     *
-     * @param <T> the generic type
-     * @param t the t
-     * @param sourceID the source ID
-     * @param transId the trans id
-     * @param path the path
-     * @throws AAIException the AAI exception
-     */
-    public <T> void Put(T t, String sourceID, String transId, String path, boolean oldserver) throws AAIException {
-        Put(t, sourceID, transId, path, oldserver, AAIConstants.AAI_RESOURCES_PORT);
-    }
-
-    /**
-     * Put.
-     *
-     * @param <T> the generic type
-     * @param t the t
-     * @param sourceID the source ID
-     * @param transId the trans id
-     * @param path the path
-     * @param oldserver the oldserver
-     * @throws AAIException the AAI exception
-     */
-    public <T> void Put(T t, String sourceID, String transId, String path, boolean oldserver, int port)
-            throws AAIException {
-        String methodName = "Put";
-        String url = "";
-        transId += ":" + UUID.randomUUID().toString();
-
-        LOGGER.debug(methodName + " start");
-
-        if (oldserver) {
-            url = AAIConfig.get(AAIConstants.AAI_OLDSERVER_URL) + path;
-        } else {
-            if (overrideLocalHost == null) {
-                overrideLocalHost = AAIConfig.get(AAIConstants.AAI_LOCAL_OVERRIDE,
-                        AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT);
-            }
-            if (AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT.equals(overrideLocalHost)) {
-                url = String.format(AAIConstants.AAI_LOCAL_REST, port,
-                        AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP)) + path;
-            } else {
-                url = String.format(AAIConstants.AAI_LOCAL_REST_OVERRIDE, overrideLocalHost,
-                        AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP)) + path;
-            }
-        }
-
-        Response response = client.target(url)
-                .request(MediaType.APPLICATION_JSON)
-                .header("X-TransactionId", transId)
-                .header("X-FromAppId", sourceID)
-                .header("Real-Time", "true")
-                .put(Entity.entity(t, MediaType.APPLICATION_JSON));
-
-        // System.out.println("response.tostring()="+response.toString());
-
-        int statuscode = response.getStatus();
-        if (statuscode >= 200 && statuscode <= 299) {
-            LOGGER.debug(methodName + ": url=" + url + ", request=" + path);
-        } else {
-            throw new AAIException("AAI_7116", methodName + " with status=" + statuscode + ", url=" + url + ", msg="
-                    + response.readEntity(String.class));
-        }
-    }
-
-    /**
-     * Put.
-     *
-     * @param <T> the generic type
-     * @param t the t
-     * @param sourceID the source ID
-     * @param transId the trans id
-     * @param path the path
-     * @param apiVersion version number
-     * @throws AAIException the AAI exception
-     */
-    public <T> void Put(T t, String sourceID, String transId, String path, String apiVersion) throws AAIException {
-        String methodName = "Put";
-        String url = "";
-        transId += ":" + UUID.randomUUID().toString();
-
-        LOGGER.debug(methodName + " start");
-
-        url = AAIConfig.get(AAIConstants.AAI_SERVER_URL_BASE) + apiVersion + "/" + path;
-
-        Response response = client.target(url)
-                .request(MediaType.APPLICATION_JSON)
-                .header("X-TransactionId", transId)
-                .header("X-FromAppId", sourceID)
-                .header("Real-Time", "true")
-                .put(Entity.entity(t, MediaType.APPLICATION_JSON));
-
-        // System.out.println("response.tostring()="+response.toString());
-
-        int statuscode = response.getStatus();
-        if (statuscode >= 200 && statuscode <= 299) {
-            LOGGER.debug(methodName + ": url=" + url + ", request=" + path);
-        } else {
-            throw new AAIException("AAI_7116", methodName + " with status=" + statuscode + ", url=" + url + ", msg="
-                    + response.getEntity());
-        }
-    }
-
-    public void Delete(String sourceID, String transId, String path) throws AAIException {
-        Delete(sourceID, transId, path, AAIConstants.AAI_RESOURCES_PORT);
-    }
-
-    /**
-     * Delete.
-     *
-     * @param sourceID the source ID
-     * @param transId the trans id
-     * @param path the path
-     * @throws AAIException the AAI exception
-     */
-    public void Delete(String sourceID, String transId, String path, int port) throws AAIException {
-        String methodName = "Delete";
-        String url = "";
-        transId += ":" + UUID.randomUUID().toString();
-
-        LOGGER.debug(methodName + " start");
-
-        String request = "{}";
-        if (overrideLocalHost == null) {
-            overrideLocalHost = AAIConfig.get(AAIConstants.AAI_LOCAL_OVERRIDE, AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT);
-        }
-        if (AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT.equals(overrideLocalHost)) {
-            url = String.format(AAIConstants.AAI_LOCAL_REST, port,
-                    AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP)) + path;
-        } else {
-            url = String.format(AAIConstants.AAI_LOCAL_REST_OVERRIDE, overrideLocalHost,
-                    AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP)) + path;
-        }
-        Response response = client.target(url)
-                .request(MediaType.APPLICATION_JSON)
-                .header("X-TransactionId", transId)
-                .header("X-FromAppId", sourceID)
-                .header("Real-Time", "true")
-                .delete();
-
-        if (response.getStatus() == 404) { // resource not found
-            LOGGER.info(
-                    "Resource does not exist...: " + response.getStatus() + ":" + response.readEntity(String.class));
-        } else if (response.getStatus() == 200 || response.getStatus() == 204) {
-            LOGGER.info("Resource " + url + " deleted");
-        } else {
-            LOGGER.error("Deleting Resource failed: " + response.getStatus() + ":" + response.readEntity(String.class));
-            throw new AAIException("AAI_7116", "Error during DELETE");
-        }
-    }
-
-    public <T> String Post(T t, String sourceID, String transId, String path) throws Exception {
-        return Post(t, sourceID, transId, path, AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP));
-    }
-
-    /**
-     * Post.
-     *
-     * @param <T> the generic type
-     * @param t the t
-     * @param sourceID the source ID
-     * @param transId the trans id
-     * @param path the path
-     * @param apiVersion the apiVersion
-     * @return the string
-     * @throws Exception the exception
-     */
-    public <T> String Post(T t, String sourceID, String transId, String path, String apiVersion) throws Exception {
-        String methodName = "Post";
-        String url = "";
-        transId += ":" + UUID.randomUUID().toString();
-
-        LOGGER.debug(methodName + " start");
-
-        try {
-
-            url = AAIConfig.get(AAIConstants.AAI_SERVER_URL_BASE) + apiVersion + "/" + path;
-
-            Response response = client.target(url)
-                    .request(MediaType.APPLICATION_JSON)
-                    .header("X-TransactionId", transId)
-                    .header("X-FromAppId", sourceID)
-                    .header("Real-Time", "true")
-                    .post(Entity.entity(t, MediaType.APPLICATION_JSON));
-
-            int statuscode = response.getStatus();
-            if (statuscode >= 200 && statuscode <= 299) {
-                LOGGER.debug(methodName + "REST api POST was successful!");
-                return response.readEntity(String.class);
-            } else {
-                throw new AAIException("AAI_7116", methodName + " with status=" + statuscode + ", url=" + url + ", msg="
-                        + response.readEntity(String.class));
-            }
-
-        } catch (AAIException e) {
-            throw new AAIException("AAI_7116", methodName + " with url=" + url + ", Exception: " + e.toString());
-        } catch (Exception e) {
-            throw new AAIException("AAI_7116", methodName + " with url=" + url + ", Exception: " + e.toString());
-
-        } finally {
-        }
-    }
-
-    /**
-     * Gets the single instance of RestController.
-     *
-     * @param <T> the generic type
-     * @param clazz the clazz
-     * @return single instance of RestController
-     * @throws IllegalAccessException the illegal access exception
-     * @throws InstantiationException the instantiation exception
-     * @throws SecurityException
-     * @throws NoSuchMethodException
-     * @throws InvocationTargetException
-     * @throws IllegalArgumentException
-     */
-    public <T> T getInstance(Class<T> clazz) throws IllegalAccessException, InstantiationException,
-            IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
-        return clazz.getDeclaredConstructor().newInstance();
-    }
-
-    /**
-     * Does resource exist.
-     *
-     * @param <T> the generic type
-     * @param resourcePath the resource path
-     * @param resourceClassName the resource class name
-     * @param fromAppId the from app id
-     * @param transId the trans id
-     * @return the t
-     */
-    /*
-     * DoesResourceExist
-     *
-     * To check whether a resource exist or get a copy of the existing version of the resource
-     *
-     * Resourcepath: should contain the qualified resource path (including encoded unique key identifier value),
-     * resourceClassName: is the canonical name of the resource class name,
-     * fromAppId:
-     * transId:
-     *
-     * Will return null (if the resource doesn’t exist) (or)
-     * Will return the specified resource from the Graph.
-     *
-     * Example:
-     * LogicalLink llink = new LogicalLink();
-     * String resourceClassName = llink.getClass().getCanonicalName();
-     * llink = RestController.DoesResourceExist("network/logical-links/logical-link/" + <encoded-link-name>,
-     * resourceClassName, fromAppId, transId);
-     */
-    public <T> T DoesResourceExist(String resourcePath, String resourceClassName, String fromAppId, String transId) {
-
-        try {
-
-            RestObject<T> restObj = new RestObject<T>();
-            @SuppressWarnings("unchecked")
-            T resourceObj = (T) getInstance(Class.forName(resourceClassName));
-            restObj.set(resourceObj);
-            Get(resourceObj, fromAppId, transId, resourcePath, restObj, false, AAIConstants.AAI_RESOURCES_PORT);
-
-            resourceObj = restObj.get();
-            if (resourceObj != null)
-                return resourceObj;
-
-        } catch (AAIException e) {
-
-        } catch (ClientErrorException che) {
-
-        } catch (Exception e) {
-
-        }
-
-        return null;
-    }
-
-    /**
-     * Patch.
-     *
-     * @param <T> the generic type
-     * @param sourceID the source ID
-     * @param transId the trans id
-     * @param path the path
-     * @throws AAIException the AAI exception
-     */
-    public <T> void Patch(T t, String sourceID, String transId, String path) throws AAIException {
-        String methodName = "Patch";
-        String url = "";
-        transId += ":" + UUID.randomUUID().toString();
-
-        int numRetries = 5;
-        Response response = null;
-        int statusCode = -1;
-
-        try {
-            if (overrideLocalHost == null) {
-                overrideLocalHost = AAIConfig.get(AAIConstants.AAI_LOCAL_OVERRIDE,
-                        AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT);
-            }
-            if (AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT.equals(overrideLocalHost)) {
-                url = String.format(AAIConstants.AAI_LOCAL_REST, AAIConstants.AAI_RESOURCES_PORT,
-                        AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP)) + path;
-            } else {
-                url = String.format(AAIConstants.AAI_LOCAL_REST_OVERRIDE, overrideLocalHost,
-                        AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP)) + path;
-            }
-
-            do {
-
-                response = client.target(url)
-                        .request(MediaType.APPLICATION_JSON)
-                        .header("X-TransactionId", transId)
-                        .header("X-FromAppId", sourceID)
-                        .header("X-HTTP-Method-Override", "PATCH")
-                        .post(Entity.entity(t, "application/merge-patch+json"));
-
-                statusCode = response.getStatus();
-
-                if (statusCode >= 200 && statusCode <= 299) {
-                    LOGGER.debug(methodName + "REST api PATCH was successful!");
-                    return;
-                } else {
-                    LOGGER.debug(methodName + "Unable to make the patch request to url " + url + " so retrying");
-                }
-
-                numRetries--;
-
-            } while (numRetries >= 0);
-
-            LOGGER.debug(methodName + "Unable to make the patch request to url " + url + " even after trying = "
-                    + numRetries + " times.");
-            throw new AAIException("AAI_7116", methodName + " with status=" + statusCode + ", url=" + url + ", msg="
-                    + response.readEntity(String.class));
-
-        } catch (AAIException e) {
-            throw new AAIException("AAI_7116", methodName + " with url=" + url + ", Exception: " + e.toString());
-        } catch (Exception e) {
-            throw new AAIException("AAI_7116", methodName + " with url=" + url + ", Exception: " + e.toString());
-
-        } finally {
-        }
-
-    }
-}
diff --git a/aai-core/src/main/java/org/onap/aai/util/RestControllerInterface.java b/aai-core/src/main/java/org/onap/aai/util/RestControllerInterface.java
deleted file mode 100644 (file)
index 6d20a01..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.util;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.onap.aai.exceptions.AAIException;
-
-public interface RestControllerInterface {
-
-    public <T> void Get(T t, String sourceID, String transId, String path, RestObject<T> restObject, boolean oldserver)
-            throws AAIException;
-
-    public <T> void Get(T t, String sourceID, String transId, String path, RestObject<T> restObject, String apiVersion)
-            throws AAIException;
-
-    public <T> void Patch(T t, String sourceID, String transId, String path) throws AAIException;
-
-    public <T> void Put(T t, String sourceID, String transId, String path) throws AAIException;
-
-    public <T> void Put(T t, String sourceID, String transId, String path, boolean oldserver) throws AAIException;
-
-    public void Delete(String sourceID, String transId, String path) throws AAIException;
-
-    public <T> T getInstance(Class<T> clazz) throws IllegalAccessException, InstantiationException,
-            IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException;
-
-    public <T> T DoesResourceExist(String resourcePath, String resourceClassName, String fromAppId, String transId);
-}
diff --git a/aai-core/src/test/resources/bundleconfig-local/aaf/cadi.properties b/aai-core/src/test/resources/bundleconfig-local/aaf/cadi.properties
deleted file mode 100644 (file)
index 8f7004f..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-## Location properties
-##
-## Localized Machine Information
-##
-cadi_loglevel=DEBUG
-cadi_latitude=38.0
-cadi_longitude=-72.0
-
-# Locate URL (which AAF Env) - Use lower case
-aaf_locate_url=https://aafist.test.org:8095
-# AAF URL - Use upper case
-aaf_url=https://AAF_LOCATE_URL/service:2.0
-#
-cadi_prop_files=src/test/resources/bundleconfig-local/aaf/org.onap.aai.props
diff --git a/aai-core/src/test/resources/bundleconfig-local/aaf/org.onap.aai.props b/aai-core/src/test/resources/bundleconfig-local/aaf/org.onap.aai.props
deleted file mode 100644 (file)
index 3056e5f..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-cm_url=cm_url
-hostname=hostname
-aaf_env=IST
-cadi_x509_issuers=CN=AAF CADI Test Issuing CA 01, OU=CSO, O=CO, C=US:CN=AAF CADI Test Issuing CA 02, OU=CSO, O=CO, C=US
\ No newline at end of file
index 31802ea..1f81866 100644 (file)
             <artifactId>javax.ws.rs-api</artifactId>
             <scope>provided</scope>
         </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.mockito</groupId>
-            <artifactId>mockito-core</artifactId>
-            <version>3.12.4</version>
-            <scope>test</scope>
-        </dependency>
         <dependency>
             <groupId>org.json</groupId>
             <artifactId>json</artifactId>
             <artifactId>spring-boot-starter-test</artifactId>
             <scope>test</scope>
             <exclusions>
-                               <exclusion>
-                                       <groupId>com.vaadin.external.google</groupId>
-                                       <artifactId>android-json</artifactId>
-                               </exclusion>
-                       </exclusions>
+                <exclusion>
+                    <groupId>com.vaadin.external.google</groupId>
+                    <artifactId>android-json</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
+            <version>3.12.4</version>
+            <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>junit</groupId>
index a7a87dc..30dd66b 100644 (file)
 
 package org.onap.aai.util;
 
-import java.io.File;
-import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.nio.charset.Charset;
 import java.util.Properties;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.commons.io.IOUtils;
 import org.eclipse.jetty.util.security.Password;
 import org.onap.aai.exceptions.AAIException;
 import org.slf4j.Logger;
@@ -39,19 +35,10 @@ public class AAIApplicationConfig {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(AAIApplicationConfig.class);
     private static String GLOBAL_PROP_FILE_NAME = "application.properties";
-    private static final String SERVER_CERTS_LOCATION_PROP_NAME = "server.certs.location";
-    private static final String PASSPHRASSES_FILENAME = ".passphrases";
-    private static final String PASSWORD_FILENAME = ".password";
-    private static final String TRUSTSTORE_PASSWORD_PROP_NAME = "cadi_truststore_password";
-    public static final String SERVER_SSL_KEYSTORE_PROP_NAME = "server.ssl.key-store";
-    public static final String SERVER_SSL_KEYSTORE_PKCS12_PROP_NAME = "server.ssl.key-store.pkcs12";
-    public static final String SERVER_SSL_TRUSTSTORE_PROP_NAME = "server.ssl.trust-store";
-    public static final String TRUSTSTORE_PASSWORD_NAME = "server.ssl.trust-store-password";
-    public static final String KEYSTORE_PASSWORD_NAME = "server.ssl.key-store-password";
+
     private static Properties serverProps;
     private static boolean propsInitialized = false;
-    private static String TRUSTSTORE_PASSWORD = null;
-    private static String KEYSTORE_PASSWORD = null;
+
     private static final String PROPERTY_REGEX = "\\$\\{([^\\$\\{\\}]+)\\}";
 
     /**
@@ -85,8 +72,6 @@ public class AAIApplicationConfig {
             newServerProps.load(is);
             propsInitialized = true;
             serverProps = newServerProps;
-            TRUSTSTORE_PASSWORD = retrieveTruststorePassword();
-            KEYSTORE_PASSWORD = retrieveKeystorePassword();
         } catch (Exception fnfe) {
             final InputStream is =
                     Thread.currentThread().getContextClassLoader().getResourceAsStream("application.properties");
@@ -95,8 +80,6 @@ public class AAIApplicationConfig {
                 try {
                     newServerProps.load(is);
                     serverProps = newServerProps;
-                    TRUSTSTORE_PASSWORD = retrieveTruststorePassword();
-                    KEYSTORE_PASSWORD = retrieveKeystorePassword();
                 } catch (IOException e) {
                     LOGGER.warn("Encountered IO Exception during loading of props from inputstream", e);
                 }
@@ -157,162 +140,6 @@ public class AAIApplicationConfig {
         return response;
     }
 
-    /**
-     * Gets the keystore path
-     *
-     * @return the string
-     * @throws AAIException the AAI exception
-     */
-    public static String getKeystore() throws AAIException {
-        return (get(SERVER_SSL_KEYSTORE_PROP_NAME));
-    }
-
-    /**
-     * Gets the PKCS12 keystore path
-     *
-     * @return the string
-     * @throws AAIException the AAI exception
-     */
-    public static String getKeystorePkcs12() throws AAIException {
-        return (get(SERVER_SSL_KEYSTORE_PKCS12_PROP_NAME));
-    }
-
-    /**
-     * Gets the keystore path
-     *
-     * @return the string
-     * @throws AAIException the AAI exception
-     */
-    public static String getTruststore() throws AAIException {
-        return (get(SERVER_SSL_TRUSTSTORE_PROP_NAME));
-    }
-
-    /**
-     * Retrieve the keystore password
-     *
-     * @return the password
-     */
-    private static String retrieveKeystorePassword() {
-        String certPath = serverProps.getProperty(SERVER_CERTS_LOCATION_PROP_NAME);
-        if (certPath == null) {
-            return null;
-        }
-        try {
-            certPath = replaceProperties(certPath);
-        } catch (AAIException e) {
-            return null;
-        }
-        return (retrieveKeystorePasswordWithCertPath(certPath));
-    }
-
-    /**
-     * Retrieve the keystore password
-     *
-     * @return the password
-     */
-    private static String retrieveKeystorePasswordWithCertPath(String certPath) {
-
-        File passwordFile = null;
-        InputStream passwordStream = null;
-        String keystorePassword = null;
-
-        // Override the passwords from application.properties if we find AAF certman files
-        try {
-            passwordFile = new File(certPath + PASSWORD_FILENAME);
-            passwordStream = new FileInputStream(passwordFile);
-            keystorePassword = IOUtils.toString(passwordStream, Charset.defaultCharset());
-            if (keystorePassword != null) {
-                keystorePassword = keystorePassword.trim();
-            }
-
-        } catch (IOException e) {
-            LOGGER.warn("Not using AAF Certman password file, e=" + e.getMessage());
-        } catch (NullPointerException n) {
-            LOGGER.warn("Not using AAF Certman passphrases file, e=" + n.getMessage());
-        } finally {
-            if (passwordStream != null) {
-                try {
-                    passwordStream.close();
-                } catch (Exception e) {
-                }
-            }
-        }
-        return keystorePassword;
-    }
-
-    /**
-     * Get the keystore password
-     *
-     * @return the password
-     */
-    public static String getKeystorePassword() {
-        return (KEYSTORE_PASSWORD);
-    }
-
-    /**
-     * Gets the truststore password
-     *
-     * @return the password
-     */
-    private static String retrieveTruststorePasswordWithCertPath(String certPath) {
-
-        File passphrasesFile = null;
-        InputStream passphrasesStream = null;
-        String truststorePassword = null;
-        try {
-            passphrasesFile = new File(certPath + PASSPHRASSES_FILENAME);
-            passphrasesStream = new FileInputStream(passphrasesFile);
-
-            Properties passphrasesProps = new Properties();
-            passphrasesProps.load(passphrasesStream);
-            truststorePassword = passphrasesProps.getProperty(TRUSTSTORE_PASSWORD_PROP_NAME);
-            if (truststorePassword != null) {
-                truststorePassword = truststorePassword.trim();
-            }
-
-        } catch (IOException e) {
-            LOGGER.warn("Not using AAF Certman passphrases file, e=" + e.getMessage());
-        } catch (NullPointerException n) {
-            LOGGER.warn("Not using AAF Certman passphrases file, e=" + n.getMessage());
-        } finally {
-            if (passphrasesStream != null) {
-                try {
-                    passphrasesStream.close();
-                } catch (Exception e) {
-                }
-            }
-        }
-
-        return truststorePassword;
-    }
-
-    /**
-     * Gets the truststore password
-     *
-     * @return the password
-     */
-    private static String retrieveTruststorePassword() {
-        String certPath = serverProps.getProperty(SERVER_CERTS_LOCATION_PROP_NAME);
-        if (certPath == null) {
-            return null;
-        }
-        try {
-            certPath = replaceProperties(certPath);
-        } catch (AAIException e) {
-            return null;
-        }
-        return (retrieveTruststorePasswordWithCertPath(certPath));
-    }
-
-    /**
-     * Get the trustore password
-     *
-     * @return the password
-     */
-    public static String getTruststorePassword() {
-        return (TRUSTSTORE_PASSWORD);
-    }
-
     /**
      * Gets the int value for the key.
      *
@@ -370,49 +197,4 @@ public class AAIApplicationConfig {
         m.appendTail(sb);
         return (sb.toString());
     }
-
-    public static Properties retrieveKeystoreProps() throws AAIException {
-
-        Properties props = new Properties();
-        String truststorePath = System.getProperty(SERVER_SSL_TRUSTSTORE_PROP_NAME);
-        String truststorePassword = System.getProperty(TRUSTSTORE_PASSWORD_NAME);
-        String keystorePath = System.getProperty(SERVER_SSL_KEYSTORE_PKCS12_PROP_NAME);
-        String keystorePassword = System.getProperty(KEYSTORE_PASSWORD_NAME);
-        String certLocation = System.getProperty(SERVER_CERTS_LOCATION_PROP_NAME);
-
-        if (truststorePath == null || truststorePath.isEmpty()) {
-            truststorePath = AAIApplicationConfig.getTruststore();
-        }
-        if (truststorePath != null) {
-            props.setProperty(SERVER_SSL_TRUSTSTORE_PROP_NAME, truststorePath);
-        }
-        if (truststorePassword == null || truststorePassword.isEmpty()) {
-            if (certLocation != null && (!certLocation.isEmpty())) {
-                truststorePassword = AAIApplicationConfig.retrieveTruststorePasswordWithCertPath(certLocation);
-            } else {
-                truststorePassword = AAIApplicationConfig.getTruststorePassword();
-            }
-
-        }
-        if (truststorePassword != null) {
-            props.setProperty(TRUSTSTORE_PASSWORD_NAME, truststorePassword);
-        }
-        if (keystorePath == null || keystorePath.isEmpty()) {
-            keystorePath = AAIApplicationConfig.getKeystorePkcs12();
-        }
-        if (keystorePath != null) {
-            props.setProperty(SERVER_SSL_KEYSTORE_PKCS12_PROP_NAME, keystorePath);
-        }
-        if (keystorePassword == null || keystorePassword.isEmpty()) {
-            if (certLocation != null && (!certLocation.isEmpty())) {
-                keystorePassword = AAIApplicationConfig.retrieveKeystorePasswordWithCertPath(certLocation);
-            } else {
-                keystorePassword = AAIApplicationConfig.getKeystorePassword();
-            }
-        }
-        if (keystorePassword != null) {
-            props.setProperty(KEYSTORE_PASSWORD_NAME, keystorePassword);
-        }
-        return (props);
-    }
 }
index a1a3618..4a7c489 100644 (file)
@@ -59,11 +59,6 @@ public final class AAIConstants {
     public static final String AAI_SCHEMA_MOD_LOGBACK_PROPS = "schemaMod-logback.xml";
     public static final String AAI_FORCE_DELETE_LOGBACK_PROPS = "forceDelete-logback.xml";
 
-    public static final String AAI_TRUSTSTORE_FILENAME = "aai.truststore.filename";
-    public static final String AAI_TRUSTSTORE_PASSWD = "aai.truststore.passwd";
-    public static final String AAI_KEYSTORE_FILENAME = "aai.keystore.filename";
-    public static final String AAI_KEYSTORE_PASSWD = "aai.keystore.passwd";
-
     public static final String AAI_SERVER_URL_BASE = "aai.server.url.base";
     public static final String AAI_SERVER_URL = "aai.server.url";
     public static final String AAI_OLDSERVER_URL = "aai.oldserver.url";
index 242e344..8294219 100644 (file)
@@ -36,21 +36,6 @@ public class AAIApplicationConfigTest {
         AAIApplicationConfig.init();
     }
 
-    @Test
-    public void truststoreTest() throws AAIException {
-        assertEquals("truststore.jks", AAIApplicationConfig.getTruststore());
-    }
-
-    @Test
-    public void keystoreTest() throws AAIException {
-        assertEquals("keystore.jks", AAIApplicationConfig.getKeystore());
-    }
-
-    @Test
-    public void getKeystorePkcs12Test() throws AAIException {
-        assertEquals("keystore.pkcs12", AAIApplicationConfig.getKeystorePkcs12());
-    }
-
     @Test
     public void getValueWithDefaultTest() throws AAIException {
         assertEquals("default-value", AAIApplicationConfig.get("non-existing-key", "default-value"));
@@ -58,7 +43,7 @@ public class AAIApplicationConfigTest {
 
     @Test
     public void getValueTest() throws AAIException {
-        assertEquals("certificates", AAIApplicationConfig.get("server.certs.location"));
+        assertEquals("8446", AAIApplicationConfig.get("server.port"));
     }
 
     @Test
@@ -70,10 +55,4 @@ public class AAIApplicationConfigTest {
     public void getIntValueWithDefaultTest() throws AAIException {
         assertTrue(9999 == AAIApplicationConfig.getInt("non-existing-key", "9999"));
     }
-
-    @Test
-    public void getValueWithReplacementTest() throws AAIException {
-        assertEquals("/opt/app/aai/etc/auth/aai-client-cert.p12",
-                AAIApplicationConfig.get("schema.service.ssl.key-store"));
-    }
 }
index df8fd64..bd2fd55 100644 (file)
@@ -2,7 +2,7 @@
 # ============LICENSE_START=======================================================
 # org.onap.aai
 # ================================================================================
-# Copyright © 2017-18 AT&T Intellectual Property. All rights reserved.
+# Copyright  2017-18 AT&T Intellectual Property. All rights reserved.
 # ================================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -20,10 +20,3 @@ spring.application.name=AAI Microservice
 server.port=8446
 server.local.startpath=/opt/app/aai
 schema.version.list=v10,v11,v12,v13,v14,v15,v16,v17,v18,v19
-server.certs.location=certificates
-server.ssl.key-store=keystore.jks
-server.ssl.key-store.pkcs12=keystore.pkcs12
-server.ssl.trust-store=truststore.jks
-schema.service.ssl.key-store=${server.local.startpath}/etc/auth/aai-client-cert.p12
-schema.service.ssl.trust-store=${server.local.startpath}/etc/auth/aai_keystore.jks
-
index c59ddbe..3623f51 100644 (file)
                </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-web</artifactId>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.springframework.boot</groupId>
-                    <artifactId>spring-boot-starter-tomcat</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.slf4j</groupId>
-                    <artifactId>log4j-over-slf4j</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-jetty</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-jersey</artifactId>
+            <artifactId>spring-boot-autoconfigure</artifactId>
         </dependency>
         <dependency>
             <groupId>javax.ws.rs</groupId>
                                </exclusion>
                        </exclusions>
         </dependency>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-test</artifactId>
-            <scope>test</scope>
-        </dependency>
         <dependency>
             <groupId>org.onap.aai.aai-common</groupId>
             <artifactId>aai-els-onap-logging</artifactId>
                 </exclusion>
             </exclusions>
         </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <scope>provided</scope>
+        </dependency>
     </dependencies>
 
 </project>
index 3e4eceb..c4b9509 100644 (file)
@@ -36,48 +36,14 @@ import org.springframework.util.MultiValueMap;
 @ConditionalOnExpression("${aai-rest-client.enabled:false}")
 public class AAIRestClient extends TwoWaySSLRestClient {
 
-    private static Logger logger = LoggerFactory.getLogger(AAIRestClient.class);
-
     @Value("${aai.base.url}")
     private String baseUrl;
 
-    @Value("${aai.ssl.key-store}")
-    private String keystorePath;
-
-    @Value("${aai.ssl.trust-store}")
-    private String truststorePath;
-
-    @Value("${aai.ssl.key-store-password}")
-    private String keystorePassword;
-
-    @Value("${aai.ssl.trust-store-password}")
-    private String truststorePassword;
-
     @Override
     public String getBaseUrl() {
         return baseUrl;
     }
 
-    @Override
-    protected String getKeystorePath() {
-        return keystorePath;
-    }
-
-    @Override
-    protected String getTruststorePath() {
-        return truststorePath;
-    }
-
-    @Override
-    protected char[] getKeystorePassword() {
-        return keystorePassword.toCharArray();
-    }
-
-    @Override
-    protected char[] getTruststorePassword() {
-        return truststorePassword.toCharArray();
-    }
-
     @Override
     public MultiValueMap<String, String> getHeaders(Map<String, String> headers) {
         HttpHeaders httpHeaders = new HttpHeaders();
diff --git a/aai-rest/src/main/java/org/onap/aai/restclient/JettyPasswordDecoder.java b/aai-rest/src/main/java/org/onap/aai/restclient/JettyPasswordDecoder.java
deleted file mode 100644 (file)
index 7a1bc11..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.restclient;
-
-import org.eclipse.jetty.util.security.Password;
-
-public class JettyPasswordDecoder implements PasswordDecoder {
-
-    @Override
-    public String decode(String input) {
-        if (input.startsWith("OBF:")) {
-            return Password.deobfuscate(input);
-        }
-        return Password.deobfuscate("OBF:" + input);
-    }
-}
index b558546..09792bb 100644 (file)
@@ -32,8 +32,6 @@ import org.springframework.web.client.RestTemplate;
 
 public abstract class NoAuthRestClient extends RestClient {
 
-    private static Logger logger = LoggerFactory.getLogger(NoAuthRestClient.class);
-
     protected RestTemplate restTemplate;
 
     @PostConstruct
index 614f677..80d3213 100644 (file)
@@ -35,8 +35,6 @@ import org.springframework.web.client.RestTemplate;
 
 public abstract class OneWaySSLRestClient extends RestClient {
 
-    private static Logger logger = LoggerFactory.getLogger(OneWaySSLRestClient.class);
-
     private RestTemplate restTemplate;
 
     @PostConstruct
@@ -56,26 +54,19 @@ public abstract class OneWaySSLRestClient extends RestClient {
 
     protected HttpClient getClient() throws Exception {
 
-        char[] trustStorePassword = getTruststorePassword();
-
-        String trustStore = getTruststorePath();
-
-        SSLContext sslContext = SSLContextBuilder.create()
-                .loadTrustMaterial(ResourceUtils.getFile(trustStore), trustStorePassword).build();
+        SSLContext sslContext = SSLContextBuilder.create().build();
 
         HttpClient client =
-                HttpClients.custom().setSSLContext(sslContext).setSSLHostnameVerifier((s, sslSession) -> true).build();
+            HttpClients.custom()
+                .setSSLContext(sslContext)
+                .setSSLHostnameVerifier((s, sslSession) -> true)
+                .build();
 
         return client;
     }
 
-    protected abstract String getTruststorePath();
-
-    protected abstract char[] getTruststorePassword();
-
     @Override
     public RestTemplate getRestTemplate() {
         return restTemplate;
     }
-
 }
diff --git a/aai-rest/src/main/java/org/onap/aai/restclient/PasswordDecoder.java b/aai-rest/src/main/java/org/onap/aai/restclient/PasswordDecoder.java
deleted file mode 100644 (file)
index a11e2b6..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.restclient;
-
-public interface PasswordDecoder {
-
-    String decode(String input);
-}
diff --git a/aai-rest/src/main/java/org/onap/aai/restclient/PropertyPasswordConfiguration.java b/aai-rest/src/main/java/org/onap/aai/restclient/PropertyPasswordConfiguration.java
deleted file mode 100644 (file)
index a6028f9..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.restclient;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.Charset;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Properties;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.commons.io.IOUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.ApplicationContextInitializer;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.core.env.ConfigurableEnvironment;
-import org.springframework.core.env.EnumerablePropertySource;
-import org.springframework.core.env.MapPropertySource;
-import org.springframework.core.env.PropertySource;
-
-public class PropertyPasswordConfiguration implements ApplicationContextInitializer<ConfigurableApplicationContext> {
-
-    private static final Pattern decodePasswordPattern = Pattern.compile("password\\((.*?)\\)");
-    private PasswordDecoder passwordDecoder = new JettyPasswordDecoder();
-    private static final Logger logger = LoggerFactory.getLogger(PropertyPasswordConfiguration.class.getName());
-
-    @Override
-    public void initialize(ConfigurableApplicationContext applicationContext) {
-        ConfigurableEnvironment environment = applicationContext.getEnvironment();
-        String certPath = environment.getProperty("server.certs.location");
-        File passwordFile = null;
-        File passphrasesFile = null;
-        InputStream passwordStream = null;
-        InputStream passphrasesStream = null;
-        Map<String, Object> sslProps = new LinkedHashMap<>();
-
-        // Override the passwords from application.properties if we find AAF certman files
-        if (certPath != null) {
-            try {
-                passwordFile = new File(certPath + ".password");
-                passwordStream = new FileInputStream(passwordFile);
-
-                if (passwordStream != null) {
-                    String keystorePassword = null;
-
-                    keystorePassword = IOUtils.toString(passwordStream, Charset.defaultCharset());
-                    if (keystorePassword != null) {
-                        keystorePassword = keystorePassword.trim();
-                    }
-                    sslProps.put("server.ssl.key-store-password", keystorePassword);
-                    sslProps.put("schema.service.ssl.key-store-password", keystorePassword);
-                    sslProps.put("validation.service.ssl.key-store-password", keystorePassword);
-                } else {
-                    logger.info("Not using AAF Certman password file");
-                }
-            } catch (IOException e) {
-                logger.warn("Not using AAF Certman password file, e=" + e.getMessage());
-            } finally {
-                if (passwordStream != null) {
-                    try {
-                        passwordStream.close();
-                    } catch (Exception e) {
-                    }
-                }
-            }
-            try {
-                passphrasesFile = new File(certPath + ".passphrases");
-                passphrasesStream = new FileInputStream(passphrasesFile);
-
-                if (passphrasesStream != null) {
-                    String truststorePassword = null;
-                    Properties passphrasesProps = new Properties();
-                    passphrasesProps.load(passphrasesStream);
-                    truststorePassword = passphrasesProps.getProperty("cadi_truststore_password");
-                    if (truststorePassword != null) {
-                        truststorePassword = truststorePassword.trim();
-                    }
-                    sslProps.put("server.ssl.trust-store-password", truststorePassword);
-                    sslProps.put("schema.service.ssl.trust-store-password", truststorePassword);
-                    sslProps.put("validation.service.ssl.trust-store-password", truststorePassword);
-                } else {
-                    logger.info("Not using AAF Certman passphrases file");
-                }
-            } catch (IOException e) {
-                logger.warn("Not using AAF Certman passphrases file, e=" + e.getMessage());
-            } finally {
-                if (passphrasesStream != null) {
-                    try {
-                        passphrasesStream.close();
-                    } catch (Exception e) {
-                    }
-                }
-            }
-        }
-        for (PropertySource<?> propertySource : environment.getPropertySources()) {
-            Map<String, Object> propertyOverrides = new LinkedHashMap<>();
-            decodePasswords(propertySource, propertyOverrides);
-            if (!propertyOverrides.isEmpty()) {
-                PropertySource<?> decodedProperties =
-                        new MapPropertySource("decoded " + propertySource.getName(), propertyOverrides);
-                environment.getPropertySources().addBefore(propertySource.getName(), decodedProperties);
-            }
-
-        }
-        if (!sslProps.isEmpty()) {
-            logger.info("Using AAF Certman files");
-            PropertySource<?> additionalProperties = new MapPropertySource("additionalProperties", sslProps);
-            environment.getPropertySources().addFirst(additionalProperties);
-        }
-    }
-
-    private void decodePasswords(PropertySource<?> source, Map<String, Object> propertyOverrides) {
-        if (source instanceof EnumerablePropertySource) {
-            EnumerablePropertySource<?> enumerablePropertySource = (EnumerablePropertySource<?>) source;
-            for (String key : enumerablePropertySource.getPropertyNames()) {
-                Object rawValue = source.getProperty(key);
-                if (rawValue instanceof String) {
-                    String decodedValue = decodePasswordsInString((String) rawValue);
-                    propertyOverrides.put(key, decodedValue);
-                }
-            }
-        }
-    }
-
-    private String decodePasswordsInString(String input) {
-        if (input == null)
-            return null;
-        StringBuffer output = new StringBuffer();
-        Matcher matcher = decodePasswordPattern.matcher(input);
-        while (matcher.find()) {
-            String replacement = passwordDecoder.decode(matcher.group(1));
-            matcher.appendReplacement(output, replacement);
-        }
-        matcher.appendTail(output);
-        return output.toString();
-    }
-
-}
index 44b1fe4..1b4a3d9 100644 (file)
@@ -133,9 +133,9 @@ public abstract class RestClient {
         HttpEntity<String> httpEntity;
         log.debug("Headers: " + headers.toString());
         if (body == null) {
-            httpEntity = new HttpEntity(getHeaders(headers));
+            httpEntity = new HttpEntity<String>(getHeaders(headers));
         } else {
-            httpEntity = new HttpEntity(body, getHeaders(headers));
+            httpEntity = new HttpEntity<String>(body, getHeaders(headers));
         }
         String url = getBaseUrl() + uri;
         return getRestTemplate().exchange(url, method, httpEntity, Resource.class);
index 5ea4fc3..7d75910 100644 (file)
 
 package org.onap.aai.restclient;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.security.KeyStore;
-
 import javax.annotation.PostConstruct;
 import javax.net.ssl.SSLContext;
 
@@ -32,16 +27,11 @@ import org.apache.http.client.HttpClient;
 import org.apache.http.impl.client.HttpClients;
 import org.apache.http.ssl.SSLContextBuilder;
 import org.onap.aai.aailog.filter.RestClientLoggingInterceptor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
-import org.springframework.util.ResourceUtils;
 import org.springframework.web.client.RestTemplate;
 
 public abstract class TwoWaySSLRestClient extends RestClient {
 
-    private static Logger logger = LoggerFactory.getLogger(TwoWaySSLRestClient.class);
-
     private RestTemplate restTemplate;
 
     @PostConstruct
@@ -60,39 +50,18 @@ public abstract class TwoWaySSLRestClient extends RestClient {
 
     protected HttpClient getClient() throws Exception {
 
-        char[] keyStorePassword = getKeystorePassword();
-        char[] trustStorePassword = getTruststorePassword();
-
-        String keyStore = getKeystorePath();
-        String trustStore = getTruststorePath();
-
         SSLContext sslContext =
-                SSLContextBuilder.create().loadKeyMaterial(loadPfx(keyStore, keyStorePassword), keyStorePassword)
-                        .loadTrustMaterial(ResourceUtils.getFile(trustStore), trustStorePassword).build();
+                SSLContextBuilder.create().build();
 
         HttpClient client =
-                HttpClients.custom().setSSLContext(sslContext).setSSLHostnameVerifier((s, sslSession) -> true).build();
+                HttpClients.custom()
+                    .setSSLContext(sslContext)
+                    .setSSLHostnameVerifier((s, sslSession) -> true)
+                    .build();
 
         return client;
     }
 
-    private KeyStore loadPfx(String file, char[] password) throws Exception {
-        KeyStore keyStore = KeyStore.getInstance("PKCS12");
-        File key = ResourceUtils.getFile(file);
-        try (InputStream in = new FileInputStream(key)) {
-            keyStore.load(in, password);
-        }
-        return keyStore;
-    }
-
-    protected abstract String getKeystorePath();
-
-    protected abstract String getTruststorePath();
-
-    protected abstract char[] getTruststorePassword();
-
-    protected abstract char[] getKeystorePassword();
-
     @Override
     public RestTemplate getRestTemplate() {
         return restTemplate;
index fba6e0f..5647d6d 100644 (file)
@@ -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 (file)
index 3f17c9b..0000000
+++ /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);
-        }
-
-    }
-
-}
index f8ffe0c..c9d19d1 100644 (file)
@@ -105,10 +105,6 @@ limitations under the License.
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-webmvc</artifactId>
                </dependency>
-               <dependency>
-                       <groupId>org.springframework.boot</groupId>
-                       <artifactId>spring-boot-starter-web</artifactId>
-               </dependency>
                <dependency>
                        <groupId>org.apache.httpcomponents</groupId>
                        <artifactId>httpclient</artifactId>
index 1f04bff..33a50c4 100644 (file)
@@ -24,8 +24,6 @@ import java.util.Collections;
 import java.util.Map;
 import java.util.UUID;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.MediaType;
@@ -33,32 +31,14 @@ import org.springframework.util.MultiValueMap;
 
 public class SchemaServiceOneWayClient extends OneWaySSLRestClient {
 
-    private static Logger logger = LoggerFactory.getLogger(SchemaServiceOneWayClient.class);
-
     @Value("${schema.service.base.url}")
     private String baseUrl;
 
-    @Value("${schema.service.ssl.trust-store}")
-    private String truststorePath;
-
-    @Value("${schema.service.ssl.trust-store-password}")
-    private String truststorePassword;
-
     @Override
     public String getBaseUrl() {
         return baseUrl;
     }
 
-    @Override
-    protected String getTruststorePath() {
-        return truststorePath;
-    }
-
-    @Override
-    protected char[] getTruststorePassword() {
-        return truststorePassword.toCharArray();
-    }
-
     @Override
     public MultiValueMap<String, String> getHeaders(Map<String, String> headers) {
         HttpHeaders httpHeaders = new HttpHeaders();
index f7bdf6d..44ad9a3 100644 (file)
@@ -34,48 +34,15 @@ import org.springframework.http.MediaType;
 import org.springframework.util.MultiValueMap;
 
 public class SchemaServiceRestClient extends TwoWaySSLRestClient {
-    private static Logger logger = LoggerFactory.getLogger(SchemaServiceRestClient.class);
 
     @Value("${schema.service.base.url}")
     private String baseUrl;
 
-    @Value("${schema.service.ssl.key-store}")
-    private String keystorePath;
-
-    @Value("${schema.service.ssl.trust-store}")
-    private String truststorePath;
-
-    @Value("${schema.service.ssl.key-store-password}")
-    private String keystorePassword;
-
-    @Value("${schema.service.ssl.trust-store-password}")
-    private String truststorePassword;
-
     @Override
     public String getBaseUrl() {
         return baseUrl;
     }
 
-    @Override
-    protected String getKeystorePath() {
-        return keystorePath;
-    }
-
-    @Override
-    protected String getTruststorePath() {
-        return truststorePath;
-    }
-
-    @Override
-    protected char[] getKeystorePassword() {
-        return keystorePassword.toCharArray();
-    }
-
-    @Override
-    protected char[] getTruststorePassword() {
-        return truststorePassword.toCharArray();
-    }
-
     @Override
     public MultiValueMap<String, String> getHeaders(Map<String, String> headers) {
         HttpHeaders httpHeaders = new HttpHeaders();
index 743fe70..96627c2 100644 (file)
@@ -35,8 +35,7 @@ import org.springframework.test.context.TestPropertySource;
 @Disabled
 @TestPropertySource(locations = "/schemaService/schema-service-rest.properties")
 @ContextConfiguration(
-        classes = {RestClientFactoryConfiguration.class, SchemaServiceRestClient.class, RestClientFactory.class,
-                PropertyPasswordConfiguration.class})
+        classes = {RestClientFactoryConfiguration.class, SchemaServiceRestClient.class, RestClientFactory.class})
 
 @SpringBootTest
 public class SchemaRestClientTest {