Class Origin

java.lang.Object
org.attribyte.snook.auth.Origin

public class Origin extends Object
An immutable origin for a request.
  • Field Details

    • EMPTY

      public static final Origin EMPTY
      The empty origin.
  • Constructor Details

    • Origin

      public Origin(String str)
      Creates an origin from a string that must be a valid URI.
      Parameters:
      str - A valid URI as a string.
      Throws:
      IllegalArgumentException - if string is not a valid URI.
    • Origin

      public Origin(URI uri)
      Creates an origin from a parsed URI.
      Parameters:
      uri - The URI.
    • Origin

      public Origin(String host, int port, boolean isSecure)
      Create an origin from a known host and port.
      Parameters:
      host - The host.
      port - The port.
      isSecure - Is the origin secure?
  • Method Details

    • host

      public final String host()
      The host or an empty string if EMPTY.
      Returns:
      The host or an empty string.
    • port

      public final int port()
      Returns:
      The port or -1.
    • isSecure

      public final boolean isSecure()
      Returns:
      Is the origin secure (https)?
    • toString

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

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object