Class Credentials

java.lang.Object
com.northconcepts.datapipeline.security.Credentials

public final class Credentials extends Object
An immutable bundle of resolved secret values keyed by name, with an optional expiry.

Values are held as char[] so they can be wiped with clear(). Well-known keys (USERNAME, PASSWORD, ACCESS_KEY, SECRET_KEY, SESSION_TOKEN, TOKEN) let backends agree on names without a rigid type hierarchy; backends may also define their own keys.

toString() prints key names only — never secret values.

See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    Assembles Credentials from key-value pairs and an optional expiry; see builder().
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    static final String
     
    static final String
     
    static final String
     
    static final String
     
    static final String
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates a builder for assembling credentials one key at a time, with an optional expiry.
    void
    Overwrites all secret values with zeros and empties this bundle.
    boolean
    Returns true if a value is present for the given key (false for every key after clear()).
    Returns an independent copy of these credentials.
    get(String key)
    Returns the value for the given key or null if it's absent (or this instance was cleared).
    long
    Returns the time in milliseconds when these credentials expire or zero (0) if no expiry is known.
    Returns a read-only view of the keys present in these credentials.
    boolean
    Indicates if these credentials have already expired; always returns false when no expiry is known.
    boolean
    isExpired(long skewMilliseconds)
    Indicates if these credentials have expired or will expire within the next skewMilliseconds.
    of(String... keyValuePairs)
    Creates credentials from alternating key-value pairs: Credentials.of(Credentials.USERNAME, "scott", Credentials.PASSWORD, "tiger").
    Returns the value for the given key or throws a DataException if it's absent.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

  • Method Details

    • builder

      public static Credentials.Builder builder()
      Creates a builder for assembling credentials one key at a time, with an optional expiry.
    • of

      public static Credentials of(String... keyValuePairs)
      Creates credentials from alternating key-value pairs: Credentials.of(Credentials.USERNAME, "scott", Credentials.PASSWORD, "tiger").
    • get

      public String get(String key)
      Returns the value for the given key or null if it's absent (or this instance was cleared).
    • require

      public String require(String key) throws DataException
      Returns the value for the given key or throws a DataException if it's absent.
      Throws:
      DataException
    • contains

      public boolean contains(String key)
      Returns true if a value is present for the given key (false for every key after clear()).
    • getKeys

      public Set<String> getKeys()
      Returns a read-only view of the keys present in these credentials.
    • getExpiresOn

      public long getExpiresOn()
      Returns the time in milliseconds when these credentials expire or zero (0) if no expiry is known.
    • isExpired

      public boolean isExpired(long skewMilliseconds)
      Indicates if these credentials have expired or will expire within the next skewMilliseconds. Always returns false when no expiry is known.
    • isExpired

      public boolean isExpired()
      Indicates if these credentials have already expired; always returns false when no expiry is known.
    • copy

      public Credentials copy()
      Returns an independent copy of these credentials. Clearing the copy does not affect this instance.
    • clear

      public void clear()
      Overwrites all secret values with zeros and empties this bundle. Subsequent calls to get(String) return null.
    • toString

      public String toString()
      Overrides:
      toString in class Object