2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 Amdocs
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=========================================================
21 package org.onap.aai.sparky.portal;
23 import javax.servlet.Filter;
25 import org.onap.aai.sparky.security.filter.LoginFilter;
26 import org.onap.portalsdk.core.onboarding.crossapi.CadiAuthFilter;
27 import org.onap.portalsdk.core.onboarding.crossapi.PortalRestAPIProxy;
28 import org.springframework.beans.factory.annotation.Value;
29 import org.springframework.boot.web.servlet.FilterRegistrationBean;
30 import org.springframework.boot.web.servlet.ServletRegistrationBean;
31 import org.springframework.context.annotation.Bean;
32 import org.springframework.context.annotation.Profile;
33 import org.springframework.stereotype.Component;
37 public class PortalBean {
39 private Filter loginFilter = new LoginFilter();
40 private Filter cadiAuthFilter = new CadiAuthFilter();
42 @Value("${portal.cadiFileLocation}")
43 private String cadiPropsLocation;
49 public FilterRegistrationBean loginFilterRegistrationBean() {
50 FilterRegistrationBean registration = new FilterRegistrationBean();
51 registration.setFilter(loginFilter);
52 registration.addUrlPatterns("/*");
53 registration.setOrder(1);
62 public FilterRegistrationBean cadiFilterRegistrationBean() {
63 FilterRegistrationBean registration = new FilterRegistrationBean();
65 registration.setFilter(cadiAuthFilter);
66 registration.addUrlPatterns("/*");
67 registration.setOrder(0);
68 registration.addInitParameter("cadi_prop_files",cadiPropsLocation);
69 registration.addInitParameter("include_url_endpoints","/api/v3/*");
70 registration.addInitParameter("exclude_url_endpoints","/api/v2/*");
76 public ServletRegistrationBean portalApiProxy() {
78 final ServletRegistrationBean servlet =
79 new ServletRegistrationBean(new PortalRestAPIProxy(), "/api/v3/*");
80 servlet.setName("PortalRestApiProxy");