--- /dev/null
+/* Copyright (c) 2019 AT&T Intellectual Property. #\r
+# #\r
+# Licensed under the Apache License, Version 2.0 (the "License"); #\r
+# you may not use this file except in compliance with the License. #\r
+# You may obtain a copy of the License at #\r
+# #\r
+# http://www.apache.org/licenses/LICENSE-2.0 #\r
+# #\r
+# Unless required by applicable law or agreed to in writing, software #\r
+# distributed under the License is distributed on an "AS IS" BASIS, #\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #\r
+# See the License for the specific language governing permissions and #\r
+# limitations under the License. #\r
+##############################################################################*/\r
+\r
+\r
+package org.oran.otf.cadi.configuration;\r
+\r
+import javax.servlet.Filter;\r
+import org.onap.aaf.cadi.Access.Level;\r
+import org.onap.aaf.cadi.config.Config;\r
+import org.onap.aaf.cadi.filter.CadiFilter;\r
+import org.springframework.beans.factory.annotation.Value;\r
+import org.springframework.boot.web.servlet.FilterRegistrationBean;\r
+import org.springframework.context.annotation.Bean;\r
+import org.springframework.context.annotation.Conditional;\r
+import org.springframework.context.annotation.Configuration;\r
+import org.springframework.context.annotation.PropertySource;\r
+\r
+@PropertySource("classpath:application.yaml")\r
+@Configuration\r
+@Conditional(value = FilterCondition.class)\r
+public class CadiFilterConfiguration {\r
+\r
+ @Value("${otf.cadi.aaf-mech-id}")\r
+ private String AAF_APPID;\r
+\r
+ @Value("${otf.cadi.aaf-mech-password}")\r
+ private String AAF_APPPASS;\r
+\r
+ @Value("${otf.cadi.hostname}")\r
+ private String CADI_HOSTNAME;\r
+\r
+ @Value("${otf.cadi.keyfile}")\r
+ private String CADI_KEYFILE;\r
+\r
+ @Value("${otf.ssl.keystore-path}")\r
+ private String CADI_KEYSTORE;\r
+\r
+ @Value("${otf.ssl.keystore-password}")\r
+ private String CADI_KEYSTORE_PASSWORD;\r
+\r
+ @Bean(name = "cadiFilterRegistrationBean")\r
+// @ConditionalOnProperty(prefix = "otf.cadi", name = "enabled", havingValue = "true", matchIfMissing = true)\r
+ public FilterRegistrationBean<Filter> cadiFilterRegistration() {\r
+ FilterRegistrationBean<Filter> registration = new FilterRegistrationBean<>();\r
+ // set cadi configuration properties\r
+ initCadiProperties(registration);\r
+\r
+ registration.addUrlPatterns("/otf/tcu/*", "/rest/*");\r
+ registration.setFilter(cadiFilter());\r
+ registration.setName("otfCadiFilter");\r
+ registration.setOrder(0);\r
+ return registration;\r
+ }\r
+\r
+ Filter cadiFilter() {\r
+ return new CadiFilter();\r
+ }\r
+\r
+ private void initCadiProperties(FilterRegistrationBean<Filter> registration) {\r
+ registration.addInitParameter(Config.AAF_APPID, AAF_APPID);\r
+ registration.addInitParameter(Config.AAF_APPPASS, AAF_APPPASS);\r
+ registration.addInitParameter(Config.AAF_CALL_TIMEOUT, "10000");\r
+ registration.addInitParameter(Config.AAF_CONN_TIMEOUT, "6000");\r
+ registration.addInitParameter(Config.AAF_DEFAULT_REALM, "localhost");\r
+ registration.addInitParameter(Config.AAF_ENV, "PROD");\r
+ registration.addInitParameter(Config.AAF_LOCATE_URL, "https://localhost");\r
+ registration.addInitParameter(Config.AAF_LUR_CLASS, "org.onap.aaf.cadi.aaf.v2_0.AAFLurPerm");\r
+ registration.addInitParameter(\r
+ Config.AAF_URL, "https://localhost");\r
+\r
+ registration.addInitParameter(Config.BASIC_REALM, "localhost");\r
+ registration.addInitParameter(Config.BASIC_WARN, "true");\r
+\r
+ registration.addInitParameter(Config.CADI_KEYFILE, CADI_KEYFILE);\r
+ registration.addInitParameter(Config.CADI_LATITUDE, "38.62782");\r
+ registration.addInitParameter(Config.CADI_LOGLEVEL, Level.ERROR.name());\r
+ registration.addInitParameter(Config.CADI_LONGITUDE, "-90.19458");\r
+ registration.addInitParameter(Config.CADI_NOAUTHN, "/health/v1");\r
+ registration.addInitParameter(Config.CADI_PROTOCOLS, "TLSv1.1,TLSv1.2");\r
+ registration.addInitParameter(Config.CADI_KEYSTORE, CADI_KEYSTORE);\r
+ registration.addInitParameter(Config.CADI_KEYSTORE_PASSWORD, CADI_KEYSTORE_PASSWORD);\r
+\r
+ registration.addInitParameter(Config.HOSTNAME, CADI_HOSTNAME);\r
+ }\r
+}\r