<properties>
<start-class>org.onap.sdnc.apps.ms.gra.GenericResourceMsApp</start-class>
- <shiro.version>1.5.0</shiro.version>
- <aaf-shiro-bundle.version>2.1.13</aaf-shiro-bundle.version>
+ <aaf.cadi.version>2.1.21</aaf.cadi.version>
<ccsdk.apps.version>1.2.0-SNAPSHOT</ccsdk.apps.version>
<ccsdk.docker.version>1.1-STAGING-latest</ccsdk.docker.version>
<sdnc.northbound.version>2.2.0-SNAPSHOT</sdnc.northbound.version>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
</dependency>
- <dependency>
- <groupId>org.apache.shiro</groupId>
- <artifactId>shiro-spring-boot-web-starter</artifactId>
- <version>${shiro.version}</version>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
<artifactId>jackson-dataformat-xml</artifactId>
</dependency>
<dependency>
- <groupId>org.onap.aaf.cadi</groupId>
- <artifactId>aaf-cadi-shiro</artifactId>
- <version>${aaf-shiro-bundle.version}</version>
+ <groupId>org.onap.aaf.authz</groupId>
+ <artifactId>aaf-auth-client</artifactId>
+ <version>${aaf.cadi.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.aaf.authz</groupId>
+ <artifactId>aaf-misc-env</artifactId>
+ <version>${aaf.cadi.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.aaf.authz</groupId>
+ <artifactId>aaf-misc-rosetta</artifactId>
+ <version>${aaf.cadi.version}</version>
</dependency>
-
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
- <forkMode>always</forkMode>
<environmentVariables>
<SDNC_CONFIG_DIR>${basedir}/src/test/resources</SDNC_CONFIG_DIR>
<SVCLOGIC_PROPERTIES>${basedir}/src/test/resources/svclogic.properties</SVCLOGIC_PROPERTIES>
--- /dev/null
+package org.onap.sdnc.apps.ms.gra;\r
+\r
+import org.onap.aaf.cadi.filter.CadiFilter;\r
+import org.onap.ccsdk.apps.filters.ContentTypeFilter;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+import org.springframework.boot.web.servlet.FilterRegistrationBean;\r
+import org.springframework.context.annotation.Bean;\r
+import org.springframework.context.annotation.Configuration;\r
+import org.springframework.core.annotation.Order;\r
+\r
+@Configuration\r
+public class FilterConfiguration {\r
+\r
+ private static final Logger log = LoggerFactory.getLogger(FilterConfiguration.class);\r
+\r
+ @Bean\r
+ @Order(1)\r
+ public FilterRegistrationBean<CadiFilter> cadiFilter() {\r
+ CadiFilter filter = new CadiFilter();\r
+\r
+ FilterRegistrationBean<CadiFilter> registrationBean = new FilterRegistrationBean<>();\r
+ registrationBean.setFilter(filter);\r
+ if ("none".equals(System.getProperty("cadi_prop_files", "none"))) {\r
+ log.info("cadi_prop_files undefined, AAF CADI disabled");\r
+ registrationBean.addUrlPatterns("/xxxx/*");\r
+ } else {\r
+ registrationBean.addUrlPatterns("/*");\r
+ registrationBean.addInitParameter("cadi_prop_files", System.getProperty("cadi_prop_files"));\r
+ }\r
+\r
+ return registrationBean;\r
+ }\r
+\r
+}\r
package org.onap.sdnc.apps.ms.gra;
-import org.apache.shiro.realm.Realm;
-import org.apache.shiro.realm.text.PropertiesRealm;
-import org.apache.shiro.spring.web.config.DefaultShiroFilterChainDefinition;
-import org.apache.shiro.spring.web.config.ShiroFilterChainDefinition;
-import org.onap.aaf.cadi.shiro.AAFRealm;
import org.onap.ccsdk.apps.ms.sliboot.controllers.RestconfApiController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
-import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
-@SpringBootApplication(scanBasePackages = { "org.onap.sdnc.apps.ms.gra", "org.onap.ccsdk.apps.services", "org.onap.ccsdk.apps.filters" })
+@SpringBootApplication(scanBasePackages = { "org.onap.sdnc.apps.ms.gra", "org.onap.ccsdk.apps.services" })
@EnableJpaRepositories(basePackages = { "org.onap.sdnc.apps.ms.gra", "org.onap.ccsdk.apps.ms.sliboot" })
@EntityScan(basePackages = { "org.onap.sdnc.apps.ms.gra", "org.onap.ccsdk.apps.ms.sliboot" })
@EnableTransactionManagement
public static void main(String[] args) throws Exception {
SpringApplication.run(GenericResourceMsApp.class, args);
}
-
- @Bean
- public Realm realm() {
-
- // If cadi prop files is not defined use local properties realm
- // src/main/resources/shiro-users.properties
- if ("none".equals(System.getProperty("cadi_prop_files", "none"))) {
- log.info("cadi_prop_files undefined, AAF Realm will not be set");
- PropertiesRealm realm = new PropertiesRealm();
- return realm;
- } else {
- AAFRealm realm = new AAFRealm();
- return realm;
- }
-
- }
-
- @Bean
- public ShiroFilterChainDefinition shiroFilterChainDefinition() {
- DefaultShiroFilterChainDefinition chainDefinition = new DefaultShiroFilterChainDefinition();
-
- // if cadi prop files is not set disable authentication
- if ("none".equals(System.getProperty("cadi_prop_files", "none"))) {
- chainDefinition.addPathDefinition("/**", "anon");
- } else {
- log.info("Loaded property cadi_prop_files, AAF REALM set");
- chainDefinition.addPathDefinition("/**", "authcBasic, rest[org.onap.sdnc.odl:odl-api]");
- }
-
- return chainDefinition;
- }
-
}
+++ /dev/null
-user.admin = Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U,service
-role.service = odl-api:*
-
+++ /dev/null
-package org.onap.sdnc.apps.ms.gra.controllers;
-
-import org.apache.shiro.realm.Realm;
-import org.apache.shiro.realm.text.PropertiesRealm;
-import org.apache.shiro.spring.web.config.ShiroFilterChainDefinition;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.sdnc.apps.ms.gra.GenericResourceMsApp;
-
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-public class GenericResourceMsAppTest {
-
- GenericResourceMsApp app;
-
- @Before
- public void setUp() throws Exception {
- app = new GenericResourceMsApp();
- System.out.println("GenericResourceMsAppTest: Setting serviceLogicProperties, serviceLogicDirectory and sdnc.config.dir");
- System.setProperty("serviceLogicProperties", "src/test/resources/svclogic.properties");
- System.setProperty("serviceLogicDirectory", "src/test/resources/svclogic");
- System.setProperty("sdnc.config.dir", "src/test/resources");
-
- }
-
- @Test
- public void realm() {
- Realm realm = app.realm();
- assertTrue(realm instanceof PropertiesRealm);
-
-
- }
-
- @Test
- public void shiroFilterChainDefinition() {
- ShiroFilterChainDefinition chainDefinition = app.shiroFilterChainDefinition();
- Map<String, String> chainMap = chainDefinition.getFilterChainMap();
- assertEquals("anon", chainMap.get("/**"));
-
-
- }
-}
\ No newline at end of file