Package uk.ac.starlink.auth
Class Challenge
java.lang.Object
uk.ac.starlink.auth.Challenge
Represents and parses challenge specifications as defined by RFC7235.
- Since:
- 9 Jun 2020
- Author:
- Mark Taylor
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns any auth parameters that form part of this challenge excluding the realm.getRealm()
Returns the authentication realm if defined.Utility method giving a non-empty value for a named parameter of this challenge.Utility method giving a non-null URL value for a named parameter of this challenge.Utility method giving a non-empty realm for this challenge.Returns the authentication scheme name.Returns the token68 value if defined.int
hashCode()
static void
Will parse a WWW-Authenticate string on the command line and print out the parsed challenges.parseChallenges
(String challengeTxt) Parses the content of a WWW-Authenticate header as a sequence of RFC7235 challenges.toString()
-
Constructor Details
-
Challenge
Constructs a challenge with an optional realm and auth parameters.- Parameters:
schemeName
- scheme name, case insensitiverealm
- specified realm value, or nullparams
- additional parameters (excluding realm); keys are case insensitive and will be mapped to lower
-
Challenge
Constructs a challenge with token68 string- Parameters:
schemeName
- scheme name, case insensitivetoken68
- token68 string
-
-
Method Details
-
getSchemeName
Returns the authentication scheme name.- Returns:
- scheme name, case insensitive
-
getRealm
Returns the authentication realm if defined.- Returns:
- realm or null
-
getToken68
Returns the token68 value if defined. If this is non-null, then there will be no parameters or realm.- Returns:
- token68 or null
-
getParams
Returns any auth parameters that form part of this challenge excluding the realm.- Returns:
- name->value map giving parameters; parameter names have been normalised to lower case
-
getRequiredRealm
Utility method giving a non-empty realm for this challenge. If no realm has been defined, a BadChallengeException is thrown.- Returns:
- non-empty realm string
- Throws:
BadChallengeException
- if there is no realm
-
getRequiredParameter
Utility method giving a non-empty value for a named parameter of this challenge. If the named parameter has not been specified, a BadChallengeException is thrown.- Parameters:
key
- parameter name, case-insensitive- Returns:
- non-empty value for parameter
key
- Throws:
BadChallengeException
- if no value is specified forkey
-
getRequiredParameterUrl
Utility method giving a non-null URL value for a named parameter of this challenge. If the named parameter is not specified or cannot be turned into a URL, a BadChallengeException is thrown.- Parameters:
key
- parameter name, case-insensitive- Returns:
- non-null URL for parameter
key
- Throws:
BadChallengeException
- if no URL value is specified forkey
-
hashCode
public int hashCode() -
equals
-
toString
-
parseChallenges
Parses the content of a WWW-Authenticate header as a sequence of RFC7235 challenges. According to RFC7235 there should be at least one value in the result, but syntactically invalid challenge text is just ignored, so the result is not guaranteed to be non-empty.- Parameters:
challengeTxt
- text as value of WWW-Authenticate header- Returns:
- list of parsed challenges
-
main
Will parse a WWW-Authenticate string on the command line and print out the parsed challenges.
-