Java library for SPIFFE support
Go to file
Max Lambrecht 618cc0e022 Improving validations to channel address 2018-06-01 16:08:28 -03:00
gradle/wrapper Upgrading gradle version to 4.7. Adding source and targe version 1.8 2018-05-30 16:15:43 -03:00
src/main Improving validations to channel address 2018-06-01 16:08:28 -03:00
.gitignore First commit 2018-05-28 12:39:13 -03:00
README.md Removing synchronous fetchSVIDs call 2018-05-30 16:22:03 -03:00
build.gradle Upgrading gradle version to 4.7. Adding source and targe version 1.8 2018-05-30 16:15:43 -03:00
gradlew First commit 2018-05-28 12:39:13 -03:00
gradlew.bat First commit 2018-05-28 12:39:13 -03:00
settings.gradle First commit 2018-05-28 12:39:13 -03:00

README.md

JAVA-SPIFFE library

Overview

The JAVA-SPIFFE library provides functionality to fetch SVIDs Bundles from a Workload API

SPIFFE Workload API ClientExample

The WorkloadAPIClient provides the method fetchX509SVIDs that fetches SVIDs from the Workload API, on an asynchronous fashion.

The channel is configured based on the Address (tcp or unix socket) and the OS detected.

Use

WorkloadAPIClient workloadAPIClient = new WorkloadAPIClient("/tmp/agent.sock");
List<X509SVID> svids = workloadAPIClient.fetchX509SVIDs();
for (X509SVID svid : svids) {
    System.out.println("Spiffe ID fetched " + svid.getSpiffeId());
}

Running the example

Required:

  • A running Spire server and agent. HowTo
  • An entry in the registry that matches this application:
cmd/spire-server/spire-server entry create \
-spiffeID spiffe://example.org/workload \
-parentID spiffe://example.org/host \
-selector unix:uid:1000

To start the Java server you can run ./gradlew run

$ ./gradlew run

> Task :run
[main] INFO ClientExample - Fetching the SVIDs asynchronously
[main] INFO ClientExample - Waiting for certificates...
[main] INFO ClientExample - Doing other work...
[main] INFO ClientExample - Doing other work...
[main] INFO ClientExample - Doing other work...
[grpc-default-executor-0] INFO ClientExample - Spiffe ID fetched: spiffe://example.org/workload
[main] INFO ClientExample - Exiting...

BUILD SUCCESSFUL in 1s

Generating the JAR

./gradlew build

The jar file java-spiffe-0.1-SNAPSHOT.jar is generated in folder libs.