eu.noleaks:zips

Signed ZIP library

License

License

GPL-3.0
GroupId

GroupId

eu.noleaks
ArtifactId

ArtifactId

zips
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

eu.noleaks:zips
Signed ZIP library
Project URL

Project URL

https://github.com/noleakseu/zips
Source Code Management

Source Code Management

https://github.com/noleakseu/zips/tree/main

Download zips

How to add to project

<!-- https://jarcasting.com/artifacts/eu.noleaks/zips/ -->
<dependency>
    <groupId>eu.noleaks</groupId>
    <artifactId>zips</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/eu.noleaks/zips/
implementation 'eu.noleaks:zips:1.0.1'
// https://jarcasting.com/artifacts/eu.noleaks/zips/
implementation ("eu.noleaks:zips:1.0.1")
'eu.noleaks:zips:jar:1.0.1'
<dependency org="eu.noleaks" name="zips" rev="1.0.1">
  <artifact name="zips" type="jar" />
</dependency>
@Grapes(
@Grab(group='eu.noleaks', module='zips', version='1.0.1')
)
libraryDependencies += "eu.noleaks" % "zips" % "1.0.1"
[eu.noleaks/zips "1.0.1"]

Dependencies

compile (1)

Group / Artifact Type Version
org.bouncycastle : bcpkix-jdk15on jar 1.68

test (1)

Group / Artifact Type Version
junit : junit jar 4.13.2

Project Modules

There are no modules declared in this project.

Signed ZIP library

The library extends standard ZipOutputStream by implementing SHA-256 signatures and trusted time stamps. Signed ZIP archive can be verified by jarsigner.

Requirements

  • Java 8+

Installation

Add Maven dependency

<dependency>
    <groupId>eu.noleaks</groupId>
    <artifactId>zips</artifactId>
    <version>1.0.1</version>
</dependency>

Usage

Create self-signed archive:

KeyStore.PrivateKeyEntry privateKeyEntry;
FileOutputStream archive = new FileOutputStream("signed.zip");
URL tsa = new URL("http://rfc3161timestamp.globalsign.com/advanced");
try (SignedZipOutputStream stream = new SignedZipOutputStream(archive, privateKeyEntry, tsa)) {
    String lorem = "Lorem ipsum dolor sit amet";
    ZipEntry entry = new ZipEntry("lorem ipsum.txt");
    entry.setSize(lorem.getBytes(StandardCharsets.UTF_8).length);
    stream.putNextEntry(entry);
    stream.write(lorem.getBytes(StandardCharsets.UTF_8));
    stream.closeEntry();
}

Annotate the archive by a tag:

stream
    .setTag(Tags.Title, "Lorem ipsum")
    .setTag(Tags.Possessor, "Cicero")
    .setTag(Tags.Subject, "Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document")
    .setTag(Tags.Keywords, "placeholder design")
    .setTag(Tags.Version, "1.10.32")

Verify:

$ jarsigner -verbose -verify signed.zip
jar verified.

Versions

Version
1.0.1