2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6 * ===========================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END====================================================
22 package org.onap.aaf.cadi.filter;
24 import javax.servlet.FilterConfig;
25 import javax.servlet.ServletContext;
27 import org.onap.aaf.cadi.Access;
28 import org.onap.aaf.cadi.Access.Level;
29 import org.onap.aaf.cadi.config.Get;
32 * A private method to query the Filter config and if not exists, return the default. This
33 * cleans up the initialization code.
35 class FCGet implements Get {
39 private final Access access;
40 private FilterConfig filterConfig;
41 private ServletContext context;
43 public FCGet(Access access, ServletContext context, FilterConfig filterConfig) {
45 this.context = context;
46 this.filterConfig = filterConfig;
49 public String get(String name, String def, boolean print) {
51 // Try Server Context First
53 str = context.getInitParameter(name);
56 // Try Filter Context next
57 if(str==null && filterConfig != null) {
58 str = filterConfig.getInitParameter(name);
62 str = access.getProperty(name, def);
64 // Take def if nothing else
69 str = str.trim(); // this is vital in Property File based values, as spaces can hide easily
71 access.log(Level.INFO,"Setting", name, "to", str);