Class SpiffeIdUtils

java.lang.Object
io.spiffe.spiffeid.SpiffeIdUtils

public final class SpiffeIdUtils extends Object
Utility class with methods to read SPIFFE IDs using different mechanisms.
  • Method Details

    • getSpiffeIdSetFromFile

      public static Set<SpiffeId> getSpiffeIdSetFromFile(Path spiffeIdsFile) throws IOException
      Reads a file containing a list of SPIFFE IDs and parses them to SpiffeId instances.

      The file should have one SPIFFE ID per line.

      Parameters:
      spiffeIdsFile - the path to the file containing a list of SPIFFE IDs
      Returns:
      a List of SpiffeId parsed from the file provided
      Throws:
      IOException - if the given spiffeIdsFile cannot be read
      IllegalArgumentException - if any of the SPIFFE IDs in the file cannot be parsed
    • toSetOfSpiffeIds

      public static Set<SpiffeId> toSetOfSpiffeIds(String spiffeIds, char separator)
      Parses a string representing a list of SPIFFE IDs and returns a list of instances of SpiffeId.
      Parameters:
      spiffeIds - a list of SPIFFE IDs represented in a string
      separator - used to separate the SPIFFE IDs in the string. Only the pipe character and the blank space are valid separators
      Returns:
      a list of SpiffeId instances.
      Throws:
      IllegalArgumentException - is the separator provided is not valid
    • toSetOfSpiffeIds

      public static Set<SpiffeId> toSetOfSpiffeIds(String spiffeIds)
      Return the list of the SPIFFE IDs parsed from the String parameter, using the default separator (pipe character).
      Parameters:
      spiffeIds - a String representing a list of SPIFFE IDs separated by the pipe character
      Returns:
      a list of SpiffeId instances
      Throws:
      IllegalArgumentException - is the string provided is blank