public abstract class AbstractPKCEGenerator extends java.lang.Object implements PKCEGenerator
PKCEGenerator
where subclasses
determine what code challenge method to be used and how to generate that data.Constructor and Description |
---|
AbstractPKCEGenerator(CodeChallengeMethod codeChallengeMethod)
Creates a new instance for the given code challenge method and a default random string generator
and true for createBase64EncodedCodeVerifiers.
|
AbstractPKCEGenerator(CodeChallengeMethod codeChallengeMethod,
StringGenerator randomStringGenerator)
Creates a new instance with the given arguments.
|
Modifier and Type | Method and Description |
---|---|
protected abstract java.lang.String |
createCodeChallenge(java.lang.String codeVerifier)
Returns the derived code challenge string for the given code verifier
by applying the
getCodeChallengeMethod() . |
ProofKeyForCodeExchange |
generate()
Generates a new random
ProofKeyForCodeExchange . |
protected java.lang.String |
generateRandomCodeVerifier()
Returns a new random string to be used as code verifier.
|
CodeChallengeMethod |
getCodeChallengeMethod()
Returns the code challenge method this generator is using to
create the code challenge.
|
protected StringGenerator |
getRandomStringGenerator()
Returns the generator for random strings.
|
java.lang.String |
toString() |
public AbstractPKCEGenerator(CodeChallengeMethod codeChallengeMethod)
codeChallengeMethod
- The mechanism to be used for deriving the code challenge from the code verifier (must not be null).public AbstractPKCEGenerator(CodeChallengeMethod codeChallengeMethod, StringGenerator randomStringGenerator)
codeChallengeMethod
- The mechanism to be used for deriving the code challenge from the code verifier (must not be null).randomStringGenerator
- A string generator that produces a different string for each invocation (must not be null).
It will be used to generate new code verifier strings.public ProofKeyForCodeExchange generate()
PKCEGenerator
ProofKeyForCodeExchange
.
The mechanism how the random code verifier gets generated and the
used code challenge method is up to the implementor of this method.generate
in interface PKCEGenerator
public CodeChallengeMethod getCodeChallengeMethod()
public java.lang.String toString()
toString
in class java.lang.Object
protected java.lang.String generateRandomCodeVerifier()
This method provides a default string generation mechanism that can be overridden by subclasses if needed, but usually the better approach for customization is providing a different StringGenerator during instance creation.
protected StringGenerator getRandomStringGenerator()
protected abstract java.lang.String createCodeChallenge(java.lang.String codeVerifier)
getCodeChallengeMethod()
.codeVerifier
- The newly created random code verifier.