Class SpiffeId

java.lang.Object
io.spiffe.spiffeid.SpiffeId

public class SpiffeId extends Object
Represents a SPIFFE ID as defined in the SPIFFE standard.

See Also:
  • Method Details

    • fromSegments

      public static SpiffeId fromSegments(@NonNull @NonNull TrustDomain trustDomain, String... segments)
      Returns a new SPIFFE ID in the given trust domain with joined path segments. The path segments must be valid according to the SPIFFE specification and must not contain path separators. See https://github.com/spiffe/spiffe/blob/main/standards/SPIFFE-ID.md#22-path
      Parameters:
      trustDomain - an instance of a TrustDomain
      segments - a list of string path segments
      Returns:
      a SpiffeId
      Throws:
      InvalidSpiffeIdException - if a given path segment contains an invalid char or empty or dot segment
    • parse

      public static SpiffeId parse(String id)
      Parses a SPIFFE ID from a string (e.g. spiffe://example.org/test).
      Parameters:
      id - a String representing a SPIFFE ID
      Returns:
      A SpiffeId
      Throws:
      IllegalArgumentException - if the given string is empty
      InvalidSpiffeIdException - if the given string id contain an invalid scheme, invalid char or empty or dot segment
    • memberOf

      public boolean memberOf(TrustDomain trustDomain)
      Returns true if the trust domain of this SPIFFE ID is the same as trust domain given as parameter.
      Parameters:
      trustDomain - an instance of a TrustDomain
      Returns:
      true if the given trust domain equals the trust domain of this object, false otherwise
    • toString

      public String toString()
      Returns the string representation of the SPIFFE ID, concatenating schema, trust domain, and path segments (e.g. 'spiffe://example.org/path1/path2')
      Overrides:
      toString in class Object
    • validatePath

      public static void validatePath(String path)
      Validates that a path string is a conformant path for a SPIFFE ID. See https://github.com/spiffe/spiffe/blob/main/standards/SPIFFE-ID.md#22-path