2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * ===================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END============================================
21 * ===================================================================
25 package org.onap.clamp.clds.config.spring;
29 import javax.annotation.PostConstruct;
31 import org.springframework.beans.factory.annotation.Autowired;
32 import org.springframework.context.annotation.Configuration;
33 import org.springframework.core.env.Environment;
36 public class SSLConfiguration {
38 private Environment env;
41 private void configureSSL() {
42 if (env.getProperty("server.ssl.trust-store") != null) {
43 URL storeResource = SSLConfiguration.class
44 .getResource(env.getProperty("server.ssl.trust-store").replaceAll("classpath:", ""));
45 System.setProperty("javax.net.ssl.trustStore", storeResource.getPath());
46 System.setProperty("javax.net.ssl.trustStorePassword", env.getProperty("server.ssl.trust-store-password"));
47 System.setProperty("javax.net.ssl.trustStoreType", env.getProperty("server.ssl.key-store-type"));
49 storeResource = SSLConfiguration.class
50 .getResource(env.getProperty("server.ssl.key-store").replaceAll("classpath:", ""));
51 System.setProperty("javax.net.ssl.keyStore", storeResource.getPath());
52 System.setProperty("javax.net.ssl.keyStorePassword", env.getProperty("server.ssl.key-store-password"));
53 System.setProperty("javax.net.ssl.keyStoreType", env.getProperty("server.ssl.key-store-type"));