Class GenericJWEReader<A>
- Type Parameters:
A- the expected payload type
- All Implemented Interfaces:
JOSEObjectReader<A,,JWEHeader, JWE<A>, GenericJWEReader<A>> JWEReader<A,GenericJWEReader<A>>
- Direct Known Subclasses:
RecipientJWEReader
Generic JSON Web Encryption compact reader implementation.
- Since:
- 1.5
- Author:
- Jeremy Kuhn
-
Field Summary
Fields inherited from class io.inverno.mod.security.jose.internal.AbstractJOSEObjectReader
applicationProcessedParameters, dataConversionService, jwkService, keys, mapper, type -
Constructor Summary
ConstructorsConstructorDescriptionGenericJWEReader(com.fasterxml.jackson.databind.ObjectMapper mapper, io.inverno.mod.security.jose.internal.converter.DataConversionService dataConversionService, JWKService jwkService, Type type, org.reactivestreams.Publisher<? extends JWK> keys, List<JWEZip> zips) Creates a generic JWE reader -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckHeader(JWEHeader header) Verifies that the JOSE header is valid.protected byte[]getAdditionalAuthenticationData(GenericJWEHeader jweHeader) Returns expected additional authentication data.protected JWEZipgetPayloadZip(String zip) Returns the JWE compression algorithm.Reads the specified compact representation using the specified payload media type and returns the corresponding JOSE object.Reads the specified compact representation using the specified payload decoder and returns the corresponding JOSE object.protected GenericJWEHeaderreadJWEHeader(String encodedHeader) Reads the JWE header.Methods inherited from class io.inverno.mod.security.jose.internal.AbstractJOSEObjectReader
checkCriticalParameters, getKeys, getPayloadDecoder, getProcessedParameters, processedParametersMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.inverno.mod.security.jose.JOSEObjectReader
processedParameters, read
-
Constructor Details
-
GenericJWEReader
public GenericJWEReader(com.fasterxml.jackson.databind.ObjectMapper mapper, io.inverno.mod.security.jose.internal.converter.DataConversionService dataConversionService, JWKService jwkService, Type type, org.reactivestreams.Publisher<? extends JWK> keys, List<JWEZip> zips) Creates a generic JWE reader
- Parameters:
mapper- an object mapperdataConversionService- a data conversion servicejwkService- a JWK servicetype- the expected payload typekeys- the keys to consider to decrypt the CEKzips- a list of supported JWE compression algorithms
-
-
Method Details
-
read
public reactor.core.publisher.Mono<JWE<A>> read(String compact, String contentType) throws JWEReadException, JWEBuildException, JOSEObjectReadException, JOSEObjectBuildException, JOSEProcessingException Description copied from interface:JOSEObjectReaderReads the specified compact representation using the specified payload media type and returns the corresponding JOSE object.
The reader will use the specified media type to determine the converter to use to deserialize the payload and ignore the content type specified in the JOSE header. The operation will fail if there is no media type converters defined for that particular media type. Media types converters are provided when building the JOSE module. Please consider read method
JOSEObjectReader.read(java.lang.String, java.util.function.Function)to provide a custom payload decoder.- Specified by:
readin interfaceJOSEObjectReader<A,JWEHeader, JWE<A>, GenericJWEReader<A>> - Parameters:
compact- a JOSE object compact representationcontentType- the expected payload media type- Returns:
- a single JOSE object publisher
- Throws:
JOSEObjectReadException- if there was an error reading the JOSE objectJOSEObjectBuildException- if there was an error building the JOSE objectJOSEProcessingException- if there was a JOSE processing errorJWEReadExceptionJWEBuildException
-
read
public reactor.core.publisher.Mono<JWE<A>> read(String compact, Function<String, reactor.core.publisher.Mono<A>> payloadDecoder) throws JWEReadException, JWEBuildException, JOSEObjectReadException, JOSEObjectBuildException, JOSEProcessingExceptionDescription copied from interface:JOSEObjectReaderReads the specified compact representation using the specified payload decoder and returns the corresponding JOSE object.
The reader will use the specified payload decoder to deserialize the payload and ignore the content type specified in the JOSE header.
- Specified by:
readin interfaceJOSEObjectReader<A,JWEHeader, JWE<A>, GenericJWEReader<A>> - Parameters:
compact- a JOSE object compact representationpayloadDecoder- a payload decoder- Returns:
- a single JOSE object publisher
- Throws:
JOSEObjectReadException- if there was an error reading the JOSE objectJOSEObjectBuildException- if there was an error building the JOSE objectJOSEProcessingException- if there was a JOSE processing errorJWEReadExceptionJWEBuildException
-
checkHeader
Description copied from class:AbstractJOSEObjectReaderVerifies that the JOSE header is valid.
This basically checks that:
- the algorithm is not blank
- Critical parameters set does not include registered parameters (see
AbstractJOSEObjectReader.getProcessedParameters()) - Critical parameters set does not include parameters not present in the custom parameters
- Overrides:
checkHeaderin classAbstractJOSEObjectReader<A,JWEHeader, JWE<A>, GenericJWEReader<A>> - Parameters:
header- the JOSE header- Throws:
JOSEObjectReadException- if the header is invalidJWEReadException
-
readJWEHeader
protected GenericJWEHeader readJWEHeader(String encodedHeader) throws JWEReadException, JOSEObjectReadException, JOSEProcessingException Reads the JWE header.
- Parameters:
encodedHeader- the Base64URL encoded JWE header- Returns:
- the JWE header
- Throws:
JWEReadException- if there was an error reading the JWE headerJOSEObjectReadException- if there was an error reading the JWE headerJOSEProcessingException- if there was a JOSE processing error
-
getAdditionalAuthenticationData
Returns expected additional authentication data.
For a compact JWE it should be
ASCII(Encoded Protected Header). For a JSON JWE it should beASCII(Encoded Protected Header || '.' || BASE64URL(JWE AAD)).- Parameters:
jweHeader- the JWE header- Returns:
- the additional authentication data
-
getPayloadZip
Returns the JWE compression algorithm.
- Parameters:
zip- the JWE compression algorithm name- Returns:
- a JWE compression algorithm or null if the compression algorithm name is blank
- Throws:
JWEReadException- if the compression algorithm name is not blank and no corresponding JWE compression algorithm could be found
-