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.filter;
25 import java.util.Properties;
27 import javax.servlet.FilterConfig;
28 import javax.servlet.ServletException;
30 import org.onap.aaf.cadi.filter.CadiFilter;
31 import org.onap.clamp.clds.config.AAFConfiguration;
32 import org.springframework.beans.factory.annotation.Autowired;
33 import org.springframework.beans.factory.annotation.Value;
35 public class ClampCadiFilter extends CadiFilter {
36 private static final String CADI_TRUST_STORE = "cadi_truststore";
37 private static final String CADI_TRUST_STORE_PW = "cadi_truststore_password";
38 private static final String CADI_KEY_STORE = "cadi_keystore";
39 private static final String CADI_KEY_STORE_PW = "cadi_keystore_password";
40 private static final String ALIAS = "cadi_alias";
42 @Value("${server.ssl.key-store:none}")
43 private String keyStore;
45 @Value("${clamp.config.cadi.cadiKeystorePassword:none}")
46 private String keyStorePass;
48 @Value("${server.ssl.trust:none}")
49 private String trustStore;
51 @Value("${clamp.config.cadi.cadiTruststorePassword:none}")
52 private String trustStorePass;
54 @Value("${server.ssl.key-alias:clamp@clamp.onap.org}")
58 private AAFConfiguration aafConfiguration;
61 public void init(FilterConfig filterConfig) throws ServletException {
62 Properties props = aafConfiguration.getProperties();
63 props.setProperty(CADI_KEY_STORE, trimFileName(keyStore));
64 props.setProperty(CADI_TRUST_STORE, trimFileName(trustStore));
65 props.setProperty(ALIAS, alias);
66 props.setProperty(CADI_KEY_STORE_PW, keyStorePass);
67 props.setProperty(CADI_TRUST_STORE_PW, trustStorePass);
69 super.init(filterConfig);
72 private String trimFileName (String fileName) {
73 int index= fileName.indexOf("file:");
77 return fileName.substring(index+5);