- parse
Invoicefrom Json file - make
Invoicesignature and save it as anEnvelop - save
Invoiceto file - load and save JWK keys from/to file
Invoiceextract fromEnvelop- signature verification when extract document from
Envelop(only one signature is supported now)
- The only possible type of document that can be placed inside a signed Envelope is an Invoice. This decision is dictated by the simplification of implementation at this stage of the project.
- There is no tax calculation logic
- and much, much more — so help is more than welcome
publicclassMain {
publicstaticvoidmain(String[] args) {
Goblgobl = newGobl();
Invoiceinvoice = gobl.parseInvoice("src/test/resources/invoice.json");
System.out.println(invoice);
}
}publicclassMain {
publicstaticvoidmain(String[] args) {
Goblgobl = newGobl();
KeySupportkeySupport = newKeySupport();
valkeys = keySupport.generate();
valenvelope = gobl.signInvoice("src/test/resources/invoice.json", keys.privateKey(), UUID.randomUUID());
System.out.println(envelope);
}
}publicclassMain {
publicstaticvoidmain(String[] args) {
Goblgobl = newGobl();
KeySupportkeySupport = newKeySupport();
Keykey = keySupport.loadKey(Path.of("src/test/resources/id_es256.jwk"));
valenvelope = gobl.signInvoice("src/test/resources/invoice.json", (ECPrivateKey) key, UUID.randomUUID());
System.out.println(envelope);
}
}try{
Filefile = newFile("src/test/resources/invoice-signed.json");
KeySupportkeySupport = newKeySupport();
KeypublicKey = keySupport.loadKey(Path.of("src/test/resources/id_es256.pub.jwk"));
Invoiceinvoice = gobl.extractFromEnvelope(file, Invoice.class, publicKey); // validation OKSystem.out.println(invoice);
} catch (SignatureExceptionex) {
// validation failed
} valinvoice = newInvoice()
.withCode("standard")
.withIssueDate("2024-01-01")
.withCustomer(newParty()
.withName("Company INC")
.withAddresses(List.of(newAddress()
.withCountry("Poland")
.withCode("05-092")
.withStreet("Warszawska")))
.withTaxId(newIdentity()
.withCode("2222222222")
.withCountry("PL"))
).withCustomer(newParty()
.withName("Customer sp. z o.o.")
.withAddresses(List.of(newAddress()
.withCountry("Poland")
.withCode("05-092")
.withStreet("Warszawska")))
.withTaxId(newIdentity()
.withCode("1111111111")
.withCountry("PL"))
).withLines(List.of(newLine()
.withI(1)
.withItem(newItem()
.withName("Myszka")
.withCurrency("PLN")
.withPrice("100"))));
Goblgobl = newGobl();
gobl.saveInvoice(invoice, System.out);<dependency>
<groupId>io.alapierre.gobl</groupId>
<artifactId>gobl-core</artifactId>
<version>0.0.2</version>
</dependency>The project can be built on JDK17+.
Building the API client library requires:
- Java 17+
- Maven