Class AddPKCECodeVerifierAndChallenge
java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
org.opensaml.messaging.handler.AbstractMessageHandler
net.shibboleth.oidc.profile.messaging.handler.impl.AbstractAuthenticationRequestParameterValueMessageHandler<PKCEOptions>
net.shibboleth.oidc.profile.messaging.handler.impl.AddPKCECodeVerifierAndChallenge
- All Implemented Interfaces:
Component,DestructableComponent,InitializableComponent,MessageHandler
public class AddPKCECodeVerifierAndChallenge
extends AbstractAuthenticationRequestParameterValueMessageHandler<PKCEOptions>
Create an OAuth 2.0 PCKE code_verifier to use in the token request, and derives a code_challenge for immediate use in
the authorization request.
-
Field Summary
FieldsFields inherited from class net.shibboleth.oidc.profile.messaging.handler.impl.AbstractAuthenticationRequestParameterValueMessageHandler
PRC_LOOKUP -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate StringcomputeCodeChallenge(String codeVerifier, OAuthAuthorizationRequest.CodeChallengeMethod method) Compute the code_challenge from the code_verifier.protected voiddoInvoke(MessageContext messageContext) private static StringgenerateCodeVerifier(Integer length) Generates a code_verifier for use during Proof Key for Code Exchange.Methods inherited from class net.shibboleth.oidc.profile.messaging.handler.impl.AbstractAuthenticationRequestParameterValueMessageHandler
doPreInvoke, getAuthenticationRequest, getParameterValue, getProviderMetadata, setAuthenticationRequestLookupStrategy, setParameterValueLookupStrategy, setProviderMetadataLookupStrategyMethods inherited from class org.opensaml.messaging.handler.AbstractMessageHandler
doPostInvoke, doPostInvoke, getActivationCondition, getLogPrefix, invoke, isPreInvokeCalled, setActivationConditionMethods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent
checkComponentActive, checkSetterPreconditions, destroy, doDestroy, doInitialize, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException, initialize, isDestroyed, isInitializedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.shibboleth.shared.component.InitializableComponent
initialize, isInitialized
-
Field Details
-
log
@Nonnull private final org.slf4j.Logger logLogger.
-
-
Constructor Details
-
AddPKCECodeVerifierAndChallenge
public AddPKCECodeVerifierAndChallenge()Constructor.
-
-
Method Details
-
doInvoke
- Specified by:
doInvokein classAbstractMessageHandler- Throws:
MessageHandlerException
-
generateCodeVerifier
@Nonnull private static String generateCodeVerifier(@Nonnull Integer length) throws MessageHandlerException Generates a code_verifier for use during Proof Key for Code Exchange. The generated bytes are base64 URL encoded before they are returned.- Parameters:
length- the byte length of the code_verifier. Must be at least 32 bytes long (RFC7636 section 7.1).- Returns:
- the base64 URL encoded coder_verifier value.
- Throws:
MessageHandlerException- if there is an error generating the verifier.
-
computeCodeChallenge
@Nonnull @NotEmpty private String computeCodeChallenge(@Nonnull @NotEmpty String codeVerifier, @Nonnull OAuthAuthorizationRequest.CodeChallengeMethod method) throws MessageHandlerException Compute the code_challenge from the code_verifier. If theOAuthAuthorizationRequest.CodeChallengeMethod.PLAINmethod is used, the codeVerifier is returned directly. If theOAuthAuthorizationRequest.CodeChallengeMethod.S256method is used, the bytes of the codeVerifier are SHA-256 hashed and base 64 URL encoded before being returned.- Parameters:
codeVerifier- the code_verifier to compute the code_challenge frommethod- the code_challenge_method- Returns:
- the computed code_challenge
- Throws:
MessageHandlerException- on error computing the code_challenge
-