Class SignJWTHandler
java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
org.opensaml.messaging.handler.AbstractMessageHandler
net.shibboleth.oidc.security.impl.SignJWTHandler
- All Implemented Interfaces:
Component,DestructableComponent,InitializableComponent,MessageHandler
Message handler that signs a JWT and sets it back to the message context via an update consumer.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Function<MessageContext,com.nimbusds.jwt.JWTClaimsSet> Strategy used to locate the payload to encrypt.private Credentialresolved credential.private com.nimbusds.jwt.JWTClaimsSetThe claims to sign.private BiConsumer<com.nimbusds.jwt.JWT,MessageContext> A consumer that takes the Signed JWT and updates the correct object inside the MessageContext.private final org.slf4j.LoggerClass logger.private StringA friendly name to log as the subject of signing.Strategy used to locate theSecurityParametersContextto use for signing.private SignatureSigningParametersThe signature signing parameters.private String"typ" header to insert while signing. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected voiddoInvoke(MessageContext messageContext) protected booleandoPreInvoke(MessageContext messageContext) private com.nimbusds.jose.JWSSignergetSigner(com.nimbusds.jose.Algorithm jwsAlgorithm) Returns correct implementation of signer based on algorithm type.protected com.nimbusds.jose.JWSAlgorithmResolves JWS algorithm from signature signing parameters.voidsetClaimsToSignLookupStrategy(Function<MessageContext, com.nimbusds.jwt.JWTClaimsSet> strategy) Set the strategy used to locate theJWTClaimsSetto sign.voidsetJwtUpdateConsumer(BiConsumer<com.nimbusds.jwt.JWT, MessageContext> consumer) Set the consumer used to update the MessageContext with the supplied EncryptedJWT.voidsetLogName(String name) Set the friendly name to log as the subject of signing.voidSet the strategy used to locate theSecurityParametersContextto use.voidsetTypeHeader(String type) Sets the value to be inserted as a "typ" header for the JWS.Methods 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, 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 logClass logger. -
securityParametersLookupStrategy
@Nonnull private Function<MessageContext,SecurityParametersContext> securityParametersLookupStrategyStrategy used to locate theSecurityParametersContextto use for signing. -
jwtUpdateConsumer
A consumer that takes the Signed JWT and updates the correct object inside the MessageContext. -
claimsToSignLookupStrategy
@NonnullAfterInit private Function<MessageContext,com.nimbusds.jwt.JWTClaimsSet> claimsToSignLookupStrategyStrategy used to locate the payload to encrypt. -
signatureSigningParameters
The signature signing parameters. -
credential
resolved credential. -
jwtClaimSetToSign
@Nullable private com.nimbusds.jwt.JWTClaimsSet jwtClaimSetToSignThe claims to sign. -
typeHeader
"typ" header to insert while signing. -
logName
A friendly name to log as the subject of signing.
-
-
Constructor Details
-
SignJWTHandler
public SignJWTHandler()Constructor.
-
-
Method Details
-
setLogName
Set the friendly name to log as the subject of signing.- Parameters:
name- the friendly name
-
doInitialize
- Overrides:
doInitializein classAbstractInitializableComponent- Throws:
ComponentInitializationException
-
setClaimsToSignLookupStrategy
public void setClaimsToSignLookupStrategy(@Nonnull Function<MessageContext, com.nimbusds.jwt.JWTClaimsSet> strategy) Set the strategy used to locate theJWTClaimsSetto sign.- Parameters:
strategy- the strategy
-
setJwtUpdateConsumer
Set the consumer used to update the MessageContext with the supplied EncryptedJWT.- Parameters:
consumer- the consumer
-
setTypeHeader
Sets the value to be inserted as a "typ" header for the JWS.- Parameters:
type- header value
-
setSecurityParametersLookupStrategy
public void setSecurityParametersLookupStrategy(@Nonnull Function<MessageContext, SecurityParametersContext> strategy) Set the strategy used to locate theSecurityParametersContextto use.- Parameters:
strategy- lookup strategy
-
doPreInvoke
protected boolean doPreInvoke(@Nonnull MessageContext messageContext) throws MessageHandlerException - Overrides:
doPreInvokein classAbstractMessageHandler- Throws:
MessageHandlerException
-
doInvoke
- Specified by:
doInvokein classAbstractMessageHandler- Throws:
MessageHandlerException
-
getSigner
private com.nimbusds.jose.JWSSigner getSigner(com.nimbusds.jose.Algorithm jwsAlgorithm) throws com.nimbusds.jose.JOSEException Returns correct implementation of signer based on algorithm type.- Parameters:
jwsAlgorithm- JWS algorithm- Returns:
- signer for algorithm and private key
- Throws:
com.nimbusds.jose.JOSEException- if algorithm cannot be supported
-
resolveAlgorithm
protected com.nimbusds.jose.JWSAlgorithm resolveAlgorithm()Resolves JWS algorithm from signature signing parameters.- Returns:
- JWS algorithm
-