BundleSource represents a source of bundles of type T keyed by trust domain.
+ * Represents a source of bundles of type T keyed by trust domain.
*/
public interface BundleSourceJwtBundle represents a collection of trusted JWT authorities (Public Keys) for a trust domain.
+ * Represents a collection of trusted JWT authorities (Public Keys) for a trust domain.
*/
@Value
public class JwtBundle implements BundleSourceJwtBundleSet represents a set of JWT bundles keyed by trust domain.
+ * Represents a set of JWT bundles keyed by trust domain.
*/
@Value
public class JwtBundleSet implements BundleSourceX509Bundle represents a collection of trusted X.509 authorities for a trust domain.
+ * Represents a collection of trusted X.509 authorities for a trust domain.
*/
@Value
public class X509Bundle implements BundleSourceX509BundleSet represents a set of X.509 bundles keyed by trust domain.
+ * Represents a set of X.509 bundles keyed by trust domain.
*/
@Value
public class X509BundleSet implements BundleSourceSpiffeId represents a SPIFFE ID as defined in SPIFFE standard.
+ * Represents a SPIFFE ID as defined in SPIFFE standard.
*
* @see https://github.com/spiffe/spiffe/blob/master/standards/SPIFFE-ID.md
*/
@@ -70,15 +70,19 @@ public class SpiffeId {
}
/**
- * Returns true if the trust domain of this SPIFFE ID is the same as the given trust domain.
+ * Returns true if the trust domain of this SPIFFE ID is the same as trust domain given as parameter.
*
- * @param trustDomain instance of a {@link TrustDomain}
+ * @param trustDomain an instance of a {@link TrustDomain}
* @return
@@ -74,8 +27,7 @@ public class SpiffeIdUtils {
*
* @param spiffeIdsFile the path to the file containing a list of SPIFFE IDs
* @return a List of {@link SpiffeId} parsed from the file provided
- *
- * @throws IOException if the given spiffeIdsFile cannot be read
+ * @throws IOException if the given spiffeIdsFile cannot be read
* @throws IllegalArgumentException if any of the SPIFFE IDs in the file cannot be parsed
*/
public static List
+ * The JWT-SVID signature is verified using the JWT bundle source.
*
* @param token a token as a string that is parsed and validated
* @param jwtBundleSource an implementation of a {@link BundleSource} that provides the authority to verify the signature
* @param audience audience as a List of String used to validate the 'aud' claim
- * @return an instance of a {@link JwtSvid} with a spiffe id parsed from the 'sub', audience from 'aud', and expiry
+ * @return an instance of a {@link JwtSvid} with a SPIFFE ID parsed from the 'sub', audience from 'aud', and expiry
* from 'exp' claim.
* @throws spiffe.exception.JwtSvidException when the token expired or the expiration claim is missing,
* when the algorithm is not supported, when the header 'kid' is missing, when the signature cannot be verified, or
@@ -118,7 +119,9 @@ public class JwtSvid {
}
/**
- * Parses and validates a JWT-SVID token and returns the JWT-SVID. The JWT-SVID signature is not verified.
+ * Parses and validates a JWT-SVID token and returns an instance of a JwtSvid.
+ *
+ * The JWT-SVID signature is not verified.
*
* @param token a token as a string that is parsed and validated
* @param audience audience as a List of String used to validate the 'aud' claim
diff --git a/java-spiffe-core/src/main/java/spiffe/svid/jwtsvid/JwtSvidSource.java b/java-spiffe-core/src/main/java/spiffe/svid/jwtsvid/JwtSvidSource.java
index 6c0d79a..5b52eaf 100644
--- a/java-spiffe-core/src/main/java/spiffe/svid/jwtsvid/JwtSvidSource.java
+++ b/java-spiffe-core/src/main/java/spiffe/svid/jwtsvid/JwtSvidSource.java
@@ -4,16 +4,16 @@ import spiffe.exception.JwtSvidException;
import spiffe.spiffeid.SpiffeId;
/**
- * A
* Contains a SPIFFE ID, a private key and a chain of X.509 certificates.
*/
@@ -33,7 +33,7 @@ public class X509Svid implements X509SvidSource {
/**
* The X.509 certificates of the X.509-SVID. The leaf certificate is
* the X.509-SVID certificate. Any remaining certificates (if any) chain
- * the X.509-SVID certificate back to a X.509 root for the trust domain.
+ * the X.509-SVID certificate back to an X.509 root for the trust domain.
*/
List
* Supports one-shot calls and watch updates for X.509 and JWT SVIDs and bundles.
*
@@ -74,7 +74,7 @@ public class WorkloadApiClient implements Closeable {
}
/**
- * Creates a new Workload API client.
+ * Creates a new Workload API client configured with the given client options.
*
* If the SPIFFE socket endpoint address is not provided in the options, it uses the default address.
*
@@ -121,11 +121,11 @@ public class WorkloadApiClient implements Closeable {
}
private WorkloadApiClient(SpiffeWorkloadAPIStub workloadApiAsyncStub,
- SpiffeWorkloadAPIBlockingStub workloadApiBlockingStub,
- ManagedChannelWrapper managedChannel,
- BackoffPolicy backoffPolicy,
- ScheduledExecutorService retryExecutor,
- ExecutorService executorService) {
+ SpiffeWorkloadAPIBlockingStub workloadApiBlockingStub,
+ ManagedChannelWrapper managedChannel,
+ BackoffPolicy backoffPolicy,
+ ScheduledExecutorService retryExecutor,
+ ExecutorService executorService) {
this.workloadApiAsyncStub = workloadApiAsyncStub;
this.workloadApiBlockingStub = workloadApiBlockingStub;
this.managedChannel = managedChannel;
@@ -182,6 +182,7 @@ public class WorkloadApiClient implements Closeable {
* @param audience the audience of the JWT-SVID
* @param extraAudience the extra audience for the JWT_SVID
* @return an instance of a {@link JwtSvid}
+ * @throws JwtSvidException if there is an error fetching or processing the JWT from the Workload API
*/
public JwtSvid fetchJwtSvid(@NonNull SpiffeId subject, @NonNull String audience, String... extraAudience) throws JwtSvidException {
List
* Contains a list of {@link X509Svid} and a {@link X509BundleSet}.
*/
diff --git a/java-spiffe-core/src/main/java/spiffe/workloadapi/X509Source.java b/java-spiffe-core/src/main/java/spiffe/workloadapi/X509Source.java
index b30af3f..cdccdd7 100644
--- a/java-spiffe-core/src/main/java/spiffe/workloadapi/X509Source.java
+++ b/java-spiffe-core/src/main/java/spiffe/workloadapi/X509Source.java
@@ -28,8 +28,7 @@ import java.util.logging.Level;
import static spiffe.workloadapi.internal.ThreadUtils.await;
/**
- * A
* It handles a {@link X509Svid} and a {@link X509BundleSet} that are updated automatically
* whenever there is an update from the Workload API.
@@ -97,7 +96,7 @@ public class X509Source implements X509SvidSource, BundleSource
* The {@link WorkloadApiClient} can be provided in the options, if it is not, a new client is created.
*
diff --git a/java-spiffe-core/src/main/java/spiffe/workloadapi/retry/BackoffPolicy.java b/java-spiffe-core/src/main/java/spiffe/workloadapi/retry/BackoffPolicy.java
index 999df0e..917d653 100644
--- a/java-spiffe-core/src/main/java/spiffe/workloadapi/retry/BackoffPolicy.java
+++ b/java-spiffe-core/src/main/java/spiffe/workloadapi/retry/BackoffPolicy.java
@@ -7,6 +7,9 @@ import lombok.val;
import java.time.Duration;
import java.util.function.UnaryOperator;
+/**
+ * Represents a backoff policy for performing retries using exponential increasing delays.
+ */
@Data
public class BackoffPolicy {
@@ -55,8 +58,8 @@ public class BackoffPolicy {
* Calculate the nextDelay based on a currentDelay, applying the backoff function
* If the calculated delay is greater than maxDelay, it returns maxDelay
*
- * @param currentDelay
- * @return next delay
+ * @param currentDelay a {@link Duration} representing the current delay
+ * @return a {@link Duration} representing the next delay
*/
public Duration nextDelay(Duration currentDelay) {
val next = backoffFunction.apply(currentDelay);
@@ -71,7 +74,7 @@ public class BackoffPolicy {
* or if the retriesCount param is lower than the maxRetries
*
* @param retriesCount the current number of retries
- * @return
+ * @return false if the number of retries did not reach the max number of retries, true otherwise
*/
public boolean didNotReachMaxRetries(int retriesCount) {
return (maxRetries == UNLIMITED_RETRIES || retriesCount < maxRetries);
diff --git a/java-spiffe-core/src/main/java/spiffe/workloadapi/retry/RetryHandler.java b/java-spiffe-core/src/main/java/spiffe/workloadapi/retry/RetryHandler.java
index 1de697d..356d87f 100644
--- a/java-spiffe-core/src/main/java/spiffe/workloadapi/retry/RetryHandler.java
+++ b/java-spiffe-core/src/main/java/spiffe/workloadapi/retry/RetryHandler.java
@@ -5,7 +5,7 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
- * Provides methods to schedule the execution of retries based on a backoff policy
+ * Provides methods to schedule the execution of retries based on a backoff policy.
*/
public class RetryHandler {
diff --git a/java-spiffe-core/src/test/java/spiffe/spiffeid/SpiffeIdUtilsTest.java b/java-spiffe-core/src/test/java/spiffe/spiffeid/SpiffeIdUtilsTest.java
index a24b189..07ced38 100644
--- a/java-spiffe-core/src/test/java/spiffe/spiffeid/SpiffeIdUtilsTest.java
+++ b/java-spiffe-core/src/test/java/spiffe/spiffeid/SpiffeIdUtilsTest.java
@@ -8,96 +8,11 @@ import java.net.URISyntaxException;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.Paths;
-import java.security.Security;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
-class piffeIdUtilsTest {
-
- @Test
- void getSpiffeIdsFromSystemProperty() {
- System.setProperty("spiffe.property", " spiffe://example.org/workload1, spiffe://example.org/workload2 ");
-
- Listtrue if the given trust domain equals the trust domain of this object, false otherwise
*/
public boolean memberOf(final TrustDomain trustDomain) {
return this.trustDomain.equals(trustDomain);
}
+ /**
+ * Returns the string representation of the SPIFFE ID, concatenating schema, trust domain,
+ * and path segments (e.g. 'spiffe://example.org/path1/path2')
+ */
@Override
public String toString() {
return String.format("%s://%s%s", SPIFFE_SCHEME, this.trustDomain.toString(), this.path);
diff --git a/java-spiffe-core/src/main/java/spiffe/spiffeid/SpiffeIdUtils.java b/java-spiffe-core/src/main/java/spiffe/spiffeid/SpiffeIdUtils.java
index 34329c3..d34064e 100644
--- a/java-spiffe-core/src/main/java/spiffe/spiffeid/SpiffeIdUtils.java
+++ b/java-spiffe-core/src/main/java/spiffe/spiffeid/SpiffeIdUtils.java
@@ -1,12 +1,10 @@
package spiffe.spiffeid;
import lombok.val;
-import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.security.Security;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@@ -22,51 +20,6 @@ public class SpiffeIdUtils {
private static final char DEFAULT_CHAR_SEPARATOR = ',';
- /**
- * Reads the Accepted SPIFFE IDs from a system property and parses them to {@link SpiffeId} instances.
- *
- * @param systemProperty name of the system property that contains a list of SPIFFE IDs separated by a commas.
- * @return a list of {@link SpiffeId} parsed from the values read from the security property, in case there's no values
- * in the System property, it returns an emtpy list
- *
- * @throws IllegalArgumentException if the given system property is empty or if any of the SPIFFE IDs
- * cannot be parsed
- */
- public static ListTrustDomain represents a normalized SPIFFE trust domain (e.g. domain.test).
+ * Represents a normalized SPIFFE trust domain (e.g. 'domain.test').
*/
@Value
public class TrustDomain {
@@ -28,7 +28,6 @@ public class TrustDomain {
*
* @param trustDomain a trust domain represented as a string, must not be blank.
* @return an instance of a {@link TrustDomain}
- *
* @throws IllegalArgumentException if the given string is blank or cannot be parsed
*/
public static TrustDomain of(@NonNull String trustDomain) {
@@ -50,8 +49,24 @@ public class TrustDomain {
return new TrustDomain(host);
}
- public SpiffeId newSpiffeId(String ...path) {
- return SpiffeId.of(this, path);
+ /**
+ * Creates a SPIFFE ID from this trust domain and the given path segments.
+ *
+ * @param segments path segments
+ * @return a {@link SpiffeId} with the current trust domain and the given path segments
+ */
+ public SpiffeId newSpiffeId(String... segments) {
+ return SpiffeId.of(this, segments);
+ }
+
+ /**
+ * Returns the trust domain as a String.
+ *
+ * @return a String with the trust domain
+ */
+ @Override
+ public String toString() {
+ return name;
}
private static void validateHost(String host) {
@@ -79,14 +94,4 @@ public class TrustDomain {
}
return s;
}
-
- /**
- * Returns the trust domain as a string.
- *
- * @return a String with the trust domain
- */
- @Override
- public String toString() {
- return name;
- }
}
diff --git a/java-spiffe-core/src/main/java/spiffe/svid/jwtsvid/JwtSvid.java b/java-spiffe-core/src/main/java/spiffe/svid/jwtsvid/JwtSvid.java
index 8e8224d..a54bb9c 100644
--- a/java-spiffe-core/src/main/java/spiffe/svid/jwtsvid/JwtSvid.java
+++ b/java-spiffe-core/src/main/java/spiffe/svid/jwtsvid/JwtSvid.java
@@ -28,33 +28,33 @@ import java.util.List;
import java.util.Map;
/**
- * A JwtSvid represents a SPIFFE JWT-SVID.
+ * Represents a SPIFFE JWT-SVID.
*/
@Value
public class JwtSvid {
/**
- * SPIFFE ID of the JWT-SVID as present in the 'sub' claim
+ * SPIFFE ID of the JWT-SVID as present in the 'sub' claim.
*/
SpiffeId spiffeId;
/**
- * Audience is the intended recipients of JWT-SVID as present in the 'aud' claim
+ * Audience is the intended recipients of JWT-SVID as present in the 'aud' claim.
*/
ListJwtSvidSource represents a source of SPIFFE JWT-SVIDs.
+ * Represents a source of SPIFFE JWT-SVIDs.
*/
public interface JwtSvidSource {
/**
- * Fetches a JWT-SVID from the source with the given parameters.
+ * Fetches a JWT-SVID from the source with the given subject and audiences.
*
* @param subject a {@link SpiffeId}
* @param audience the audience
- * @param extraAudiences an array of Strings
+ * @param extraAudiences a list of extra audiences as an array of String
* @return a {@link JwtSvid}
* @throws JwtSvidException when there is an error fetching the JWT SVID
*/
diff --git a/java-spiffe-core/src/main/java/spiffe/svid/x509svid/X509Svid.java b/java-spiffe-core/src/main/java/spiffe/svid/x509svid/X509Svid.java
index 136b54f..22bdd43 100644
--- a/java-spiffe-core/src/main/java/spiffe/svid/x509svid/X509Svid.java
+++ b/java-spiffe-core/src/main/java/spiffe/svid/x509svid/X509Svid.java
@@ -21,7 +21,7 @@ import java.util.List;
import static spiffe.internal.CertificateUtils.*;
/**
- * A X509Svid represents a SPIFFE X.509 SVID.
+ * Represents a SPIFFE X.509 SVID.
* X509SvidSource represents a source of X.509 SVIDs.
+ * Represents a source of X.509 SVIDs.
*/
public interface X509SvidSource {
diff --git a/java-spiffe-core/src/main/java/spiffe/svid/x509svid/X509SvidValidator.java b/java-spiffe-core/src/main/java/spiffe/svid/x509svid/X509SvidValidator.java
index 0d62100..225b046 100644
--- a/java-spiffe-core/src/main/java/spiffe/svid/x509svid/X509SvidValidator.java
+++ b/java-spiffe-core/src/main/java/spiffe/svid/x509svid/X509SvidValidator.java
@@ -16,8 +16,7 @@ import java.util.List;
import java.util.function.Supplier;
/**
- * A X509SvidValidator provides methods to validate
- * a chain of X.509 certificates using an X.509 bundle source.
+ * Provides methods to validate a chain of X.509 certificates using an X.509 bundle source.
*/
public class X509SvidValidator {
diff --git a/java-spiffe-core/src/main/java/spiffe/workloadapi/Address.java b/java-spiffe-core/src/main/java/spiffe/workloadapi/Address.java
index 92498e7..abe604c 100644
--- a/java-spiffe-core/src/main/java/spiffe/workloadapi/Address.java
+++ b/java-spiffe-core/src/main/java/spiffe/workloadapi/Address.java
@@ -27,7 +27,7 @@ public class Address {
/**
* Returns the default Workload API address hold by the system environment variable
- * defined by SOCKET_ENV_VARIABLE
+ * defined by SOCKET_ENV_VARIABLE.
*/
public static String getDefaultAddress() {
return System.getenv(Address.SOCKET_ENV_VARIABLE);
diff --git a/java-spiffe-core/src/main/java/spiffe/workloadapi/JwtSource.java b/java-spiffe-core/src/main/java/spiffe/workloadapi/JwtSource.java
index 7df270d..f095b06 100644
--- a/java-spiffe-core/src/main/java/spiffe/workloadapi/JwtSource.java
+++ b/java-spiffe-core/src/main/java/spiffe/workloadapi/JwtSource.java
@@ -29,8 +29,7 @@ import java.util.logging.Level;
import static spiffe.workloadapi.internal.ThreadUtils.await;
/**
- * A JwtSource represents a source of SPIFFE JWT SVIDs and JWT bundles
- * maintained via the Workload API.
+ * Represents a source of SPIFFE JWT SVIDs and JWT bundles maintained via the Workload API.
*/
@Log
public class JwtSource implements JwtSvidSource, BundleSourceWatcher handles updates of type T.
+ * Watches updates of type T.
*
* @param WorkloadApiClient represents a client to interact with the Workload API.
+ * Represents a client to interact with the Workload API.
* X509Context represents the X.509 materials that are fetched from the Workload API.
+ * Represents the X.509 materials that are fetched from the Workload API.
* X509Source represents a source of X.509 SVIDs and X.509 bundles maintained via the
- * Workload API.
+ * Represents a source of X.509 SVIDs and X.509 bundles maintained via the Workload API.
*