2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============LICENSE_END=========================================================
\r
21 package org.onap.ccsdk.apps.ms.sliboot;
\r
23 import org.slf4j.Logger;
\r
24 import org.slf4j.LoggerFactory;
\r
25 import org.springframework.boot.SpringApplication;
\r
26 import org.springframework.boot.autoconfigure.SpringBootApplication;
\r
27 import org.springframework.context.annotation.ComponentScan;
\r
28 import springfox.documentation.swagger2.annotations.EnableSwagger2;
\r
29 import org.apache.shiro.realm.Realm;
\r
30 import org.apache.shiro.realm.text.PropertiesRealm;
\r
31 import org.apache.shiro.spring.web.config.DefaultShiroFilterChainDefinition;
\r
32 import org.apache.shiro.spring.web.config.ShiroFilterChainDefinition;
\r
33 import org.springframework.context.annotation.Bean;
\r
34 import org.onap.aaf.cadi.shiro.AAFRealm;
\r
36 @SpringBootApplication
\r
38 @ComponentScan(basePackages = { "org.onap.ccsdk.apps.ms.sliboot.*", "org.onap.ccsdk.apps.services" })
\r
41 private static final Logger log = LoggerFactory.getLogger(App.class);
\r
43 public static void main(String[] args) throws Exception {
\r
44 SpringApplication.run(App.class, args);
\r
48 public Realm realm() {
\r
50 // If cadi prop files is not defined use local properties realm
\r
51 // src/main/resources/shiro-users.properties
\r
52 if ("none".equals(System.getProperty("cadi_prop_files", "none"))) {
\r
53 log.info("cadi_prop_files undefined, AAF Realm will not be set");
\r
54 PropertiesRealm realm = new PropertiesRealm();
\r
57 AAFRealm realm = new AAFRealm();
\r
64 public ShiroFilterChainDefinition shiroFilterChainDefinition() {
\r
65 DefaultShiroFilterChainDefinition chainDefinition = new DefaultShiroFilterChainDefinition();
\r
67 // if cadi prop files is not set disable authentication
\r
68 if ("none".equals(System.getProperty("cadi_prop_files", "none"))) {
\r
69 chainDefinition.addPathDefinition("/**", "anon");
\r
71 log.info("Loaded property cadi_prop_files, AAF REALM set");
\r
72 chainDefinition.addPathDefinition("/**", "authcBasic, rest[org.onap.sdnc.odl:odl-api]");
\r
75 return chainDefinition;
\r