Class AbstractJOSEObjectReader<A,B extends JOSEHeader,C extends JOSEObject<A,B>,D extends AbstractJOSEObjectReader<A,B,C,D>>
- Type Parameters:
A- the payload typeB- the JOSE header typeC- the JOSE object typeD- the JOSE object reader type
- All Implemented Interfaces:
JOSEObjectReader<A,B, C, D>
- Direct Known Subclasses:
GenericJWEReader,GenericJWSReader
Base JOSE object reader implementation.
- Since:
- 1.5
- Author:
- Jeremy Kuhn
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe set of custom parameters processed by the application.protected final io.inverno.mod.security.jose.internal.converter.DataConversionServiceThe data conversion service.protected final JWKServiceThe JWK service.protected final org.reactivestreams.Publisher<? extends JWK>The keys to consider to verify or decrypt JOSE objectsprotected final com.fasterxml.jackson.databind.ObjectMapperThe object mapper.protected final TypeThe payload type. -
Constructor Summary
ConstructorsConstructorDescriptionAbstractJOSEObjectReader(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) Creates a JOSE object reader. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckCriticalParameters(Set<String> crit, JWA... jwas) Verifies that all parameters in the critical parameters set are understood and processed either by the reader (seegetProcessedParameters()) or the application (seeprocessedParameters(java.lang.String...)).protected voidcheckHeader(B header) Verifies that the JOSE header is valid.protected reactor.core.publisher.Flux<? extends JWK>getKeys(JOSEHeader header) Returns the keys to consider to verify or decrypt JOSE objects.getPayloadDecoder(Function<String, reactor.core.publisher.Mono<A>> overridingPayloadDecoder, String overridingContentType, JOSEHeader header) Returns the payload decoder to use to deserialize the payload.Returns the set of parameters processed by the reader.processedParameters(String... parameters) Specifies the JOSE header custom parameters processed by the application.Methods 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
read, read, read
-
Field Details
-
mapper
protected final com.fasterxml.jackson.databind.ObjectMapper mapperThe object mapper. -
dataConversionService
protected final io.inverno.mod.security.jose.internal.converter.DataConversionService dataConversionServiceThe data conversion service. -
jwkService
The JWK service. -
type
The payload type. -
keys
The keys to consider to verify or decrypt JOSE objects -
applicationProcessedParameters
The set of custom parameters processed by the application.
-
-
Constructor Details
-
AbstractJOSEObjectReader
public AbstractJOSEObjectReader(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) Creates a JOSE object reader.
- Parameters:
mapper- an object mapperdataConversionService- a data conversion servicejwkService- a JWK servicetype- the expected payload typekeys- the keys to consider to verify or decrypt JOSE objects
-
-
Method Details
-
processedParameters
Description copied from interface:JOSEObjectReaderSpecifies the JOSE header custom parameters processed by the application.
These parameters are expected to be present in the JOSE header, they are not processed by the reader but by the application reading the JOSE object. This enables the reader to check that the critical parameters set defined in the JOSE header actually contains parameters that are understood and processed by either the reader or the application.
- Specified by:
processedParametersin interfaceJOSEObjectReader<A,B extends JOSEHeader, C extends JOSEObject<A, B>, D extends AbstractJOSEObjectReader<A, B, C, D>> - Parameters:
parameters- a list of parameters- Returns:
- this reader
-
getProcessedParameters
Returns the set of parameters processed by the reader.
These basically corresponds to the registered parameters processed and understood by the expected JOSE header.
- Returns:
- a set of parameters
-
getKeys
protected reactor.core.publisher.Flux<? extends JWK> getKeys(JOSEHeader header) throws JOSEObjectReadException Returns the keys to consider to verify or decrypt JOSE objects.
Keys can be provided explicitly to the reader, in which case, only the keys that supports the algorithm specified in the parsed JOSE header will be retained to verify or decrypt JOSE objects otherwise the reader will try to resolve keys based on the parsed JOSE header and only retain the trusted keys, typically those resolved from the
JWKStore, from a trustedKeyStoreor from a valid certificate chain.The resulting publisher will fail if no key could be found.
- Parameters:
header- the JOSE header- Returns:
- a publisher of keys
- Throws:
JOSEObjectReadException- if no suitable key could be found
-
checkHeader
Verifies that the JOSE header is valid.
This basically checks that:
- the algorithm is not blank
- Critical parameters set does not include registered parameters (see
getProcessedParameters()) - Critical parameters set does not include parameters not present in the custom parameters
- Parameters:
header- the JOSE header- Throws:
JOSEObjectReadException- if the header is invalidJOSEProcessingException- if there was a JOSE processing error
-
checkCriticalParameters
protected void checkCriticalParameters(Set<String> crit, JWA... jwas) throws JOSEObjectReadException, JOSEProcessingException Verifies that all parameters in the critical parameters set are understood and processed either by the reader (see
getProcessedParameters()) or the application (seeprocessedParameters(java.lang.String...)).The set of processed parameters is composed of the parameters processed by the reader (see
getProcessedParameters(), the parameters processed by the JSON Web Algorithms used to verify or decrypt JOSE objects and the parameters processed by the application (seeprocessedParameters(java.lang.String...)).- Parameters:
crit- the critical parameters setjwas- the list of JSON Web Algorithms used to verify or decrypt the JOSE object- Throws:
JOSEObjectReadException- if critical parameters set is invalid (i.e. it contains ununderstood and unprocessed parameters)JOSEProcessingException- if there was a JOSE processing error
-
getPayloadDecoder
protected Function<String,reactor.core.publisher.Mono<A>> getPayloadDecoder(Function<String, reactor.core.publisher.Mono<A>> overridingPayloadDecoder, String overridingContentType, JOSEHeader header) throws JOSEObjectReadException, JOSEProcessingExceptionReturns the payload decoder to use to deserialize the payload.
This method first considers the overriding payload decoder which is returned if present. Then the overriding content type is used if present to resolve the media type converter to use. Finally the payload content type in the parsed JOSE header is considered to resolve the media type converter to use.
- Parameters:
overridingPayloadDecoder- the overriding payload decoderoverridingContentType- the overriding payload media typeheader- the JOSE header- Returns:
- a payload decoder
- Throws:
JOSEObjectReadException- if no payload encoder could have been resolvedJOSEProcessingException- if there was a JOSE processing error
-