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 private static String AFT_ENVIRONMENT_VAR = "AFT_ENVIRONMENT";
42 private static String AAF_API_VERSION = "aaf_api_version";
44 @Value("${mso.config.cadi.cadiLoglevel:#{null}}")
45 private String cadiLoglevel;
47 @Value("${mso.config.cadi.cadiKeyFile:#{null}}")
48 private String cadiKeyFile;
50 @Value("${mso.config.cadi.cadiTruststorePassword:#{null}}")
51 private String cadiTrustStorePassword;
53 @Value("${mso.config.cadi.cadiTrustStore:#{null}}")
54 private String cadiTrustStore;
56 @Value("${mso.config.cadi.cadiLatitude:#{null}}")
57 private String cadiLatitude;
59 @Value("${mso.config.cadi.cadiLongitude:#{null}}")
60 private String cadiLongitude;
62 @Value("${mso.config.cadi.aafEnv:#{null}}")
63 private String aafEnv;
65 @Value("${mso.config.cadi.aafApiVersion:#{null}}")
66 private String aafApiVersion;
68 @Value("${mso.config.cadi.aafRootNs:#{null}}")
69 private String aafRootNs;
71 @Value("${mso.config.cadi.aafId:#{null}}")
72 private String aafMechId;
74 @Value("${mso.config.cadi.aafPassword:#{null}}")
75 private String aafMechIdPassword;
77 @Value("${mso.config.cadi.aafLocateUrl:#{null}}")
78 private String aafLocateUrl;
80 @Value("${mso.config.cadi.aafUrl:#{null}}")
81 private String aafUrl;
83 @Value("${mso.config.cadi.apiEnforcement:#{null}}")
84 private String apiEnforcement;
86 @Value("${mso.config.cadi.userExpires:#{null}}")
87 private String userExpires;
89 private void checkIfNullProperty(String key, String value) {
91 * When value is null, it is not defined in application.yaml set nothing in System properties
94 System.setProperty(key, value);
99 public void init(FilterConfig filterConfig) throws ServletException {
100 checkIfNullProperty(Config.CADI_LOGLEVEL, cadiLoglevel);
101 checkIfNullProperty(Config.CADI_KEYFILE, cadiKeyFile);
102 checkIfNullProperty(Config.CADI_TRUSTSTORE, cadiTrustStore);
103 checkIfNullProperty(Config.CADI_TRUSTSTORE_PASSWORD, cadiTrustStorePassword);
104 checkIfNullProperty(Config.CADI_LATITUDE, cadiLatitude);
105 checkIfNullProperty(Config.CADI_LONGITUDE, cadiLongitude);
106 checkIfNullProperty(Config.AAF_ENV, aafEnv);
107 checkIfNullProperty(Config.AAF_API_VERSION, aafApiVersion);
108 checkIfNullProperty(Config.AAF_ROOT_NS, aafRootNs);
109 checkIfNullProperty(Config.AAF_APPID, aafMechId);
110 checkIfNullProperty(Config.AAF_APPPASS, aafMechIdPassword);
111 checkIfNullProperty(Config.AAF_LOCATE_URL, aafLocateUrl);
112 checkIfNullProperty(Config.AAF_URL, aafUrl);
113 checkIfNullProperty(Config.CADI_API_ENFORCEMENT, apiEnforcement);
114 checkIfNullProperty(Config.AAF_USER_EXPIRES, userExpires);
115 // checkIfNullProperty(AFT_ENVIRONMENT_VAR, aftEnv);
116 logger.debug(" *** init Filter Config *** ");
117 super.init(filterConfig);