2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2018 European Software Marketing Ltd.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.onap.aaf.fproxy;
22 import java.util.HashMap;
23 import javax.annotation.PostConstruct;
24 import org.eclipse.jetty.util.security.Password;
25 import org.springframework.beans.factory.annotation.Autowired;
26 import org.springframework.boot.autoconfigure.SpringBootApplication;
27 import org.springframework.boot.builder.SpringApplicationBuilder;
28 import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
29 import org.springframework.context.annotation.PropertySource;
30 import org.springframework.core.env.Environment;
32 @SpringBootApplication
33 @PropertySource("file:${CONFIG_HOME}/fproxy.properties")
34 public class FProxyApplication extends SpringBootServletInitializer {
37 private Environment env;
40 * Spring Boot Initialization.
42 * @param args main args
44 public static void main(String[] args) {
45 String keyStorePassword = System.getProperty("KEY_STORE_PASSWORD");
46 if (keyStorePassword == null || keyStorePassword.isEmpty()) {
47 throw new IllegalArgumentException("Env property KEY_STORE_PASSWORD not set");
49 HashMap<String, Object> props = new HashMap<>();
50 props.put("server.ssl.key-store-password", Password.deobfuscate(keyStorePassword));
51 new FProxyApplication().configure(new SpringApplicationBuilder(FProxyApplication.class).properties(props))
56 * Set required trust store system properties using values from application.properties
59 public void setSystemProperties() {
60 String keyStorePath = env.getProperty("server.ssl.key-store");
61 if (keyStorePath != null) {
62 String keyStorePassword = env.getProperty("server.ssl.key-store-password");
64 if (keyStorePassword != null) {
65 System.setProperty("javax.net.ssl.keyStore", keyStorePath);
66 System.setProperty("javax.net.ssl.keyStorePassword", keyStorePassword);
67 System.setProperty("javax.net.ssl.trustStore", keyStorePath);
68 System.setProperty("javax.net.ssl.trustStorePassword", keyStorePassword);
70 throw new IllegalArgumentException("Env property server.ssl.key-store-password not set");