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.clamp.clds.config;
25 import java.util.Properties;
27 import javax.servlet.Filter;
29 import org.onap.clamp.clds.filter.ClampCadiFilter;
30 import org.springframework.beans.factory.annotation.Autowired;
31 import org.springframework.boot.web.servlet.FilterRegistrationBean;
32 import org.springframework.context.annotation.Bean;
33 import org.springframework.context.annotation.Configuration;
34 import org.springframework.context.annotation.Profile;
35 import org.springframework.boot.context.properties.ConfigurationProperties;
36 import org.springframework.stereotype.Component;
40 @Profile("clamp-aaf-authentication")
41 @ConfigurationProperties(prefix = "clamp.config.cadi")
42 public class AAFConfiguration {
43 private static final String CADI_KEY_FILE = "cadi_keyfile";
44 private static final String CADI_LOG_LEVEL = "cadi_loglevel";
45 private static final String LATITUDE = "cadi_latitude";
46 private static final String LONGITUDE = "cadi_longitude";
47 private static final String LOCATE_URL = "aaf_locate_url";
48 private static final String OAUTH_TOKEN_URL = "aaf_oauth2_token_url";
49 private static final String OAUTH_INTROSPECT_URL = "aaf_oauth2_introspect_url";
50 private static final String AAF_ENV = "aaf_env";
51 private static final String AAF_URL = "aaf_url";
52 private static final String X509_ISSUERS = "cadi_x509_issuers";
54 private String keyFile;
55 private String cadiLoglevel;
56 private String cadiLatitude;
57 private String cadiLongitude;
58 private String aafLocateUrl;
59 private String oauthTokenUrl;
60 private String oauthIntrospectUrl;
61 private String aafEnv;
62 private String aafUrl;
63 private String cadiX509Issuers;
66 * Method to return clamp cadi filter.
70 @Bean(name = "cadiFilter")
71 public Filter cadiFilter() {
72 return new ClampCadiFilter();
76 * Method to register cadi filter.
78 * @return FilterRegistrationBean
81 public FilterRegistrationBean cadiFilterRegistration() {
82 FilterRegistrationBean registration = new FilterRegistrationBean();
83 registration.setFilter(cadiFilter());
84 registration.addUrlPatterns("/restservices/*");
85 //registration.addUrlPatterns("*");
86 registration.setName("cadiFilter");
87 registration.setOrder(0);
91 public String getKeyFile() {
95 public void setKeyFile(String keyFile) {
96 this.keyFile = keyFile;
99 public String getCadiLoglevel() {
103 public void setCadiLoglevel(String cadiLoglevel) {
104 this.cadiLoglevel = cadiLoglevel;
107 public String getCadiLatitude() {
111 public void setCadiLatitude(String cadiLatitude) {
112 this.cadiLatitude = cadiLatitude;
115 public String getCadiLongitude() {
116 return cadiLongitude;
119 public void setCadiLongitude(String cadiLongitude) {
120 this.cadiLongitude = cadiLongitude;
123 public String getAafLocateUrl() {
127 public void setAafLocateUrl(String aafLocateUrl) {
128 this.aafLocateUrl = aafLocateUrl;
131 public String getOauthTokenUrl() {
132 return oauthTokenUrl;
135 public void setOauthTokenUrl(String oauthTokenUrl) {
136 this.oauthTokenUrl = oauthTokenUrl;
139 public String getOauthIntrospectUrl() {
140 return oauthIntrospectUrl;
143 public void setOauthIntrospectUrl(String oauthIntrospectUrl) {
144 this.oauthIntrospectUrl = oauthIntrospectUrl;
147 public String getAafEnv() {
151 public void setAafEnv(String aafEnv) {
152 this.aafEnv = aafEnv;
155 public String getAafUrl() {
159 public void setAafUrl(String aafUrl) {
160 this.aafUrl = aafUrl;
163 public String getCadiX509Issuers() {
164 return cadiX509Issuers;
167 public void setCadiX509Issuers(String cadiX509Issuers) {
168 this.cadiX509Issuers = cadiX509Issuers;
171 public Properties getProperties() {
172 Properties prop = System.getProperties();
173 //prop.put("cadi_prop_files", "");
174 prop.put(CADI_KEY_FILE, keyFile);
175 prop.put(CADI_LOG_LEVEL, cadiLoglevel);
176 prop.put(LATITUDE, cadiLatitude);
177 prop.put(LONGITUDE, cadiLongitude);
178 prop.put(LOCATE_URL, aafLocateUrl);
179 if (oauthTokenUrl != null) {
180 prop.put(OAUTH_TOKEN_URL, oauthTokenUrl);
182 if (oauthIntrospectUrl != null) {
183 prop.put(OAUTH_INTROSPECT_URL, oauthIntrospectUrl);
185 prop.put(AAF_ENV, aafEnv);
186 prop.put(AAF_URL, aafUrl);
187 prop.put(X509_ISSUERS, cadiX509Issuers);