Record Class TurnstileAnswer

java.lang.Object
java.lang.Record
org.jwcarman.who.turnstile.TurnstileAnswer
Record Components:
success - whether Cloudflare accepts the token
action - the action the widget was given when the token was made, if any
hostname - the hostname the token was made on, if any
challengeTs - when the widget's challenge was solved, if given
cdata - the data the page gave the widget when it made the token, if any
errorCodes - why Cloudflare refused the token, empty when it accepted it

public record TurnstileAnswer(boolean success, Optional<String> action, Optional<String> hostname, Optional<Instant> challengeTs, Optional<String> cdata, List<String> errorCodes) extends Record
Cloudflare's siteverify answer about a token.
  • Constructor Details

  • Method Details

    • of

      public static TurnstileAnswer of(Map<String,Object> json)
      Reads siteverify's JSON. Only a JSON true is success; fields of the wrong type, and a challenge_ts that is not an ISO-8601 instant, count as absent.
      Parameters:
      json - the answer, as Spring read it
      Returns:
      the answer
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • success

      public boolean success()
      Returns the value of the success record component.
      Returns:
      the value of the success record component
    • action

      public Optional<String> action()
      Returns the value of the action record component.
      Returns:
      the value of the action record component
    • hostname

      public Optional<String> hostname()
      Returns the value of the hostname record component.
      Returns:
      the value of the hostname record component
    • challengeTs

      public Optional<Instant> challengeTs()
      Returns the value of the challengeTs record component.
      Returns:
      the value of the challengeTs record component
    • cdata

      public Optional<String> cdata()
      Returns the value of the cdata record component.
      Returns:
      the value of the cdata record component
    • errorCodes

      public List<String> errorCodes()
      Returns the value of the errorCodes record component.
      Returns:
      the value of the errorCodes record component