Skip to content

Commit

Permalink
ci(monorepo): monorepo jans notify (#234)
Browse files Browse the repository at this point in the history
* Initial commit

* Initial version

* Init Weld and Resteasy

* Update configuration. Allow to create pooled client

* Laod config at startup

* Init clients at startup

* Add AWS region

* Branch for 3.1.1

* JSON serialization fixes

* JSON serialization fixes

* Use .well-known url for oxNotify metadata configuration

* Remove old web.xml

* Remove old web.xml

* Fix device registration comment

* Add oxnotify-client2 for 2.4.4

* Fix device registration comment

* Add oxnotify-client2 for 2.4.4

* Use .well-known url for oxNotify metadata configuration

* Remove test files

* Remove test files

* Fix client2 version

* Use commons Base64 encoder for java 1.7

* Use commons Base64 encoder for java 1.7

* Add workaround for old apache PoolingHttpClientConnectionManager

* Add workaround for old apache PoolingHttpClientConnectionManager

* Final oxnotify version

* Final oxnotify version

* Remove log4j dependency in clients

* Remove log4j dependency in clients

* Version 3.1.1.Final

* Branch for 3.1.2

* Fix typo in method name

* Fix typo in method name

* Store clientId/clientIp in custom user data

* Store clientId/clientIp in custom user data

* Return already added device endpoint instead of throwing error

* Return already added device endpoint instead of throwing error

* Add debug to update custom user data method

* Fix custom user data update

* Try to fix updata data method

* Fix update custom user data

* Fix HTTP code when server update user custom data

* Update version number

* Try to re-enable user endpoint #3

* Dump enpoint before re-enabling it

* Try to upgrade AWS sdk

* Fix typo in set endpoint attribute

* Version 4.0.0

* Change org.xdi -> org.gluu oxCore #58

* Try to add Jackson 1 annotation to fix metadata

* Try to add Jackson 1 annotation to fix metadata

* Use resteasy-jackson2-provider

* Update jackson2 library

* Provides notifyEndpoint instead of notify_endpoint for 3.1.6

* Exclude bind api

* Revert "Exclude bind api"

This reverts commit 89590d1.

* Update jackson to latest version

* Update jacksdon libs ad weld configs

* Update jackson-databind

* Update jackson-databind

* oxnotify : jackson-databind 2.9.9.1 -> 2.9.9.2

* Branch for version 4.1

* Update jackson-databind

* Branch for version 4.2

* Update libs

* Use gluu-core-bom

* Branch for version 4.3

* Branch for version 5.0

* Fix update user custom data if current entry is empty

* Custom user data should be less than 2K

* Dump user data before removal

* Fix typo in log record

* Update README.md

* Renamed `org.gluu -> org.janssen`. `oxnotify -> janssen-notify`

* Renaming maven artifacts org.janssen -> io.jans

* Fixing imports.

* Renamed package org.gluu -> io.jans

* Added -parent suffix to parent pom.xml

* Updated dependencies to latest bom

* Added jans- prefix to artifact names.

* Use janssen version

* Fix license, properties and conform jans project

* Use gluu.base to find jans.properties location

* Update README.md

* Define health check endpoint

* Changed version 5.0.0-SNAPSHOT -> 1.0.0-SNAPSHOT

* Use jans repo

* docs(codacy): Add badge

* ci(commit-check): Add commit reporter

* ci(commit-check): show details in commit

* ci(commit-check): check all branches

* ci(workflows): sync workflows

* ci(workflows): sync workflows

* ci(workflows): sync workflows

* ci(workflows): sync workflows

* ci(workflows): sync workflows

* ci(workflows): sync workflows

* ci: add interation with JaCoCo and Sonarcloud

* fix: use the correct project name

* fix: remove Sonar workflow file

After review, it was decided to have a central workflow file.
This is approach is more maintainable than having separate
workflow file for each repository.
Hence, removing individual workflow file from this repo so
that common workflow file can take its place.

* ci(workflows): sync workflows

* ci(workflows): sync workflows

* ci(workflows): sync workflows

* ci(workflows): sync central workflows

Signed-off-by: mo-auto <54212639+mo-auto@users.noreply.github.com>

* ci(workflows): sync central workflows

Signed-off-by: mo-auto <54212639+mo-auto@users.noreply.github.com>

* ci: fix version

* ci(workflows): sync central workflows

Signed-off-by: mo-auto <54212639+mo-auto@users.noreply.github.com>

* ci(workflows): sync central workflows

Signed-off-by: mo-auto <54212639+mo-auto@users.noreply.github.com>

* ci(workflows): sync central workflows

Signed-off-by: mo-auto <54212639+mo-auto@users.noreply.github.com>

* ci(workflows): sync central workflows

Signed-off-by: mo-auto <54212639+mo-auto@users.noreply.github.com>

* ci(workflows): sync central workflows

Signed-off-by: mo-auto <54212639+mo-auto@users.noreply.github.com>

* ci(workflows): sync central workflows

Signed-off-by: mo-auto <54212639+mo-auto@users.noreply.github.com>

* ci(workflows): sync central workflows

Signed-off-by: mo-auto <54212639+mo-auto@users.noreply.github.com>

* chore: update resteasy

* ci(workflows): sync central workflows

Signed-off-by: mo-auto <54212639+mo-auto@users.noreply.github.com>

* ci(workflows): sync central workflows

Signed-off-by: mo-auto <54212639+mo-auto@users.noreply.github.com>

* ci(monorepo): prepare jans-notify

* ci(codeowners): remove unnecessary files

Co-authored-by: Yuriy Movchan <Yuriy.Movchan@gmail.com>
Co-authored-by: YuriyZ <yzabrovarniy@gmail.com>
Co-authored-by: HemantKMehta <70174684+HemantKMehta@users.noreply.github.com>
Co-authored-by: Sync bot <54212639+mo-auto@users.noreply.github.com>
Co-authored-by: ossdhaval <ossdhaval@outlook.com>
Co-authored-by: ossdhaval <343411+ossdhaval@users.noreply.github.com>
  • Loading branch information
7 people authored Jan 13, 2022
1 parent f6ce3a2 commit a7d2476
Show file tree
Hide file tree
Showing 53 changed files with 2,654 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
/docker-jans-*/requirments.txt @mo-auto
/jans-bom/ @yurem @yuriyz
/jans-core/ @yurem @yuriyz
/jans-orm/ @yurem @yuriyz
/jans-orm/ @yurem @yuriyz
/jans-notify/ @yurem
8 changes: 0 additions & 8 deletions .github/JANNSEN_CODEOWNERS/jans-notify_CODEOWNERS

This file was deleted.

1 change: 0 additions & 1 deletion .github/workflows/central_code_quality_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ jobs:
JanssenProject/jans-client-api
JanssenProject/jans-scim
JanssenProject/jans-core
JanssenProject/jans-notify
JanssenProject/jans-fido2
JanssenProject/jans-eleven
NON_JVM_PROJECTS: |
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/central_sync_workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ jobs:
JanssenProject/jans-core
JanssenProject/jans-eleven
JanssenProject/jans-fido2
JanssenProject/jans-notify
JanssenProject/jans-scim
JanssenProject/jans-setup
WORKFLOW_FILES: |
Expand Down
32 changes: 32 additions & 0 deletions jans-notify/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# IntelliJ IDEA project files
.idea
*.iml
.classpath
.project

# Maven
target
.settings/
21 changes: 21 additions & 0 deletions jans-notify/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Gluu

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
4 changes: 4 additions & 0 deletions jans-notify/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/a15caeadce644612b70f095af6b97934)](https://www.codacy.com/gh/JanssenProject/jans-notify/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=JanssenProject/jans-notify&amp;utm_campaign=Badge_Grade)

# Jansssen Notify
Janssen Notify is a simple push notification server.
33 changes: 33 additions & 0 deletions jans-notify/client/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>
<artifactId>jans-notify-client</artifactId>
<name>notify Client</name>
<packaging>jar</packaging>

<parent>
<artifactId>jans-notify-parent</artifactId>
<groupId>io.jans</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<dependencies>
<!-- jans -->
<dependency>
<groupId>io.jans</groupId>
<artifactId>jans-notify-model</artifactId>
</dependency>

<!-- Resteasy -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson2-provider</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text.
*
* Copyright (c) 2020, Janssen Project
*/

package io.jans.notify.client;

import io.jans.notify.model.NotifyMetadata;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.jboss.resteasy.client.jaxrs.ResteasyClient;
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget;
import org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient43Engine;

import javax.ws.rs.core.UriBuilder;
import java.util.Base64;

/**
* Helper class which creates proxy
*
* @author Yuriy Movchan
* @version September 15, 2017
*/
public class NotifyClientFactory {

private final static NotifyClientFactory instance = new NotifyClientFactory();
private ResteasyClient client;
private ResteasyClient pooledClient;

private NotifyClientFactory() {
// Create single connection client
this.client = ((ResteasyClientBuilder) ResteasyClientBuilder.newBuilder()).build();

// Create polled client
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
cm.setMaxTotal(200); // Increase max total connection to 200
cm.setDefaultMaxPerRoute(20); // Increase default max connection per route to 20

CloseableHttpClient httpClient = HttpClients.custom().setConnectionManager(cm).build();
ApacheHttpClient43Engine engine = new ApacheHttpClient43Engine(httpClient);

this.pooledClient = ((ResteasyClientBuilder) ResteasyClientBuilder.newBuilder()).httpEngine(engine).build();
}

public static NotifyClientFactory instance() {
return instance;
}

public NotifyMetadataClientService createMetaDataConfigurationService(String issuer) {
ResteasyWebTarget target = client.target(UriBuilder.fromPath(issuer + "/.well-known/notify-configuration"));
return target.proxy(NotifyMetadataClientService.class);
}

public NotifyClientService createNotifyService(NotifyMetadata notifyMetadata) {
ResteasyWebTarget target = pooledClient.target(UriBuilder.fromPath(notifyMetadata.getNotifyEndpoint()));
return target.proxy(NotifyClientService.class);
}

public static String getAuthorization(String accessKeyId, String secretAccessKey) {
String credentials = accessKeyId + ":" + secretAccessKey;
String authorization = "Basic " + Base64.getEncoder().encodeToString(credentials.getBytes());

return authorization;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text.
*
* Copyright (c) 2020, Janssen Project
*/

package io.jans.notify.client;

import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import io.jans.notify.model.NotificationResponse;
import io.jans.notify.model.RegisterDeviceResponse;

/**
* Notification endpoint allows to register device and send notification
*
* @author Yuriy Movchan
* @version September 15, 2017
*/
public interface NotifyClientService {

@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces({ MediaType.APPLICATION_JSON })
@Path("/register")
RegisterDeviceResponse registerDevice(@HeaderParam("Authorization") String authorization, @FormParam("token") String token,
@FormParam("user_data") String userData);

@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces({ MediaType.APPLICATION_JSON })
@Path("/notify")
NotificationResponse sendNotification(@HeaderParam("Authorization") String authorization, @FormParam("enpoint") String endpoint,
@FormParam("message") String message);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text.
*
* Copyright (c) 2020, Janssen Project
*/

package io.jans.notify.client;

import javax.ws.rs.GET;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import io.jans.notify.model.NotifyMetadata;

/**
* Metadata endpoint at which the requester can obtain Notify metadata
* configuration
*
* @author Yuriy Movchan
* @version September 15, 2017
*/
public interface NotifyMetadataClientService {

@GET
@Produces({ MediaType.APPLICATION_JSON })
public NotifyMetadata getMetadataConfiguration();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/dev/
50 changes: 50 additions & 0 deletions jans-notify/client2/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>
<artifactId>jans-notify-client2</artifactId>
<name>notify Client2</name>
<packaging>jar</packaging>

<parent>
<artifactId>jans-notify-parent</artifactId>
<groupId>io.jans</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<properties>
<httpcore.version>4.3.3</httpcore.version>
<httpclient.version>4.3.6</httpclient.version>
</properties>

<dependencies>
<!-- jans -->
<dependency>
<groupId>io.jans</groupId>
<artifactId>jans-notify-model</artifactId>
</dependency>

<!-- Net -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpclient.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>${httpcore.version}</version>
</dependency>

<!-- Resteasy -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson2-provider</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text.
*
* Copyright (c) 2020, Janssen Project
*/

package io.jans.notify.client;

import javax.ws.rs.core.UriBuilder;

import org.apache.commons.codec.binary.Base64;
import org.apache.http.conn.ssl.SSLContexts;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import io.jans.notify.model.NotifyMetadata;
import org.jboss.resteasy.client.jaxrs.ResteasyClient;
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget;
import org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient43Engine;
/**
* Helper class which creates proxy
*
* @author Yuriy Movchan
* @version September 15, 2017
*/
public class NotifyClientFactory {

private final static NotifyClientFactory instance = new NotifyClientFactory();

private ApacheHttpClient43Engine engine;

private NotifyClientFactory() {
// Create polled client
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
cm.setMaxTotal(200); // Increase max total connection to 200
cm.setDefaultMaxPerRoute(20); // Increase default max connection per route to 20

CloseableHttpClient httpClient = HttpClients.custom().setConnectionManager(cm).setSslcontext(SSLContexts.createSystemDefault()).build();

this.engine = new ApacheHttpClient43Engine(httpClient);
}

public static NotifyClientFactory instance() {
return instance;
}

public NotifyMetadataClientService createMetaDataConfigurationService(String issuer) {
ResteasyClient client = ((ResteasyClientBuilder) ResteasyClientBuilder.newBuilder()).httpEngine(engine).build();
String metadataUri = issuer + "/.well-known/notify-configuration";
ResteasyWebTarget target = client.target(UriBuilder.fromPath(metadataUri));

return target.proxy(NotifyMetadataClientService.class);
}

public NotifyClientService createNotifyService(NotifyMetadata notifyMetadata) {
ResteasyClient client = ((ResteasyClientBuilder) ResteasyClientBuilder.newBuilder()).httpEngine(engine).build();

String targetUri = notifyMetadata.getNotifyEndpoint();
ResteasyWebTarget target = client.target(UriBuilder.fromPath(targetUri));

return target.proxy(NotifyClientService.class);
}

public static String getAuthorization(String accessKeyId, String secretAccessKey) {
String credentials = accessKeyId + ":" + secretAccessKey;
String authorization = "Basic " + Base64.encodeBase64String(credentials.getBytes());

return authorization;
}

}
Loading

0 comments on commit a7d2476

Please sign in to comment.