summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrv871f <richard.vondadelszen@amdocs.com>2018-03-29 11:38:04 -0400
committerrv871f <richard.vondadelszen@amdocs.com>2018-03-29 11:38:30 -0400
commit439e16586f6a1b05a892cada09e7b48cb322878c (patch)
tree7a2caa507265c1471e2d1241e7591f177a8f8233
parentb505658d523507b2aa8eec564b599ce1e2b1956a (diff)
Portal Login Filter reintegration
Issue-ID: AAI-599 Change-Id: I119608a418a07546cd58d4fcbdf93f033c8fbd88 Signed-off-by: rv871f <richard.vondadelszen@amdocs.com>
-rw-r--r--sparkybe-onap-application/pom.xml159
-rw-r--r--sparkybe-onap-application/src/main/java/org/onap/aai/sparky/Application.java44
-rw-r--r--sparkybe-onap-application/src/main/scripts/start.sh3
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/config/SparkyResourceLoader.java36
4 files changed, 109 insertions, 133 deletions
diff --git a/sparkybe-onap-application/pom.xml b/sparkybe-onap-application/pom.xml
index 92c3126..ec40b53 100644
--- a/sparkybe-onap-application/pom.xml
+++ b/sparkybe-onap-application/pom.xml
@@ -1,5 +1,6 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
@@ -8,9 +9,9 @@
</parent>
<groupId>org.onap.aai.sparky-be</groupId>
- <artifactId>sparkybe-onap-application</artifactId>
+ <artifactId>sparkybe-onap-application</artifactId>
<version>1.2.0-SNAPSHOT</version>
- <packaging>jar</packaging>
+ <packaging>jar</packaging>
<properties>
<java.version>1.8</java.version>
@@ -29,26 +30,26 @@
<dependencyManagement>
- <dependencies>
+ <dependencies>
+
+ <!-- Camel BOM -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-spring-boot-dependencies</artifactId>
+ <version>${camel-spring-boot.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
- <!-- Camel BOM -->
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-spring-boot-dependencies</artifactId>
- <version>${camel-spring-boot.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
-
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- <version>1.2.1</version>
- </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>1.2.1</version>
+ </dependency>
- </dependencies>
+ </dependencies>
-</dependencyManagement>
+ </dependencyManagement>
<dependencies>
@@ -73,14 +74,14 @@
</exclusion>
</exclusions>
</dependency>
-
+
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
<exclusions>
<exclusion>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
@@ -125,7 +126,7 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
- </dependency>
+ </dependency>
<!-- https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-util -->
<dependency>
@@ -144,11 +145,11 @@
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
- <dependency>
- <groupId>org.onap.aai.sparky-be</groupId>
- <artifactId>sparkybe-onap-service</artifactId>
- <version>1.2.0-SNAPSHOT</version>
- </dependency>
+ <dependency>
+ <groupId>org.onap.aai.sparky-be</groupId>
+ <artifactId>sparkybe-onap-service</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </dependency>
@@ -378,6 +379,13 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
+ <configuration>
+ <folders>
+ <folder>
+ ${CONFIG_HOME}/portal/
+ </folder>
+ </folders>
+ </configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -486,38 +494,14 @@
</reportPlugins>
</configuration>
</plugin>
-
- <!-- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-resources-plugin</artifactId>
- <version>2.7</version>
- <executions>
- <execution>
- <id>copy-docker-file</id>
- <phase>package</phase>
- <goals>
- <goal>copy-resources</goal>
- </goals>
- <configuration>
- <outputDirectory>target</outputDirectory>
- <overwrite>true</overwrite>
- <resources>
- <resource>
- <directory>${basedir}/src/main/docker</directory>
- <filtering>true</filtering>
- <includes>
- <include>**/*</include>
- </includes>
- </resource>
- <resource>
- <directory>${basedir}/src/main/scripts/</directory>
- </resource>
- </resources>
- </configuration>
- </execution>
- </executions>
- </plugin>
- -->
+
+ <!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId>
+ <version>2.7</version> <executions> <execution> <id>copy-docker-file</id>
+ <phase>package</phase> <goals> <goal>copy-resources</goal> </goals> <configuration>
+ <outputDirectory>target</outputDirectory> <overwrite>true</overwrite> <resources>
+ <resource> <directory>${basedir}/src/main/docker</directory> <filtering>true</filtering>
+ <includes> <include>**/*</include> </includes> </resource> <resource> <directory>${basedir}/src/main/scripts/</directory>
+ </resource> </resources> </configuration> </execution> </executions> </plugin> -->
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
@@ -534,41 +518,26 @@
</configuration>
</plugin>
<!-- license plugin -->
-<!-- <plugin>
- <groupId>com.mycila</groupId>
- <artifactId>license-maven-plugin</artifactId>
- <version>3.0</version>
- <configuration>
- <header>LICENSE</header>
- <includes>
- <include>src/main/java/**</include>
- </includes>
- </configuration>
- <executions>
- <execution>
- <goals>
- <goal>format</goal>
- </goals>
- <phase>process-sources</phase>
- </execution>
- </executions>
- </plugin>
- -->
+ <!-- <plugin> <groupId>com.mycila</groupId> <artifactId>license-maven-plugin</artifactId>
+ <version>3.0</version> <configuration> <header>LICENSE</header> <includes>
+ <include>src/main/java/**</include> </includes> </configuration> <executions>
+ <execution> <goals> <goal>format</goal> </goals> <phase>process-sources</phase>
+ </execution> </executions> </plugin> -->
</plugins>
</build>
- <distributionManagement>
- <repository>
- <id>ecomp-releases</id>
- <name>ECOMP Release Repository</name>
- <url>${nexusproxy}/content/repositories/releases/</url>
- </repository>
- <snapshotRepository>
- <id>ecomp-snapshots</id>
- <name>ECOMP Snapshot Repository</name>
- <url>${nexusproxy}/content/repositories/snapshots/</url>
- </snapshotRepository>
- </distributionManagement>
-
+ <distributionManagement>
+ <repository>
+ <id>ecomp-releases</id>
+ <name>ECOMP Release Repository</name>
+ <url>${nexusproxy}/content/repositories/releases/</url>
+ </repository>
+ <snapshotRepository>
+ <id>ecomp-snapshots</id>
+ <name>ECOMP Snapshot Repository</name>
+ <url>${nexusproxy}/content/repositories/snapshots/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
</project>
diff --git a/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/Application.java b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/Application.java
index 693617b..1077642 100644
--- a/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/Application.java
+++ b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/Application.java
@@ -20,25 +20,30 @@
*/
package org.onap.aai.sparky;
+import javax.servlet.Filter;
+
+import org.onap.aai.sparky.security.filter.LoginFilter;
+
import org.apache.camel.component.servlet.CamelHttpTransportServlet;
import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
+import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
@SpringBootApplication
public class Application {
-
- public static void main(String[] args) {
- SpringApplication.run(Application.class, args);
+ private Filter loginFilter = new LoginFilter();
+ public static void main(String[] args) {
+ SpringApplication.run(Application.class, args);
}
-
+
/*
* This initialization code enabled access to aai-ui-proxy-processor
*/
-
@Bean
ServletRegistrationBean servletRegistrationBean() {
final ServletRegistrationBean servlet =
@@ -48,20 +53,19 @@ public class Application {
}
/**
- * bind LoginFilter
+ * bind LoginFilter
*/
-
- /*@Bean
- public FilterRegistrationBean myFilter() {
- FilterRegistrationBean registration = new FilterRegistrationBean();
- Filter myFilter = new LoginFilter();
- beanFactory.autowireBean(myFilter);
- registration.setFilter(myFilter);
- registration.addUrlPatterns("/*");
- return registration;
- }*/
-
-
-
-
+ @Bean
+ @ConditionalOnProperty(value = "sparky.portal.enabled", havingValue = "true")
+ public FilterRegistrationBean loginFilterRegistrationBean() {
+ FilterRegistrationBean registration = new FilterRegistrationBean();
+
+ registration.setFilter(loginFilter);
+ registration.addUrlPatterns("/*");
+
+ return registration;
+ }
+
+
+
}
diff --git a/sparkybe-onap-application/src/main/scripts/start.sh b/sparkybe-onap-application/src/main/scripts/start.sh
index 0db0d37..f2f6f31 100644
--- a/sparkybe-onap-application/src/main/scripts/start.sh
+++ b/sparkybe-onap-application/src/main/scripts/start.sh
@@ -6,5 +6,6 @@ CONFIG_HOME=${APP_HOME}/appconfig
PROPS="-DAPP_HOME=${APP_HOME} -DCONFIG_HOME=${CONFIG_HOME}"
set -x
-java -Xms1024m -Xmx4096m $PROPS -jar ${APP_HOME}/lib/sparkybe-onap-application*.jar --sparky.ssl.enabled=${UI_SSL_ENABLED}
+jar ufv ${APP_HOME}/lib/sparkybe-onap-application*.jar -C ${CONFIG_HOME}/portal/ BOOT-INF/classes/portal.properties
+java -Xms1024m -Xmx4096m $PROPS -jar ${APP_HOME}/lib/sparkybe-onap-application*.jar --sparky.ssl.enabled=${UI_SSL_ENABLED} --sparky.portal.enabled=${UI_PORTAL_ENABLED}
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/config/SparkyResourceLoader.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/config/SparkyResourceLoader.java
index 8d99221..6bb0c45 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/config/SparkyResourceLoader.java
+++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/config/SparkyResourceLoader.java
@@ -30,8 +30,8 @@ import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
public class SparkyResourceLoader implements ResourceLoaderAware {
-
-
+
+
private static final String FILE_URI = "file:";
private ResourceLoader resourceLoader;
private String configHomeEnvVar;
@@ -42,7 +42,7 @@ public class SparkyResourceLoader implements ResourceLoaderAware {
public void setResourceLoader(ResourceLoader resourceLoader) {
this.resourceLoader = resourceLoader;
}
-
+
public String getFullFileUri(String uriFilePath) {
return FILE_URI + System.getProperty(configHomeEnvVar) + uriFilePath;
}
@@ -50,38 +50,40 @@ public class SparkyResourceLoader implements ResourceLoaderAware {
public String getAbsolutePath(String uriFilePath) {
return System.getProperty(configHomeEnvVar) + uriFilePath;
}
-
+
protected Resource getResource(String uriFilePath, boolean isRelative) {
String fileUri = uriFilePath;
- if (!uriFilePath.startsWith("file:")) {
- fileUri = "file:" + uriFilePath;
- }
+ if (!uriFilePath.startsWith(FILE_URI)) {
+
+ if (isRelative) {
+ fileUri = getFullFileUri(fileUri);
+ } else {
+ fileUri = FILE_URI + uriFilePath;
+ }
- if (isRelative) {
- return resourceLoader.getResource(getFullFileUri(fileUri));
- } else {
- return resourceLoader.getResource(fileUri);
}
+ return resourceLoader.getResource(fileUri);
+
}
public File getResourceAsFile(String uriFilePath, boolean isRelativePath) throws IOException {
-
- Resource resource = getResource(uriFilePath, isRelativePath);
+
+ Resource resource = getResource(uriFilePath, isRelativePath);
if (resource.exists()) {
return resource.getFile();
}
return null;
-
+
}
public byte[] getResourceAsBytes(String uriFilePath, boolean isRelativePath) throws IOException {
- Resource resource = getResource(uriFilePath, isRelativePath);
+ Resource resource = getResource(uriFilePath, isRelativePath);
if (resource.exists()) {
return getResourceAsBytes(resource);
@@ -89,10 +91,10 @@ public class SparkyResourceLoader implements ResourceLoaderAware {
return null;
}
-
+
public byte[] getResourceAsBytes(Resource resource) throws IOException {
- if ( resource != null && resource.exists()) {
+ if (resource != null && resource.exists()) {
return Files.readAllBytes(Paths.get(resource.getFile().getAbsolutePath()));
}