Skip to content

Commit

Permalink
Merge pull request #52 from digipost/jakarta
Browse files Browse the repository at this point in the history
Use jakarta xml and java 11
  • Loading branch information
eivinhb authored Nov 30, 2023
2 parents da0ff4a + 5714476 commit f1a0659
Show file tree
Hide file tree
Showing 40 changed files with 278 additions and 173 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '8', '11' ]
java: [ '11', '17', '21' ]

name: build java ${{ matrix.java }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion .java-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.8
11.0
8 changes: 4 additions & 4 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Licensed under Apache 2 - http://www.apache.org/licenses/LICENSE-2.0.html

This software includes third party software subject to the following licenses:

Angus Activation Registries under EDL 1.0
Apache Commons Codec under Apache License, Version 2.0
Apache Commons Lang under Apache License, Version 2.0
Apache HttpClient under Apache License, Version 2.0
Expand All @@ -21,16 +22,15 @@ This software includes third party software subject to the following licenses:
Digipost HTTP Client Builder under The Apache Software License, Version 2.0
Digipost User Agreements API Client under The Apache Software License, Version 2.0
error-prone annotations under Apache 2.0
Extended StAX API under Eclipse Distribution License - v 1.0
fastinfoset under Apache License, Version 2.0 or Eclipse Distribution License - v 1.0
FindBugs-jsr305 under The Apache Software License, Version 2.0
Guava InternalFutureFailureAccess and InternalFutures under The Apache Software License, Version 2.0
Guava ListenableFuture only under The Apache Software License, Version 2.0
Guava: Google Core Libraries for Java under Apache License, Version 2.0
istack common utility code runtime under Eclipse Distribution License - v 1.0
J2ObjC Annotations under Apache License, Version 2.0
jakarta.xml.bind-api under Eclipse Distribution License - v 1.0
JavaBeans Activation Framework API jar under EDL 1.0
Jakarta Activation API under EDL 1.0
Jakarta XML Binding API under Eclipse Distribution License - v 1.0
JAXB Core under Eclipse Distribution License - v 1.0
JAXB Runtime under Eclipse Distribution License - v 1.0
JCL 1.2 implemented over SLF4J under Apache License, Version 2.0
SLF4J API Module under MIT License
Expand Down
19 changes: 10 additions & 9 deletions docs/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ GEM
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
addressable (2.8.4)
addressable (2.8.5)
public_suffix (>= 2.0.2, < 6.0)
base64 (0.2.0)
bigdecimal (3.1.4)
Expand All @@ -33,12 +33,13 @@ GEM
ethon (0.16.0)
ffi (>= 1.15.0)
eventmachine (1.2.7)
execjs (2.8.1)
faraday (2.7.4)
execjs (2.9.1)
faraday (2.7.12)
base64
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-net_http (3.0.2)
ffi (1.15.5)
ffi (1.16.3)
forwardable-extended (2.6.0)
gemoji (3.0.1)
github-pages (228)
Expand Down Expand Up @@ -221,19 +222,19 @@ GEM
jekyll-seo-tag (~> 2.1)
minitest (5.20.0)
mutex_m (0.2.0)
nokogiri (1.14.3-x86_64-darwin)
nokogiri (1.15.5-x86_64-darwin)
racc (~> 1.4)
octokit (4.25.1)
faraday (>= 1, < 3)
sawyer (~> 0.9)
pathutil (0.16.2)
forwardable-extended (~> 2.6)
public_suffix (4.0.7)
racc (1.6.2)
racc (1.7.3)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
rexml (3.2.5)
rexml (3.2.6)
rouge (3.26.0)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
Expand All @@ -250,13 +251,13 @@ GEM
unf (~> 0.1.4)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
typhoeus (1.4.0)
typhoeus (1.4.1)
ethon (>= 0.9.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.8.2)
unf_ext (0.0.9.1)
unicode-display_width (1.8.0)
webrick (1.8.1)

Expand Down
26 changes: 6 additions & 20 deletions docs/_config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# site title
title: Java client library for Digipost API for User Agreements
# current version of the software
version: 1.2
version: 4.0.0
# url of the download button
downloadUrl: https://github.com/digipost/digipost-useragreements-api-client-java
# licence of the software
Expand All @@ -10,8 +10,8 @@ licenseUrl: http://www.apache.org/licenses/LICENSE-2.0.txt

baseurl: "/digipost-useragreements-api-client-java"

currentVersion: "3.x"
versions: ["3.x", "2.x", "1.x"]
currentVersion: "4.x"
versions: ["4.x", "3.x", "2.x", "1.x"]

collections:
v1_x:
Expand All @@ -23,6 +23,9 @@ collections:
v3_x:
output: true
permalink: /v3.x/
v4_x:
output: true
permalink: /v4.x/

# list of additional links on the right of the top menu
headerLinks:
Expand Down Expand Up @@ -51,23 +54,6 @@ githubButton:
user: digipost
repo: digipost-useragreements-api-client-java

# twitter buttons
twitter:
enabled: true
via:
hash:
account: digipost_no

# facebook buttons
facebook:
enabled: false
profileUrl:

# google analytics
analytics:
account:
domain:

# DON'T MODIFY
highlight: rouge

Expand Down
34 changes: 0 additions & 34 deletions docs/_layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -179,39 +179,5 @@
<script>trianglify('{{site.header.color1}}', '{{site.header.color2}}');</script>
{% endif %}

{% if site.twitter.enabled or site.twitter.account %}
<script>
window.twttr = (function (d,s,id) {
var t, js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return; js=d.createElement(s); js.id=id; js.async=1;
js.src="https://platform.twitter.com/widgets.js"; fjs.parentNode.insertBefore(js, fjs);
return window.twttr || (t = { _e: [], ready: function(f){ t._e.push(f) } });
}(document, "script", "twitter-wjs"));
</script>
{% endif %}

{% if site.facebook.enabled or site.facebook.profileUrl %}
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.0";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
{% endif %}

{% if site.analytics.account and site.analytics.domain %}
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '{{site.analytics.account}}', '{{site.analytics.domain}}');
ga('send', 'pageview');
</script>
{% endif %}

</body>
</html>
56 changes: 56 additions & 0 deletions docs/_v4_x/1_introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
title: Introduction
identifier: introduction
layout: default
---

This API makes it possible to access agreements between Digipost users and third parties, and followingly perform certain operations which the user has granted the third party.
For instance, the user may permit that certain information may be provided to a third party in order to receive a service. The user may also grant the sender access to documents
through an agreement. The agreement governs which documents the sender can access and what operations it can perform.


### Download

The library can be acquired from Maven Central Repository, using the dependency management tool of your choice.
For Maven you can use the following dependency:

```xml
<dependency>
<groupId>no.digipost</groupId>
<artifactId>digipost-useragreements-api-client-java</artifactId>
<version>4.0.0</version>
</dependency>
```

### Prerequisites

This library now requires Java 11 and above and uses `jakarta.xml-bind`.


### Instantiate and configure client

```java
InputStream key = getClass().getResourceAsStream("certificate.p12");

HttpHost proxy = new HttpHost("proxy.example.com", 8080, "http");

BrokerId brokerId = BrokerId.of(1234L);

DigipostUserAgreementsClient client = new DigipostUserAgreementsClient
.Builder(brokerId, key, "password")
.useProxy(proxy) //optional
.setHttpClientBuilder(HttpClientBuilder.create()) //optional
.serviceEndpoint(URI.create("https://api.digipost.no")) //optional
.build();
```

### Identify Digipost user

```java
final SenderId senderId = SenderId.of(1234L);
final UserId userId = UserId.of("01017012345");

final IdentificationResult identificationResult = client.identifyUser(senderId, userId);
boolean isDigipost = identificationResult.getResult() == IdentificationResultCode.DIGIPOST;
```

64 changes: 64 additions & 0 deletions docs/_v4_x/2_fetch_messages.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
title: Messages sent to user
identifier: fetch_messages
layout: default
---

The agreement type `FETCH_MESSAGES` allows a sender to retrieve metadata for
documents that sender has previously sent to the user, that e.g. can be used to
present a synthetic inbox to the user. The metadata includes a deep-link the
user can use to access the document in Digipost.


### Create, read, update and delete agreement

```java
final SenderId senderId = SenderId.of(1234L);
final UserId userId = UserId.of("01017012345");

//CreateAgreement
client.createOrReplaceAgreement(senderId, Agreement.createAgreement(userId, AgreementType.FETCH_MESSAGES));

//GetAgreement
final GetAgreementResult agreement = client.getAgreement(senderId, AgreementType.FETCH_MESSAGES, userId);

//UpdateAgreement
client.createOrReplaceAgreement(senderId, Agreement.createAgreement(userId, AgreementType.FETCH_MESSAGES));

//DeleteAgreement
client.deleteAgreement(senderId, AgreementType.FETCH_MESSAGES, userId);
```

### Get and verify agreement

```java
final SenderId senderId = SenderId.of(1234L);
final UserId userId = UserId.of("01017012345");

final GetAgreementResult agreementResult = client.getAgreement(senderId, AgreementType.FETCH_MESSAGES, userId);
if (agreementResult.isSuccess()) {
final Agreement agreement = agreementResult.getAgreement();
} else {
switch (agreementResult.getFailedReason()) {
case UNKNOWN_USER: //User does not have a Digipost account
case NO_AGREEMENT: //No agreement exists for user
}
}
```

### Get documents

```java
final SenderId senderId = SenderId.of(1234L);
final UserId userId = UserId.of("01017012345");

final List<Document> previouslyDeliveredDocs = client.getDocuments(senderId, AgreementType.FETCH_MESSAGES,
userId, GetDocumentsQuery.empty());

final ZoneId OSLO_ZONE = ZoneId.of("Europe/Oslo");
final List<Document> withinTimeWindow = client.getDocuments(senderId, AgreementType.FETCH_MESSAGES, userId,
GetDocumentsQuery.builder()
.deliveryTimeFrom(ZonedDateTime.of(2020, 1, 1, 0, 0, 0, 0, OSLO_ZONE))
.deliveryTimeTo(ZonedDateTime.now(OSLO_ZONE))
.build());
```
15 changes: 15 additions & 0 deletions docs/_v4_x/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
identifier: index
layout: default
redirect_from: /
---

<!-- Documentation -->
{% for dok in site.v4_x %}
{% if dok.identifier != 'index' %}
<section class="bs-docs-section">
<h1 id="{{ dok.identifier }}" class="page-header">{{ dok.title}}</h1>
{{dok.content}}
</section>
{% endif%}
{% endfor %}
Loading

0 comments on commit f1a0659

Please sign in to comment.