2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END============================================
20 * ===================================================================
23 package org.onap.so.security;
25 import javax.servlet.FilterConfig;
26 import javax.servlet.ServletException;
27 import org.onap.aaf.cadi.config.Config;
28 import org.onap.aaf.cadi.filter.CadiFilter;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
31 import org.springframework.beans.factory.annotation.Value;
32 import org.springframework.context.annotation.Profile;
33 import org.springframework.stereotype.Component;
36 @Profile("!test & aaf")
37 public class SoCadiFilter extends CadiFilter {
39 protected final Logger logger = LoggerFactory.getLogger(SoCadiFilter.class);
41 @Value("${mso.config.cadi.cadiLoglevel:#{null}}")
42 private String cadiLoglevel;
44 @Value("${mso.config.cadi.cadiKeyFile:#{null}}")
45 private String cadiKeyFile;
47 @Value("${mso.config.cadi.cadiTruststorePassword:#{null}}")
48 private String cadiTrustStorePassword;
50 @Value("${mso.config.cadi.cadiTrustStore:#{null}}")
51 private String cadiTrustStore;
53 @Value("${mso.config.cadi.cadiLatitude:#{null}}")
54 private String cadiLatitude;
56 @Value("${mso.config.cadi.cadiLongitude:#{null}}")
57 private String cadiLongitude;
59 @Value("${mso.config.cadi.aafEnv:#{null}}")
60 private String aafEnv;
62 @Value("${mso.config.cadi.aafApiVersion:#{null}}")
63 private String aafApiVersion;
65 @Value("${mso.config.cadi.aafRootNs:#{null}}")
66 private String aafRootNs;
68 @Value("${mso.config.cadi.aafId:#{null}}")
69 private String aafMechId;
71 @Value("${mso.config.cadi.aafPassword:#{null}}")
72 private String aafMechIdPassword;
74 @Value("${mso.config.cadi.aafLocateUrl:#{null}}")
75 private String aafLocateUrl;
77 @Value("${mso.config.cadi.aafUrl:#{null}}")
78 private String aafUrl;
80 @Value("${mso.config.cadi.apiEnforcement:#{null}}")
81 private String apiEnforcement;
83 @Value("${mso.config.cadi.userExpires:#{null}}")
84 private String userExpires;
86 private void checkIfNullProperty(String key, String value) {
88 * When value is null, it is not defined in application.yaml set nothing in System properties
91 System.setProperty(key, value);
96 public void init(FilterConfig filterConfig) throws ServletException {
97 checkIfNullProperty(Config.CADI_LOGLEVEL, cadiLoglevel);
98 checkIfNullProperty(Config.CADI_KEYFILE, cadiKeyFile);
99 checkIfNullProperty(Config.CADI_TRUSTSTORE, cadiTrustStore);
100 checkIfNullProperty(Config.CADI_TRUSTSTORE_PASSWORD, cadiTrustStorePassword);
101 checkIfNullProperty(Config.CADI_LATITUDE, cadiLatitude);
102 checkIfNullProperty(Config.CADI_LONGITUDE, cadiLongitude);
103 checkIfNullProperty(Config.AAF_ENV, aafEnv);
104 checkIfNullProperty(Config.AAF_API_VERSION, aafApiVersion);
105 checkIfNullProperty(Config.AAF_ROOT_NS, aafRootNs);
106 checkIfNullProperty(Config.AAF_APPID, aafMechId);
107 checkIfNullProperty(Config.AAF_APPPASS, aafMechIdPassword);
108 checkIfNullProperty(Config.AAF_LOCATE_URL, aafLocateUrl);
109 checkIfNullProperty(Config.AAF_URL, aafUrl);
110 checkIfNullProperty(Config.CADI_API_ENFORCEMENT, apiEnforcement);
111 checkIfNullProperty(Config.AAF_USER_EXPIRES, userExpires);
112 // checkIfNullProperty(AFT_ENVIRONMENT_VAR, aftEnv);
113 logger.debug(" *** init Filter Config *** ");
114 super.init(filterConfig);