Refine access control, peer access 47/247/1
authorSerban Jora <sj2381@att.com>
Tue, 26 Dec 2017 16:43:09 +0000 (11:43 -0500)
committerSerban Jora <sj2381@att.com>
Tue, 26 Dec 2017 16:44:23 +0000 (11:44 -0500)
Change-Id: Iab38c3ba77adef8356b18de7516cbc602499a1c4
Signed-off-by: Serban Jora <sj2381@att.com>
25 files changed:
gateway/application-error.properties [new file with mode: 0644]
gateway/pom.xml
gateway/src/main/java/org/acumos/federation/gateway/config/APINames.java
gateway/src/main/java/org/acumos/federation/gateway/controller/AbstractController.java
gateway/src/main/java/org/acumos/federation/gateway/controller/CatalogController.java [new file with mode: 0644]
gateway/src/main/java/org/acumos/federation/gateway/controller/FederationController.java [deleted file]
gateway/src/main/java/org/acumos/federation/gateway/controller/PeerController.java [new file with mode: 0644]
gateway/src/main/java/org/acumos/federation/gateway/security/Peer.java [new file with mode: 0644]
gateway/src/main/java/org/acumos/federation/gateway/security/Priviledge.java [new file with mode: 0644]
gateway/src/main/java/org/acumos/federation/gateway/security/Role.java [new file with mode: 0644]
gateway/src/main/java/org/acumos/federation/gateway/security/X509AuthenticationFilter.java
gateway/src/main/java/org/acumos/federation/gateway/security/X509ResourceFilter.java.noneed [new file with mode: 0644]
gateway/src/main/java/org/acumos/federation/gateway/service/CatalogService.java [moved from gateway/src/main/java/org/acumos/federation/gateway/service/FederationService.java with 81% similarity]
gateway/src/main/java/org/acumos/federation/gateway/service/PeerService.java
gateway/src/main/java/org/acumos/federation/gateway/service/ServiceContext.java [new file with mode: 0644]
gateway/src/main/java/org/acumos/federation/gateway/service/impl/CatalogServiceImpl.java [moved from gateway/src/main/java/org/acumos/federation/gateway/service/impl/FederationServiceImpl.java with 69% similarity]
gateway/src/main/java/org/acumos/federation/gateway/service/impl/CatalogServiceLocalImpl.java [moved from gateway/src/main/java/org/acumos/federation/gateway/service/impl/FederationServiceLocalImpl.java with 76% similarity]
gateway/src/main/java/org/acumos/federation/gateway/service/impl/PeerServiceImpl.java
gateway/src/main/java/org/acumos/federation/gateway/service/impl/PeerServiceLocalImpl.java
gateway/src/test/java/org/acumos/federation/gateway/test/PeerGatewayTest.java
gateway/src/test/resources/acumosa-peers.json
gateway/src/test/resources/acumosb-peers.json
gateway/src/test/resources/application-acumosa.properties
gateway/src/test/resources/docker-compose-test.yml [new file with mode: 0644]
gateway/src/test/resources/docker-compose.yml [new file with mode: 0644]

diff --git a/gateway/application-error.properties b/gateway/application-error.properties
new file mode 100644 (file)
index 0000000..428c7bb
--- /dev/null
@@ -0,0 +1,7 @@
+
+# CDmS REST endpoints are protected by HTTP Basic Authentication
+#Common Data Source Configuration
+cdms.client.url=http://cdms.research.att.com:8002/ccds
+cdms.client.username=ccds_client
+cdms.client.password=ccds_client
+
index dce5aeb..efe6dbb 100644 (file)
                <!-- Docker daemon -->
                <docker.host.url>unix:/var/run/docker.sock</docker.host.url>
                <!-- Docker image registry -->
                <!-- Docker daemon -->
                <docker.host.url>unix:/var/run/docker.sock</docker.host.url>
                <!-- Docker image registry -->
+               <!--
                <docker.registry.url>Set by Jenkins</docker.registry.url>
                <docker.registry.login>Registry userId - supplied by jenkins</docker.registry.login>
                <docker.registry.password>Registry password - supplied by jenkins</docker.registry.password>
                <docker.registry.url>Set by Jenkins</docker.registry.url>
                <docker.registry.login>Registry userId - supplied by jenkins</docker.registry.login>
                <docker.registry.password>Registry password - supplied by jenkins</docker.registry.password>
+               -->
+               <docker.registry.url>registry.hub.docker.io</docker.registry.url> 
                <!-- dependencies versions -->
                <slf4j.version>1.7.25</slf4j.version>
                <logback.version>1.2.3</logback.version>
                <!-- dependencies versions -->
                <slf4j.version>1.7.25</slf4j.version>
                <logback.version>1.2.3</logback.version>
@@ -49,6 +52,7 @@
                <acumos.nexus.url>http://cognita-nexus01.eastus.cloudapp.azure.com:8081</acumos.nexus.url>
                <acumos.nexus.snapshot.path>repository/repo_cognita_platform_maven_snapshots</acumos.nexus.snapshot.path>
                <acumos.nexus.release.path>repository/repo_cognita_platform_maven</acumos.nexus.release.path>
                <acumos.nexus.url>http://cognita-nexus01.eastus.cloudapp.azure.com:8081</acumos.nexus.url>
                <acumos.nexus.snapshot.path>repository/repo_cognita_platform_maven_snapshots</acumos.nexus.snapshot.path>
                <acumos.nexus.release.path>repository/repo_cognita_platform_maven</acumos.nexus.release.path>
+               <maven.build.timestamp.format>yyyy.MM.dd_HH.mm</maven.build.timestamp.format>
        </properties>
 
        <repositories>
        </properties>
 
        <repositories>
                                <configuration>
                                        <verbose>true</verbose>
                                        <dockerHost>${docker.host.url}</dockerHost>
                                <configuration>
                                        <verbose>true</verbose>
                                        <dockerHost>${docker.host.url}</dockerHost>
+<!--
                                        <registry>${docker.registry.url}</registry>
                                        <authConfig>
                                                <username>${docker.registry.login}</username>
                                                <password>${docker.registry.password}</password>
                                        </authConfig>
                                        <registry>${docker.registry.url}</registry>
                                        <authConfig>
                                                <username>${docker.registry.login}</username>
                                                <password>${docker.registry.password}</password>
                                        </authConfig>
+-->
                                        <images>
                                                <image>
                                                        <name>federation-gateway:${project.version}</name>
                                        <images>
                                                <image>
                                                        <name>federation-gateway:${project.version}</name>
                                                                                                <destName>application.properties</destName>
                                                                                        </file>
                                                                                        <file>
                                                                                                <destName>application.properties</destName>
                                                                                        </file>
                                                                                        <file>
-                                                                                               <source>src/test/resources/acumosa.pkcs12</source>
+                                                                                               <source>src/test/resources/ist-acumosa.pkcs12</source>
                                                                                                <outputDirectory />
                                                                                                <outputDirectory />
-                                                                                               <destName>acumosa.pkcs12</destName>
+                                                                                               <destName>ist-acumosa.pkcs12</destName>
                                                                                        </file>
                                                                                        <file>
                                                                                        </file>
                                                                                        <file>
-                                                                                               <source>src/test/resources/acumosb.pkcs12</source>
+                                                                                               <source>src/test/resources/ist-acumosb.pkcs12</source>
                                                                                                <outputDirectory />
                                                                                                <outputDirectory />
-                                                                                               <destName>acumosb.pkcs12</destName>
+                                                                                               <destName>ist-acumosb.pkcs12</destName>
                                                                                        </file>
                                                                                        <file>
                                                                                        </file>
                                                                                        <file>
-                                                                                               <source>src/test/resources/ist-acumosa.pkcs12</source>
+                                                                                               <source>src/test/resources/acumosTrustStore.jks</source>
                                                                                                <outputDirectory />
                                                                                                <outputDirectory />
-                                                                                               <destName>ist-acumosa.pkcs12</destName>
+                                                                                               <destName>acumosTrustStore.jks</destName>
                                                                                        </file>
                                                                                        <file>
                                                                                        </file>
                                                                                        <file>
-                                                                                               <source>src/test/resources/ist-acumosb.pkcs12</source>
+                                                                                               <source>target/${project.artifactId}-${project.version}.${project.packaging}</source>
                                                                                                <outputDirectory />
                                                                                                <outputDirectory />
-                                                                                               <destName>ist-acumosb.pkcs12</destName>
+                                                                                       </file>
+                                                                               </files>
+                                                                       </inline>
+                                                               </assembly>
+                                                               <!-- This is the same CMD used in a Dockerfile -->
+                                                               <cmd>
+                                                                       <shell>cd /maven; java -Djava.security.egd=file:/dev/./urandom -jar ${project.artifactId}-${project.version}.${project.packaging}</shell>
+                                                               </cmd>
+                                                       </build>
+                                               </image>
+                                               <image>
+                                                       <name>federation-gateway-test:${project.version}</name>
+                                                       <build>
+                                                               <!-- This is the same FROM used in a Dockerfile -->
+                                                               <!-- <from>openjdk:8-jdk</from> -->
+                                                               <from>frolvlad/alpine-oraclejdk8:slim</from>
+                                                               <tags>
+                                                               <tag>latest</tag>
+                                                       <tag>${project.version}</tag>
+                                                               <tag>${maven.build.timestamp}</tag>
+                                                               </tags>
+                                                               <assembly>
+                                                                       <inline>
+                                                                               <files>
+                                                                                       <file>
+                                                                                               <source>application.properties.template</source>
+                                                                                               <outputDirectory />
+                                                                                               <destName>application.properties</destName>
+                                                                                       </file>
+<!--
+       need the following two for server config
+-->
+                                                                                       <file>
+                                                                                               <source>src/test/resources/acumosa.pkcs12</source>
+                                                                                               <outputDirectory />
+                                                                                               <destName>acumosa.pkcs12</destName>
+                                                                                       </file>
+                                                                                       <file>
+                                                                                               <source>src/test/resources/acumosb.pkcs12</source>
+                                                                                               <outputDirectory />
+                                                                                               <destName>acumosb.pkcs12</destName>
                                                                                        </file>
                                                                                        <file>
                                                                                                <source>src/test/resources/acumosTrustStore.jks</source>
                                                                                        </file>
                                                                                        <file>
                                                                                                <source>src/test/resources/acumosTrustStore.jks</source>
                                                                                                <source>target/${project.artifactId}-${project.version}.${project.packaging}</source>
                                                                                                <outputDirectory />
                                                                                        </file>
                                                                                                <source>target/${project.artifactId}-${project.version}.${project.packaging}</source>
                                                                                                <outputDirectory />
                                                                                        </file>
+                                                                                       <file>
+                                                                                               <source>target/${project.artifactId}-${project.version}-tests.${project.packaging}</source>
+                                                                                               <outputDirectory />
+                                                                                       </file>
                                                                                </files>
                                                                                </files>
+                                                                               <fileSets>
+                      <fileSet>
+                        <directory>${basedir}/target/deps/</directory>
+                        <outputDirectory>/libs/</outputDirectory>
+                        <includes>
+                          <include>*</include>
+                        </includes>
+                        <fileMode>0755</fileMode>
+                                                                                       </fileSet>
+                                                                               </fileSets>
                                                                        </inline>
                                                                </assembly>
                                                                <!-- This is the same CMD used in a Dockerfile -->
                                                                <cmd>
                                                                        </inline>
                                                                </assembly>
                                                                <!-- This is the same CMD used in a Dockerfile -->
                                                                <cmd>
-                                                                       <shell>cd /maven; java -Djava.security.egd=file:/dev/./urandom -jar ${project.artifactId}-${project.version}.${project.packaging}</shell>
+                                                                       <shell>cd /maven; java -cp ${project.artifactId}-${project.version}.${project.packaging}:${project.artifactId}-${project.version}-tests.${project.packaging}:/libs/* -Djavax.net.ssl.trustStore=acumosTrustStore.jks -Djavax.net.ssl.trustStorePassword=acumos -Djava.security.egd=file:/dev/./urandom org.springframework.boot.loader.PropertiesLauncher</shell>
                                                                </cmd>
                                                        </build>
                                                </image>
                                        </images>
                                </configuration>
                                                                </cmd>
                                                        </build>
                                                </image>
                                        </images>
                                </configuration>
+                               <executions>
+                                       <execution>
+                                               <goals>
+                                                       <!-- build is bound to install phase -->
+                                                       <goal>build</goal>
+                                                       <!-- push is bound to deploy phase -->
+                                                       <goal>push</goal>
+                                               </goals>
+                                       </execution>
+                               </executions>
                        </plugin>
                        <plugin>
                                <groupId>org.codehaus.mojo</groupId>
                        </plugin>
                        <plugin>
                                <groupId>org.codehaus.mojo</groupId>
index f4bec84..6a53b63 100644 (file)
@@ -30,12 +30,17 @@ package org.acumos.federation.gateway.config;
 public class APINames {
         //Solutions APIs for MarketPlace Catalog
     public static final String PEER_SOLUTIONS = "/solutions";
 public class APINames {
         //Solutions APIs for MarketPlace Catalog
     public static final String PEER_SOLUTIONS = "/solutions";
-    public static final String PEER_SOLUTIONS_DETAILS = "/solutions/{solutionId}";
+    public static final String PEER_SOLUTION_DETAILS = "/solutions/{solutionId}";
     
     
-    public static final String PEER_SOLUTIONS_REVISIONS = "/solutions/{solutionId}/revisions";
-    public static final String PEER_SOLUTIONS_REVISIONS_ARTIFACTS = "/solutions/{solutionId}/revisions/{revisionId}";
+    public static final String PEER_SOLUTION_REVISIONS = "/solutions/{solutionId}/revisions";
+    public static final String PEER_SOLUTION_REVISION_DETAILS = "/solutions/{solutionId}/revisions/{revisionId}";
     
     
-    public static final String PEER_ARTIFACT = "/artifacts";
+    public static final String PEER_SOLUTION_REVISION_ARTIFACTS = "/solutions/{solutionId}/revisions/{revisionId}/artifacts";
     public static final String PEER_ARTIFACT_DETAILS = "/artifacts/{artifactId}";
     public static final String PEER_ARTIFACT_DETAILS = "/artifacts/{artifactId}";
-    public static final String PEER_ARTIFACT_download = "/artifacts/{artifactId}/download";
+    public static final String PEER_ARTIFACT_DOWNLOAD = "/artifacts/{artifactId}/download";
+    
+               public static final String PEER_PEERS = "/peers";
+               
+               //public static final String PEER_SUBSCRIBE = "/peer/subscribe";
+               //public static final String PEER_UNSUBSCRIBE = "/peer/unsubscribe";
 }
 }
index 52998b9..c02c1ea 100644 (file)
@@ -22,6 +22,8 @@ package org.acumos.federation.gateway.controller;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 
+import org.acumos.federation.gateway.config.EELFLoggerDelegate;
+
 
 /**
  * 
 
 /**
  * 
@@ -31,6 +33,7 @@ public abstract class AbstractController {
 
        protected static final String APPLICATION_JSON = "application/json";
 
 
        protected static final String APPLICATION_JSON = "application/json";
 
+       protected final EELFLoggerDelegate log = EELFLoggerDelegate.getLogger(getClass().getName());
        protected final ObjectMapper mapper;
 
        public AbstractController() {
        protected final ObjectMapper mapper;
 
        public AbstractController() {
diff --git a/gateway/src/main/java/org/acumos/federation/gateway/controller/CatalogController.java b/gateway/src/main/java/org/acumos/federation/gateway/controller/CatalogController.java
new file mode 100644 (file)
index 0000000..5d4e84c
--- /dev/null
@@ -0,0 +1,349 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * 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
+ *  
+ * This file is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ===============LICENSE_END=========================================================
+ */
+
+package org.acumos.federation.gateway.controller;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.InputStreamResource;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.util.UriComponentsBuilder;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import org.acumos.cds.domain.MLPArtifact;
+import org.acumos.cds.domain.MLPSolution;
+import org.acumos.cds.domain.MLPSolutionRevision;
+import org.acumos.federation.gateway.common.JSONTags;
+import org.acumos.federation.gateway.common.JsonResponse;
+import org.acumos.federation.gateway.config.APINames;
+import org.acumos.federation.gateway.config.EELFLoggerDelegate;
+import org.acumos.federation.gateway.service.CatalogService;
+import org.acumos.federation.gateway.service.ServiceContext;
+import org.acumos.federation.gateway.security.Peer;
+
+import io.swagger.annotations.ApiOperation;
+
+/**
+ * 
+ *
+ */
+@Controller
+@RequestMapping("/")
+public class CatalogController extends AbstractController {
+       
+       
+       @Autowired
+       CatalogService catalogService;
+       
+       
+//     /**
+//      * @param request
+//      *            HttpServletRequest
+//      * @param response
+//      *                      HttpServletResponse
+//      * @return List of Published ML Solutions in JSON format.
+//      */
+//     @CrossOrigin
+//     @ApiOperation(value = "Invoked by Peer Acumos to get a Paginated list of Published Solutions from the Catalog of the local Acumos Instance .", response = MLPSolution.class, responseContainer = "Page")
+//     @RequestMapping(value = {APINames.PEER_SOLUTIONS}, method = RequestMethod.GET, produces = APPLICATION_JSON)
+//     @ResponseBody
+//     public JsonResponse<RestPageResponse<MLPSolution>> getSolutionsListFromPeer(HttpServletRequest request, HttpServletResponse response,
+//                     @RequestParam("pageNumber") Integer pageNumber, @RequestParam("maxSize") Integer maxSize, 
+//                     @RequestParam(required = false) String sortingOrder, @RequestParam(required = false) String mlpModelTypes) {
+//             JsonResponse<RestPageResponse<MLPSolution>> data = null;
+//             RestPageResponse<MLPSolution> peerCatalogSolutions = null;
+//             try {
+//                     data = new JsonResponse<RestPageResponse<MLPSolution>>();
+//                     peerCatalogSolutions = federationGatewayService.getPeerCatalogSolutions(pageNumber, maxSize, sortingOrder, null);
+//                     if(peerCatalogSolutions != null) {
+//                             data.setResponseBody(peerCatalogSolutions);
+//                             logger.debug(EELFLoggerDelegate.debugLogger, "getSolutionsListFromPeer: size is {} ");
+//                     }
+//             } catch (Exception e) {
+//                     logger.error(EELFLoggerDelegate.errorLogger, "Exception Occurred Fetching Solutions for Market Place Catalog", e);
+//             }
+//             return data;
+//     }
+       
+       /**
+        * @param request
+        *            HttpServletRequest
+        * @param response
+        *                      HttpServletResponse
+        * @return List of Published ML Solutions in JSON format.
+        */
+       @CrossOrigin
+//@PreAuthorize("hasAuthority('PEER')"
+       @PreAuthorize("hasAuthority(T(org.acumos.federation.gateway.security.Priviledge).CATALOG_ACCESS)")
+       @ApiOperation(value = "Invoked by Peer Acumos to get a list of Published Solutions from the Catalog of the local Acumos Instance .", response = MLPSolution.class, responseContainer = "List")
+       @RequestMapping(value = {APINames.PEER_SOLUTIONS}, method = RequestMethod.GET, produces = APPLICATION_JSON)
+       @ResponseBody
+       public JsonResponse<List<MLPSolution>> getSolutions(
+                       /* HttpServletRequest theHttpRequest,*/
+                       HttpServletResponse theHttpResponse,
+                       @RequestParam(value = "modelTypeCode", required = false) String mlpModelTypes) {
+               JsonResponse<List<MLPSolution>> response = null;
+               List<MLPSolution> peerCatalogSolutions = null;
+               log.debug(EELFLoggerDelegate.debugLogger, APINames.PEER_SOLUTIONS);
+               try {
+                       response = new JsonResponse<List<MLPSolution>>();
+                       log.debug(EELFLoggerDelegate.debugLogger, "getSolutionsListFromPeer: model types " + mlpModelTypes);
+                       peerCatalogSolutions = catalogService.getSolutions(mlpModelTypes, new ControllerContext());
+                       if(peerCatalogSolutions != null) {
+                               response.setResponseBody(peerCatalogSolutions);
+                               response.setResponseCode(String.valueOf(HttpServletResponse.SC_OK));
+                               response.setResponseDetail(JSONTags.TAG_STATUS_SUCCESS);
+                               response.setStatus(true);
+                               theHttpResponse.setStatus(HttpServletResponse.SC_OK);
+                               log.debug(EELFLoggerDelegate.debugLogger, "getSolutions: size is " + peerCatalogSolutions.size());
+                       }
+               } catch (Exception e) {
+                       response.setResponseCode(String.valueOf(HttpServletResponse.SC_BAD_REQUEST));
+                       response.setResponseDetail(JSONTags.TAG_STATUS_FAILURE);
+                       response.setStatus(false);
+                       theHttpResponse.setStatus(HttpServletResponse.SC_BAD_REQUEST);
+                       log.error(EELFLoggerDelegate.errorLogger, "Exception occurred fetching Solutions for Market Place Catalog", e);
+               }
+               return response;
+       }
+
+       @CrossOrigin
+       @PreAuthorize("hasAuthority('CATALOG_ACCESS')")
+       @ApiOperation(value = "Invoked by Peer Acumos to get a list detailed solution information from the Catalog of the local Acumos Instance .", response = MLPSolution.class)
+       @RequestMapping(value = {APINames.PEER_SOLUTION_DETAILS}, method = RequestMethod.GET, produces = APPLICATION_JSON)
+       @ResponseBody
+       public JsonResponse<MLPSolution> getSolutionDetails(
+                       HttpServletResponse theHttpResponse,
+                       @PathVariable(value="solutionId") String theSolutionId) {
+               JsonResponse<MLPSolution> response = null;
+               MLPSolution solution = null;
+               log.debug(EELFLoggerDelegate.debugLogger, APINames.PEER_SOLUTION_DETAILS + ": " + theSolutionId);
+               try {
+                       response = new JsonResponse<MLPSolution>();
+                       solution = catalogService.getSolution(theSolutionId, new ControllerContext());
+                       if(solution != null) {
+                               response.setResponseBody(solution);
+                               response.setResponseCode(String.valueOf(HttpServletResponse.SC_OK));
+                               response.setResponseDetail(JSONTags.TAG_STATUS_SUCCESS);
+                               response.setStatus(true);
+                               theHttpResponse.setStatus(HttpServletResponse.SC_OK);
+                       }
+               }
+               catch (Exception e) {
+                       response.setResponseCode(String.valueOf(HttpServletResponse.SC_BAD_REQUEST));
+                       response.setResponseDetail(JSONTags.TAG_STATUS_FAILURE);
+                       response.setStatus(false);
+                       theHttpResponse.setStatus(HttpServletResponse.SC_BAD_REQUEST);
+                       log.error(EELFLoggerDelegate.errorLogger, "An error occurred fetching solution " + theSolutionId, e);
+               }
+               return response;
+       }
+
+
+       
+       /**
+        * @param request
+        *            HttpServletRequest
+        * @param response
+        *                      HttpServletResponse
+        * @return List of Published ML Solutions in JSON format.
+        */
+       @CrossOrigin
+       @PreAuthorize("hasAuthority('CATALOG_ACCESS')")
+       @ApiOperation(value = "Invoked by Peer Acumos to get a list of Solution Revision from the Catalog of the local Acumos Instance .", response = MLPSolutionRevision.class, responseContainer = "List")
+       @RequestMapping(value = {APINames.PEER_SOLUTION_REVISIONS}, method = RequestMethod.GET, produces = APPLICATION_JSON)
+       @ResponseBody
+       public JsonResponse<List<MLPSolutionRevision>> getSolutionRevisions(
+                       HttpServletResponse theHttpResponse,
+                       @PathVariable("solutionId") String theSolutionId) {
+               JsonResponse<List<MLPSolutionRevision>> response = null;
+               List<MLPSolutionRevision> solutionRevisions= null;
+               log.debug(EELFLoggerDelegate.debugLogger, APINames.PEER_SOLUTION_REVISIONS);
+               try {
+                       response = new JsonResponse<List<MLPSolutionRevision>>();
+                       solutionRevisions = catalogService.getSolutionRevisions(theSolutionId, new ControllerContext());
+                       if(solutionRevisions != null) {
+                               response.setResponseBody(solutionRevisions);
+                               response.setResponseCode(String.valueOf(HttpServletResponse.SC_OK));
+                               response.setResponseDetail(JSONTags.TAG_STATUS_SUCCESS);
+                               response.setStatus(true);
+                               theHttpResponse.setStatus(HttpServletResponse.SC_OK);
+                               log.debug(EELFLoggerDelegate.debugLogger, "getSolutionsRevisions: size is {} ", solutionRevisions.size());
+                       }
+               }
+               catch (Exception e) {
+                       response.setResponseCode(String.valueOf(HttpServletResponse.SC_BAD_REQUEST));
+                       response.setResponseDetail(JSONTags.TAG_STATUS_FAILURE);
+                       response.setStatus(false);
+                       theHttpResponse.setStatus(HttpServletResponse.SC_BAD_REQUEST);
+                       log.error(EELFLoggerDelegate.errorLogger, "Exception Occurred Fetching Solution Revisions", e);
+               }
+               return response;
+       }
+
+ /**
+        * @param request
+        *            HttpServletRequest
+        * @param response
+        *                      HttpServletResponse
+        * @return List of Published ML Solutions in JSON format.
+        */
+       @CrossOrigin
+       @PreAuthorize("hasAuthority('CATALOG_ACCESS')")
+       @ApiOperation(value = "Invoked by Peer Acumos to get Solution Revision details from the Catalog of the local Acumos Instance .", response = MLPSolutionRevision.class)
+       @RequestMapping(value = {APINames.PEER_SOLUTION_REVISION_DETAILS}, method = RequestMethod.GET, produces = APPLICATION_JSON)
+       @ResponseBody
+       public JsonResponse<MLPSolutionRevision> getSolutionRevisionDetails(
+                       HttpServletResponse theHttpResponse,
+                       @PathVariable("solutionId") String theSolutionId,
+                       @PathVariable("revisionId") String theRevisionId) {
+               JsonResponse<MLPSolutionRevision> response = null;
+               MLPSolutionRevision solutionRevision= null;
+               log.debug(EELFLoggerDelegate.debugLogger, APINames.PEER_SOLUTION_REVISION_DETAILS);
+               try {
+                       response = new JsonResponse<MLPSolutionRevision>();
+                       solutionRevision = catalogService.getSolutionRevision(theSolutionId, theRevisionId, new ControllerContext());
+                       if(solutionRevision != null) {
+                               response.setResponseBody(solutionRevision);
+                               response.setResponseCode(String.valueOf(HttpServletResponse.SC_OK));
+                               response.setResponseDetail(JSONTags.TAG_STATUS_SUCCESS);
+                               response.setStatus(true);
+                               theHttpResponse.setStatus(HttpServletResponse.SC_OK);
+                       }
+               }
+               catch (Exception e) {
+                       response.setResponseCode(String.valueOf(HttpServletResponse.SC_BAD_REQUEST));
+                       response.setResponseDetail(JSONTags.TAG_STATUS_FAILURE);
+                       response.setStatus(false);
+                       theHttpResponse.setStatus(HttpServletResponse.SC_BAD_REQUEST);
+                       log.error(EELFLoggerDelegate.errorLogger, "Exception Occurred Fetching Solution Revision", e);
+               }
+               return response;
+       }
+       
+       /**
+        * @param request
+        *            HttpServletRequest
+        * @param response
+        *                      HttpServletResponse
+        * @return List of Published ML Solutions in JSON format.
+        */
+       @CrossOrigin
+       @PreAuthorize("hasAuthority('CATALOG_ACCESS')")
+       @ApiOperation(value = "Invoked by Peer Acumos to get a list of Solution Revision Artifacts from the Catalog of the local Acumos Instance .", response = MLPArtifact.class, responseContainer = "List")
+       @RequestMapping(value = {APINames.PEER_SOLUTION_REVISION_ARTIFACTS}, method = RequestMethod.GET, produces = APPLICATION_JSON)
+       @ResponseBody
+       public JsonResponse<List<MLPArtifact>> getSolutionRevisionArtifacts (
+                       HttpServletRequest theHttpRequest,
+                       HttpServletResponse theHttpResponse,
+                       @PathVariable("solutionId") String theSolutionId,
+                       @PathVariable("revisionId") String theRevisionId) {
+               JsonResponse<List<MLPArtifact>> response = null;
+               List<MLPArtifact> solutionRevisionArtifacts= null;
+               log.debug(EELFLoggerDelegate.debugLogger, APINames.PEER_SOLUTION_REVISION_ARTIFACTS + ":" + theSolutionId + ":" + theRevisionId);
+               try {
+                       response = new JsonResponse<List<MLPArtifact>>();
+                       solutionRevisionArtifacts = catalogService.getSolutionRevisionArtifacts(theSolutionId, theRevisionId, new ControllerContext());
+                       if(solutionRevisionArtifacts != null) {
+                               //re-encode the artifact uri
+                               {
+                     UriComponentsBuilder uriBuilder = 
+                                               UriComponentsBuilder.fromHttpUrl(theHttpRequest.getRequestURL().toString());
+
+                                       for (MLPArtifact artifact: solutionRevisionArtifacts) {
+                                               artifact.setUri(uriBuilder.replacePath("/artifacts/" + artifact.getArtifactId() + "/download")
+                                                                                                                                                       .toUriString());
+                                       }
+                               }
+
+                               response.setResponseBody(solutionRevisionArtifacts);
+                               response.setResponseCode(String.valueOf(HttpServletResponse.SC_OK));
+                               response.setResponseDetail(JSONTags.TAG_STATUS_SUCCESS);
+                               response.setStatus(true);
+                               theHttpResponse.setStatus(HttpServletResponse.SC_OK);
+                               log.debug(EELFLoggerDelegate.debugLogger, "getSolutionRevisionArtifacts: size is {} ", solutionRevisionArtifacts.size());
+                       }
+               }
+               catch (Exception e) {
+                       response.setResponseCode(String.valueOf(HttpServletResponse.SC_BAD_REQUEST));
+                       response.setResponseDetail(JSONTags.TAG_STATUS_FAILURE);
+                       response.setStatus(false);
+                       theHttpResponse.setStatus(HttpServletResponse.SC_BAD_REQUEST);
+                       log.error(EELFLoggerDelegate.errorLogger, "Exception Occurred Fetching Solution Revisions Artifacts for Market Place Catalog", e);
+               }
+               return response;
+       }
+       
+       /**
+        * @param request
+        *            HttpServletRequest
+        * @param response
+        *                      HttpServletResponse
+        * @return Archive file of the Artifact for the Solution.
+        */
+       @CrossOrigin
+       @PreAuthorize("hasAuthority('CATALOG_ACCESS')")
+       @ApiOperation(value = "API to download the Machine Learning Artifact of the Machine Learning Solution", response = InputStreamResource.class, code = 200)
+       @RequestMapping(value = {APINames.PEER_ARTIFACT_DOWNLOAD}, method = RequestMethod.GET, produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
+       @ResponseBody
+       public InputStreamResource downloadSolutionArtifact(
+                       HttpServletRequest theHttpRequest,
+                       HttpServletResponse theHttpResponse,
+                       @PathVariable("artifactId") String theArtifactId) {
+               InputStreamResource inputStreamResource = null;
+               try {
+                       inputStreamResource = catalogService.getSolutionRevisionArtifactContent(theArtifactId, new ControllerContext());
+                       //TODO : Need to Implement a logic to download a Artifact or Docker Image from Nexus
+                       theHttpResponse.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
+                       theHttpResponse.setHeader("Pragma", "no-cache");
+                       theHttpResponse.setHeader("Expires", "0");
+                       theHttpResponse.setStatus(HttpServletResponse.SC_OK);
+               }
+               catch (Exception e) {
+                       theHttpResponse.setStatus(HttpServletResponse.SC_BAD_REQUEST);
+                       log.error(EELFLoggerDelegate.errorLogger, "Exception Occurred downloading a artifact for a Solution in Market Place Catalog", e);
+               }
+               return inputStreamResource;
+       }
+
+       /**
+        */
+       protected class ControllerContext implements ServiceContext {
+
+               public Peer getPeer() {
+                       return (Peer)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
+               }
+       }
+}
+
diff --git a/gateway/src/main/java/org/acumos/federation/gateway/controller/FederationController.java b/gateway/src/main/java/org/acumos/federation/gateway/controller/FederationController.java
deleted file mode 100644 (file)
index b0081cb..0000000
+++ /dev/null
@@ -1,251 +0,0 @@
-/*-
- * ===============LICENSE_START=======================================================
- * Acumos
- * ===================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
- * ===================================================================================
- * This Acumos software file is distributed by AT&T and Tech Mahindra
- * 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
- *  
- * This file is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ===============LICENSE_END=========================================================
- */
-
-package org.acumos.federation.gateway.controller;
-
-import java.util.List;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.io.InputStreamResource;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.util.UriComponentsBuilder;
-import org.springframework.web.bind.annotation.CrossOrigin;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.ResponseBody;
-
-import org.acumos.cds.domain.MLPArtifact;
-import org.acumos.cds.domain.MLPSolution;
-import org.acumos.cds.domain.MLPSolutionRevision;
-import org.acumos.federation.gateway.common.JSONTags;
-import org.acumos.federation.gateway.common.JsonResponse;
-import org.acumos.federation.gateway.config.APINames;
-import org.acumos.federation.gateway.config.EELFLoggerDelegate;
-import org.acumos.federation.gateway.service.FederationService;
-
-import io.swagger.annotations.ApiOperation;
-
-/**
- * 
- *
- */
-@Controller
-@RequestMapping("/")
-public class FederationController extends AbstractController {
-       
-       private final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FederationController.class);
-       
-       @Autowired
-       FederationService federationService;
-       
-       
-//     /**
-//      * @param request
-//      *            HttpServletRequest
-//      * @param response
-//      *                      HttpServletResponse
-//      * @return List of Published ML Solutions in JSON format.
-//      */
-//     @CrossOrigin
-//     @ApiOperation(value = "Invoked by Peer Acumos to get a Paginated list of Published Solutions from the Catalog of the local Acumos Instance .", response = MLPSolution.class, responseContainer = "Page")
-//     @RequestMapping(value = {APINames.PEER_SOLUTIONS}, method = RequestMethod.GET, produces = APPLICATION_JSON)
-//     @ResponseBody
-//     public JsonResponse<RestPageResponse<MLPSolution>> getSolutionsListFromPeer(HttpServletRequest request, HttpServletResponse response,
-//                     @RequestParam("pageNumber") Integer pageNumber, @RequestParam("maxSize") Integer maxSize, 
-//                     @RequestParam(required = false) String sortingOrder, @RequestParam(required = false) String mlpModelTypes) {
-//             JsonResponse<RestPageResponse<MLPSolution>> data = null;
-//             RestPageResponse<MLPSolution> peerCatalogSolutions = null;
-//             try {
-//                     data = new JsonResponse<RestPageResponse<MLPSolution>>();
-//                     peerCatalogSolutions = federationGatewayService.getPeerCatalogSolutions(pageNumber, maxSize, sortingOrder, null);
-//                     if(peerCatalogSolutions != null) {
-//                             data.setResponseBody(peerCatalogSolutions);
-//                             logger.debug(EELFLoggerDelegate.debugLogger, "getSolutionsListFromPeer: size is {} ");
-//                     }
-//             } catch (Exception e) {
-//                     logger.error(EELFLoggerDelegate.errorLogger, "Exception Occurred Fetching Solutions for Market Place Catalog", e);
-//             }
-//             return data;
-//     }
-       
-       /**
-        * @param request
-        *            HttpServletRequest
-        * @param response
-        *                      HttpServletResponse
-        * @return List of Published ML Solutions in JSON format.
-        */
-       @CrossOrigin
-       @PreAuthorize("hasAuthority('PEER')")
-       @ApiOperation(value = "Invoked by Peer Acumos to get a list of Published Solutions from the Catalog of the local Acumos Instance .", response = MLPSolution.class, responseContainer = "List")
-       @RequestMapping(value = {APINames.PEER_SOLUTIONS}, method = RequestMethod.GET, produces = APPLICATION_JSON)
-       @ResponseBody
-       public JsonResponse<List<MLPSolution>> getSolutionsListFromPeer(HttpServletRequest request, HttpServletResponse response, 
-                       @RequestParam(value = "modelTypeCode", required = false) String mlpModelTypes) {
-               JsonResponse<List<MLPSolution>> data = null;
-               List<MLPSolution> peerCatalogSolutions = null;
-               logger.debug(EELFLoggerDelegate.debugLogger, APINames.PEER_SOLUTIONS);
-               try {
-                       data = new JsonResponse<List<MLPSolution>>();
-                       logger.debug(EELFLoggerDelegate.debugLogger, "getSolutionsListFromPeer: model types " + mlpModelTypes);
-                       peerCatalogSolutions = federationService.getPeerCatalogSolutionsList(mlpModelTypes);
-                       if(peerCatalogSolutions != null) {
-                               data.setResponseBody(peerCatalogSolutions);
-                               data.setResponseCode(String.valueOf(HttpServletResponse.SC_OK));
-                               data.setResponseDetail(JSONTags.TAG_STATUS_SUCCESS);
-                               data.setStatus(true);
-                               response.setStatus(HttpServletResponse.SC_OK);
-                               logger.debug(EELFLoggerDelegate.debugLogger, "getSolutionsListFromPeer: size is " + peerCatalogSolutions.size());
-                       }
-               } catch (Exception e) {
-                       data.setResponseCode(String.valueOf(HttpServletResponse.SC_BAD_REQUEST));
-                       data.setResponseDetail(JSONTags.TAG_STATUS_FAILURE);
-                       data.setStatus(false);
-                       response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
-                       logger.error(EELFLoggerDelegate.errorLogger, "Exception Occurred Fetching Solutions for Market Place Catalog", e);
-               }
-               return data;
-       }
-       
-       /**
-        * @param request
-        *            HttpServletRequest
-        * @param response
-        *                      HttpServletResponse
-        * @return List of Published ML Solutions in JSON format.
-        */
-       @CrossOrigin
-       @PreAuthorize("hasAuthority('PEER')")
-       @ApiOperation(value = "Invoked by Peer Acumos to get a list of Solution Revision from the Catalog of the local Acumos Instance .", response = MLPSolutionRevision.class, responseContainer = "List")
-       @RequestMapping(value = {APINames.PEER_SOLUTIONS_REVISIONS}, method = RequestMethod.GET, produces = APPLICATION_JSON)
-       @ResponseBody
-       public JsonResponse<List<MLPSolutionRevision>> getSolutionsRevisionListFromPeer(HttpServletRequest request, HttpServletResponse response, 
-                       @PathVariable("solutionId") String solutionId) {
-               JsonResponse<List<MLPSolutionRevision>> data = null;
-               List<MLPSolutionRevision> peerCatalogSolutionRevisions= null;
-               logger.debug(EELFLoggerDelegate.debugLogger, APINames.PEER_SOLUTIONS_REVISIONS);
-               try {
-                       data = new JsonResponse<List<MLPSolutionRevision>>();
-                       peerCatalogSolutionRevisions = federationService.getPeerCatalogSolutionRevision(solutionId);
-                       if(peerCatalogSolutionRevisions != null) {
-                               data.setResponseBody(peerCatalogSolutionRevisions);
-                               data.setResponseCode(String.valueOf(HttpServletResponse.SC_OK));
-                               data.setResponseDetail(JSONTags.TAG_STATUS_SUCCESS);
-                               data.setStatus(true);
-                               response.setStatus(HttpServletResponse.SC_OK);
-                               logger.debug(EELFLoggerDelegate.debugLogger, "getSolutionsRevisionListFromPeer: size is {} ", peerCatalogSolutionRevisions.size());
-                       }
-               } catch (Exception e) {
-                       data.setResponseCode(String.valueOf(HttpServletResponse.SC_BAD_REQUEST));
-                       data.setResponseDetail(JSONTags.TAG_STATUS_FAILURE);
-                       data.setStatus(false);
-                       response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
-                       logger.error(EELFLoggerDelegate.errorLogger, "Exception Occurred Fetching Solution Revisions for Market Place Catalog", e);
-               }
-               return data;
-       }
-       
-       /**
-        * @param request
-        *            HttpServletRequest
-        * @param response
-        *                      HttpServletResponse
-        * @return List of Published ML Solutions in JSON format.
-        */
-       @CrossOrigin
-       @PreAuthorize("hasAuthority('PEER')")
-       @ApiOperation(value = "Invoked by Peer Acumos to get a list of Solution Revision Artifacts from the Catalog of the local Acumos Instance .", response = MLPArtifact.class, responseContainer = "List")
-       @RequestMapping(value = {APINames.PEER_SOLUTIONS_REVISIONS_ARTIFACTS}, method = RequestMethod.GET, produces = APPLICATION_JSON)
-       @ResponseBody
-       public JsonResponse<List<MLPArtifact>> getSolutionsRevisionArtifactListFromPeer(HttpServletRequest request, HttpServletResponse response, 
-                       @PathVariable("solutionId") String solutionId, @PathVariable("revisionId") String revisionId) {
-               JsonResponse<List<MLPArtifact>> data = null;
-               List<MLPArtifact> peerSolutionArtifacts= null;
-               logger.debug(EELFLoggerDelegate.debugLogger, APINames.PEER_SOLUTIONS_REVISIONS_ARTIFACTS);
-               try {
-                       data = new JsonResponse<List<MLPArtifact>>();
-                       peerSolutionArtifacts = federationService.getPeerSolutionArtifacts(solutionId, revisionId);
-                       if(peerSolutionArtifacts != null) {
-                               //re-encode the artifact uri
-                               {
-                     UriComponentsBuilder uriBuilder = UriComponentsBuilder.fromHttpUrl(request.getRequestURL().toString());
-
-                                       for (MLPArtifact artifact: peerSolutionArtifacts) {
-                                               artifact.setUri(uriBuilder.replacePath("/artifacts/" + artifact.getArtifactId() + "/download")
-                                                                                                                                                       .toUriString());
-                                       }
-                               }
-
-                               data.setResponseBody(peerSolutionArtifacts);
-                               data.setResponseCode(String.valueOf(HttpServletResponse.SC_OK));
-                               data.setResponseDetail(JSONTags.TAG_STATUS_SUCCESS);
-                               data.setStatus(true);
-                               response.setStatus(HttpServletResponse.SC_OK);
-                               logger.debug(EELFLoggerDelegate.debugLogger, "getSolutionsRevisionArtifactListFromPeer: size is {} ", peerSolutionArtifacts.size());
-                       }
-               } catch (Exception e) {
-                       data.setResponseCode(String.valueOf(HttpServletResponse.SC_BAD_REQUEST));
-                       data.setResponseDetail(JSONTags.TAG_STATUS_FAILURE);
-                       data.setStatus(false);
-                       response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
-                       logger.error(EELFLoggerDelegate.errorLogger, "Exception Occurred Fetching Solution Revisions Artifacts for Market Place Catalog", e);
-               }
-               return data;
-       }
-       
-       /**
-        * @param request
-        *            HttpServletRequest
-        * @param response
-        *                      HttpServletResponse
-        * @return Archive file of the Artifact for the Solution.
-        */
-       @CrossOrigin
-       @PreAuthorize("hasAuthority('PEER')")
-       @ApiOperation(value = "API to download the Machine Learning Artifact of the Machine Learning Solution", response = InputStreamResource.class, code = 200)
-       @RequestMapping(value = {APINames.PEER_ARTIFACT_download}, method = RequestMethod.GET, produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
-       @ResponseBody
-       public InputStreamResource downloadSolutionArtifact(@PathVariable("artifactId") String artifactId,
-               HttpServletRequest request, HttpServletResponse response) {
-               InputStreamResource inputStreamResource = null;
-               try {
-                       inputStreamResource = federationService.getPeerSolutionArtifactFile(artifactId);
-                       //TODO : Need to Implement a logic to download a Artifact or Docker Image from Nexus
-                       response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
-                       response.setHeader("Pragma", "no-cache");
-                       response.setHeader("Expires", "0");
-                       response.setStatus(HttpServletResponse.SC_OK);
-               } catch (Exception e) {
-                       response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
-                       logger.error(EELFLoggerDelegate.errorLogger, "Exception Occurred downloading a artifact for a Solution in Market Place Catalog", e);
-               }
-               return inputStreamResource;
-       }
-}
-
diff --git a/gateway/src/main/java/org/acumos/federation/gateway/controller/PeerController.java b/gateway/src/main/java/org/acumos/federation/gateway/controller/PeerController.java
new file mode 100644 (file)
index 0000000..13220e8
--- /dev/null
@@ -0,0 +1,121 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * 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
+ *  
+ * This file is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ===============LICENSE_END=========================================================
+ */
+
+package org.acumos.federation.gateway.controller;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.InputStreamResource;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.util.UriComponentsBuilder;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import org.acumos.cds.domain.MLPPeer;
+import org.acumos.federation.gateway.common.JSONTags;
+import org.acumos.federation.gateway.common.JsonResponse;
+import org.acumos.federation.gateway.config.APINames;
+import org.acumos.federation.gateway.config.EELFLoggerDelegate;
+import org.acumos.federation.gateway.service.PeerService;
+import org.acumos.federation.gateway.service.ServiceContext;
+import org.acumos.federation.gateway.security.Peer;
+
+import io.swagger.annotations.ApiOperation;
+
+/**
+ * 
+ *
+ */
+@Controller
+@RequestMapping("/")
+public class PeerController extends AbstractController {
+       
+       
+       @Autowired
+       PeerService peerService;
+       
+       /**
+        * @param request
+        *            HttpServletRequest
+        * @param response
+        *                      HttpServletResponse
+        * @return List of Published ML Solutions in JSON format.
+        */
+       @CrossOrigin
+       @PreAuthorize("hasAuthority('PEERS_ACCESS')")
+       @ApiOperation(value = "Invoked by Peer Acumos to get a list of peers from local Acumos Instance .", response = MLPPeer.class, responseContainer = "List")
+       @RequestMapping(value = {APINames.PEER_PEERS}, method = RequestMethod.GET, produces = APPLICATION_JSON)
+       @ResponseBody
+       public JsonResponse<List<MLPPeer>> getSolutions(
+                       /* HttpServletRequest theHttpRequest,*/
+                       HttpServletResponse theHttpResponse) {
+
+               JsonResponse<List<MLPPeer>> response = null;
+               List<MLPPeer> peers = null;
+               log.debug(EELFLoggerDelegate.debugLogger, APINames.PEER_PEERS);
+               try {
+                       response = new JsonResponse<List<MLPPeer>>();
+                       log.debug(EELFLoggerDelegate.debugLogger, "getPeers");
+
+                       peers = peerService.getPeers(new ControllerContext());
+/*
+ * TODO: We only expose simple peers, not the partners.
+ * But we only serve this service
+ * to parners so .. ?? No pb.
+ */
+                       if(peers != null) {
+                               response.setResponseBody(peers);
+                               response.setResponseCode(String.valueOf(HttpServletResponse.SC_OK));
+                               response.setResponseDetail(JSONTags.TAG_STATUS_SUCCESS);
+                               response.setStatus(true);
+                               theHttpResponse.setStatus(HttpServletResponse.SC_OK);
+                               log.debug(EELFLoggerDelegate.debugLogger, "getPeers: size is " + peers.size());
+                       }
+               } catch (Exception e) {
+                       response.setResponseCode(String.valueOf(HttpServletResponse.SC_BAD_REQUEST));
+                       response.setResponseDetail(JSONTags.TAG_STATUS_FAILURE);
+                       response.setStatus(false);
+                       theHttpResponse.setStatus(HttpServletResponse.SC_BAD_REQUEST);
+                       log.error(EELFLoggerDelegate.errorLogger, "Exception Occurred Fetching Peers", e);
+               }
+               return response;
+       }
+
+       protected class ControllerContext implements ServiceContext {
+
+               public Peer getPeer() {
+                       return (Peer)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
+               }
+       }
+}
+
diff --git a/gateway/src/main/java/org/acumos/federation/gateway/security/Peer.java b/gateway/src/main/java/org/acumos/federation/gateway/security/Peer.java
new file mode 100644 (file)
index 0000000..95be787
--- /dev/null
@@ -0,0 +1,38 @@
+/* 
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * 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
+ *
+ * This file is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ===============LICENSE_END=========================================================
+ */
+package org.acumos.federation.gateway.security;
+
+import java.util.Collection;
+
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.userdetails.User;
+
+/**
+ */
+public class Peer extends User {
+
+       //private MLPPeer       peer;
+
+       public Peer(String theName, Collection<? extends GrantedAuthority> theAuthorities) {
+               super (theName, "", true, true, true, true, theAuthorities);
+       }
+
+}
+
diff --git a/gateway/src/main/java/org/acumos/federation/gateway/security/Priviledge.java b/gateway/src/main/java/org/acumos/federation/gateway/security/Priviledge.java
new file mode 100644 (file)
index 0000000..f301fcd
--- /dev/null
@@ -0,0 +1,53 @@
+/* 
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * 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
+ *
+ * This file is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ===============LICENSE_END=========================================================
+ */
+package org.acumos.federation.gateway.security;
+
+
+import org.springframework.security.core.GrantedAuthority;
+
+/**
+ * An enumeratoin of federated access fine grained proviledges
+ */
+public enum Priviledge implements GrantedAuthority {
+
+       /** 
+               Gives access to catalog items (solutions); coarse at this point, all
+               (list/read/download) or nothing
+        */
+       CATALOG_ACCESS,
+       /**
+               Gives access to the local list of peers.
+               In the future we might want to refine this by defining which peers should be provided (byb some base selection criteria)
+        */
+       PEERS_ACCESS,
+       /**
+               The right to submit a subscription request. This is granted to ANY if so enabled system wide.
+        */
+       SUBSCRIPTION;
+
+       Priviledge() {
+       }
+
+       @Override
+       public String getAuthority() {
+               return name();
+       }
+}
+
diff --git a/gateway/src/main/java/org/acumos/federation/gateway/security/Role.java b/gateway/src/main/java/org/acumos/federation/gateway/security/Role.java
new file mode 100644 (file)
index 0000000..b0a80ec
--- /dev/null
@@ -0,0 +1,64 @@
+/* 
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * 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
+ *
+ * This file is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ===============LICENSE_END=========================================================
+ */
+package org.acumos.federation.gateway.security;
+
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Arrays;
+
+import org.springframework.security.core.GrantedAuthority;
+
+/**
+ * Each Role states a predefined set of available federation priviledges.
+ */
+public enum Role {
+
+       /**
+   * Un-authenticated client. Will at most be granted access to subscribe
+        * functionality
+        */
+       ANY(Collections.EMPTY_LIST),
+       /**
+        * Common peer, grants generic solution catalog access
+        */
+       PEER(Arrays.asList(Priviledge.CATALOG_ACCESS)),
+       /**
+   * Enhanced peer, gains (some lovel of) read access to the local peer list
+        */
+       PARTNER(Arrays.asList(Priviledge.CATALOG_ACCESS, Priviledge.PEERS_ACCESS)),
+       /**
+        * The actual gateway system, used for local calls, grants all proviledges
+        */
+       SYSTEM(Arrays.asList(Priviledge.class.getEnumConstants()));
+
+
+       private Collection<Priviledge> priviledges;
+
+       Role(Collection<Priviledge> thePriviledges) {
+               this.priviledges = thePriviledges;
+       }
+
+       public Collection<Priviledge> priviledges() {
+               return this.priviledges;
+       }
+
+}
+
index efbfbcb..05dc5c8 100644 (file)
@@ -50,7 +50,7 @@ import org.springframework.security.core.userdetails.UserDetailsService;
 
 @Configuration
 @EnableWebSecurity
 
 @Configuration
 @EnableWebSecurity
-//@EnableGlobalMethodSecurity(prePostEnabled = true)
+@EnableGlobalMethodSecurity(prePostEnabled = true)
 public class X509AuthenticationFilter extends WebSecurityConfigurerAdapter {
        
        private final EELFLoggerDelegate log = EELFLoggerDelegate.getLogger(getClass().getName());
 public class X509AuthenticationFilter extends WebSecurityConfigurerAdapter {
        
        private final EELFLoggerDelegate log = EELFLoggerDelegate.getLogger(getClass().getName());
@@ -62,14 +62,13 @@ public class X509AuthenticationFilter extends WebSecurityConfigurerAdapter {
        private boolean securityEnabled;
 
        public X509AuthenticationFilter() {
        private boolean securityEnabled;
 
        public X509AuthenticationFilter() {
-               // TODO Auto-generated constructor stub
        }
 
        }
 
+/*
        public X509AuthenticationFilter(boolean disableDefaults) {
                super(disableDefaults);
        public X509AuthenticationFilter(boolean disableDefaults) {
                super(disableDefaults);
-               // TODO Auto-generated constructor stub
        }
        }
-
+*/
        /**
      * subjectPrincipalRegex("CN=(.*?)(?:,|$)") :- The regular expression used to extract a username from the client certificates subject name.
      * (CN value of the client certificate)
        /**
      * subjectPrincipalRegex("CN=(.*?)(?:,|$)") :- The regular expression used to extract a username from the client certificates subject name.
      * (CN value of the client certificate)
@@ -87,7 +86,7 @@ public class X509AuthenticationFilter extends WebSecurityConfigurerAdapter {
 
        }
        
 
        }
        
-       @Bean
+       //@Bean
        public UserDetailsService userDetailsService() {
                return (username -> {
                        log.info(EELFLoggerDelegate.debugLogger, " X509 subject : " + username);
        public UserDetailsService userDetailsService() {
                return (username -> {
                        log.info(EELFLoggerDelegate.debugLogger, " X509 subject : " + username);
@@ -95,10 +94,11 @@ public class X509AuthenticationFilter extends WebSecurityConfigurerAdapter {
                        log.info(EELFLoggerDelegate.debugLogger, " Peers matching X509 subject : " + mlpPeers);
       if(!Utils.isEmptyList(mlpPeers)) {
                                log.info(EELFLoggerDelegate.debugLogger, " We are providing a matching Use ");
                        log.info(EELFLoggerDelegate.debugLogger, " Peers matching X509 subject : " + mlpPeers);
       if(!Utils.isEmptyList(mlpPeers)) {
                                log.info(EELFLoggerDelegate.debugLogger, " We are providing a matching Use ");
-                               return new User(username, "", AuthorityUtils.commaSeparatedStringToAuthorityList("PEER"));
+                               return new Peer(username, Role.PEER.priviledges());
                        }
                        else    {
                        }
                        else    {
-                               return null;
+                               return new Peer(username, Role.ANY.priviledges());
+                               //return null;
                        }
                });
        }
                        }
                });
        }
diff --git a/gateway/src/main/java/org/acumos/federation/gateway/security/X509ResourceFilter.java.noneed b/gateway/src/main/java/org/acumos/federation/gateway/security/X509ResourceFilter.java.noneed
new file mode 100644 (file)
index 0000000..0f5a640
--- /dev/null
@@ -0,0 +1,101 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * 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
+ *  
+ * This file is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ===============LICENSE_END=========================================================
+ */
+
+package org.acumos.federation.gateway.security;
+
+import java.util.List;
+
+import org.acumos.cds.domain.MLPPeer;
+
+import org.acumos.federation.gateway.config.EELFLoggerDelegate;
+import org.acumos.federation.gateway.service.PeerService;
+import org.acumos.federation.gateway.util.Utils;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+import org.springframework.security.core.authority.AuthorityUtils;
+import org.springframework.security.core.userdetails.User;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.core.userdetails.UserDetailsService;
+
+import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
+import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
+import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
+
+/**
+ * 
+ * X.509 certificate authentication :  verifying the identity of a communication peer when using the HTTPS (HTTP over SSL) protocol.
+ *
+ */
+
+@Configuration
+@EnableResourceServer
+public class X509ResourceFilter extends ResourceServerConfigurerAdapter {
+       
+       private final EELFLoggerDelegate log = EELFLoggerDelegate.getLogger(getClass().getName());
+
+       @Autowired
+       private PeerService peerService;
+
+       public X509ResourceFilter() {
+       }
+
+       @Override
+       public void configure(ResourceServerSecurityConfigurer resources) {
+               resources
+                       .resourceId("web");
+       }
+
+       @Override
+       public void configure(HttpSecurity http) throws Exception {
+               http
+               .authorizeRequests()
+                       .anyRequest().authenticated()
+               .and()
+                       .x509()
+                               .subjectPrincipalRegex("CN=(.*?)(?:,|$)")
+                               .userDetailsService(userDetailsService());
+       }
+       
+       //@Bean
+       public UserDetailsService userDetailsService() {
+               return (username -> {
+                       log.info(EELFLoggerDelegate.debugLogger, " X509 subject : " + username);
+                       List<MLPPeer> mlpPeers = peerService.getPeer(username);
+                       log.info(EELFLoggerDelegate.debugLogger, " Peers matching X509 subject : " + mlpPeers);
+      if(!Utils.isEmptyList(mlpPeers)) {
+                               log.info(EELFLoggerDelegate.debugLogger, " We are providing a matching Use ");
+                               return new Peer(username, Role.PEER.priviledges());
+                       }
+                       else    {
+                               return new Peer(username, Role.ANY.priviledges());
+                               //return null;
+                       }
+               });
+       }
+}
+
@@ -33,10 +33,11 @@ import org.acumos.cds.domain.MLPSolution;
 import org.acumos.cds.domain.MLPSolutionRevision;
 import org.acumos.cds.transport.RestPageResponse;
 
 import org.acumos.cds.domain.MLPSolutionRevision;
 import org.acumos.cds.transport.RestPageResponse;
 
+
 /**
 /**
- * Handles the business behind the Acumos federation interface
+ * Handles access to the solutions catalog 
  */
  */
-public interface FederationService {
+public interface CatalogService {
        
        
        /**
        
        
        /**
@@ -54,9 +55,11 @@ public interface FederationService {
         * 
         * @return Pageable List of the Catalog Solutions
         */
         * 
         * @return Pageable List of the Catalog Solutions
         */
+       /*
        RestPageResponse<MLPSolution>  getPeerCatalogSolutions(Integer pageNumber, Integer maxSize, String sortingOrder, 
                        List<String> mlpModelTypes);
        RestPageResponse<MLPSolution>  getPeerCatalogSolutions(Integer pageNumber, Integer maxSize, String sortingOrder, 
                        List<String> mlpModelTypes);
-       
+       */
+
        /**
         * 
         *  API to be invoked by Peer Acumos to fetch the Catalog Solutions List.
        /**
         * 
         *  API to be invoked by Peer Acumos to fetch the Catalog Solutions List.
@@ -65,7 +68,12 @@ public interface FederationService {
         * 
         * @return List of the Catalog Solutions for the specified list of query parameters
         */
         * 
         * @return List of the Catalog Solutions for the specified list of query parameters
         */
-       List<MLPSolution> getPeerCatalogSolutionsList(String mlpModelTypes);
+       List<MLPSolution> getSolutions(String mlpModelTypes, ServiceContext theContext);
+       
+
+       /**
+        */
+       MLPSolution getSolution(String theSolutionId, ServiceContext theContext);
        
        
        /**
        
        
        /**
@@ -73,8 +81,12 @@ public interface FederationService {
         * 
         * @return List of the Solution Revision for the specified solution Id
         */
         * 
         * @return List of the Solution Revision for the specified solution Id
         */
-       List<MLPSolutionRevision> getPeerCatalogSolutionRevision(String solutionId);
+       List<MLPSolutionRevision> getSolutionRevisions(String theSolutionId, ServiceContext theContext);
        
        
+       /**
+        */
+       MLPSolutionRevision getSolutionRevision(String theSolutionId, String theRevisionId, ServiceContext theContext);
+
        /**
         * @param solutionId : SolutionId for which Solution Revision Artifacts Needs to be returned
         * 
        /**
         * @param solutionId : SolutionId for which Solution Revision Artifacts Needs to be returned
         * 
@@ -82,7 +94,7 @@ public interface FederationService {
         * 
         * @return List of the Solution Artifacts for the specified solution Id & revisionId
         */
         * 
         * @return List of the Solution Artifacts for the specified solution Id & revisionId
         */
-       List<MLPArtifact> getPeerSolutionArtifacts(String solutionId, String revisionId);
+       List<MLPArtifact> getSolutionRevisionArtifacts(String theSolutionId, String theRevisionId, ServiceContext theContext);
        
        
        
        
        
        
@@ -90,6 +102,6 @@ public interface FederationService {
         * @param artifactId of the File stored in Nexus repository
         * @return Artifact File for the Machine Learning Solution 
         */
         * @param artifactId of the File stored in Nexus repository
         * @return Artifact File for the Machine Learning Solution 
         */
-       InputStreamResource getPeerSolutionArtifactFile(String artifactId);
+       InputStreamResource getSolutionRevisionArtifactContent(String theArtifactId, ServiceContext theContext);
        
 }
        
 }
index a5077e9..3a7a7e1 100644 (file)
@@ -35,6 +35,11 @@ public interface PeerService {
         */
        List<MLPPeer> getPeers();
        
         */
        List<MLPPeer> getPeers();
        
+       /**
+        * Provide the list of locally registered peers to one of our peers
+        */
+       List<MLPPeer> getPeers(ServiceContext theContext);
+       
        /**
         * @return Peer based on the configured Subject Name
         */
        /**
         * @return Peer based on the configured Subject Name
         */
diff --git a/gateway/src/main/java/org/acumos/federation/gateway/service/ServiceContext.java b/gateway/src/main/java/org/acumos/federation/gateway/service/ServiceContext.java
new file mode 100644 (file)
index 0000000..68ed830
--- /dev/null
@@ -0,0 +1,42 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * 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
+ *  
+ * This file is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ===============LICENSE_END=========================================================
+ */
+
+/**
+ * 
+ */
+package org.acumos.federation.gateway.service;
+
+import org.acumos.federation.gateway.security.Peer;
+
+
+
+/**
+ * Expose the invocation frame for service calls (whenever a call is selectively
+ * provided).
+ */
+public interface ServiceContext {
+       
+       /*
+        * In who's behalf are we providing the service
+        */
+       public Peer     getPeer();
+
+}
+
@@ -38,7 +38,8 @@ import javax.annotation.PostConstruct;
 
 import org.apache.commons.io.FileUtils;
 import org.acumos.federation.gateway.config.EELFLoggerDelegate;
 
 import org.apache.commons.io.FileUtils;
 import org.acumos.federation.gateway.config.EELFLoggerDelegate;
-import org.acumos.federation.gateway.service.FederationService;
+import org.acumos.federation.gateway.service.CatalogService;
+import org.acumos.federation.gateway.service.ServiceContext;
 import org.acumos.federation.gateway.util.Utils;
 import org.acumos.federation.gateway.common.GatewayCondition;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.acumos.federation.gateway.util.Utils;
 import org.acumos.federation.gateway.common.GatewayCondition;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -59,14 +60,14 @@ import org.acumos.cds.domain.MLPSolutionRevision;
 import org.acumos.cds.transport.RestPageResponse;
 
 /**
 import org.acumos.cds.transport.RestPageResponse;
 
 /**
- * 
+ * CDS based implementation of the CatalogService. 
  *
  */
 @Service
 @Conditional(GatewayCondition.class)
  *
  */
 @Service
 @Conditional(GatewayCondition.class)
-public class FederationServiceImpl extends AbstractServiceImpl implements FederationService {
-
-       private static final EELFLoggerDelegate log = EELFLoggerDelegate.getLogger(FederationServiceImpl.class);
+public class CatalogServiceImpl 
+                                                               extends AbstractServiceImpl
+                                                               implements CatalogService {
 
        @Autowired
        private Environment env;
 
        @Autowired
        private Environment env;
@@ -76,32 +77,35 @@ public class FederationServiceImpl extends AbstractServiceImpl implements Federa
        @PostConstruct
        public void initService() {
                baseSelector = new HashMap<String, Object>();
        @PostConstruct
        public void initService() {
                baseSelector = new HashMap<String, Object>();
-/*
+
                baseSelector.put("active", true); //Fetch all active solutions
                baseSelector.put("accessTypeCode", AccessTypeCode.PB.toString()); // Fetch allowed only for Public models
                baseSelector.put("validationStatusCode", ValidationStatusCode.PS.toString()); // Validation status should be Passed locally
                baseSelector.put("active", true); //Fetch all active solutions
                baseSelector.put("accessTypeCode", AccessTypeCode.PB.toString()); // Fetch allowed only for Public models
                baseSelector.put("validationStatusCode", ValidationStatusCode.PS.toString()); // Validation status should be Passed locally
-               baseSelector.put("provider", env.getProperty("federated.instance.name"));
-*/     
+//             baseSelector.put("provider", env.getProperty("federated.instance.name"));
+       
        }
 
        /**
         * This needs to be implemented for future enhancement where pagination is allowed
         */
        }
 
        /**
         * This needs to be implemented for future enhancement where pagination is allowed
         */
+/*
        @Override
        public RestPageResponse<MLPSolution>  getPeerCatalogSolutions(Integer pageNumber, Integer maxSize, String sortingOrder,
                        List<String> mlpModelTypes) {
                return null;
        }
        @Override
        public RestPageResponse<MLPSolution>  getPeerCatalogSolutions(Integer pageNumber, Integer maxSize, String sortingOrder,
                        List<String> mlpModelTypes) {
                return null;
        }
-
+*/
        @Override
        @Override
-       public List<MLPSolution> getPeerCatalogSolutionsList(String mlpModelTypes) {
-               log.debug(EELFLoggerDelegate.debugLogger, "getPeerCatalogSolutionsList");
+       public List<MLPSolution> getSolutions(
+               String mlpModelTypes, ServiceContext theContext) {
+               
+               log.debug(EELFLoggerDelegate.debugLogger, "getSolutions");
                List<MLPSolution> filteredMLPSolutions = null;
                ICommonDataServiceRestClient dataServiceRestClient = getClient();
                //TODO: revisit this code to pass query parameters to CCDS Service
                Map<String, Object> queryParameters = new HashMap<String, Object>(this.baseSelector);
                List<MLPSolution> mlpSolutions = dataServiceRestClient.searchSolutions(queryParameters, false);
                List<MLPSolution> filteredMLPSolutions = null;
                ICommonDataServiceRestClient dataServiceRestClient = getClient();
                //TODO: revisit this code to pass query parameters to CCDS Service
                Map<String, Object> queryParameters = new HashMap<String, Object>(this.baseSelector);
                List<MLPSolution> mlpSolutions = dataServiceRestClient.searchSolutions(queryParameters, false);
-               log.debug(EELFLoggerDelegate.debugLogger, "getPeerCatalogSolutionsList: data service provided solutions " + mlpSolutions);
+               log.debug(EELFLoggerDelegate.debugLogger, "getSolutions: data service provided solutions " + mlpSolutions);
 
                if(mlpSolutions != null && mlpSolutions.size() > 0 && !Utils.isEmptyOrNullString(mlpModelTypes)) {
                        //Filter List using Lamba to get solutions which matches the ML Model Type
 
                if(mlpSolutions != null && mlpSolutions.size() > 0 && !Utils.isEmptyOrNullString(mlpModelTypes)) {
                        //Filter List using Lamba to get solutions which matches the ML Model Type
@@ -117,36 +121,60 @@ public class FederationServiceImpl extends AbstractServiceImpl implements Federa
                return filteredMLPSolutions;
        }
 
                return filteredMLPSolutions;
        }
 
+       @Override
+       public MLPSolution getSolution(
+               String theSolutionId, ServiceContext theContext) {
+               
+               log.debug(EELFLoggerDelegate.debugLogger, "getSolution");
+               ICommonDataServiceRestClient cdsClient = getClient();
+               return cdsClient.getSolution(theSolutionId);
+       }
        
        @Override
        
        @Override
-       public List<MLPSolutionRevision> getPeerCatalogSolutionRevision(String solutionId) {
-               log.debug(EELFLoggerDelegate.debugLogger, "getPeerCatalogSolutionRevision`");
-               List<MLPSolutionRevision> mlpSolutionRevisions = null;
+       public List<MLPSolutionRevision> getSolutionRevisions(
+               String theSolutionId, ServiceContext theContext) {
+
+               log.debug(EELFLoggerDelegate.debugLogger, "getSolutionRevisions");
                ICommonDataServiceRestClient dataServiceRestClient = getClient();
                ICommonDataServiceRestClient dataServiceRestClient = getClient();
-               mlpSolutionRevisions = dataServiceRestClient.getSolutionRevisions(solutionId);
+               List<MLPSolutionRevision> mlpSolutionRevisions =
+                       dataServiceRestClient.getSolutionRevisions(theSolutionId);
                return mlpSolutionRevisions;
        }
 
        @Override
                return mlpSolutionRevisions;
        }
 
        @Override
-       public List<MLPArtifact> getPeerSolutionArtifacts(String solutionId, String revisionId) {
-               log.debug(EELFLoggerDelegate.debugLogger, "getPeerSolutionArtifacts`");
-               List<MLPArtifact> mlpSolutionRevisions = new ArrayList<>();
+       public MLPSolutionRevision getSolutionRevision(
+               String theSolutionId, String theRevisionId, ServiceContext theContext) {
+
+               log.debug(EELFLoggerDelegate.debugLogger, "getSolutionRevision");
+               ICommonDataServiceRestClient dataServiceRestClient = getClient();
+               MLPSolutionRevision mlpSolutionRevision =
+                       dataServiceRestClient.getSolutionRevision(theSolutionId, theRevisionId);
+               return mlpSolutionRevision;
+       }
+
+       @Override
+       public List<MLPArtifact> getSolutionRevisionArtifacts(
+               String theSolutionId, String theRevisionId, ServiceContext theContext) {
+               
+               log.debug(EELFLoggerDelegate.debugLogger, "getSolutionRevisionArtifacts");
+               List<MLPArtifact> mlpArtifacts = new ArrayList<>();
                FederationDataClient commonDataClient = getCommonDataClient();
                FederationDataClient commonDataClient = getCommonDataClient();
-               Iterable<MLPArtifact> iterable = commonDataClient.getSolutionRevisionArtifacts(solutionId, revisionId);
-               for (MLPArtifact mlpArtifact : iterable) {
-                       mlpSolutionRevisions.add(mlpArtifact);
+               Iterable<MLPArtifact> artifacts = commonDataClient.getSolutionRevisionArtifacts(theSolutionId, theRevisionId);
+               for (MLPArtifact mlpArtifact : artifacts) {
+                       mlpArtifacts.add(mlpArtifact);
                }
                }
-               return mlpSolutionRevisions;
+               return mlpArtifacts;
        }
 
        @Override
        }
 
        @Override
-       public InputStreamResource getPeerSolutionArtifactFile(String artifactId) {
+       public InputStreamResource getSolutionRevisionArtifactContent(
+               String theArtifactId, ServiceContext theContext) {
+
                InputStreamResource streamResource = null;
                ByteArrayOutputStream byteArrayOutputStream  = null;
                try{
                InputStreamResource streamResource = null;
                ByteArrayOutputStream byteArrayOutputStream  = null;
                try{
-                       ICommonDataServiceRestClient dataServiceRestClient = getClient();
-                       MLPArtifact mlpArtifact = dataServiceRestClient.getArtifact(artifactId);
-                       
+                       ICommonDataServiceRestClient cdsClient = getClient();
+                       MLPArtifact mlpArtifact = cdsClient.getArtifact(theArtifactId);
                        
                        String path = Utils.getTempFolderPath(mlpArtifact.getName(), mlpArtifact.getVersion(), env.getProperty("nexus.tempFolder", ""));
                        
                        
                        String path = Utils.getTempFolderPath(mlpArtifact.getName(), mlpArtifact.getVersion(), env.getProperty("nexus.tempFolder", ""));
                        
@@ -173,7 +201,7 @@ public class FederationServiceImpl extends AbstractServiceImpl implements Federa
                        Utils.deletetTempFiles(path);
                        
                } catch (Exception e) {
                        Utils.deletetTempFiles(path);
                        
                } catch (Exception e) {
-                       log.error(EELFLoggerDelegate.errorLogger, "getPeerSolutionArtifactFile`", e);
+                       log.error(EELFLoggerDelegate.errorLogger, "getSolutionRevisionArtifactiContent", e);
                } 
                // TODO Auto-generated method stub
                return streamResource;
                } 
                // TODO Auto-generated method stub
                return streamResource;
@@ -48,7 +48,8 @@ import com.fasterxml.jackson.databind.ObjectReader;
 import org.apache.commons.io.FileUtils;
 
 import org.acumos.federation.gateway.config.EELFLoggerDelegate;
 import org.apache.commons.io.FileUtils;
 
 import org.acumos.federation.gateway.config.EELFLoggerDelegate;
-import org.acumos.federation.gateway.service.FederationService;
+import org.acumos.federation.gateway.service.CatalogService;
+import org.acumos.federation.gateway.service.ServiceContext;
 import org.acumos.federation.gateway.util.Utils;
 import org.acumos.federation.gateway.util.LocalWatchService;
 import org.acumos.federation.gateway.common.AdapterCondition;
 import org.acumos.federation.gateway.util.Utils;
 import org.acumos.federation.gateway.util.LocalWatchService;
 import org.acumos.federation.gateway.common.AdapterCondition;
@@ -76,8 +77,8 @@ import org.acumos.cds.transport.RestPageResponse;
 @Service
 @ConfigurationProperties(prefix="catalogLocal")
 @Conditional(AdapterCondition.class)
 @Service
 @ConfigurationProperties(prefix="catalogLocal")
 @Conditional(AdapterCondition.class)
-public class FederationServiceLocalImpl extends AbstractServiceLocalImpl
-                                                                                                                                                                implements FederationService {
+public class CatalogServiceLocalImpl extends AbstractServiceLocalImpl
+                                                                                                                                                implements CatalogService {
 
        private List<FLPSolution>                                       solutions;
 
 
        private List<FLPSolution>                                       solutions;
 
@@ -98,7 +99,7 @@ public class FederationServiceLocalImpl extends AbstractServiceLocalImpl
                loadSolutionsCatalogInfo();
 
     // Done
                loadSolutionsCatalogInfo();
 
     // Done
-    log.debug(EELFLoggerDelegate.debugLogger, "Local FederationService available");
+    log.debug(EELFLoggerDelegate.debugLogger, "Local CatalogService available");
        }
 
        @PreDestroy
        }
 
        @PreDestroy
@@ -122,17 +123,12 @@ public class FederationServiceLocalImpl extends AbstractServiceLocalImpl
                }
        }
 
                }
        }
 
-       /**
-        */
-       @Override
-       public RestPageResponse<MLPSolution>  getPeerCatalogSolutions(Integer pageNumber, Integer maxSize, String sortingOrder,
-                       List<String> mlpModelTypes) {
-               return null;
-       }
 
        @Override
 
        @Override
-       public List<MLPSolution> getPeerCatalogSolutionsList(String mlpModelTypes) {
-               log.debug(EELFLoggerDelegate.debugLogger, "getPeerCatalogSolutionsList");
+       public List<MLPSolution> getSolutions(
+               String mlpModelTypes, ServiceContext theContext) {
+
+               log.debug(EELFLoggerDelegate.debugLogger, "getSolutions");
                final List<String> modelTypes =
                        mlpModelTypes == null ? null : Arrays.asList(mlpModelTypes.split(","));
                return solutions.stream()
                final List<String> modelTypes =
                        mlpModelTypes == null ? null : Arrays.asList(mlpModelTypes.split(","));
                return solutions.stream()
@@ -144,11 +140,24 @@ public class FederationServiceLocalImpl extends AbstractServiceLocalImpl
                                                        .collect(Collectors.toList());
        }
 
                                                        .collect(Collectors.toList());
        }
 
+       @Override
+       public MLPSolution getSolution(
+               final String theSolutionId, ServiceContext theContext) {
+
+               log.debug(EELFLoggerDelegate.debugLogger, "getSolution");
+               return solutions.stream()
+                                                       .filter(solution -> {
+                                                                                               return theSolutionId.equals(solution.getSolutionId());
+                                                                                       })
+                                                       .findFirst()
+                                                       .orElse(null);
+       }
        
        @Override
        
        @Override
-       public List<MLPSolutionRevision> getPeerCatalogSolutionRevision(
-                                                                                                                                                                       final String theSolutionId) {
-               log.debug(EELFLoggerDelegate.debugLogger, "getPeerCatalogSolutionRevision`");
+       public List<MLPSolutionRevision> getSolutionRevisions(
+               final String theSolutionId, ServiceContext theContext) {
+
+               log.debug(EELFLoggerDelegate.debugLogger, "getSolutionRevisions");
                FLPSolution solution =
                                                this.solutions.stream()
                                                        .filter(sol ->
                FLPSolution solution =
                                                this.solutions.stream()
                                                        .filter(sol ->
@@ -158,35 +167,42 @@ public class FederationServiceLocalImpl extends AbstractServiceLocalImpl
                
                return (solution == null) ? null : solution.getMLPRevisions();
        }
                
                return (solution == null) ? null : solution.getMLPRevisions();
        }
-
+       
        @Override
        @Override
-       public List<MLPArtifact> getPeerSolutionArtifacts(
-                                                                                                                                                                               final String theSolutionId,
-                                                                                                                                                                               final String theRevisionId) {
-               log.debug(EELFLoggerDelegate.debugLogger, "getPeerSolutionArtifacts`");
-               FLPSolution solution =
-                                                this.solutions.stream()
-                                                       .filter(sol ->
-                                                                                               sol.getSolutionId().equals(theSolutionId))
-                                                       .findFirst()
-                                                       .orElse(null);
+       public MLPSolutionRevision getSolutionRevision(
+               String theSolutionId, String theRevisionId, ServiceContext theContext) {
+
+               log.debug(EELFLoggerDelegate.debugLogger, "getSolutionRevision");
+               List<MLPSolutionRevision> revisions = getSolutionRevisions(theSolutionId, theContext);
 
 
-               if (solution == null)
+               if (revisions == null)
                        return null;
 
                        return null;
 
-               FLPRevision revision = 
-                       solution.getRevisions().stream()
+               return revisions.stream()
                                                        .filter(rev ->
                                                                                                rev.getRevisionId().equals(theRevisionId))
                                                        .findFirst()
                                                        .orElse(null);
                                                        .filter(rev ->
                                                                                                rev.getRevisionId().equals(theRevisionId))
                                                        .findFirst()
                                                        .orElse(null);
+       }
+
+       @Override
+       public List<MLPArtifact> getSolutionRevisionArtifacts(
+               final String theSolutionId,     final String theRevisionId, ServiceContext theContext) {
+               log.debug(EELFLoggerDelegate.debugLogger, "getSolutionRevisionArtifacts");
+
+               FLPRevision revision = (FLPRevision)
+                       getSolutionRevision(theSolutionId, theRevisionId, theContext);
 
                return (revision == null) ? null : revision.getArtifacts();
        }
 
        @Override
 
                return (revision == null) ? null : revision.getArtifacts();
        }
 
        @Override
-       public InputStreamResource getPeerSolutionArtifactFile(
-                                                                                                               final String theArtifactId) {
+       public InputStreamResource getSolutionRevisionArtifactContent(
+               String theArtifactId, ServiceContext theContext) {
+
+               log.debug(EELFLoggerDelegate.debugLogger, "getSolutionRevisionArtifactContent");
+               //difficult here as we only have the artifact id ..
+       
                return null;
        }
 
                return null;
        }
 
index 05d08c8..edd8394 100644 (file)
@@ -31,6 +31,7 @@ import java.util.Collections;
 import org.acumos.federation.gateway.common.GatewayCondition;
 import org.acumos.federation.gateway.config.EELFLoggerDelegate;
 import org.acumos.federation.gateway.service.PeerService;
 import org.acumos.federation.gateway.common.GatewayCondition;
 import org.acumos.federation.gateway.config.EELFLoggerDelegate;
 import org.acumos.federation.gateway.service.PeerService;
+import org.acumos.federation.gateway.service.ServiceContext;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.env.Environment;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.env.Environment;
@@ -66,6 +67,12 @@ public class PeerServiceImpl extends AbstractServiceImpl implements PeerService
                return mlpPeers;
        }
 
                return mlpPeers;
        }
 
+       @Override
+       public List<MLPPeer> getPeers(ServiceContext theContext) {
+               log.debug(EELFLoggerDelegate.debugLogger, "getPeers(ServiceContext)");
+               return getPeers();
+       }
+
        @Override
        public List<MLPPeer> getPeer(String subjectName) {
                log.debug(EELFLoggerDelegate.debugLogger, "savePeer");
        @Override
        public List<MLPPeer> getPeer(String subjectName) {
                log.debug(EELFLoggerDelegate.debugLogger, "savePeer");
index 53abc8c..a5a503e 100644 (file)
@@ -58,6 +58,7 @@ import org.acumos.federation.gateway.util.LocalWatchService;
 import org.acumos.federation.gateway.common.AdapterCondition;
 import org.acumos.federation.gateway.config.EELFLoggerDelegate;
 import org.acumos.federation.gateway.service.PeerService;
 import org.acumos.federation.gateway.common.AdapterCondition;
 import org.acumos.federation.gateway.config.EELFLoggerDelegate;
 import org.acumos.federation.gateway.service.PeerService;
+import org.acumos.federation.gateway.service.ServiceContext;
 import org.acumos.federation.gateway.service.PeerSubscriptionService;
 
 import org.acumos.cds.domain.MLPPeer;
 import org.acumos.federation.gateway.service.PeerSubscriptionService;
 
 import org.acumos.cds.domain.MLPPeer;
@@ -126,7 +127,12 @@ public class PeerServiceLocalImpl
                                                                                                                                                .collect(Collectors.toList());
                }
        }
                                                                                                                                                .collect(Collectors.toList());
                }
        }
-       
+
+       /** */
+       public List<MLPPeer> getPeers(ServiceContext theContext) {
+               return getPeers();      
+       }
+
        /** */
        public List<MLPPeer> getPeer(final String theSubjectName) {
                log.info(EELFLoggerDelegate.debugLogger, "Looking for peer " + theSubjectName);
        /** */
        public List<MLPPeer> getPeer(final String theSubjectName) {
                log.info(EELFLoggerDelegate.debugLogger, "Looking for peer " + theSubjectName);
index c10fc46..cafbbaf 100644 (file)
@@ -52,6 +52,7 @@ import org.acumos.federation.gateway.common.JsonResponse;
 import org.acumos.federation.gateway.common.HttpClientConfigurationBuilder;
 import static org.acumos.federation.gateway.common.HttpClientConfigurationBuilder.SSLBuilder;
 
 import org.acumos.federation.gateway.common.HttpClientConfigurationBuilder;
 import static org.acumos.federation.gateway.common.HttpClientConfigurationBuilder.SSLBuilder;
 
+import org.acumos.cds.domain.MLPPeer;
 import org.acumos.cds.domain.MLPSolution;
 import org.acumos.cds.domain.MLPSolutionRevision;
 import org.acumos.cds.domain.MLPArtifact;
 import org.acumos.cds.domain.MLPSolution;
 import org.acumos.cds.domain.MLPSolutionRevision;
 import org.acumos.cds.domain.MLPArtifact;
@@ -104,7 +105,7 @@ public class PeerGatewayTest {
                assertTrue(response.getBody().getResponseBody().size() == 1);
        }
 
                assertTrue(response.getBody().getResponseBody().size() == 1);
        }
 
-/*
+
        @Test
        public void testSolutionSuccess() {
 
        @Test
        public void testSolutionSuccess() {
 
@@ -124,7 +125,7 @@ public class PeerGatewayTest {
                assertTrue(response.getStatusCodeValue() == 200);
                assertTrue(response.getBody().getResponseBody().getModelTypeCode().equals("CL")); //no errors
        }
                assertTrue(response.getStatusCodeValue() == 200);
                assertTrue(response.getBody().getResponseBody().getModelTypeCode().equals("CL")); //no errors
        }
-*/
+
        @Test
        public void testSolutionRevisionsSuccess() {
     
        @Test
        public void testSolutionRevisionsSuccess() {
     
@@ -145,6 +146,26 @@ public class PeerGatewayTest {
                assertTrue(response.getBody().getResponseBody().size() == 1); //no errors
        }
 
                assertTrue(response.getBody().getResponseBody().size() == 1); //no errors
        }
 
+       @Test
+       public void testSolutionRevisionSuccess() {
+
+    ((HttpComponentsClientHttpRequestFactory)
+                       this.restTemplate.getRestTemplate().getRequestFactory())
+                               .setHttpClient(prepareHttpClient());
+
+               ResponseEntity<JsonResponse<MLPSolution>> response =
+                       this.restTemplate.exchange("/solutions/00000000-0000-0000-0000-000000000000/revisions/01010101-0101-0101-0101-010101010101", HttpMethod.GET, prepareRequest(), new ParameterizedTypeReference<JsonResponse<MLPSolution>>() {} );
+       
+               if (response != null)   {
+                       System.out.println("testSolution: " + response.getBody());
+                       System.out.println("testSolution: " + response);
+               }
+
+               assertTrue(response != null);
+               assertTrue(response.getStatusCodeValue() == 200);
+               assertTrue(response.getBody().getResponseBody().getOwnerId().equals("admin")); //no errors
+       }
+
        @Test
        public void testSolutionRevisionArtifactsSuccess() {
     
        @Test
        public void testSolutionRevisionArtifactsSuccess() {
     
@@ -153,7 +174,7 @@ public class PeerGatewayTest {
                                .setHttpClient(prepareHttpClient());
 
                ResponseEntity<JsonResponse<List<MLPArtifact>>> response =
                                .setHttpClient(prepareHttpClient());
 
                ResponseEntity<JsonResponse<List<MLPArtifact>>> response =
-                       this.restTemplate.exchange("/solutions/00000000-0000-0000-0000-000000000000/revisions/01010101-0101-0101-0101-010101010101", HttpMethod.GET, prepareRequest(), new ParameterizedTypeReference<JsonResponse<List<MLPArtifact>>>() {});
+                       this.restTemplate.exchange("/solutions/00000000-0000-0000-0000-000000000000/revisions/01010101-0101-0101-0101-010101010101/artifacts", HttpMethod.GET, prepareRequest(), new ParameterizedTypeReference<JsonResponse<List<MLPArtifact>>>() {});
                
                if (response != null)   {
                        System.out.println("testSolutionRevisionsArtifacts: " + response.getBody());
                
                if (response != null)   {
                        System.out.println("testSolutionRevisionsArtifacts: " + response.getBody());
@@ -165,6 +186,24 @@ public class PeerGatewayTest {
                assertTrue(response.getBody().getResponseBody().size() == 1); //no errors
        }
 
                assertTrue(response.getBody().getResponseBody().size() == 1); //no errors
        }
 
+       @Test
+       public void testPeersForbidden() {
+
+    ((HttpComponentsClientHttpRequestFactory)
+                       this.restTemplate.getRestTemplate().getRequestFactory())
+                               .setHttpClient(prepareHttpClient());
+
+               ResponseEntity<JsonResponse<List<MLPPeer>>> response =
+                       this.restTemplate.exchange("/peers", HttpMethod.GET, prepareRequest(), new ParameterizedTypeReference<JsonResponse<List<MLPPeer>>>() {} );
+       
+               if (response != null)   {
+                       System.out.println("testPeers: " + response.getBody());
+                       System.out.println("testPeers: " + response);
+               }
+
+               assertTrue(response.getStatusCodeValue() == 403);
+       }
+
        private HttpEntity prepareRequest(String theResourceName) {
                String content = new Scanner(
                                                                           Thread.currentThread().getContextClassLoader().getResourceAsStream(theResourceName), "UTF-8")
        private HttpEntity prepareRequest(String theResourceName) {
                String content = new Scanner(
                                                                           Thread.currentThread().getContextClassLoader().getResourceAsStream(theResourceName), "UTF-8")
index 9770a0f..dadcbc8 100644 (file)
@@ -16,7 +16,7 @@
                "description":"acumosb",
     "active": "true",
     "self": "false",
                "description":"acumosb",
     "active": "true",
     "self": "false",
-               "apiUrl":"https://localhost:9002",
+               "apiUrl":"https://gateway.acumosb.org:9002",
                "subscriptions":[
                        {
         "subId":1,
                "subscriptions":[
                        {
         "subId":1,
index e24ae09..1e90b21 100644 (file)
@@ -15,7 +15,7 @@
                "description":"acumosa",
                "active":"true",
     "self":"false",
                "description":"acumosa",
                "active":"true",
     "self":"false",
-               "apiUrl":"https://localhost:9001",
+               "apiUrl":"https://gateway.acumosa.org:9001",
                "subscriptions":[
                        {
                                "subId":1,
                "subscriptions":[
                        {
                                "subId":1,
index dd9eec4..ccbd3f4 100644 (file)
@@ -5,7 +5,7 @@ server.ssl.key-store-type = PKCS12
 server.ssl.key-password = acumosa
 server.ssl.trust-store = src/test/resources/acumosTrustStore.jks
 server.ssl.trust-store-password = acumos
 server.ssl.key-password = acumosa
 server.ssl.trust-store = src/test/resources/acumosTrustStore.jks
 server.ssl.trust-store-password = acumos
-server.ssl.client-auth = want
+server.ssl.client-auth = need
 
 client.ssl.key-store = file:///{path_to_src}/acumos/federation/gateway/src/test/resources/acumosa.pkcs12
 client.ssl.key-store-password = acumosa
 
 client.ssl.key-store = file:///{path_to_src}/acumos/federation/gateway/src/test/resources/acumosa.pkcs12
 client.ssl.key-store-password = acumosa
@@ -17,5 +17,5 @@ federation.instance=adapter
 federation.instance.name=ghost
 
 #replace 
 federation.instance.name=ghost
 
 #replace 
-peersLocal.sourceUri=file:///{path_to_src}/acumos/federation/gateway/src/test/resources/acumosa-peers.json
-catalogLocal.catalogUri=file:///{path_to_src}acumos/federation/gateway/src/test/resources/acumosa-catalog.json
+peersLocal.source=file:///{path_to_src}/acumos/federation/gateway/src/test/resources/acumosa-peers.json
+catalogLocal.source=file:///{path_to_src}acumos/federation/gateway/src/test/resources/acumosa-catalog.json
diff --git a/gateway/src/test/resources/docker-compose-test.yml b/gateway/src/test/resources/docker-compose-test.yml
new file mode 100644 (file)
index 0000000..d3a1f9c
--- /dev/null
@@ -0,0 +1,110 @@
+version: '2.0'
+services:
+  gateway.acumosa.org:
+    container_name: acumosa
+    image: federation-gateway-test:latest
+    environment:
+      SPRING_APPLICATION_JSON: '{
+        "server" : {
+          "port" : 9001,
+          "ssl" : {
+            "key-store" : "acumosa.pkcs12",
+            "key-store-password" : "acumosa",
+            "key-store-type" : "PKCS12",
+            "key-password" : "acumosa",
+            "trust-store" : "acumosTrustStore.jks",
+            "trust-store-password" : "acumos",
+            "client-auth" : "need"
+          }
+        },
+        "client" : {
+          "ssl" : {
+            "key-store" : "classpath:/acumosa.pkcs12",
+            "key-store-password" : "acumosa",
+            "key-store-type" : "PKCS12",
+            "key-password" : "acumosa"
+          }
+        },
+        "spring": {
+          "profiles": {
+            "active": "gateway"
+          }
+        },
+        "peer": {
+          "jobchecker": {
+            "interval": 300
+          }
+        },
+        "federation" : {
+          "instance" : "adapter",
+          "instance.name": "ghost",
+          "operator" : "anonymous"
+        },
+        "peersLocal" : {
+          "source" : "classpath:/acumosa-peers.json"
+        },
+        "catalogLocal" : {
+          "source" : "classpath:/acumosa-catalog.json"
+        }
+      }'
+    expose:
+      - "9001"
+    ports:
+      - "9001:9001"
+    logging:
+      driver: json-file
+
+  gateway.acumosb.org:
+    container_name: acumosb
+    image: federation-gateway-test:latest
+    environment:
+      SPRING_APPLICATION_JSON: '{
+        "server" : {
+          "port" : 9002,
+          "ssl" : {
+            "key-store" : "acumosb.pkcs12",
+            "key-store-password" : "acumosb",
+            "key-store-type" : "PKCS12",
+            "key-password" : "acumosb",
+            "trust-store" : "acumosTrustStore.jks",
+            "trust-store-password" : "acumos",
+            "client-auth" : "need"
+          }
+        },
+        "client" : {
+          "ssl" : {
+            "key-store" : "classpath:/acumosb.pkcs12",
+            "key-store-password" : "acumosb",
+            "key-store-type" : "PKCS12",
+            "key-password" : "acumosb"
+          }
+        },
+        "spring": {
+          "profiles": {
+            "active": "gateway"
+          }
+        },
+        "peer": {
+          "jobchecker": {
+            "interval": 300
+          }
+        },
+        "federation" : {
+          "instance" : "adapter",
+          "instance.name": "ghost",
+          "operator" : "anonymous"
+        },
+        "peersLocal" : {
+          "source" : "classpath:/acumosb-peers.json"
+        },
+        "catalogLocal" : {
+          "source" : "classpath:/acumosb-catalog.json"
+        }
+      }'
+    expose:
+      - "9002"
+    ports:
+      - "9002:9002"
+    logging:
+      driver: json-file
+
diff --git a/gateway/src/test/resources/docker-compose.yml b/gateway/src/test/resources/docker-compose.yml
new file mode 100644 (file)
index 0000000..6770c06
--- /dev/null
@@ -0,0 +1,64 @@
+version: '2.0'
+services:
+  federation:
+    container_name: federation-gateway
+    image: federation-gateway:latest
+    environment:
+      SPRING_APPLICATION_JSON: '{
+        "server" : {
+          "port" : 9084,
+          "ssl" : {
+            "key-store" : "ist-acumosa.pkcs12",
+            "key-store-password" : "acumosa",
+            "key-store-type" : "PKCS12",
+            "key-password" : "acumosa",
+            "trust-store" : "acumosTrustStore.jks",
+            "trust-store-password" : "acumos",
+            "client-auth" : "need"
+          }
+        },
+        "client" : {
+          "ssl" : {
+            "key-store" : "file:///ist-acumosa.pkcs12",
+            "key-store-password" : "acumosa",
+            "key-store-type" : "PKCS12",
+            "key-password" : "acumosa"
+          }
+        },
+        "nexus": {
+          "url": "http://cognita-nexus01.eastus.cloudapp.azure.com:8081/repository/repo_cognita_model_maven/",
+          "proxy": "",
+          "password": "not4you",
+          "username": "cognita_model_rw",
+          "groupid": "com.artifact"
+        },
+        "spring": {
+          "profiles": {
+            "active": "gateway"
+          }
+        },
+        "peer": {
+          "jobchecker": {
+            "interval": 300
+          }
+        },
+        "federation" : {
+          "instance" : "gateway",
+          "instance.name": "ATT",
+          "operator" : "d468656f-57d0-46e3-9f94-7ffa4f66dc03"
+        },
+        "cdms" : {
+          "client" : {
+            "url": "http://mlp-cmn-data-svc:8000/ccds",
+            "username": "ccds_client",
+            "password": "ccds_client"
+          }
+        }
+      }'
+    expose:
+      - "9084"
+    ports:
+      - "9084:9084"
+    logging:
+      driver: json-file
+