org.pfsw.security.oauth.pkce
Class S256PKCEGenerator

java.lang.Object
  extended by org.pfsw.security.oauth.pkce.AbstractPKCEGenerator
      extended by org.pfsw.security.oauth.pkce.S256PKCEGenerator
All Implemented Interfaces:
PKCEGenerator

public class S256PKCEGenerator
extends AbstractPKCEGenerator

An RFC-7636 PKCE proof key generator for the "S256" code challenge method.


Constructor Summary
S256PKCEGenerator()
          Creates a new instance with a default random string generator for new code verifier strings.
S256PKCEGenerator(org.pfsw.text.StringGenerator randomStringGenerator)
          Creates a new instance with the given random string generator.
 
Method Summary
static S256PKCEGenerator create()
          Creates a new instance with a default random string generator for new code verifier strings.
static S256PKCEGenerator create(org.pfsw.text.StringGenerator randomStringGenerator)
          Creates a new instance with the given random string generator.
protected  java.lang.String createCodeChallenge(java.lang.String codeVerifier)
          Returns the derived code challenge string for the given code verifier by applying the AbstractPKCEGenerator.getCodeChallengeMethod().
protected  java.lang.String encodeBase64(byte[] hash)
          This method is responsible for doing a proper base64 URL encoding of the given hash value.
static S256PKCEGenerator instance()
          Returns always the same instance of this class.
static ProofKeyForCodeExchange newProofKey()
          Returns a newly generated proof key.
 
Methods inherited from class org.pfsw.security.oauth.pkce.AbstractPKCEGenerator
generate, generateRandomCodeVerifier, getCodeChallengeMethod, getRandomStringGenerator, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

S256PKCEGenerator

public S256PKCEGenerator()
Creates a new instance with a default random string generator for new code verifier strings.


S256PKCEGenerator

public S256PKCEGenerator(org.pfsw.text.StringGenerator randomStringGenerator)
Creates a new instance with the given random string generator.

Parameters:
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.
Method Detail

instance

public static S256PKCEGenerator instance()
Returns always the same instance of this class.


create

public static S256PKCEGenerator create()
Creates a new instance with a default random string generator for new code verifier strings.


create

public static S256PKCEGenerator create(org.pfsw.text.StringGenerator randomStringGenerator)
Creates a new instance with the given random string generator.

Parameters:
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.

newProofKey

public static ProofKeyForCodeExchange newProofKey()
Returns a newly generated proof key.


createCodeChallenge

protected java.lang.String createCodeChallenge(java.lang.String codeVerifier)
Description copied from class: AbstractPKCEGenerator
Returns the derived code challenge string for the given code verifier by applying the AbstractPKCEGenerator.getCodeChallengeMethod().

Specified by:
createCodeChallenge in class AbstractPKCEGenerator
Parameters:
codeVerifier - The newly created random code verifier.
Returns:
The calculated code challenge.

encodeBase64

protected java.lang.String encodeBase64(byte[] hash)
This method is responsible for doing a proper base64 URL encoding of the given hash value.