Class StateData

java.lang.Object
net.shibboleth.sp.state.StateData

@NotThreadSafe public class StateData extends Object
A DTO class that carries protocol state information that needs to be recovered to validate a protocol response; this class is designed for JSON serialization and deserialization for storage e.g. in a cookie or database.

This class is designed to be extended to support non-generic protocol state as required.

The resource URL is typed internally as String and is opaque to this class so as to support any character encoding necessary without assuming UTF-8. Callers should take care to encode the URL as required (e.g., even base64 encoding is acceptable), or use the method suitable for operating to and from byte array to allow the class to address it.

  • Field Details

    • clientAddress

      @Nullable private String clientAddress
      The client's address for optional enforcement.
    • issuer

      @Nullable private String issuer
      The identifier of the party that is making a request, i.e., us.
    • authenticatingAuthority

      @Nullable private String authenticatingAuthority
      The expected issuer of the authentication response.
    • passive

      @Nullable private Boolean passive
      Set when request is passive.
    • requestTime

      @Nullable private Instant requestTime
      The time at which a request was issued.
    • acrs

      @Nonnull @Unmodifiable @NotLive private List<String> acrs
      List of authentication context class references requested in the authentication request.
    • responseLocation

      @Nullable private String responseLocation
      The location to which a response is expected.
    • resource

      @Nullable private String resource
      A resource location associated with the request.
  • Constructor Details

    • StateData

      public StateData()
      Constructor.
  • Method Details

    • getClientAddress

      @Nullable public String getClientAddress()
      Get the IP address of the client associated with the state.

      Can be used to optionally enforce the address when recovering the state.

      Returns:
      the client's address
    • setClientAddress

      @Nonnull public StateData setClientAddress(@Nullable String address)
      Set the identifier of the client that is making the authentication request. Can be used to ensure the audience of the response matches the client that made the request.
      Parameters:
      address - client address
      Returns:
      the updated object
    • getIssuer

      @Nullable public String getIssuer()
      Get the identifier of the party that is making the request, i.e., us.

      Can be used to ensure the audience of the response matches the client that made the request.

      Returns:
      the issuer
    • setIssuer

      @Nonnull public StateData setIssuer(@Nullable String id)
      Set the identifier of the party that is making the request, i.e., us.
      Parameters:
      id - the issuer to set
      Returns:
      the updated object
    • getAuthenticationAuthority

      @Nullable public String getAuthenticationAuthority()
      Get the expected issuer of a response to the message.
      Returns:
      the authentication authority
    • setAuthenticationAuthority

      @Nonnull public StateData setAuthenticationAuthority(@Nullable String authority)
      Set the expected issuer of a response to the message.
      Parameters:
      authority - the authentication authority to set
      Returns:
      the updated object
    • getPassive

      @Nullable public Boolean getPassive()
      Get the passive request indicator.
      Returns:
      passive indicator
    • setPassive

      @Nonnull public StateData setPassive(@Nullable Boolean flag)
      Set the passive request indicator.
      Parameters:
      flag - indicator
      Returns:
      the updated object
    • getRequestTime

      @Nullable public Instant getRequestTime()
      Get the time at which the request was issued.
      Returns:
      the time the request was issued
    • setRequestTime

      @Nonnull public StateData setRequestTime(@Nullable Instant time)
      Set the time at which the request was issued.
      Parameters:
      time - the time the request was issued
      Returns:
      the updated object
    • getAcrs

      @Nonnull @Live public List<String> getAcrs()
      Get the mutable list of authentication context classes requested.
      Returns:
      the context classes
    • setAcrs

      @Nonnull public StateData setAcrs(@Nullable List<String> refs)
      Set the authentication context classes requested.
      Parameters:
      refs - context class references
      Returns:
      the updated object
    • getResponseLocation

      @Nullable public String getResponseLocation()
      Get the location to which the response is expected to be sent.
      Returns:
      the expected response location
    • setResponseLocation

      public StateData setResponseLocation(@Nullable String loc)
      Set the location to which the response is expected to be sent.
      Parameters:
      loc - the location
      Returns:
      the updated object
    • getResource

      @Nullable public String getResource()
      Get the resource location associated with the request.
      Returns:
      the resource location
    • setResource

      public StateData setResource(@Nullable String loc)
      Set the resource location associated with the request.
      Parameters:
      loc - the location
      Returns:
      the updated object
    • getRawResource

      @Nullable public byte[] getRawResource()
      Get the resource location associated with the request in a raw form.

      The value retrieved must have previously been set via the setRawResource(byte[]) method.

      Returns:
      resource as a byte array
    • setRawResource

      public StateData setRawResource(@Nullable byte[] loc)
      Set the resource location associated with the request in a raw form.
      Parameters:
      loc - the location
      Returns:
      the updated object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • mask

      protected static String mask(String value)
      A method to mask all but the last 2 characters of a string value for logging purposes.
      Parameters:
      value - the string value to mask
      Returns:
      the masked string
    • encode

      @Nonnull protected static String encode(@Nonnull byte[] bytes)
      A simple encoder for non-ASCII characters.
      Parameters:
      bytes - bytes to encode
      Returns:
      the encoded string
    • decode

      @Nonnull protected static byte[] decode(@Nonnull String s)
      Decode URL-encoded data using ISO-8859-1 to guarantee a single byte encoding.
      Parameters:
      s - input string
      Returns:
      ISO-8859-1 byte string
    • hexchar

      private static int hexchar(int b)
      Converts a byte into a hex character.
      Parameters:
      b - input byte
      Returns:
      the hex character equivalent (capitalized)