public final class PKCE
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
METHOD_PLAIN |
static java.lang.String |
METHOD_S256 |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
createCodeChallenge(java.lang.String code_verifier,
java.lang.String code_challenge_method)
Uses the
code_challenge_method to transform the code_verifier to
produce a code_challenge . |
static java.lang.String |
createCodeVerifier()
Generates a cryptographically random, high entropy string that is
suitable to use as a code_verifier.
|
static boolean |
pkceMatch(java.lang.String code_verifier,
java.lang.String code_challenge,
java.lang.String code_challenge_method)
Checks that the
code_verifier matches the code_challenge . |
public static final java.lang.String METHOD_PLAIN
public static final java.lang.String METHOD_S256
public static java.lang.String createCodeVerifier()
public static java.lang.String createCodeChallenge(java.lang.String code_verifier, java.lang.String code_challenge_method)
code_challenge_method
to transform the code_verifier
to
produce a code_challenge
.code_verifier
- a cryptographically random, high entropy stringcode_challenge_method
- either plain
or S256
. When S256
,
the code_verifier
is hashed using the SHA-256 hashing algorithm and Base64-encoded.
When plain
, an empty String or null
, the code_verifier
is
not transformed; the code_challenge
is the same as the code_verifier
.code_challenge
public static boolean pkceMatch(java.lang.String code_verifier, java.lang.String code_challenge, java.lang.String code_challenge_method)
code_verifier
matches the code_challenge
.code_verifier
- a cryptographically random, high entropy string that is passed to the authorization endpointcode_challenge
- the result of transforming the code_verifier
using the code_challenge_methodcode_challenge_method
- the method used to transform code_verifier
into code_challenge
.true
if the supplied code_verifier
, when transformed per the code_challenge_method
,
matches the supplied code_challenge
. Otherwise, false
.