Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions toolbox/fdc3-appd-java/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# FDC3 APP Directory Reference Implementation - Java + Springboot

An application directory (appD) is a structured repository of information about apps that can be used in an FDC3-enabled desktop(more info [here](https://fdc3.finos.org)). In other words, it’s a convenient way of storing and managing metadata about apps in your ecosystem.

The application metadata stored in appD records may include: the app name, type, details about how to run the application, its icons, publisher, support contact details and so on. It may also include links to or embed manifest formats defined elsewhere, such as proprietary manifests for launching the app in a container product or a Web Application Manifest (as defined by the W3C).

All this information is readily available in one place and can be used both to populate a launcher or app catalog UI for your users, and by the Desktop Agent managing the apps on your desktop. In fact, if your desktop platform supports the FDC3 standard, appD is the primary way that the FDC3 Desktop Agent implementation should receive the details about apps available to run on your desktop. Conversely, if an app is not listed in appD, the Desktop Agent can’t ensure its participation in context sharing or use it to resolve intents.

## Foreword

This is a reference implementation for app Directory implemented in Java and springboot.

The implementation is packaged with a sample App Directory JSON (src/main/resources/local.v2.json) to demo the functional APIs out of he bix We have also configured a sample user base to demo the authorization and authentication. The details for exeuting the API end points are given below.


## Try out on local machine

> Note : Required Java Version 17+.

1. Clone the repository to your local machine

> mkdir FDC3
>
> cd FDC3
>
> git clone https://github.com/amanjmd/FINOS.git
>

2. Install the Dependencies

> cd FINOS/fdc3-app-directory-java
>
> mvn clean install

3. Run the application

>java -jar target/*.jar
>

# Test the application
>curl --location 'http://localhost:8080/v2/apps' \
>
>--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiYWxpY2UifQ.2cfycMS2ZZlROOrhG23Dz8fxnq2AnW4dspC3agP2MMo' \
>
>--data ''


### API End points implemented
1. /v2/apps
2. /v2/apps/{appId}


# Key Demos

## Support for multiple Datasources
This is implementation by default implementation for the JSON datasource .
It can be further extended using the "V2ApplicationReader" to provide the custom implementation for other datasources like releational , NoSQL etc.

## Support for authentication/ authorization

This implementaiton further includes a simpler implementation of authentication and authorization . Here in , there are 2 valid users "alice", "bob" (user_db.json).

To run this application in local , we would require the JWT tokens . Below are the tokens for Alice and Bob , which needs to be sent in "Authorization" header.

> Alice : Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjoiYWxpY2UiLCJyb2xlIjoicG9ydGZvbGlvLW1hbmFnZXIifQ.iJk3t2bUjWQJ-CNaJ4dzzJ5AQfcjpb8oxq0epX9G8cg
>
> Bob : Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjoiYm9iIiwicm9sZSI6ImVxdWl0eS1zZWxsLXRyYWRlciJ9.NLfQbFWUrOtiHEe_FpMsB3TK-DtJgLJdBrHwVNGbbIw
>
> Key to generate token : mIU3RoraRfc8TF3ScboaF8lcQF0nb5gb
>
>
Note : In the enterprise implementation , there would be an IAM services in place to generate the token.Hence the UserManagementService can be modified accordingly.







Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/mvnw text eol=lf
*.cmd text eol=crlf
33 changes: 33 additions & 0 deletions toolbox/fdc3-appd-java/fdc3-app-directory-java/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
wrapperVersion=3.3.2
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
225 changes: 225 additions & 0 deletions toolbox/fdc3-appd-java/fdc3-app-directory-java/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.4.0-SNAPSHOT</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.fdc</groupId>
<artifactId>appd</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>fdc3-app-directory-java-spring</name>
<description>Java Spring boot implementation for App Directory with FDC3 Specs</description>
<url/>
<licenses>
<license/>
</licenses>
<developers>
<developer/>
</developers>
<scm>
<connection/>
<developerConnection/>
<tag/>
<url/>
</scm>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>

<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.15</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>0.11.5</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>0.11.5</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>0.11.5</version>
<scope>runtime</scope>
</dependency>


<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/io.swagger.core.v3/swagger-annotations -->
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
<version>2.2.25</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.validation/validation-api -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/jakarta.validation/jakarta.validation-api -->
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>3.0.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openapitools/jackson-databind-nullable -->
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>0.2.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.annotation/javax.annotation-api -->
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>

<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>0.11.5</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>0.11.5</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>0.11.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.18.1</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- <plugin>-->
<!-- <groupId>org.openapitools</groupId>-->
<!-- <artifactId>openapi-generator-maven-plugin</artifactId>-->
<!-- <version>7.8.0</version>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <goals>-->
<!-- <goal>generate</goal>-->
<!-- </goals>-->
<!-- <configuration>-->
<!-- <inputSpec>-->
<!-- ${project.basedir}/src/main/resources/app-directory-schema-2.0.yml-->
<!-- </inputSpec>-->
<!-- <generatorName>spring</generatorName>-->
<!-- <apiPackage>com.fdc.appd</apiPackage>-->
<!-- <modelPackage>com.fdc.appd.model</modelPackage>-->
<!-- <supportingFilesToGenerate>-->
<!-- ApiUtil.java-->
<!-- </supportingFilesToGenerate>-->
<!-- <configOptions>-->

<!-- <sourceFolder>test</sourceFolder>-->
<!--&lt;!&ndash; <interfaceOnly>true</interfaceOnly>&ndash;&gt;-->
<!--&lt;!&ndash; <skipDefaultInterface>true</skipDefaultInterface>&ndash;&gt;-->
<!--&lt;!&ndash; <useBeanValidation>true</useBeanValidation>&ndash;&gt;-->
<!--&lt;!&ndash; <useTags>true</useTags>&ndash;&gt;-->
<!-- <useSpringBoot3>true</useSpringBoot3>-->
<!-- <dateLibrary>java8</dateLibrary>-->
<!-- <delegatePattern>true</delegatePattern>-->
<!-- &lt;!&ndash; <useOpenApiNullable>false</useOpenApiNullable>&ndash;&gt;-->
<!-- &lt;!&ndash; <openApiNullable>false</openApiNullable>&ndash;&gt;-->
<!-- </configOptions>-->

<!-- </configuration>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>

<pluginRepositories>

<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
</pluginRepository>
</pluginRepositories>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.fdc.appd;


import org.springframework.web.context.request.NativeWebRequest;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class ApiUtil {
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
try {
HttpServletResponse res = req.getNativeResponse(HttpServletResponse.class);
res.setCharacterEncoding("UTF-8");
res.addHeader("Content-Type", contentType);
res.getWriter().print(example);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
Loading