Class JwtCNonceHandler
java.lang.Object
org.keycloak.protocol.oid4vc.issuance.keybinding.JwtCNonceHandler
- All Implemented Interfaces:
CNonceHandler,Provider
- Author:
- Pascal Knüppel
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionused to build a cNonce in any style.protected booleancheckAttributeEquality(String key, Object object, Object actualValue) voidconsumeCNonce(String cNonce) Marks a verified cNonce value as consumed.voidconsumeCNonce(String cNonce, JsonWebToken cNonceToken) Marks a verified cNonce value as consumed.voidensureCNonceNotYetConsumed(String cNonce) Checks ifcNonceis so far not yet consumed (without consuming it) for fail-fast purposes.protected KeyWrapperselectSigningKey(RealmModel realm) booleanbooleanvoidmust verify the validity of a cNonce value that has been issued by theCNonceHandler.buildCNonce(List, Map)method.verifyCNonceAndGetToken(String cNonce, List<String> audiences, Map<String, Object> additionalDetails) Verifies the validity of a cNonce value and returns its verified token representation.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.keycloak.protocol.oid4vc.issuance.keybinding.CNonceHandler
close
-
Field Details
-
SOURCE_ENDPOINT
- See Also:
-
NONCE_DEFAULT_LENGTH
public static final int NONCE_DEFAULT_LENGTH- See Also:
-
NONCE_LENGTH_RANDOM_OFFSET
public static final int NONCE_LENGTH_RANDOM_OFFSET- See Also:
-
-
Constructor Details
-
JwtCNonceHandler
-
-
Method Details
-
buildCNonce
Description copied from interface:CNonceHandlerused to build a cNonce in any style. For jwt-based cNonces we will additionally require the audience-values that should be added into the cNonce- Specified by:
buildCNoncein interfaceCNonceHandler- Parameters:
audiences- the audiences for jwt-based cNoncesadditionalDetails- additional attributes that might be required to build the cNonce and that are handler specific- Returns:
- the cNonce in string representation
-
verifyCNonce
public void verifyCNonce(String cNonce, List<String> audiences, @Nullable Map<String, Object> additionalDetails) throws VerificationExceptionDescription copied from interface:CNonceHandlermust verify the validity of a cNonce value that has been issued by theCNonceHandler.buildCNonce(List, Map)method.- Specified by:
verifyCNoncein interfaceCNonceHandler- Parameters:
cNonce- the cNonce to validateaudiences- the expected audiences for jwt-based cNoncesadditionalDetails- additional attributes that might be required to build the cNonce and that are handler specific- Throws:
VerificationException- if the cNonce cannot be verified
-
verifyCNonceAndGetToken
public JsonWebToken verifyCNonceAndGetToken(String cNonce, List<String> audiences, @Nullable Map<String, Object> additionalDetails) throws VerificationExceptionDescription copied from interface:CNonceHandlerVerifies the validity of a cNonce value and returns its verified token representation.- Specified by:
verifyCNonceAndGetTokenin interfaceCNonceHandler- Parameters:
cNonce- the cNonce to validateaudiences- the expected audiences for jwt-based cNoncesadditionalDetails- additional attributes that might be required to build the cNonce and that are handler specific- Returns:
- the verified cNonce token representation
- Throws:
VerificationException- if the cNonce cannot be verified
-
supportsCNonceTokenRetrieval
public boolean supportsCNonceTokenRetrieval()- Specified by:
supportsCNonceTokenRetrievalin interfaceCNonceHandler- Returns:
trueif this handler can return the verified cNonce token representation.
-
ensureCNonceNotYetConsumed
Description copied from interface:CNonceHandlerChecks ifcNonceis so far not yet consumed (without consuming it) for fail-fast purposes.- Specified by:
ensureCNonceNotYetConsumedin interfaceCNonceHandler- Throws:
VerificationException- if already consumed or check not supported.
-
consumeCNonce
Description copied from interface:CNonceHandlerMarks a verified cNonce value as consumed.- Specified by:
consumeCNoncein interfaceCNonceHandler- Parameters:
cNonce- the cNonce to consume- Throws:
VerificationException
-
consumeCNonce
Description copied from interface:CNonceHandlerMarks a verified cNonce value as consumed.- Specified by:
consumeCNoncein interfaceCNonceHandler- Parameters:
cNonce- the cNonce to consumecNonceToken- the already verified cNonce token- Throws:
VerificationException
-
supportsCNonceConsumption
public boolean supportsCNonceConsumption()- Specified by:
supportsCNonceConsumptionin interfaceCNonceHandler- Returns:
trueif this handler can mark cNonce values as consumed.
-
checkAttributeEquality
protected boolean checkAttributeEquality(String key, Object object, Object actualValue) throws VerificationException - Throws:
VerificationException
-
selectSigningKey
-