Class EncryptJWTHandler
- java.lang.Object
-
- net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
-
- org.opensaml.messaging.handler.AbstractMessageHandler
-
- net.shibboleth.oidc.security.impl.EncryptJWTHandler
-
- All Implemented Interfaces:
Component,DestructableComponent,InitializableComponent,MessageHandler
public class EncryptJWTHandler extends AbstractMessageHandler
AMessageHandlerthat encrypts a JWT using theEncryptionParametersfound in theSecurityParametersContext. ThePayloadto encrypt is determined by lookup strategy. A supplied consumer takes theEncryptedJWTand updates the correct object in theMessageContext.
-
-
Field Summary
Fields Modifier and Type Field Description private EncryptionParametersencryptionParametersThe signature signing parameters.private BiConsumer<com.nimbusds.jwt.JWT,MessageContext>jwtUpdateConsumerA consumer that takes the EncryptedJWT and updates the correct object inside the MessageContext.private org.slf4j.LoggerlogClass logger.private StringlogNameA friendly name to log as the subject of encryption.private Function<MessageContext,com.nimbusds.jose.Payload>payloadToEncryptLookupStrategyStrategy used to locate the payload to encrypt.private Function<MessageContext,SecurityParametersContext>securityParametersLookupStrategyStrategy used to locate theSecurityParametersContextto use for signing.
-
Constructor Summary
Constructors Constructor Description EncryptJWTHandler()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddoInitialize()protected voiddoInvoke(MessageContext messageContext)protected booleandoPreInvoke(MessageContext messageContext)private voidlogEncryption(String keyID, String alg, String enc)A convince method to log encryption parameters.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 encryption.voidsetPayloadToEncryptLookupStrategy(Function<MessageContext,com.nimbusds.jose.Payload> strategy)Set the strategy used to locate thePayloadto encrypt.voidsetSecurityParametersLookupStrategy(Function<MessageContext,SecurityParametersContext> strategy)Set the strategy used to locate theSecurityParametersContextto use.-
Methods inherited from class org.opensaml.messaging.handler.AbstractMessageHandler
doPostInvoke, doPostInvoke, getActivationCondition, getLogPrefix, invoke, setActivationCondition
-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, doDestroy, initialize, isDestroyed, isInitialized
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.shibboleth.utilities.java.support.component.InitializableComponent
initialize, isInitialized
-
-
-
-
Field Detail
-
log
@Nonnull private final org.slf4j.Logger log
Class logger.
-
securityParametersLookupStrategy
@Nonnull private Function<MessageContext,SecurityParametersContext> securityParametersLookupStrategy
Strategy used to locate theSecurityParametersContextto use for signing.
-
payloadToEncryptLookupStrategy
@NonnullAfterInit private Function<MessageContext,com.nimbusds.jose.Payload> payloadToEncryptLookupStrategy
Strategy used to locate the payload to encrypt.
-
jwtUpdateConsumer
@NonnullAfterInit private BiConsumer<com.nimbusds.jwt.JWT,MessageContext> jwtUpdateConsumer
A consumer that takes the EncryptedJWT and updates the correct object inside the MessageContext.
-
encryptionParameters
@Nullable private EncryptionParameters encryptionParameters
The signature signing parameters.
-
logName
@Nonnull private String logName
A friendly name to log as the subject of encryption.
-
-
Method Detail
-
setLogName
public void setLogName(@Nonnull @NotEmpty String name)
Set the friendly name to log as the subject of encryption.- Parameters:
name- the friendly name
-
setJwtUpdateConsumer
public void setJwtUpdateConsumer(BiConsumer<com.nimbusds.jwt.JWT,MessageContext> consumer)
Set the consumer used to update the MessageContext with the supplied EncryptedJWT.- Parameters:
consumer- the consumer
-
setPayloadToEncryptLookupStrategy
public void setPayloadToEncryptLookupStrategy(@Nonnull Function<MessageContext,com.nimbusds.jose.Payload> strategy)Set the strategy used to locate thePayloadto encrypt.- Parameters:
strategy- the strategy
-
setSecurityParametersLookupStrategy
public void setSecurityParametersLookupStrategy(@Nonnull Function<MessageContext,SecurityParametersContext> strategy)Set the strategy used to locate theSecurityParametersContextto use.- Parameters:
strategy- lookup strategy
-
doInitialize
protected void doInitialize() throws ComponentInitializationException- Overrides:
doInitializein classAbstractInitializableComponent- Throws:
ComponentInitializationException
-
doPreInvoke
protected boolean doPreInvoke(@Nonnull MessageContext messageContext) throws MessageHandlerException- Overrides:
doPreInvokein classAbstractMessageHandler- Throws:
MessageHandlerException
-
doInvoke
protected void doInvoke(@Nonnull MessageContext messageContext) throws MessageHandlerException- Specified by:
doInvokein classAbstractMessageHandler- Throws:
MessageHandlerException
-
logEncryption
private void logEncryption(@Nullable String keyID, @Nullable String alg, @Nullable String enc)A convince method to log encryption parameters. Avoids some of the clutter in the calling methods.- Parameters:
keyID- the keyIDalg- the content encryption algorithmenc- the key management algorithm
-
-