Class TokenSchemeError

    • Constructor Detail

      • TokenSchemeError

        protected TokenSchemeError​(AccessTokenType scheme,
                                   String code,
                                   String description,
                                   int httpStatusCode,
                                   URI uri,
                                   String realm,
                                   Scope scope)
        Creates a new token error with the specified code, description, HTTP status code, page URI, realm and scope.
        Parameters:
        scheme - The token scheme. Must not be null.
        code - The error code, null if not specified.
        description - The error description, null if not specified.
        httpStatusCode - The HTTP status code, zero if not specified.
        uri - The error page URI, null if not specified.
        realm - The realm, null if not specified.
        scope - The required scope, null if not specified.
    • Method Detail

      • isScopeWithValidChars

        public static boolean isScopeWithValidChars​(Scope scope)
        Returns true if the specified scope consists of valid characters. Values for the "scope" attributes must not include characters outside the [0x20, 0x21] | [0x23 - 0x5B] | [0x5D - 0x7E] range. See RFC 6750, section 3.
        Parameters:
        scope - The scope.
        Returns:
        true if the scope contains valid characters, else false.
        See Also:
        ErrorObject.isLegal(String)
      • getRealm

        public String getRealm()
        Returns the realm.
        Returns:
        The realm, null if not specified.
      • getScope

        public Scope getScope()
        Returns the required scope.
        Returns:
        The required scope, null if not specified.
      • appendDescription

        public abstract TokenSchemeError appendDescription​(String text)
        Description copied from class: ErrorObject
        Appends the specified text to the error description.
        Overrides:
        appendDescription in class ErrorObject
        Parameters:
        text - The text to append to the error description, null if not specified.
        Returns:
        A copy of this error with the specified appended description.
      • setHTTPStatusCode

        public abstract TokenSchemeError setHTTPStatusCode​(int httpStatusCode)
        Description copied from class: ErrorObject
        Sets the HTTP status code.
        Overrides:
        setHTTPStatusCode in class ErrorObject
        Parameters:
        httpStatusCode - The HTTP status code, zero if not specified.
        Returns:
        A copy of this error with the specified HTTP status code.
      • setURI

        public abstract TokenSchemeError setURI​(URI uri)
        Description copied from class: ErrorObject
        Sets the error page URI.
        Overrides:
        setURI in class ErrorObject
        Parameters:
        uri - The error page URI, null if not specified.
        Returns:
        A copy of this error with the specified page URI.
      • setRealm

        public abstract TokenSchemeError setRealm​(String realm)
        Sets the realm.
        Parameters:
        realm - realm, null if not specified.
        Returns:
        A copy of this error with the specified realm.
      • setScope

        public abstract TokenSchemeError setScope​(Scope scope)
        Sets the required scope.
        Parameters:
        scope - The required scope, null if not specified.
        Returns:
        A copy of this error with the specified required scope.
      • toWWWAuthenticateHeader

        public String toWWWAuthenticateHeader()
        Returns the WWW-Authenticate HTTP response header code for this token scheme error.

        Example:

         Bearer realm="example.com", error="invalid_token", error_description="Invalid access token"
         
        Returns:
        The Www-Authenticate header value.