Class Authorization


  • public final class Authorization
    extends java.lang.Object
    The value of an HTTP Authorization header.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static @NonNull Authorization basic​(@NonNull java.lang.String username, @NonNull java.lang.String password)
      Create an Authorization using the Basic scheme with the given username and password.
      boolean equals​(java.lang.Object o)  
      int hashCode()  
      static Authorization of​(@NonNull java.lang.String scheme, @NonNull java.lang.String parameters)
      Creates a new Authorization instance.
      @NonNull java.lang.String parameters()
      The parameters for the authorization.
      @NonNull java.lang.String scheme()
      Specifies the authentication scheme, which determines the format of the parameters() field.
      @NonNull HttpHeader toHeader()
      Return this Authorization as an HttpHeader.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Method Detail

      • toHeader

        @NonNull
        public @NonNull HttpHeader toHeader()
        Return this Authorization as an HttpHeader.
        Returns:
        an Authorization HttpHeader containing the scheme and parameters
      • basic

        @NonNull
        public static @NonNull Authorization basic​(@NonNull
                                                   @NonNull java.lang.String username,
                                                   @NonNull
                                                   @NonNull java.lang.String password)

        Create an Authorization using the Basic scheme with the given username and password.

        For Basic auth, the username and password are joined with a ':' and the resulting string is base64-encoded.

        Parameters:
        username - the username to authenticate as
        password - the password for the given username
        Returns:
        an Authorization with the encoded username and password
      • of

        public static Authorization of​(@NonNull
                                       @NonNull java.lang.String scheme,
                                       @NonNull
                                       @NonNull java.lang.String parameters)
        Creates a new Authorization instance.
        Parameters:
        scheme - Specifies the authentication scheme, which determines the format of the parameters() field. Common schemes are:
        • Basic: base64-encoded username and password
        • Bearer: OAuth 2.0
        parameters - The parameters for the authorization. The format and contents of this field are entirely determined by the scheme().
      • scheme

        @NonNull
        public @NonNull java.lang.String scheme()
        Specifies the authentication scheme, which determines the format of the parameters() field. Common schemes are:
        • Basic: base64-encoded username and password
        • Bearer: OAuth 2.0
      • parameters

        @NonNull
        public @NonNull java.lang.String parameters()
        The parameters for the authorization. The format and contents of this field are entirely determined by the scheme().
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object