Class AbstractJOSEObjectBuilder<A,B extends JOSEHeader,C extends JOSEObject<A,B>,D extends JOSEHeaderConfigurator<D>,E extends AbstractJOSEObjectBuilder<A,B,C,D,E>>
- Type Parameters:
A- the payload typeB- the JOSE header typeC- the JOSE object typeD- the JOSE header configurator typeE- the JOSE object builder type
- All Implemented Interfaces:
JOSEObjectBuilder<A,B, C, D, E>
- Direct Known Subclasses:
GenericJWEBuilder,GenericJWSBuilder
Base JOSE object builder implementation.
- Since:
- 1.5
- Author:
- Jeremy Kuhn
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected 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 secure JOSE objects.protected final com.fasterxml.jackson.databind.ObjectMapperThe object mapper.protected AThe payload.protected final TypeThe payload type. -
Constructor Summary
ConstructorsConstructorDescriptionAbstractJOSEObjectBuilder(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 builder. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckHeader(B header) Verifies that the JOSE header is valid.protected voidVerifies that the payload is valid.protected reactor.core.publisher.Flux<? extends JWK>getKeys(JOSEHeader header) Returns the keys to consider to secure JOSE objects.getPayloadEncoder(Function<A, reactor.core.publisher.Mono<String>> overridingPayloadEncoder, String overridingContentType, JOSEHeader header) Returns the payload encoder to use to serialize the payload.Returns the set of parameters processed by the builder.Specifies the JOSE object payload.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.JOSEObjectBuilder
build, build, build, header
-
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 secure JOSE objects. -
payload
The payload.
-
-
Constructor Details
-
AbstractJOSEObjectBuilder
public AbstractJOSEObjectBuilder(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 builder.
- Parameters:
mapper- an object mapperdataConversionService- a data conversion servicejwkService- a JWK servicetype- the payload typekeys- the keys to consider to secure JOSE objects
-
-
Method Details
-
payload
Description copied from interface:JOSEObjectBuilderSpecifies the JOSE object payload.
- Specified by:
payloadin interfaceJOSEObjectBuilder<A,B extends JOSEHeader, C extends JOSEObject<A, B>, D extends JOSEHeaderConfigurator<D>, E extends AbstractJOSEObjectBuilder<A, B, C, D, E>> - Parameters:
payload- a payload- Returns:
- this builder
-
getProcessedParameters
Returns the set of parameters processed by the builder.
These basically corresponds to the registered parameters processed and understood by the JOSE header.
- Returns:
- a set of parameters
-
getKeys
protected reactor.core.publisher.Flux<? extends JWK> getKeys(JOSEHeader header) throws JOSEObjectBuildException Returns the keys to consider to secure JOSE objects.
Keys can be provided explicitly to the builder, in which case, only the keys that supports the specified algorithm will be retained to secure JOSE objects otherwise the builder will try to resolve keys based on the JOSE header built from the builder's parameters and only retain the trusted keys, typically those resolved from the
JWKStoreor from a trustedKeyStore.The resulting publisher will fail if no key could be found.
- Parameters:
header- the JOSE header- Returns:
- a publisher of keys
- Throws:
JOSEObjectBuildException- if no suitable key could be found
-
checkHeader
Verifies that the JOSE header is valid.
This basically checks that:
- the algorithm is not blank
- Custom parameters do not include registered parameters (see
getProcessedParameters()) - Critical parameters set does not include undefined parameters
- Parameters:
header- the JOSE header- Throws:
JOSEObjectBuildException- if the header is invalidJOSEProcessingException- if there was a JOSE processing error
-
checkPayload
Verifies that the payload is valid.
This basically checks that the payload is not null.
- Throws:
JOSEObjectBuildException- if the payload is invalidJOSEProcessingException- if there was a JOSE processing error
-
getPayloadEncoder
protected Function<A,reactor.core.publisher.Mono<String>> getPayloadEncoder(Function<A, reactor.core.publisher.Mono<String>> overridingPayloadEncoder, String overridingContentType, JOSEHeader header) throws JOSEObjectBuildException, JOSEProcessingExceptionReturns the payload encoder to use to serialize the payload.
This method first considers the overriding payload encoder 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 defined in the JOSE header is considered to resolve the media type converter to use.
- Parameters:
overridingPayloadEncoder- the overriding payload encoderoverridingContentType- the overriding payload media typeheader- the JOSE header- Returns:
- a payload encoder
- Throws:
JOSEObjectBuildException- if no payload encoder could have been resolvedJOSEProcessingException- if there was a JOSE processing error
-