diff options
20 files changed, 1115 insertions, 1120 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/user/UserBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/user/UserBusinessLogic.java index f90440011d..62232beaf5 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/user/UserBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/user/UserBusinessLogic.java @@ -33,6 +33,7 @@ import java.util.stream.Collectors; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.tinkerpop.gremlin.structure.Edge; +import org.onap.portalsdk.core.onboarding.util.CipherUtil; import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.dao.utils.UserStatusEnum; @@ -68,6 +69,7 @@ public class UserBusinessLogic { } public User getUser(String userId, boolean inTransaction) { + userId = decryptUserId(userId); Either<User, ActionStatus> result = userAdminOperation.getUserData(userId, inTransaction); if (result.isRight()) { handleUserAccessAuditing(userId, result.right().value()); @@ -81,7 +83,19 @@ public class UserBusinessLogic { return user; } + private String decryptUserId(final String userId) { + if (StringUtils.isNotEmpty(userId)) { + try { + return CipherUtil.decryptPKC(userId); + } catch (final Exception e) { + return userId; + } + } + return userId; + } + public User getUser(String userId) { + userId = decryptUserId(userId); UserContext userContext = ThreadLocalsHolder.getUserContext(); if (Objects.isNull(userContext) || Objects.isNull(userContext.getUserId())) { log.info("USER_NOT_FOUND, user=" + userId); @@ -106,6 +120,7 @@ public class UserBusinessLogic { } public boolean hasActiveUser(String userId) { + userId = decryptUserId(userId); UserContext userContext = ThreadLocalsHolder.getUserContext(); if (Objects.isNull(userContext) || Objects.isNull(userContext.getUserId())) { handleUserAccessAuditing(userId, ActionStatus.USER_NOT_FOUND); diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/users/data/users.json b/catalog-be/src/main/resources/scripts/sdcBePy/users/data/users.json index 9ce2be4dd3..ed3adafe66 100755 --- a/catalog-be/src/main/resources/scripts/sdcBePy/users/data/users.json +++ b/catalog-be/src/main/resources/scripts/sdcBePy/users/data/users.json @@ -7,13 +7,6 @@ "email": "demo@openecomp.org" }, { - "userId": "op0001", - "firstName": "Oper", - "lastName": "P", - "role": "OPS", - "email": "op0001@openecomp.org" - }, - { "userId": "gv0001", "firstName": "Giuseppe", "lastName": "Verdi", diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/PortalServlet.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/PortalServlet.java index 6378b996cf..228f65db85 100644 --- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/PortalServlet.java +++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/PortalServlet.java @@ -113,7 +113,7 @@ public class PortalServlet extends HttpServlet { * @throws IOException */ private void addRequestHeadersUsingWebseal(final HttpServletRequest request, final HttpServletResponse response) - throws ServletException, IOException { + throws ServletException, IOException, CipherUtilException { response.setContentType("text/html"); // Create new request object to dispatch MutableHttpServletRequest mutableRequest = new MutableHttpServletRequest(request); @@ -170,7 +170,6 @@ public class PortalServlet extends HttpServlet { getValueFromCookie(request, Constants.HTTP_CSP_FIRSTNAME); getValueFromCookie(request, Constants.HTTP_CSP_LASTNAME); //To be fixed - //addAuthCookie(response, userId, firstNameFromCookie, lastNameFromCookie); RequestDispatcher rd = request.getRequestDispatcher("index.html"); rd.forward(mutableRequest, response); @@ -180,7 +179,7 @@ public class PortalServlet extends HttpServlet { } boolean addAuthCookie(HttpServletResponse response, String userId, String firstName, String lastName) throws IOException { - boolean isBuildCookieCompleted = true; + boolean isBuildCookieCompleted = false; Cookie authCookie = null; Configuration.CookieConfig confCookie = ConfigurationManager.getConfigurationManager().getConfiguration().getAuthCookie(); //create authentication and send it to encryption @@ -188,9 +187,9 @@ public class PortalServlet extends HttpServlet { try { AuthenticationCookie authenticationCookie = new AuthenticationCookie(userId, firstName, lastName); String cookieAsJson = RepresentationUtils.toRepresentation(authenticationCookie); - encryptedCookie = org.onap.sdc.security.CipherUtil.encryptPKC(cookieAsJson, confCookie.getSecurityKey()); + encryptedCookie = CipherUtil.encryptPKC(cookieAsJson, confCookie.getSecurityKey()); + isBuildCookieCompleted = true; } catch (Exception e) { - isBuildCookieCompleted = false; log.error(" Cookie Encryption failed ", e); } authCookie = new Cookie(confCookie.getCookieName(), encryptedCookie); @@ -243,12 +242,13 @@ public class PortalServlet extends HttpServlet { * @param request * @param headers */ - private void addCookies(final HttpServletResponse response, final HttpServletRequest request, final String[] headers) { + private void addCookies(final HttpServletResponse response, final HttpServletRequest request, final String[] headers) + throws CipherUtilException { for (var i = 0; i < headers.length; i++) { final var currHeader = ValidationUtils.sanitizeInputString(headers[i]); final var headerValue = ValidationUtils.sanitizeInputString(request.getHeader(currHeader)); if (headerValue != null) { - final var cookie = new Cookie(currHeader, headerValue); + final var cookie = new Cookie(currHeader, CipherUtil.encryptPKC(headerValue)); cookie.setSecure(true); response.addCookie(cookie); } diff --git a/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/PortalServletTest.java b/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/PortalServletTest.java index b31b2f970e..11a4aecede 100644 --- a/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/PortalServletTest.java +++ b/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/PortalServletTest.java @@ -55,14 +55,14 @@ import org.openecomp.sdc.fe.config.ConfigurationManager; class PortalServletTest extends JerseyTest { - private final static HttpServletRequest request = Mockito.mock(HttpServletRequest.class); - private final static HttpSession httpSession = Mockito.mock(HttpSession.class); - private final static ServletContext servletContext = Mockito.mock(ServletContext.class); - private final static ConfigurationManager configurationManager = Mockito.mock(ConfigurationManager.class); - private final static Configuration configuration = Mockito.mock(Configuration.class); - private final static HttpServletResponse response = Mockito.spy(HttpServletResponse.class); - private final static RequestDispatcher rd = Mockito.spy(RequestDispatcher.class); - final static Configuration.CookieConfig cookieConfiguration = Mockito.mock(Configuration.CookieConfig.class); + private static final HttpServletRequest request = Mockito.mock(HttpServletRequest.class); + private static final HttpSession httpSession = Mockito.mock(HttpSession.class); + private static final ServletContext servletContext = Mockito.mock(ServletContext.class); + private static final ConfigurationManager configurationManager = Mockito.mock(ConfigurationManager.class); + private static final Configuration configuration = Mockito.mock(Configuration.class); + private static final HttpServletResponse response = Mockito.spy(HttpServletResponse.class); + private static final RequestDispatcher rd = Mockito.spy(RequestDispatcher.class); + private static final Configuration.CookieConfig cookieConfiguration = Mockito.mock(Configuration.CookieConfig.class); @SuppressWarnings("serial") @BeforeAll diff --git a/catalog-model/pom.xml b/catalog-model/pom.xml index 77b90a78cd..57d5e8b458 100644 --- a/catalog-model/pom.xml +++ b/catalog-model/pom.xml @@ -1,515 +1,520 @@ <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> - - <groupId>org.openecomp.sdc.be</groupId> - <artifactId>catalog-model</artifactId> - - <parent> - <groupId>org.openecomp.sdc</groupId> - <artifactId>sdc-main</artifactId> - <version>1.10.0-SNAPSHOT</version> - </parent> - - <properties> - <awaitility.version>4.0.3</awaitility.version> - </properties> - - <dependencies> - <dependency> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-core</artifactId> - <version>${jackson.version}</version> - </dependency> - <dependency> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-annotations</artifactId> - <version>${jackson.version}</version> - </dependency> - - <!-- Common of SDC --> - <dependency> - <groupId>org.openecomp.sdc</groupId> - <artifactId>common-app-api</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - <exclusions> - <exclusion> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-core</artifactId> - </exclusion> - </exclusions> - </dependency> - - <dependency> - <groupId>org.openecomp.sdc.be</groupId> - <artifactId>common-be</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - <exclusions> - <exclusion> - <groupId>org.springframework</groupId> - <artifactId>spring-core</artifactId> - </exclusion> - <exclusion> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-databind</artifactId> - </exclusion> - </exclusions> - </dependency> - - <dependency> - <groupId>ch.qos.logback</groupId> - <artifactId>logback-classic</artifactId> - <version>${logback.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.google.code.bean-matchers</groupId> - <artifactId>bean-matchers</artifactId> - <version>${bean-matcher.version}</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>ch.qos.logback</groupId> - <artifactId>logback-core</artifactId> - <version>${logback.version}</version> - <scope>provided</scope> - </dependency> - - <!-- catalog dao --> - <dependency> - <groupId>org.openecomp.sdc.be</groupId> - <artifactId>catalog-dao</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - <exclusions> - <exclusion> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-core</artifactId> - </exclusion> - <exclusion> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-databind</artifactId> - </exclusion> - <exclusion> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-annotations</artifactId> - </exclusion> - </exclusions> - </dependency> - - <dependency> - <groupId>com.google.guava</groupId> - <artifactId>guava</artifactId> - <version>${guava.version}</version><!--$NO-MVN-MAN-VER$ --> - <scope>provided</scope> - </dependency> - - <dependency> - <groupId>org.functionaljava</groupId> - <artifactId>functionaljava</artifactId> - <version>${functionaljava.version}</version> - <scope>provided</scope> - </dependency> - - <!-- spring --> - - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-core</artifactId> - <version>${spring.version}</version> - <scope>provided</scope> - </dependency> - - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-beans</artifactId> - <version>${spring.version}</version> - <scope>provided</scope> - </dependency> - - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-context</artifactId> - <version>${spring.version}</version> - <scope>provided</scope> - <exclusions> - <exclusion> - <groupId>org.springframework</groupId> - <artifactId>spring-expression</artifactId> - </exclusion> - <exclusion> - <groupId>org.springframework</groupId> - <artifactId>spring-core</artifactId> - </exclusion> - </exclusions> - </dependency> - - <dependency> - <groupId>javax.validation</groupId> - <artifactId>validation-api</artifactId> - <version>${javax.validation.version}</version> - </dependency> - - <dependency> - <groupId>org.hibernate.validator</groupId> - <artifactId>hibernate-validator</artifactId> - <version>${hibernate.validator.version}</version> - </dependency> - - <!-- Gson --> - <dependency> - <groupId>com.google.code.gson</groupId> - <artifactId>gson</artifactId> - <version>${gson.version}</version> - <scope>provided</scope> - </dependency> - - <dependency> - <groupId>org.janusgraph</groupId> - <artifactId>janusgraph-core</artifactId> - <version>${janusgraph.version}</version> - <scope>provided</scope> - <exclusions> - <exclusion> - <artifactId>gremlin-groovy</artifactId> - <groupId>org.apache.tinkerpop</groupId> - </exclusion> - <exclusion> - <groupId>org.json</groupId> - <artifactId>json</artifactId> - </exclusion> - <exclusion> - <artifactId>slf4j-log4j12</artifactId> - <groupId>org.slf4j</groupId> - </exclusion> - <exclusion> - <artifactId>commons-collections</artifactId> - <groupId>commons-collections</groupId> - </exclusion> - <exclusion> - <artifactId>groovy</artifactId> - <groupId>org.codehaus.groovy</groupId> - </exclusion> - <exclusion> - <groupId>org.apache.thrift</groupId> - <artifactId>libthrift</artifactId> - </exclusion> - <exclusion> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - </exclusion> - <exclusion> - <groupId>commons-codec</groupId> - <artifactId>commons-codec</artifactId> - </exclusion> - <exclusion> - <groupId>dom4j</groupId> - <artifactId>dom4j</artifactId> - </exclusion> - </exclusions> - </dependency> - - <dependency> - <groupId>org.janusgraph</groupId> - <artifactId>janusgraph-cassandra</artifactId> - <version>${janusgraph.version}</version> - <scope>provided</scope> - <exclusions> - <exclusion> - <artifactId>slf4j-log4j12</artifactId> - <groupId>org.slf4j</groupId> - </exclusion> - <exclusion> - <groupId>org.apache.thrift</groupId> - <artifactId>libthrift</artifactId> - </exclusion> - <exclusion> - <groupId>org.codehaus.jackson</groupId> - <artifactId>jackson-mapper-asl</artifactId> - </exclusion> - <exclusion> - <groupId>commons-codec</groupId> - <artifactId>commons-codec</artifactId> - </exclusion> - <exclusion> - <groupId>org.hibernate</groupId> - <artifactId>hibernate-validator</artifactId> - </exclusion> - <exclusion> - <groupId>org.apache.cassandra</groupId> - <artifactId>cassandra-all</artifactId> - </exclusion> - </exclusions> - </dependency> - - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-lang3</artifactId> - <version>${lang3.version}</version> - <scope>provided</scope> - </dependency> - - <!-- http client --> - <dependency> - <groupId>org.apache.httpcomponents</groupId> - <artifactId>httpclient</artifactId> - <version>${httpclient.version}</version> - <scope>provided</scope> - <exclusions> - <exclusion> - <groupId>commons-codec</groupId> - <artifactId>commons-codec</artifactId> - </exclusion> - </exclusions> - </dependency> - - <dependency> - <groupId>org.apache.httpcomponents</groupId> - <artifactId>httpcore</artifactId> - <version>${httpcore.version}</version> - <scope>provided</scope> - </dependency> - - <!-- CASSANDRA --> - <dependency> - <groupId>com.datastax.cassandra</groupId> - <artifactId>cassandra-driver-core</artifactId> - <version>${cassandra.driver.version}</version> - <scope>provided</scope> - <exclusions> - <exclusion> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-databind</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>com.datastax.cassandra</groupId> - <artifactId>cassandra-driver-mapping</artifactId> - <version>${cassandra.driver.version}</version> - <scope>provided</scope> - </dependency> - <!-- CASSANDRA END --> - - <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest</artifactId> - <version>${hamcrest.version}</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-library</artifactId> - <version>${hamcrest.version}</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.junit.jupiter</groupId> - <artifactId>junit-jupiter</artifactId> - <version>${junitJupiter.version}</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-junit-jupiter</artifactId> - <version>${mockitoJupiter.version}</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.assertj</groupId> - <artifactId>assertj-core</artifactId> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-test</artifactId> - <version>${spring.version}</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.aspectj</groupId> - <artifactId>aspectjrt</artifactId> - <version>${aspectj.version}</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.aspectj</groupId> - <artifactId>aspectjweaver</artifactId> - <version>${aspectj.version}</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-web</artifactId> - <version>${spring.version}</version> - <scope>test</scope> - <exclusions> - <exclusion> - <groupId>org.springframework</groupId> - <artifactId>spring-core</artifactId> - </exclusion> - </exclusions> - </dependency> - - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-tx</artifactId> - <scope>test</scope> - <version>${spring.version}</version> - <exclusions> - <exclusion> - <groupId>org.springframework</groupId> - <artifactId>spring-core</artifactId> - </exclusion> - </exclusions> - </dependency> - - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-expression</artifactId> - <scope>test</scope> - <version>${spring.version}</version> - </dependency> - - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-jci-core</artifactId> - <version>${commons-jci-core.version}</version> - <scope>test</scope> - <exclusions> - <exclusion> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - </exclusion> - </exclusions> - </dependency> - - <dependency> - <groupId>org.awaitility</groupId> - <artifactId>awaitility</artifactId> - <version>${awaitility.version}</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy</artifactId> - </dependency> - - <dependency> - <groupId>io.netty</groupId> - <artifactId>netty-all</artifactId> - </dependency> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-collections4</artifactId> - <version>${commons.collections.version}</version> - </dependency> - - <dependency> - <groupId>io.netty</groupId> - <artifactId>netty-handler</artifactId> - </dependency> - <dependency> - <groupId>org.projectlombok</groupId> - <artifactId>lombok</artifactId> - <version>${lombok.version}</version> - </dependency> - <dependency> - <groupId>joda-time</groupId> - <artifactId>joda-time</artifactId> - <version>${joda.time.version}</version> - </dependency> - <dependency> - <groupId>org.openecomp.sdc.core</groupId> - <artifactId>openecomp-tosca-lib</artifactId> - <version>${project.version}</version> - <exclusions> - <exclusion> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-core</artifactId> - </exclusion> - <exclusion> - <groupId>org.springframework</groupId> - <artifactId>spring-core</artifactId> - </exclusion> - <exclusion> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-databind</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>com.vdurmont</groupId> - <artifactId>semver4j</artifactId> - <version>3.1.0</version> - </dependency> - - <dependency> - <groupId>com.googlecode.jmapper-framework</groupId> - <artifactId>jmapper-core</artifactId> - <version>${jMapper.version}</version> - <exclusions> - <exclusion> - <groupId>com.thoughtworks.xstream</groupId> - <artifactId>xstream</artifactId> - </exclusion> - </exclusions> - </dependency> - - </dependencies> - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-deploy-plugin</artifactId> - <configuration> - <skip>true</skip> - </configuration> - </plugin> - <plugin> - <groupId>com.github.sylvainlaurent.maven</groupId> - <artifactId>yaml-json-validator-maven-plugin</artifactId> - <executions> - <execution> - <id>validate</id> - <phase>validate</phase> - <goals> - <goal>validate</goal> - </goals> - <configuration> - <validationSets> - <validationSet> - <includes> - <include>src/main/resources/**/*.y*ml</include> - <include>src/test/resources/**/*.y*ml</include> - </includes> - </validationSet> - <validationSet> - <includes> - <include>src/main/resources/**/*.json</include> - <include>src/test/resources/**/*.json</include> - </includes> - </validationSet> - </validationSets> - <skip>${skipYamlJsonValidator}</skip> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> + 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> + + <groupId>org.openecomp.sdc.be</groupId> + <artifactId>catalog-model</artifactId> + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>sdc-main</artifactId> + <version>1.10.0-SNAPSHOT</version> + </parent> + + <properties> + <awaitility.version>4.0.3</awaitility.version> + </properties> + + <dependencies> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-core</artifactId> + <version>${jackson.version}</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-annotations</artifactId> + <version>${jackson.version}</version> + </dependency> + + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + <version>${jackson.version}</version> + </dependency> + <!-- Common of SDC --> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>common-app-api</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + <exclusions> + <exclusion> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-core</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>org.openecomp.sdc.be</groupId> + <artifactId>common-be</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + <exclusions> + <exclusion> + <groupId>org.springframework</groupId> + <artifactId>spring-core</artifactId> + </exclusion> + <exclusion> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + <version>${logback.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.google.code.bean-matchers</groupId> + <artifactId>bean-matchers</artifactId> + <version>${bean-matcher.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-core</artifactId> + <version>${logback.version}</version> + <scope>provided</scope> + </dependency> + + <!-- catalog dao --> + <dependency> + <groupId>org.openecomp.sdc.be</groupId> + <artifactId>catalog-dao</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + <exclusions> + <exclusion> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-core</artifactId> + </exclusion> + <exclusion> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + </exclusion> + <exclusion> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-annotations</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + <version>${guava.version}</version><!--$NO-MVN-MAN-VER$ --> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.functionaljava</groupId> + <artifactId>functionaljava</artifactId> + <version>${functionaljava.version}</version> + <scope>provided</scope> + </dependency> + + <!-- spring --> + + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-core</artifactId> + <version>${spring.version}</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-beans</artifactId> + <version>${spring.version}</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + <version>${spring.version}</version> + <scope>provided</scope> + <exclusions> + <exclusion> + <groupId>org.springframework</groupId> + <artifactId>spring-expression</artifactId> + </exclusion> + <exclusion> + <groupId>org.springframework</groupId> + <artifactId>spring-core</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>javax.validation</groupId> + <artifactId>validation-api</artifactId> + <version>${javax.validation.version}</version> + </dependency> + + <dependency> + <groupId>org.hibernate.validator</groupId> + <artifactId>hibernate-validator</artifactId> + <version>${hibernate.validator.version}</version> + </dependency> + + <!-- Gson --> + <dependency> + <groupId>com.google.code.gson</groupId> + <artifactId>gson</artifactId> + <version>${gson.version}</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.janusgraph</groupId> + <artifactId>janusgraph-core</artifactId> + <version>${janusgraph.version}</version> + <scope>provided</scope> + <exclusions> + <exclusion> + <artifactId>gremlin-groovy</artifactId> + <groupId>org.apache.tinkerpop</groupId> + </exclusion> + <exclusion> + <groupId>org.json</groupId> + <artifactId>json</artifactId> + </exclusion> + <exclusion> + <artifactId>slf4j-log4j12</artifactId> + <groupId>org.slf4j</groupId> + </exclusion> + <exclusion> + <artifactId>commons-collections</artifactId> + <groupId>commons-collections</groupId> + </exclusion> + <exclusion> + <artifactId>groovy</artifactId> + <groupId>org.codehaus.groovy</groupId> + </exclusion> + <exclusion> + <groupId>org.apache.thrift</groupId> + <artifactId>libthrift</artifactId> + </exclusion> + <exclusion> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + </exclusion> + <exclusion> + <groupId>commons-codec</groupId> + <artifactId>commons-codec</artifactId> + </exclusion> + <exclusion> + <groupId>dom4j</groupId> + <artifactId>dom4j</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>org.janusgraph</groupId> + <artifactId>janusgraph-cassandra</artifactId> + <version>${janusgraph.version}</version> + <scope>provided</scope> + <exclusions> + <exclusion> + <artifactId>slf4j-log4j12</artifactId> + <groupId>org.slf4j</groupId> + </exclusion> + <exclusion> + <groupId>org.apache.thrift</groupId> + <artifactId>libthrift</artifactId> + </exclusion> + <exclusion> + <groupId>org.codehaus.jackson</groupId> + <artifactId>jackson-mapper-asl</artifactId> + </exclusion> + <exclusion> + <groupId>commons-codec</groupId> + <artifactId>commons-codec</artifactId> + </exclusion> + <exclusion> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-validator</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.cassandra</groupId> + <artifactId>cassandra-all</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + <version>${lang3.version}</version> + <scope>provided</scope> + </dependency> + + <!-- http client --> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + <version>${httpclient.version}</version> + <scope>provided</scope> + <exclusions> + <exclusion> + <groupId>commons-codec</groupId> + <artifactId>commons-codec</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpcore</artifactId> + <version>${httpcore.version}</version> + <scope>provided</scope> + </dependency> + + <!-- CASSANDRA --> + <dependency> + <groupId>com.datastax.cassandra</groupId> + <artifactId>cassandra-driver-core</artifactId> + <version>${cassandra.driver.version}</version> + <scope>provided</scope> + <exclusions> + <exclusion> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>com.datastax.cassandra</groupId> + <artifactId>cassandra-driver-mapping</artifactId> + <version>${cassandra.driver.version}</version> + <scope>provided</scope> + </dependency> + <!-- CASSANDRA END --> + + <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest</artifactId> + <version>${hamcrest.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-library</artifactId> + <version>${hamcrest.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter</artifactId> + <version>${junitJupiter.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-junit-jupiter</artifactId> + <version>${mockitoJupiter.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.assertj</groupId> + <artifactId>assertj-core</artifactId> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-test</artifactId> + <version>${spring.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.aspectj</groupId> + <artifactId>aspectjrt</artifactId> + <version>${aspectj.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.aspectj</groupId> + <artifactId>aspectjweaver</artifactId> + <version>${aspectj.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-web</artifactId> + <version>${spring.version}</version> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>org.springframework</groupId> + <artifactId>spring-core</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-tx</artifactId> + <scope>test</scope> + <version>${spring.version}</version> + <exclusions> + <exclusion> + <groupId>org.springframework</groupId> + <artifactId>spring-core</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-expression</artifactId> + <scope>test</scope> + <version>${spring.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-jci-core</artifactId> + <version>${commons-jci-core.version}</version> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>org.awaitility</groupId> + <artifactId>awaitility</artifactId> + <version>${awaitility.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.codehaus.groovy</groupId> + <artifactId>groovy</artifactId> + </dependency> + + <dependency> + <groupId>io.netty</groupId> + <artifactId>netty-all</artifactId> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-collections4</artifactId> + <version>${commons.collections.version}</version> + </dependency> + + <dependency> + <groupId>io.netty</groupId> + <artifactId>netty-handler</artifactId> + </dependency> + <dependency> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + <version>${lombok.version}</version> + </dependency> + <dependency> + <groupId>joda-time</groupId> + <artifactId>joda-time</artifactId> + <version>${joda.time.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc.core</groupId> + <artifactId>openecomp-tosca-lib</artifactId> + <version>${project.version}</version> + <exclusions> + <exclusion> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-core</artifactId> + </exclusion> + <exclusion> + <groupId>org.springframework</groupId> + <artifactId>spring-core</artifactId> + </exclusion> + <exclusion> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>com.vdurmont</groupId> + <artifactId>semver4j</artifactId> + <version>3.1.0</version> + </dependency> + + <dependency> + <groupId>com.googlecode.jmapper-framework</groupId> + <artifactId>jmapper-core</artifactId> + <version>${jMapper.version}</version> + <exclusions> + <exclusion> + <groupId>com.thoughtworks.xstream</groupId> + <artifactId>xstream</artifactId> + </exclusion> + </exclusions> + </dependency> + + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-deploy-plugin</artifactId> + <configuration> + <skip>true</skip> + </configuration> + </plugin> + <plugin> + <groupId>com.github.sylvainlaurent.maven</groupId> + <artifactId>yaml-json-validator-maven-plugin</artifactId> + <executions> + <execution> + <id>validate</id> + <phase>validate</phase> + <goals> + <goal>validate</goal> + </goals> + <configuration> + <validationSets> + <validationSet> + <includes> + <include>src/main/resources/**/*.y*ml</include> + <include>src/test/resources/**/*.y*ml</include> + </includes> + </validationSet> + <validationSet> + <includes> + <include>src/main/resources/**/*.json</include> + <include>src/test/resources/**/*.json</include> + </includes> + </validationSet> + </validationSets> + <skip>${skipYamlJsonValidator}</skip> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> </project> diff --git a/common-app-api/pom.xml b/common-app-api/pom.xml index f411fdafa0..8dbed601e5 100644 --- a/common-app-api/pom.xml +++ b/common-app-api/pom.xml @@ -42,6 +42,10 @@ <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> </exclusion> + <exclusion> + <groupId>org.onap.portal.sdk</groupId> + <artifactId>epsdk-fw</artifactId> + </exclusion> </exclusions> </dependency> <dependency> diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index 1056fbd4c9..d0eebdba5d 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -290,6 +290,12 @@ limitations under the License. <version>${spring.version}</version> <scope>test</scope> </dependency> + <dependency> + <groupId>org.onap.portal.sdk</groupId> + <artifactId>epsdk-fw</artifactId> + <version>${ecomp.version}</version> + <scope>test</scope> + </dependency> </dependencies> <build> @@ -435,6 +441,7 @@ limitations under the License. <verbose>${verbose}</verbose> <apiVersion>${docker.api.version}</apiVersion> <autoCreateCustomNetworks>true</autoCreateCustomNetworks> + <startParallel>true</startParallel> <images> <image> <name>onap/sdc-cassandra:${it.docker.version}</name> @@ -524,7 +531,7 @@ limitations under the License. <alias>sdc-cassandra-onboard-init</alias> <run> <dependsOn> - <container>sdc-cassandra</container> + <container>sdc-cassandra-init</container> </dependsOn> <env> <RELEASE>${project.version}</RELEASE> @@ -557,7 +564,7 @@ limitations under the License. <name>onap/sdc-onboard-backend:${it.docker.version}</name> <alias>sdc-onboard-backend</alias> <run> - <dependsOn> + <dependsOn> <container>sdc-cassandra-onboard-init</container> </dependsOn> <env> @@ -738,9 +745,6 @@ limitations under the License. <name>onap/sdc-simulator:${it.docker.version}</name> <alias>sdc-simulator</alias> <run> - <dependsOn> - <container>sdc-frontend</container> - </dependsOn> <env> <!--<FE_URL>${it.env.name}</FE_URL>--> <JAVA_OPTIONS>-Xmx128m -Xms128m -Xss1m</JAVA_OPTIONS> @@ -761,13 +765,15 @@ limitations under the License. <ports> <port>8080</port> <port>8443</port> + <port>5000</port> </ports> </tcp> </wait> <ports> <!-- http://localhost:8285/login to access SDC --> - <port>8285:8080</port> + <port>8285:8080</port> <port>8286:8443</port> + <port>5000:5000</port> </ports> <network> <mode>custom</mode> @@ -821,32 +827,32 @@ limitations under the License. </volumes> </run> </image> - <image> - <name>onap/org.onap.sdc.sdc-helm-validator:${it.helm-validator.version}</name> - <alias>helm-validator</alias> - <run> - <skip>${it.helm-validator.disabled}</skip> - <hostname>helm-validator</hostname> - <wait> - <time>20000</time> - <tcp> - <host>helm-validator</host> - <mode>direct</mode> - <ports> - <port>8080</port> - </ports> - </tcp> - </wait> - <ports> - <port>8085:8080</port> - </ports> - <network> - <mode>custom</mode> - <name>sdc-network</name> + <image> + <name>onap/org.onap.sdc.sdc-helm-validator:${it.helm-validator.version}</name> <alias>helm-validator</alias> - </network> - </run> - </image> + <run> + <skip>${it.helm-validator.disabled}</skip> + <hostname>helm-validator</hostname> + <wait> + <time>20000</time> + <tcp> + <host>helm-validator</host> + <mode>direct</mode> + <ports> + <port>8080</port> + </ports> + </tcp> + </wait> + <ports> + <port>8085:8080</port> + </ports> + <network> + <mode>custom</mode> + <name>sdc-network</name> + <alias>helm-validator</alias> + </network> + </run> + </image> </images> </configuration> <executions> diff --git a/onboarding/pom.xml b/onboarding/pom.xml index 3dcdee54c2..cf8ca1abeb 100644 --- a/onboarding/pom.xml +++ b/onboarding/pom.xml @@ -66,7 +66,6 @@ <javax.el.version>2.2.6</javax.el.version> <javax.el-api.version>3.0.1-b06</javax.el-api.version> <javax.inject.version>1</javax.inject.version> - <javax.servlet.version>2.5</javax.servlet.version> <jackson.annotations.version>${jackson.version}</jackson.annotations.version> <jackson.dataformat.version>${jackson.version}</jackson.dataformat.version> <jcommander.version>1.58</jcommander.version> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/pom.xml index 9f735fe857..8765d6618c 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/pom.xml @@ -25,7 +25,7 @@ </dependency> <dependency> <groupId>javax.servlet</groupId> - <artifactId>servlet-api</artifactId> + <artifactId>javax.servlet-api</artifactId> <version>${javax.servlet.version}</version> <scope>provided</scope> </dependency> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/pom.xml index 00f9be18ef..13b31e403f 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/pom.xml @@ -71,7 +71,7 @@ </dependency> <dependency> <groupId>javax.servlet</groupId> - <artifactId>servlet-api</artifactId> + <artifactId>javax.servlet-api</artifactId> <version>${javax.servlet.version}</version> <scope>provided</scope> </dependency> diff --git a/openecomp-be/backend/openecomp-sdc-security-util/pom.xml b/openecomp-be/backend/openecomp-sdc-security-util/pom.xml index 30b50a9795..494b9aac57 100644 --- a/openecomp-be/backend/openecomp-sdc-security-util/pom.xml +++ b/openecomp-be/backend/openecomp-sdc-security-util/pom.xml @@ -63,7 +63,7 @@ <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> - <version>3.1.0</version> + <version>${javax.servlet.version}</version> </dependency> </dependencies> @@ -52,7 +52,7 @@ Modifications copyright (c) 2018-2019 Nokia <netty.version>4.1.66.Final</netty.version> <servlet-api.version>3.1.0</servlet-api.version> <wire-mock.version>2.26.3</wire-mock.version> - <ecomp.version>2.6.0</ecomp.version> + <ecomp.version>3.4.0</ecomp.version> <cassandra.unit.version>4.3.1.0</cassandra.unit.version> <cadi.version>2.1.8</cadi.version> <lombok.version>1.18.20</lombok.version> @@ -72,6 +72,7 @@ Modifications copyright (c) 2018-2019 Nokia <commons.collections.version>4.1</commons.collections.version> <ws.rs.version>2.1.1</ws.rs.version> <javax.validation.version>2.0.1.Final</javax.validation.version> + <javax.servlet.version>4.0.1</javax.servlet.version> <jetty.version>9.4.41.v20210516</jetty.version> <cxf.version>3.4.4</cxf.version> diff --git a/sdc-os-chef/scripts/docker_run.sh b/sdc-os-chef/scripts/docker_run.sh index 3ffc974c74..d3de8039b4 100755 --- a/sdc-os-chef/scripts/docker_run.sh +++ b/sdc-os-chef/scripts/docker_run.sh @@ -27,9 +27,9 @@ OS_USER="onap" # Java Options: -BE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=4000,server=y,suspend=n -Xmx1536m -Xms1536m" -FE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=6000,server=y,suspend=n -Xmx256m -Xms256m" -ONBOARD_BE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=4001,server=y,suspend=n -Xmx1g -Xms1g" +BE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=*:4000,server=y,suspend=n -Xmx1536m -Xms1536m" +FE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=*:6000,server=y,suspend=n -Xmx256m -Xms256m" +ONBOARD_BE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=*:4001,server=y,suspend=n -Xmx1g -Xms1g" SIM_JAVA_OPTIONS=" -Xmx128m -Xms128m -Xss1m -Dlog4j.configuration=file:///${JETTY_BASE}/config/sdc-simulator/log4j2.properties" API_TESTS_JAVA_OPTIONS="-Xmx512m -Xms512m" UI_TESTS_JAVA_OPTIONS="-Xmx1024m -Xms1024m" diff --git a/utils/webseal-simulator/pom.xml b/utils/webseal-simulator/pom.xml index 02f2bdc22c..e9801c9402 100644 --- a/utils/webseal-simulator/pom.xml +++ b/utils/webseal-simulator/pom.xml @@ -1,273 +1,282 @@ <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/maven-v4_0_0.xsd"> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <artifactId>webseal-simulator</artifactId> - <packaging>war</packaging> + <modelVersion>4.0.0</modelVersion> + <artifactId>webseal-simulator</artifactId> + <packaging>war</packaging> - <parent> - <groupId>org.openecomp.sdc</groupId> - <artifactId>sdc-main</artifactId> - <version>1.10.0-SNAPSHOT</version> - <relativePath>../../</relativePath> - </parent> + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>sdc-main</artifactId> + <version>1.10.0-SNAPSHOT</version> + <relativePath>../../</relativePath> + </parent> - <properties> - <maven.build.timestamp.format>yyyyMMdd'T'HHmmss'Z'</maven.build.timestamp.format> - <nexus.proxy>https://nexus.onap.org</nexus.proxy> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <sonar.skip>true</sonar.skip> - </properties> + <properties> + <maven.build.timestamp.format>yyyyMMdd'T'HHmmss'Z'</maven.build.timestamp.format> + <nexus.proxy>https://nexus.onap.org</nexus.proxy> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <sonar.skip>true</sonar.skip> + </properties> - <dependencies> - <dependency> - <groupId>javax.servlet</groupId> - <artifactId>servlet-api</artifactId> - <version>2.5</version> - <scope>compile</scope> - </dependency> + <dependencies> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + <version>${javax.servlet.version}</version> + </dependency> - <dependency> - <groupId>org.apache.httpcomponents</groupId> - <artifactId>httpclient</artifactId> - <version>${httpclient.version}</version> - </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + <version>${httpclient.version}</version> + </dependency> - <dependency> - <groupId>commons-logging</groupId> - <artifactId>commons-logging-api</artifactId> - <version>1.0.4</version> - </dependency> + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging-api</artifactId> + <version>1.0.4</version> + </dependency> - <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - <version>${commons.io.version}</version> - </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>${commons.io.version}</version> + </dependency> - <dependency> - <groupId>commons-codec</groupId> - <artifactId>commons-codec</artifactId> - <version>${commons-codec}</version> - <scope>compile</scope> - </dependency> + <dependency> + <groupId>commons-codec</groupId> + <artifactId>commons-codec</artifactId> + <version>${commons-codec}</version> + <scope>compile</scope> + </dependency> - <dependency> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-proxy</artifactId> - <version>${jetty.version}</version> - <scope>compile</scope> - <exclusions> - <exclusion> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-http</artifactId> - </exclusion> - </exclusions> - </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-proxy</artifactId> + <version>${jetty.version}</version> + <scope>compile</scope> + <exclusions> + <exclusion> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-http</artifactId> + </exclusion> + </exclusions> + </dependency> - <dependency> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-servlets</artifactId> - <version>${jetty.version}</version> - <scope>compile</scope> - <exclusions> - <exclusion> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-http</artifactId> - </exclusion> - </exclusions> - </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-servlets</artifactId> + <version>${jetty.version}</version> + <scope>compile</scope> + <exclusions> + <exclusion> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-http</artifactId> + </exclusion> + </exclusions> + </dependency> - <!-- Proxy servlet --> - <dependency> - <groupId>com.typesafe</groupId> - <artifactId>config</artifactId> - <version>1.0.2</version> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-logging-api</artifactId> - <version>${project.version}</version> - </dependency> + <!-- Proxy servlet --> + <dependency> + <groupId>com.typesafe</groupId> + <artifactId>config</artifactId> + <version>1.0.2</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-logging-api</artifactId> + <version>${project.version}</version> + <exclusions> + <exclusion> + <groupId>org.powermock</groupId> + <artifactId>powermock-module-junit4</artifactId> + </exclusion> + </exclusions> + </dependency> + </dependencies> - </dependencies> - <build> - <finalName>WSSimulator-${project.version}</finalName> - <plugins> - <plugin> - <groupId>com.github.sylvainlaurent.maven</groupId> - <artifactId>yaml-json-validator-maven-plugin</artifactId> - <executions> - <execution> - <id>validate</id> - <phase>validate</phase> - <goals> - <goal>validate</goal> - </goals> - <configuration> - <validationSets> - <validationSet> - <includes> - <include>src/main/resources/**/*.y*ml</include> - <include>src/test/resources/**/*.y*ml</include> - </includes> - </validationSet> - <validationSet> - <includes> - <include>src/main/resources/**/*.json</include> - <include>src/test/resources/**/*.json</include> - </includes> - </validationSet> - </validationSets> - <skip>${skipYamlJsonValidator}</skip> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> + <build> + <finalName>WSSimulator-${project.version}</finalName> + <plugins> + <plugin> + <groupId>com.github.sylvainlaurent.maven</groupId> + <artifactId>yaml-json-validator-maven-plugin</artifactId> + <executions> + <execution> + <id>validate</id> + <phase>validate</phase> + <goals> + <goal>validate</goal> + </goals> + <configuration> + <validationSets> + <validationSet> + <includes> + <include>src/main/resources/**/*.y*ml</include> + <include>src/test/resources/**/*.y*ml</include> + </includes> + </validationSet> + <validationSet> + <includes> + <include>src/main/resources/**/*.json</include> + <include>src/test/resources/**/*.json</include> + </includes> + </validationSet> + </validationSets> + <skip>${skipYamlJsonValidator}</skip> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> - <repositories> - <!-- LF repositories --> - <repository> - <id>ecomp-releases</id> - <name>Release Repository</name> - <url>${nexus.proxy}/content/repositories/releases/</url> - </repository> - <repository> - <id>ecomp-snapshots</id> - <name>Snapshots Repository</name> - <url>${nexus.proxy}/content/repositories/snapshots/</url> - </repository> - <repository> - <id>ecomp-public</id> - <name>Public Repository</name> - <url>${nexus.proxy}/content/repositories/public/</url> - </repository> - <!-- LF repositories END--> - </repositories> + <repositories> + <!-- LF repositories --> + <repository> + <id>ecomp-releases</id> + <name>Release Repository</name> + <url>${nexus.proxy}/content/repositories/releases/</url> + </repository> + <repository> + <id>ecomp-snapshots</id> + <name>Snapshots Repository</name> + <url>${nexus.proxy}/content/repositories/snapshots/</url> + </repository> + <repository> + <id>ecomp-public</id> + <name>Public Repository</name> + <url>${nexus.proxy}/content/repositories/public/</url> + </repository> + <!-- LF repositories END--> + </repositories> - <profiles> - <profile> - <id>docker</id> - <activation> - <activeByDefault>false</activeByDefault> - </activation> - <build> - <plugins> + <profiles> + <profile> + <id>docker</id> + <activation> + <activeByDefault>false</activeByDefault> + </activation> + <build> + <plugins> - <plugin> - <artifactId>maven-clean-plugin</artifactId> - <version>3.0.0</version> - <executions> - <execution> - <id>clean-static-files</id> - <phase>clean</phase> - <goals> - <goal>clean</goal> - </goals> - <configuration> - <filesets> - <fileset> - <directory>${project.basedir}/sdc-simulator</directory> - <includes> - <include>*.war</include> - </includes> - <followSymlinks>false</followSymlinks> - </fileset> - </filesets> - </configuration> - </execution> - </executions> - </plugin> + <plugin> + <artifactId>maven-clean-plugin</artifactId> + <version>3.0.0</version> + <executions> + <execution> + <id>clean-static-files</id> + <phase>clean</phase> + <goals> + <goal>clean</goal> + </goals> + <configuration> + <filesets> + <fileset> + <directory>${project.basedir}/sdc-simulator</directory> + <includes> + <include>*.war</include> + </includes> + <followSymlinks>false</followSymlinks> + </fileset> + </filesets> + </configuration> + </execution> + </executions> + </plugin> - <plugin> - <artifactId>maven-resources-plugin</artifactId> - <executions> - <execution> - <id>copy-resources-simulator</id> - <phase>verify</phase> - <goals> - <goal>copy-resources</goal> - </goals> - <configuration> - <outputDirectory>${project.basedir}/sdc-simulator</outputDirectory> - <resources> - <resource> - <directory>${project.basedir}/target</directory> - <includes> - <include>WSSimulator*.war</include> - </includes> - </resource> - </resources> - </configuration> - </execution> - </executions> - </plugin> + <plugin> + <artifactId>maven-resources-plugin</artifactId> + <executions> + <execution> + <id>copy-resources-simulator</id> + <phase>verify</phase> + <goals> + <goal>copy-resources</goal> + </goals> + <configuration> + <outputDirectory>${project.basedir}/sdc-simulator + </outputDirectory> + <resources> + <resource> + <directory>${project.basedir}/target</directory> + <includes> + <include>WSSimulator*.war</include> + </includes> + </resource> + </resources> + </configuration> + </execution> + </executions> + </plugin> - <plugin> - <groupId>io.fabric8</groupId> - <artifactId>docker-maven-plugin</artifactId> - <configuration> - <verbose>${verbose}</verbose> - <apiVersion>${docker.api.version}</apiVersion> - <registry>nexus3.onap.org:10001</registry> - <authConfig> - <pull> - <username>docker</username> - <password>docker</password> - </pull> - </authConfig> - <images> - <!-- Build simulator image --> - <image> - <name>onap/sdc-simulator</name> - <alias>sdc-simulator</alias> - <build> - <cleanup>try</cleanup> - <dockerFileDir>${basedir}${file.separator}sdc-simulator</dockerFileDir> - <tags> - <tag>latest</tag> - <tag> - ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-STAGING-latest - </tag> - <tag>${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-${maven.build.timestamp}</tag> - </tags> - </build> - </image> - </images> - </configuration> - <executions> - <execution> - <id>clean-images</id> - <phase>pre-clean</phase> - <goals> - <goal>remove</goal> - </goals> - </execution> - <execution> - <id>generate-images</id> - <phase>install</phase> - <goals> - <goal>build</goal> - </goals> - </execution> - <execution> - <id>push-images</id> - <phase>deploy</phase> - <goals> - <goal>push</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - </profiles> + <plugin> + <groupId>io.fabric8</groupId> + <artifactId>docker-maven-plugin</artifactId> + <configuration> + <verbose>${verbose}</verbose> + <apiVersion>${docker.api.version}</apiVersion> + <registry>nexus3.onap.org:10001</registry> + <authConfig> + <pull> + <username>docker</username> + <password>docker</password> + </pull> + </authConfig> + <images> + <!-- Build simulator image --> + <image> + <name>onap/sdc-simulator</name> + <alias>sdc-simulator</alias> + <build> + <cleanup>try</cleanup> + <dockerFileDir>${basedir}${file.separator}sdc-simulator + </dockerFileDir> + <tags> + <tag>latest</tag> + <tag> + ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-STAGING-latest + </tag> + <tag> + ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-${maven.build.timestamp} + </tag> + </tags> + </build> + </image> + </images> + </configuration> + <executions> + <execution> + <id>clean-images</id> + <phase>pre-clean</phase> + <goals> + <goal>remove</goal> + </goals> + </execution> + <execution> + <id>generate-images</id> + <phase>install</phase> + <goals> + <goal>build</goal> + </goals> + </execution> + <execution> + <id>push-images</id> + <phase>deploy</phase> + <goals> + <goal>push</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> </project> diff --git a/utils/webseal-simulator/sdc-simulator/chef-repo/cookbooks/sdc-simulator/templates/default/SDC-Simulator-webseal.conf.erb b/utils/webseal-simulator/sdc-simulator/chef-repo/cookbooks/sdc-simulator/templates/default/SDC-Simulator-webseal.conf.erb index 4cdd4fbfba..f6e634481f 100644 --- a/utils/webseal-simulator/sdc-simulator/chef-repo/cookbooks/sdc-simulator/templates/default/SDC-Simulator-webseal.conf.erb +++ b/utils/webseal-simulator/sdc-simulator/chef-repo/cookbooks/sdc-simulator/templates/default/SDC-Simulator-webseal.conf.erb @@ -10,14 +10,6 @@ lastName="Santana" role="Designer" email="csantana@sdc.com" - }, - { - userId="op0001" - password="123123a" - firstName="Aretha" - lastName="Franklin" - role="Ops" - email="afranklin@sdc.com" }, { userId="jh0003" @@ -34,14 +26,6 @@ lastName="Depp" role="Tester" email="tester@sdc.com" - }, - { - userId="gv0001" - password="123123a" - firstName="David" - lastName="Shadmi" - role="Governor" - email="governor@sdc.com" } ] } diff --git a/utils/webseal-simulator/sdc-simulator/startup.sh b/utils/webseal-simulator/sdc-simulator/startup.sh index e8774be9f0..49fdf3ef16 100644 --- a/utils/webseal-simulator/sdc-simulator/startup.sh +++ b/utils/webseal-simulator/sdc-simulator/startup.sh @@ -1,14 +1,13 @@ #!/bin/sh JAVA_OPTIONS=" $JAVA_OPTIONS \ - -Xdebug -agentlib:jdwp=transport=dt_socket,address=5000,server=y,suspend=n -Xmx128m -Xms128m -Xss1m \ - -Dconfig.home=$JETTY_BASE/config/sdc-simulator \ - -Dlog.home=$JETTY_BASE/logs \ - -Dlogback.configurationFile=$JETTY_BASE/config/sdc-simulator/logback.xml \ - -Djavax.net.ssl.trustStore=$JETTY_BASE/etc/org.onap.sdc.trust.jks \ - -Djavax.net.ssl.trustStorePassword=z+KEj;t+,KN^iimSiS89e#p0 \ - -Djetty.console-capture.dir=$JETTY_BASE/logs" - + -Xdebug -agentlib:jdwp=transport=dt_socket,address=*:5000,server=y,suspend=n -Xmx128m -Xms128m -Xss1m \ + -Dconfig.home=$JETTY_BASE/config/sdc-simulator \ + -Dlog.home=$JETTY_BASE/logs \ + -Dlogback.configurationFile=$JETTY_BASE/config/sdc-simulator/logback.xml \ + -Djavax.net.ssl.trustStore=$JETTY_BASE/etc/org.onap.sdc.trust.jks \ + -Djavax.net.ssl.trustStorePassword=z+KEj;t+,KN^iimSiS89e#p0 \ + -Djetty.console-capture.dir=$JETTY_BASE/logs" cd $JETTY_BASE/chef-solo chef-solo -c solo.rb -E ${ENVNAME} @@ -16,4 +15,3 @@ chef-solo -c solo.rb -E ${ENVNAME} cd $JETTY_HOME java $JAVA_OPTIONS -jar "${JETTY_HOME}/start.jar" - diff --git a/utils/webseal-simulator/src/main/java/org/openecomp/sdc/webseal/simulator/Login.java b/utils/webseal-simulator/src/main/java/org/openecomp/sdc/webseal/simulator/Login.java index 3d4e772006..32d8c2916d 100644 --- a/utils/webseal-simulator/src/main/java/org/openecomp/sdc/webseal/simulator/Login.java +++ b/utils/webseal-simulator/src/main/java/org/openecomp/sdc/webseal/simulator/Login.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,149 +20,137 @@ package org.openecomp.sdc.webseal.simulator; -import org.openecomp.sdc.webseal.simulator.conf.Conf; - -import javax.servlet.ServletConfig; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Collection; +import java.util.Iterator; import javax.servlet.ServletException; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.Collection; -import java.util.Iterator; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; +import org.openecomp.sdc.webseal.simulator.conf.Conf; public class Login extends HttpServlet { - private static final long serialVersionUID = 1L; - - @Override - public void init(final ServletConfig config) throws ServletException { - super.init(config); - } - - @Override - protected void doGet(final HttpServletRequest request, final HttpServletResponse response) - throws ServletException, IOException { - - if (null != request.getParameter("userId")) { - doPost(request, response); - return; - } - System.out.println("about to build login page"); - response.setContentType("text/html"); - PrintWriter writer = response.getWriter(); - - Collection<User> allUsers = Conf.getInstance().getUsers().values(); - writer.println("<html>"); - - writer.println("<head>"); - writer.println("<style>"); - writer.println("body {padding: 40px; font-family: Arial; font-size: 14px;}"); - writer.println("h1 {background-color: #DDDDDD; padding: 4px 10px;}"); - writer.println("h2 {margin-top: 20px;}"); - writer.println(".label {width: 100px; float:left;}"); - writer.println(".break {display: block; margin-bottom: 10px;}"); - writer.println("tr {padding: 4px 10px;}"); - writer.println("th {padding: 4px 10px; text-align: left; background-color: #dddddd;}"); - writer.println("td {padding: 4px 10px; text-align: left;}"); - writer.println("</style>"); - writer.println("</head>"); - - writer.println("<body>"); - - writer.println("<h1>Webseal simulator</h1>"); - writer.println("<h2>Login:</h2>"); - - writer.println("<form action=\"\" method=\"post\">"); - writer.println(" <div class='label'>User id:</div>"); - writer.println(" <input type='text' name='userId'>"); - writer.println(" <div class='break'></div>"); - - writer.println(" <div class='label'>Password:</div>"); - writer.println(" <input type='password' name='password'>"); - writer.println(" <div class='break'></div>"); - - writer.println(" <input type='submit' value='Login'>"); - writer.println(" <label name='message'></label>"); - writer.println("</form>"); - - writer.println("<hr/>"); - writer.println("<h2>Quick links:</h2>"); - writer.println("<table>"); - writer.println("<tr>"); - writer.println("<th>full name</th>"); - writer.println("<th>user id</th>"); - writer.println("<th>role</th>"); - writer.println("<th>action</th>"); - writer.println("</tr>"); - Iterator<User> iterator = allUsers.iterator(); - while (iterator.hasNext()) { - User user = iterator.next(); - writer.println("<tr>"); - writer.println("<td>" + user.getUserRef() + "</td>"); - writer.println("<td>" + user.getUserId() + "</td>"); - writer.println("<td>" + user.getRole() + "</td>"); - writer.println("<td>" + user.getUserCreateRef() + "</td>"); - writer.println("</tr>"); - } - writer.println("</table>"); - - writer.println("<a href='create?all=true' target='resultFrame'>Create All</a>"); - writer.println("<hr/><iframe name='resultFrame' width='400' height='300'></iframe>"); - - writer.println("</body>"); - writer.println("</html>"); - - } - - public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - - String userId = request.getParameter("userId"); - String password = request.getParameter("password"); - request.setAttribute("message", "OK"); - - System.out.println("Login -> doPost userId=" + userId); - User user = getUser(userId, password); - if (user == null) { - response.sendError(500, "ERROR: userId or password incorrect"); -// doGet(request, response); - } else { - System.out.println("Login -> doPost redirect to /sdc1 (to proxy)"); - Cookie cookieUser = new Cookie("HTTP_IV_USER", user.getUserId()); - Cookie cookieUserId = new Cookie("USER_ID", user.getUserId()); - Cookie cookieFirstName = new Cookie("HTTP_CSP_FIRSTNAME", user.getFirstName()); - Cookie cookieEmail = new Cookie("HTTP_CSP_EMAIL", user.getEmail()); - Cookie cookieLastName = new Cookie("HTTP_CSP_LASTNAME", user.getLastName()); - Cookie cookieRemoteAddress = new Cookie("HTTP_IV_REMOTE_ADDRESS", "0.0.0.0"); - Cookie cookieWsType = new Cookie("HTTP_CSP_WSTYPE", "Intranet"); - response.addCookie(cookieUser); - response.addCookie(cookieUserId); - response.addCookie(cookieFirstName); - response.addCookie(cookieEmail); - response.addCookie(cookieLastName); - response.addCookie(cookieRemoteAddress); - response.addCookie(cookieWsType); - response.addCookie(new Cookie(Conf.getInstance().getPortalCookieName(), "portal")); - response.sendRedirect("/sdc1"); - } - - } - - private User getUser(String userId, String password) { - User user = Conf.getInstance().getUsers().get(userId); - if (user == null) { - return null; - } - if (!password.equals(user.getPassword())) { - return null; - } - return user; - } - - @Override - public String getServletInfo() { - return "Http Proxy Servlet"; - } + private static final long serialVersionUID = 1L; + private static final Logger logger = LoggerFactory.getLogger(Login.class); + + @Override + protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { + + if (null != request.getParameter("userId")) { + doPost(request, response); + return; + } + logger.info("about to build login page"); + response.setContentType("text/html"); + PrintWriter writer = response.getWriter(); + + Collection<User> allUsers = Conf.getInstance().getUsers().values(); + writer.println("<html>"); + + writer.println("<head>"); + writer.println("<style>"); + writer.println("body {padding: 40px; font-family: Arial; font-size: 14px;}"); + writer.println("h1 {background-color: #DDDDDD; padding: 4px 10px;}"); + writer.println("h2 {margin-top: 20px;}"); + writer.println(".label {width: 100px; float:left;}"); + writer.println(".break {display: block; margin-bottom: 10px;}"); + writer.println("tr {padding: 4px 10px;}"); + writer.println("th {padding: 4px 10px; text-align: left; background-color: #dddddd;}"); + writer.println("td {padding: 4px 10px; text-align: left;}"); + writer.println("</style>"); + writer.println("</head>"); + + writer.println("<body>"); + + writer.println("<h1>Webseal simulator</h1>"); + writer.println("<h2>Login:</h2>"); + + writer.println("<form action=\"\" method=\"post\">"); + writer.println(" <div class='label'>User id:</div>"); + writer.println(" <input type='text' name='userId'>"); + writer.println(" <div class='break'></div>"); + + writer.println(" <div class='label'>Password:</div>"); + writer.println(" <input type='password' name='password'>"); + writer.println(" <div class='break'></div>"); + + writer.println(" <input type='submit' value='Login'>"); + writer.println(" <label name='message'></label>"); + writer.println("</form>"); + + writer.println("<hr/>"); + writer.println("<h2>Quick links:</h2>"); + writer.println("<table>"); + writer.println("<tr>"); + writer.println("<th>full name</th>"); + writer.println("<th>user id</th>"); + writer.println("<th>role</th>"); + writer.println("<th>action</th>"); + writer.println("</tr>"); + Iterator<User> iterator = allUsers.iterator(); + while (iterator.hasNext()) { + User user = iterator.next(); + writer.println("<tr>"); + writer.println("<td>" + user.getUserRef() + "</td>"); + writer.println("<td>" + user.getUserId() + "</td>"); + writer.println("<td>" + user.getRole() + "</td>"); + writer.println("<td>" + user.getUserCreateRef() + "</td>"); + writer.println("</tr>"); + } + writer.println("</table>"); + + writer.println("<a href='create?all=true' target='resultFrame'>Create All</a>"); + writer.println("<hr/><iframe name='resultFrame' width='400' height='300'></iframe>"); + + writer.println("</body>"); + writer.println("</html>"); + + } + + @Override + public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + + String userId = request.getParameter("userId"); + String password = request.getParameter("password"); + request.setAttribute("message", "OK"); + + logger.info("Login -> doPost userId={}", userId); + User user = getUser(userId, password); + if (user == null) { + response.sendError(500, "ERROR: userId or password incorrect"); + } else { + logger.info("Login -> doPost redirect to /sdc1 (to proxy)"); + response.addCookie(new Cookie("HTTP_IV_USER", user.getUserId())); + response.addCookie(new Cookie("USER_ID", user.getUserId())); + response.addCookie(new Cookie("HTTP_CSP_FIRSTNAME", user.getFirstName())); + response.addCookie(new Cookie("HTTP_CSP_EMAIL", user.getEmail())); + response.addCookie(new Cookie("HTTP_CSP_LASTNAME", user.getLastName())); + response.addCookie(new Cookie("HTTP_IV_REMOTE_ADDRESS", "0.0.0.0")); + response.addCookie(new Cookie("HTTP_CSP_WSTYPE", "Intranet")); + response.addCookie(new Cookie(Conf.getInstance().getPortalCookieName(), "portal")); + response.sendRedirect("/sdc1"); + } + + } + + private User getUser(String userId, String password) { + User user = Conf.getInstance().getUsers().get(userId); + if (user == null) { + return null; + } + if (!password.equals(user.getPassword())) { + return null; + } + return user; + } + + @Override + public String getServletInfo() { + return "Http Proxy Servlet"; + } } diff --git a/utils/webseal-simulator/src/main/java/org/openecomp/sdc/webseal/simulator/SdcProxy.java b/utils/webseal-simulator/src/main/java/org/openecomp/sdc/webseal/simulator/SdcProxy.java index ea4203dcc1..51d6796c4c 100644 --- a/utils/webseal-simulator/src/main/java/org/openecomp/sdc/webseal/simulator/SdcProxy.java +++ b/utils/webseal-simulator/src/main/java/org/openecomp/sdc/webseal/simulator/SdcProxy.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,8 +20,43 @@ package org.openecomp.sdc.webseal.simulator; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.UnsupportedEncodingException; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLEncoder; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Enumeration; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.zip.GZIPInputStream; +import javax.net.ssl.SSLContext; +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletInputStream; +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import lombok.AllArgsConstructor; +import lombok.Getter; import org.apache.http.Header; -import org.apache.http.client.methods.*; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpDelete; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.methods.HttpPut; +import org.apache.http.client.methods.HttpRequestBase; +import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.config.Registry; import org.apache.http.config.RegistryBuilder; import org.apache.http.conn.socket.ConnectionSocketFactory; @@ -35,54 +70,31 @@ import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.apache.http.ssl.SSLContextBuilder; -import org.openecomp.sdc.logging.api.Logger; -import org.openecomp.sdc.logging.api.LoggerFactory; import org.openecomp.sdc.webseal.simulator.conf.Conf; -import javax.net.ssl.SSLContext; -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletInputStream; -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLEncoder; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.util.*; -import java.util.stream.Collectors; -import java.util.zip.GZIPInputStream; - public class SdcProxy extends HttpServlet { private static final long serialVersionUID = 1L; - private static URL url; + private static final Set<String> RESERVED_HEADERS = + Arrays.stream(ReservedHeaders.values()).map(ReservedHeaders::getValue).collect(Collectors.toSet()); + private static final String USER_ID = "USER_ID"; + private static final String HTTP_IV_USER = "HTTP_IV_USER"; + private static final String SDC1 = "/sdc1"; + private static final String ONBOARDING = "/onboarding/"; + private static final String SCRIPTS = "/scripts"; + private static final String STYLES = "/styles"; + private static final String LANGUAGES = "/languages"; + private static final String CONFIGURATIONS = "/configurations"; + private URL url; private CloseableHttpClient httpClient; private Conf conf; - private final String SDC1 = "/sdc1"; - private final String ONBOARDING = "/onboarding/"; - private final String SCRIPTS = "/scripts"; - private final String STYLES = "/styles"; - private final String LANGUAGES = "/languages"; - private final String CONFIGURATIONS = "/configurations"; - private static final Set<String> RESERVED_HEADERS = Arrays.stream(ReservedHeaders.values()).map(h -> h.getValue()).collect(Collectors.toSet()); - - private static final Logger logger = LoggerFactory.getLogger(SdcProxy.class); + @Override public void init(ServletConfig config) throws ServletException { super.init(config); conf = Conf.getInstance(); try { - String feHost = conf.getFeHost(); - url = new URL(feHost); + url = new URL(conf.getFeHost()); } catch (MalformedURLException me) { throw new ServletException("Proxy URL is invalid", me); } @@ -94,10 +106,12 @@ public class SdcProxy extends HttpServlet { } } + @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { proxy(request, response, MethodEnum.GET); } + @Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String userId = request.getParameter("userId"); @@ -105,7 +119,7 @@ public class SdcProxy extends HttpServlet { // Already sign-in if (userId == null) { - userId = request.getHeader("USER_ID"); + userId = request.getHeader(USER_ID); } System.out.println("SdcProxy -> doPost userId=" + userId); @@ -117,25 +131,25 @@ public class SdcProxy extends HttpServlet { view.forward(mutableRequest, response); } else { System.out.println("SdcProxy -> doPost going to doGet"); - request.setAttribute("HTTP_IV_USER", userId); + request.setAttribute(HTTP_IV_USER, userId); proxy(request, response, MethodEnum.POST); } } + @Override public void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { proxy(request, response, MethodEnum.PUT); } + @Override public void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { proxy(request, response, MethodEnum.DELETE); } - private synchronized void proxy(HttpServletRequest request, HttpServletResponse response, MethodEnum methodEnum) throws IOException, UnsupportedEncodingException { + private synchronized void proxy(HttpServletRequest request, HttpServletResponse response, MethodEnum methodEnum) throws IOException { Map<String, String[]> requestParameters = request.getParameterMap(); String userIdHeader = getUseridFromRequest(request); - User user = getUser(userIdHeader); - // new request - forward to login page if (userIdHeader == null) { System.out.print("Going to login"); @@ -143,17 +157,19 @@ public class SdcProxy extends HttpServlet { return; } + final User user = getUser(userIdHeader); + String uri = getUri(request, requestParameters); HttpRequestBase httpMethod = createHttpMethod(request, methodEnum, uri); addHeadersToMethod(httpMethod, user, request); - try (CloseableHttpResponse closeableHttpResponse = httpClient.execute(httpMethod)){; + try (CloseableHttpResponse closeableHttpResponse = httpClient.execute(httpMethod)) { response.setStatus(closeableHttpResponse.getStatusLine().getStatusCode()); if (request.getRequestURI().indexOf(".svg") > -1) { response.setContentType("image/svg+xml"); } - if(closeableHttpResponse.getEntity() != null) { + if (closeableHttpResponse.getEntity() != null) { InputStream responseBodyStream = closeableHttpResponse.getEntity().getContent(); Header contentEncodingHeader = closeableHttpResponse.getLastHeader("Content-Encoding"); if (contentEncodingHeader != null && contentEncodingHeader.getValue().equalsIgnoreCase("gzip")) { @@ -194,8 +210,7 @@ public class SdcProxy extends HttpServlet { suffix = alignUrlProxy(suffix); } StringBuilder query = alignUrlParameters(requestParameters); - String uri = String.format("%s%s", new Object[]{this.url.toString() + suffix, query.toString()}); - return uri; + return String.format("%s%s", url.toString() + suffix, query.toString()); } private HttpRequestBase createHttpMethod(HttpServletRequest request, MethodEnum methodEnum, String uri) throws IOException { @@ -228,20 +243,20 @@ public class SdcProxy extends HttpServlet { private ContentType getContentType(HttpServletRequest request) { String contentTypeStr = request.getContentType(); - if (contentTypeStr == null ){ - contentTypeStr = request.getHeader("contentType"); - } + if (contentTypeStr == null) { + contentTypeStr = request.getHeader("contentType"); + } ContentType contentType = ContentType.parse(contentTypeStr); return ContentType.create(contentType.getMimeType()); } private String getUseridFromRequest(HttpServletRequest request) { - String userIdHeader = request.getHeader("USER_ID"); + String userIdHeader = request.getHeader(USER_ID); if (userIdHeader != null) { return userIdHeader; } - Object o = request.getAttribute("HTTP_IV_USER"); + Object o = request.getAttribute(HTTP_IV_USER); if (o != null) { return o.toString(); } @@ -249,7 +264,7 @@ public class SdcProxy extends HttpServlet { if (cookies != null) { for (int i = 0; i < cookies.length; ++i) { - if (cookies[i].getName().equals("USER_ID")) { + if (cookies[i].getName().equals(USER_ID)) { userIdHeader = cookies[i].getValue(); } } @@ -257,7 +272,7 @@ public class SdcProxy extends HttpServlet { return userIdHeader; } - private static void addHeadersToMethod(HttpUriRequest proxyMethod, User user, HttpServletRequest request) { + private void addHeadersToMethod(HttpUriRequest proxyMethod, User user, HttpServletRequest request) { proxyMethod.setHeader(ReservedHeaders.HTTP_IV_USER.name(), user.getUserId()); proxyMethod.setHeader(ReservedHeaders.USER_ID.name(), user.getUserId()); @@ -266,19 +281,19 @@ public class SdcProxy extends HttpServlet { proxyMethod.setHeader(ReservedHeaders.HTTP_CSP_LASTNAME.name(), user.getLastName()); proxyMethod.setHeader(ReservedHeaders.HTTP_IV_REMOTE_ADDRESS.name(), "0.0.0.0"); proxyMethod.setHeader(ReservedHeaders.HTTP_CSP_WSTYPE.name(), "Intranet"); - proxyMethod.setHeader(ReservedHeaders.HTTP_CSP_EMAIL.name(), "me@mail.com"); - - Enumeration<String> headerNames = request.getHeaderNames(); - while (headerNames.hasMoreElements()) { - String headerName = headerNames.nextElement(); - if (!RESERVED_HEADERS.contains(headerName)) { - Enumeration<String> headers = request.getHeaders(headerName); - while (headers.hasMoreElements()) { - String headerValue = headers.nextElement(); - proxyMethod.setHeader(headerName, headerValue); - } - } - } + proxyMethod.setHeader(ReservedHeaders.HTTP_CSP_EMAIL.name(), "me@mail.com"); + + Enumeration<String> headerNames = request.getHeaderNames(); + while (headerNames.hasMoreElements()) { + String headerName = headerNames.nextElement(); + if (!RESERVED_HEADERS.contains(headerName)) { + Enumeration<String> headers = request.getHeaders(headerName); + while (headers.hasMoreElements()) { + String headerValue = headers.nextElement(); + proxyMethod.setHeader(headerName, headerValue); + } + } + } } private String alignUrlProxy(String requestURI) { @@ -301,19 +316,16 @@ public class SdcProxy extends HttpServlet { return SDC1 + requestURI; } - private static StringBuilder alignUrlParameters(Map<String, String[]> requestParameters) throws UnsupportedEncodingException { - StringBuilder query = new StringBuilder(); - for (String name : requestParameters.keySet()) { - for (String value : (String[]) requestParameters.get(name)) { + private StringBuilder alignUrlParameters(Map<String, String[]> requestParameters) throws UnsupportedEncodingException { + final var query = new StringBuilder(); + for (final Entry<String, String[]> entry : requestParameters.entrySet()) { + for (final String value : entry.getValue()) { if (query.length() == 0) { query.append("?"); } else { query.append("&"); } - name = URLEncoder.encode(name, "UTF-8"); - value = URLEncoder.encode(value, "UTF-8"); - - query.append(String.format("&%s=%s", new Object[]{name, value})); + query.append(String.format("&%s=%s", URLEncoder.encode(entry.getKey(), "UTF-8"), URLEncoder.encode(value, "UTF-8"))); } } return query; @@ -327,38 +339,36 @@ public class SdcProxy extends HttpServlet { outputStream.flush(); } + @Override public String getServletInfo() { return "Http Proxy Servlet"; } - enum ReservedHeaders { - HTTP_IV_USER("HTTP_IV_USER"), USER_ID("USER_ID"), HTTP_CSP_FIRSTNAME("HTTP_CSP_FIRSTNAME"), HTTP_CSP_EMAIL("HTTP_CSP_EMAIL"), HTTP_CSP_LASTNAME("HTTP_CSP_LASTNAME"), HTTP_IV_REMOTE_ADDRESS("HTTP_IV_REMOTE_ADDRESS"), HTTP_CSP_WSTYPE("HTTP_CSP_WSTYPE"), HOST("Host"), CONTENTLENGTH("Content-Length"); - - private String value; - - ReservedHeaders(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - } - - - private static CloseableHttpClient buildRestClient() throws NoSuchAlgorithmException, KeyStoreException { - SSLContextBuilder builder = new SSLContextBuilder(); + private CloseableHttpClient buildRestClient() throws NoSuchAlgorithmException, KeyStoreException { + final var builder = new SSLContextBuilder(); builder.loadTrustMaterial(null, new TrustSelfSignedStrategy()); SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(SSLContext.getDefault(), - NoopHostnameVerifier.INSTANCE); + NoopHostnameVerifier.INSTANCE); Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create() - .register("http", new PlainConnectionSocketFactory()) - .register("https", sslsf) - .build(); + .register("http", new PlainConnectionSocketFactory()) + .register("https", sslsf) + .build(); PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(registry); return HttpClients.custom() - .setSSLSocketFactory(sslsf) - .setConnectionManager(cm) - .build(); + .setSSLSocketFactory(sslsf) + .setConnectionManager(cm) + .build(); + } + + @AllArgsConstructor + @Getter + enum ReservedHeaders { + HTTP_IV_USER(SdcProxy.HTTP_IV_USER), USER_ID(SdcProxy.USER_ID), HTTP_CSP_FIRSTNAME("HTTP_CSP_FIRSTNAME"), HTTP_CSP_EMAIL( + "HTTP_CSP_EMAIL"), HTTP_CSP_LASTNAME("HTTP_CSP_LASTNAME"), HTTP_IV_REMOTE_ADDRESS("HTTP_IV_REMOTE_ADDRESS"), HTTP_CSP_WSTYPE( + "HTTP_CSP_WSTYPE"), HOST("Host"), CONTENTLENGTH("Content-Length"); + + private final String value; + } + } diff --git a/utils/webseal-simulator/src/main/resources/webseal.conf b/utils/webseal-simulator/src/main/resources/webseal.conf index 7065725ab1..c711a73113 100644 --- a/utils/webseal-simulator/src/main/resources/webseal.conf +++ b/utils/webseal-simulator/src/main/resources/webseal.conf @@ -11,14 +11,6 @@ email="csantana@sdc.com" }, { - userId="op0001" - password="123123a" - firstName="Aretha" - lastName="Franklin" - role="Ops" - email="afranklin@sdc.com" - }, - { userId="jh0003" password="123123a" firstName="Jimmy" @@ -35,14 +27,6 @@ email="tester@sdc.com" }, { - userId="gv0001" - password="123123a" - firstName="David" - lastName="Shadmi" - role="Governor" - email="governor@sdc.com" - }, - { userId="pm0001" password="123123a" firstName="Teddy" diff --git a/utils/webseal-simulator/src/main/webapp/login.html b/utils/webseal-simulator/src/main/webapp/login.html index 2f6a324fcf..4d9eccb670 100644 --- a/utils/webseal-simulator/src/main/webapp/login.html +++ b/utils/webseal-simulator/src/main/webapp/login.html @@ -1,5 +1,5 @@ <!-- - ~ Copyright © 2016-2018 European Support Limited + ~ Copyright (C) 2016-2018 European Support Limited ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. @@ -13,22 +13,21 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - -<html> + +<!DOCTYPE html> +<html lang="en"> +<head><title>Login page</title></head> <body> Login - - <form action="access" method="post"> - UserId:<br> - <input type="text" name="userId" > - <br> - PASSWORD:<br> - <input type="password" name="password" > - <br><br> - <input type="submit" value="Submit"> - - <label name="message"/> + <label>UserId:<br> + <input type="text" name="userId"> + </label> + <label>PASSWORD:<br> + <input type="password" name="password"> + </label> + <input type="submit" value="Submit"> + + <label name="message"></label> </form> </body> -</html>
\ No newline at end of file |