Class AuthorizationHeader


  • public class AuthorizationHeader
    extends Header
    A header class representing the Authorization HTTP header.

    The Authorization header is made up of <type><space><credentials>, where credentials can be any text that fulfils the requirements of the type. e.g. for a type of Basic, the credentials will be base64encode(username + ":" + password).

    • Constructor Detail

      • AuthorizationHeader

        public AuthorizationHeader()
    • Method Detail

      • getName

        public String getName()
        Description copied from class: Header
        Returns the name of the header, as it would canonically appear within an HTTP message.
        Specified by:
        getName in class Header
        Returns:
        The name of the header, as it would canonically appear within an HTTP message.
      • getValues

        public List<String> getValues()
        Description copied from class: Header
        Returns the header as a list of strings. If the header has no values then it must return an empty list, never null. Each String should represent the value component of the key-value pair that makes up the HTTP header - as such, for some Header implementations each String in this List may contain multiple token-separated values.

        The List returned from this method should not be expected to be mutable. However, some subclasses of Header may choose to implement it as such.

        Specified by:
        getValues in class Header
        Returns:
        The header as a non-null list of string values. Can be an empty list.
      • getRawValue

        public String getRawValue()
        Get the raw value of the header.
        Returns:
        The raw value.
      • getType

        public String getType()
        Get the type of the authorization being presented, e.g. Basic
        Returns:
        The type.
      • getCredentials

        public String getCredentials()
        Get the credentials component of the header value.
        Returns:
        The credentials string.
      • parseCredentials

        public <C> Optional<C> parseCredentials​(CredentialsParser<C> parser)
                                         throws MalformedHeaderException
        Parse the credentials to a rich type.
        Type Parameters:
        C - The rich type for the credentials.
        Parameters:
        parser - The parser that can parse to the rich type.
        Returns:
        An optional of the parsed credentials, or an empty optional if the type is not supported by the provided parser.
        Throws:
        MalformedHeaderException - If the credentials are not valid for the type.