Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
59c2dbc
Use api-specification that supports multiple docs
Oct 14, 2020
282619c
Adds repository to get sonatype snapshots
Oct 14, 2020
d494f74
Adds possibility to add multiple docs to portal job
Oct 15, 2020
cb56074
Adds all portal documents to manifest
Oct 15, 2020
8fb4822
Adds default getDocument to interface, and throw if now exactly one
Nov 4, 2020
696e39a
Use XMLHref for hrefs to documents in ASiCE bundle
runeflobakk Nov 12, 2020
ec4c71a
Move title etc from doc to job for portal jobs
Jan 5, 2021
d277be4
Stop using ::set-env
Jan 5, 2021
277ac8e
Just single document in direct job API
runeflobakk Jan 12, 2021
2773aa8
Use oppdragstittel-SNAPSHOT api spec
Jan 13, 2021
810a33d
Merge pull request #186 from digipost/singular-direct-document
Jan 13, 2021
2af6c49
Upgrade dependencies
runeflobakk Jan 14, 2021
f165f0f
Update api version
Jan 14, 2021
fb23873
Use SNAPSHOT for multi-doc api spec
Jan 14, 2021
1a0049d
Merge pull request #185 from digipost/oppdragstittel
Jan 14, 2021
44e1779
Merge branch 'main' into multiple-documents
Jan 20, 2021
04c9ee5
Use on API spec 2.8 release candidate 1
runeflobakk Jan 22, 2021
9a4d34f
Upgrade equalsverifier
runeflobakk Jan 22, 2021
5c35f32
Merge branch '5.0-final' into multiple-documents
runeflobakk Jan 22, 2021
95554a7
Add possibility for multiple documents for direct jobs
sarawe Feb 4, 2021
2823b93
Add builder for one direct signer and multiple documents
sarawe Feb 4, 2021
20247f4
Use builder method instead of returning new Builder
sarawe Feb 4, 2021
b6f2f79
API Specification v2.8-RC2
runeflobakk Feb 8, 2021
417c965
Merge pull request #190 from digipost/multiple-documents-direct-job
runeflobakk Feb 8, 2021
14bfcf2
Remove temporary snapshot repo definition
runeflobakk Jun 9, 2021
5dc6639
Upgrade dependencies
runeflobakk Jun 9, 2021
ec3fe98
Upgrade Maven plugins
runeflobakk Jun 9, 2021
677cd39
Add line break
runeflobakk Jun 9, 2021
87457d4
Remove method to get singular document from job
runeflobakk Jun 9, 2021
30421a7
Some minor code reformatting
runeflobakk Jun 9, 2021
3977dd9
Add a few final modifiers
runeflobakk Jun 9, 2021
2283466
Change to Java Time API for job availability
runeflobakk Jun 9, 2021
6bd26c2
Clean up construction of Portal and Direct jobs
runeflobakk Jun 9, 2021
45af037
Fix NPE if not setting PortalJob.availableFor
runeflobakk Jun 14, 2021
1742771
Generate filenames for document bundle
runeflobakk Jun 14, 2021
8ca1f1a
Include index in filename to ensure uniqueness
runeflobakk Jun 20, 2021
f7bb511
Replace term mimeType with mediaType
runeflobakk Jun 20, 2021
060d140
Merge pull request #206 from digipost/autogenerate-asice-filenames
runeflobakk Jun 21, 2021
5dd4cc6
API specification 2.8-RC3
runeflobakk Jun 21, 2021
944012f
Upgrade SLF4J and commons-io
runeflobakk Jun 21, 2021
bb665c5
Consistently use "content" for the document bytes
runeflobakk Jun 22, 2021
aeb9f7a
API specification 2.8
runeflobakk Jun 22, 2021
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
7 changes: 3 additions & 4 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ This software includes third party software subject to the following licenses:
Apache Commons Lang under Apache License, Version 2.0
Apache HttpClient under Apache License, Version 2.0
Apache HttpCore under Apache License, Version 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
istack common utility code runtime under Eclipse Distribution License - v 1.0
Jakarta Activation under EDL 1.0
Jakarta Activation API jar under EDL 1.0
Jakarta Annotations API under EPL 2.0 or GPL2 w/ CPE
Jakarta XML Binding API under Eclipse Distribution License - v 1.0
jakarta.ws.rs-api under EPL 2.0 or GPL2 w/ CPE
jakarta.xml.bind-api under Eclipse Distribution License - v 1.0
JavaBeans Activation Framework API jar under EDL 1.0
javax.inject:1 as OSGi bundle under EPL 2.0 or GPL2 w/ CPE
JAXB Runtime under Eclipse Distribution License - v 1.0
JAXB2 Basics - Runtime under BSD-Style License
Expand Down
40 changes: 20 additions & 20 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,30 @@
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.previousVersion>set_with_-Dproject.previousVersion=X.Y</project.previousVersion>
<signature.api.version>2.7</signature.api.version>
<slf4j.version>1.7.30</slf4j.version>
<signature.api.version>2.8</signature.api.version>
<slf4j.version>1.7.31</slf4j.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>5.3.3</version>
<version>5.3.8</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>2.33</version>
<version>2.34</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.7.0</version>
<version>5.8.0-M1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -88,7 +88,7 @@
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.2</version>
<version>2.3.4</version>
<scope>runtime</scope>
</dependency>
<dependency>
Expand All @@ -106,7 +106,7 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.8.0</version>
<version>2.10.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -125,12 +125,12 @@
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-xml</artifactId>
<version>3.0.10.RELEASE</version>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.11</version>
<version>3.12.0</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -170,7 +170,7 @@
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier</artifactId>
<version>3.5.2</version>
<version>3.6.1</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -194,7 +194,7 @@
<dependency>
<groupId>no.digipost</groupId>
<artifactId>digg</artifactId>
<version>0.25</version>
<version>0.30</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -227,12 +227,12 @@
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.2</version>
<version>2.3.4</version>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.2</version>
<version>2.3.3</version>
</dependency>
</dependencies>
</plugin>
Expand All @@ -243,7 +243,7 @@
<plugin>
<groupId>com.github.siom79.japicmp</groupId>
<artifactId>japicmp-maven-plugin</artifactId>
<version>0.15.2</version>
<version>0.15.3</version>
<configuration>
<oldVersion>
<dependency>
Expand Down Expand Up @@ -271,7 +271,7 @@
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
<version>3.0.0-M5</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
Expand All @@ -283,23 +283,23 @@
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
<version>3.1.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>3.0.0-M1</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<version>3.2.0</version>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.8.2</version>
<version>3.9.1</version>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.1</version>
<version>3.2.0</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
Expand Down Expand Up @@ -331,7 +331,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.7</version>
<version>2.8.1</version>
</plugin>
</plugins>
</pluginManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@
import static org.apache.commons.codec.digest.DigestUtils.sha256;

public interface ASiCEAttachable extends SignableFileReference {

public static final String XML_MEDIATYPE = "application/xml";

@Override
String getFileName();

byte[] getBytes();
byte[] getContent();

String getMimeType();
@Override
String getMediaType();

@Override
default byte[] getSha256() {
return sha256(getBytes());
return sha256(getContent());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ public DocumentBundle createASiCE(JOB job) {

Manifest manifest = manifestCreator.createManifest(job, sender);

List<ASiCEAttachable> files = new ArrayList<>();
files.add(job.getDocument());
List<ASiCEAttachable> files = new ArrayList<>(job.getDocuments());
files.add(manifest);

Signature signature = createSignature.createSignature(files, keyStoreConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public byte[] zipIt(final List<ASiCEAttachable> files) {
try (ZipOutputStream zipOutputStream = new ZipOutputStream(archive)) {
for (ASiCEAttachable file : files) {
ZipEntry zipEntry = new ZipEntry(file.getFileName());
zipEntry.setSize(file.getBytes().length);
zipEntry.setSize(file.getContent().length);
zipOutputStream.putNextEntry(zipEntry);
zipOutputStream.write(file.getBytes());
zipOutputStream.write(file.getContent());
zipOutputStream.closeEntry();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
import no.digipost.signature.api.xml.XMLDirectDocument;
import no.digipost.signature.api.xml.XMLDirectSignatureJobManifest;
import no.digipost.signature.api.xml.XMLDirectSigner;
import no.digipost.signature.api.xml.XMLHref;
import no.digipost.signature.api.xml.XMLSender;
import no.digipost.signature.client.core.AuthenticationLevel;
import no.digipost.signature.client.core.IdentifierInSignedDocuments;
import no.digipost.signature.client.core.OnBehalfOf;
import no.digipost.signature.client.core.Sender;
import no.digipost.signature.client.core.SignatureType;
import no.digipost.signature.client.direct.DirectDocument;
import no.digipost.signature.client.direct.DirectJob;
import no.digipost.signature.client.direct.DirectSigner;

import java.util.ArrayList;
import java.util.List;

import static java.util.stream.Collectors.toList;

public class CreateDirectManifest extends ManifestCreator<DirectJob> {

@Override
Object buildXmlManifest(DirectJob job, Sender sender) {
DirectDocument document = job.getDocument();

List<XMLDirectSigner> signers = new ArrayList<>();
for (DirectSigner signer : job.getSigners()) {
XMLDirectSigner xmlSigner = new XMLDirectSigner()
Expand All @@ -39,13 +39,14 @@ Object buildXmlManifest(DirectJob job, Sender sender) {
.withSigners(signers)
.withRequiredAuthentication(job.getRequiredAuthentication().map(AuthenticationLevel::getXmlEnumValue).orElse(null))
.withSender(new XMLSender().withOrganizationNumber(sender.getOrganizationNumber()))
.withDocument(new XMLDirectDocument()
.withTitle(document.getTitle())
.withDescription(document.getMessage())
.withHref(document.getFileName())
.withMime(document.getMimeType())
)
.withIdentifierInSignedDocuments(job.getIdentifierInSignedDocuments().map(IdentifierInSignedDocuments::getXmlEnumValue).orElse(null))
;
.withTitle(job.getTitle())
.withDescription(job.getDescription().orElse(null))
.withDocuments(job.getDocuments().stream()
.map(document -> new XMLDirectDocument()
.withTitle(document.getTitle())
.withHref(XMLHref.of(document.getFileName()))
.withMediaType(document.getMediaType()))
.collect(toList()))
.withIdentifierInSignedDocuments(job.getIdentifierInSignedDocuments().map(IdentifierInSignedDocuments::getXmlEnumValue).orElse(null));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import no.digipost.signature.api.xml.XMLAvailability;
import no.digipost.signature.api.xml.XMLEmail;
import no.digipost.signature.api.xml.XMLEnabled;
import no.digipost.signature.api.xml.XMLHref;
import no.digipost.signature.api.xml.XMLNotifications;
import no.digipost.signature.api.xml.XMLNotificationsUsingLookup;
import no.digipost.signature.api.xml.XMLPortalDocument;
Expand All @@ -17,15 +18,16 @@
import no.digipost.signature.client.core.SignatureType;
import no.digipost.signature.client.portal.Notifications;
import no.digipost.signature.client.portal.NotificationsUsingLookup;
import no.digipost.signature.client.portal.PortalDocument;
import no.digipost.signature.client.portal.PortalJob;
import no.digipost.signature.client.portal.PortalSigner;

import java.time.Clock;
import java.time.Duration;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.List;

import static java.util.stream.Collectors.toList;
import static no.digipost.signature.client.core.exceptions.SignerNotSpecifiedException.SIGNER_NOT_SPECIFIED;

public class CreatePortalManifest extends ManifestCreator<PortalJob> {
Expand All @@ -41,7 +43,6 @@ Object buildXmlManifest(PortalJob job, Sender sender) {
List<XMLPortalSigner> xmlSigners = new ArrayList<>();
for (PortalSigner signer : job.getSigners()) {
XMLPortalSigner xmlPortalSigner = generateSigner(signer);

if (signer.getNotifications() != null) {
xmlPortalSigner.setNotifications(generateNotifications(signer.getNotifications()));
} else if (signer.getNotificationsUsingLookup() != null) {
Expand All @@ -50,27 +51,25 @@ Object buildXmlManifest(PortalJob job, Sender sender) {
xmlSigners.add(xmlPortalSigner);
}

PortalDocument document = job.getDocument();

ZonedDateTime activationTime = job.getActivationTime().map(activation -> activation.atZone(clock.getZone())).orElse(null);

return new XMLPortalSignatureJobManifest()
.withSigners(xmlSigners)
.withRequiredAuthentication(job.getRequiredAuthentication().map(AuthenticationLevel::getXmlEnumValue).orElse(null))
.withSender(new XMLSender().withOrganizationNumber(sender.getOrganizationNumber()))
.withDocument(new XMLPortalDocument()
.withTitle(document.getTitle())
.withNonsensitiveTitle(document.getNonsensitiveTitle())
.withDescription(document.getMessage())
.withHref(document.getFileName())
.withMime(document.getMimeType())
)
.withTitle(job.getTitle())
.withNonsensitiveTitle(job.getNonsensitiveTitle().orElse(null))
.withDescription(job.getDescription().orElse(null))
.withDocuments(job.getDocuments().stream()
.map(document -> new XMLPortalDocument()
.withTitle(document.getTitle())
.withHref(XMLHref.of(document.getFileName()))
.withMediaType(document.getMediaType()))
.collect(toList()))
.withAvailability(new XMLAvailability()
.withActivationTime(activationTime)
.withAvailableSeconds(job.getAvailableSeconds())
)
.withIdentifierInSignedDocuments(job.getIdentifierInSignedDocuments().map(IdentifierInSignedDocuments::getXmlEnumValue).orElse(null))
;
.withAvailableSeconds(job.getAvailable().map(Duration::getSeconds).orElse(null)))
.withIdentifierInSignedDocuments(job.getIdentifierInSignedDocuments().map(IdentifierInSignedDocuments::getXmlEnumValue).orElse(null));
}

private XMLPortalSigner generateSigner(PortalSigner signer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ public String getFileName() {
}

@Override
public byte[] getBytes() {
public byte[] getContent() {
return xmlBytes;
}

@Override
public String getMimeType() {
return "application/xml";
public String getMediaType() {
return XML_MEDIATYPE;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,9 @@ private List<Reference> references(final XMLSignatureFactory xmlSignatureFactory
for (int i = 0; i < files.size(); i++) {
try {
String signatureElementId = "ID_" + i;
String uri = URLEncoder.encode(files.get(i).getFileName(), "UTF-8");
Reference reference = xmlSignatureFactory.newReference(uri, sha256DigestMethod, null, null, signatureElementId, files.get(i).getSha256());
SignableFileReference file = files.get(i);
String uri = URLEncoder.encode(file.getFileName(), "UTF-8");
Reference reference = xmlSignatureFactory.newReference(uri, sha256DigestMethod, null, null, signatureElementId, file.getSha256());
result.add(reference);
} catch(UnsupportedEncodingException e) {
throw new RuntimeException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private List<DataObjectFormat> dataObjectFormats(List<? extends SignableFileRefe
List<DataObjectFormat> result = new ArrayList<>();
for (int i = 0; i < files.size(); i++) {
String signatureElementIdReference = format("#ID_%s", i);
result.add(new DataObjectFormat(null, null, files.get(i).getMimeType(), null, signatureElementIdReference));
result.add(new DataObjectFormat(null, null, files.get(i).getMediaType(), null, signatureElementIdReference));
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ public interface SignableFileReference {

byte[] getSha256();

String getMimeType();
String getMediaType();

}
Loading