Class GenericJsonJWEBuilder<A>
- Type Parameters:
A- the payload type
- All Implemented Interfaces:
JsonJOSEObjectBuilder<A,,JsonJWE<A, JsonJWE.BuiltRecipient<A>>, GenericJWEHeader, GenericJsonJWEBuilder<A>> JsonJWEBuilder<A,GenericJWEHeader, GenericJsonJWEBuilder<A>>
Generic JSON JWE builder implementation.
- Since:
- 1.5
- Author:
- Jeremy Kuhn
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classBuilt recipient info for building and holding recipient specific information. -
Field Summary
Fields inherited from class io.inverno.mod.security.jose.internal.AbstractJsonJOSEObjectBuilder
dataConversionService, jwkService, mapper, payload, protectedHeaderConfigurer, type, unprotectedHeaderConfigurer -
Constructor Summary
ConstructorsConstructorDescriptionGenericJsonJWEBuilder(com.fasterxml.jackson.databind.ObjectMapper mapper, io.inverno.mod.security.jose.internal.converter.DataConversionService dataConversionService, JWKService jwkService, Type type, List<JWEZip> zips) Creates a generic JSON JWE builder. -
Method Summary
Modifier and TypeMethodDescriptionSpecifies the additional authentication data to use when encrypting the payload.reactor.core.publisher.Mono<JsonJWE<A,JsonJWE.BuiltRecipient<A>>> Builds the JSON JOSE object using the specified payload media type.reactor.core.publisher.Mono<JsonJWE<A,JsonJWE.BuiltRecipient<A>>> Builds the JSON JOSE object using the specified payload encoder.reactor.core.publisher.Mono<JsonJWE<A,JsonJWE.BuiltRecipient<A>>> build(Function<A, reactor.core.publisher.Mono<String>> overridingPayloadEncoder, String overridingContentType) Builds a JSON JWE.protected reactor.core.publisher.Mono<GenericJWEPayload<A>>buildJWEPayload(Function<A, reactor.core.publisher.Mono<String>> overridingPayloadEncoder, String overridingContentType, String cty) Builds the JSON JWE payloadprotected JsonJWEHeaderBuilds the protected JSON JWE header.protected JsonJWEHeaderBuilds the unprotected JSON JWE header.recipient(Consumer<GenericJWEHeader> headerConfigurer, org.reactivestreams.Publisher<? extends JWK> keys) Specifies a recipient to add to the resulting JSON JWE object using the specified keys.secureRandom(SecureRandom secureRandom) Specifies the secure random to use when encrypting the payload.Methods inherited from class io.inverno.mod.security.jose.internal.AbstractJsonJOSEObjectBuilder
checkPayload, getPayloadEncoder, headers, payloadMethods 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.JsonJOSEObjectBuilder
build, headers, payloadMethods inherited from interface io.inverno.mod.security.jose.jwe.JsonJWEBuilder
recipient
-
Constructor Details
-
GenericJsonJWEBuilder
public GenericJsonJWEBuilder(com.fasterxml.jackson.databind.ObjectMapper mapper, io.inverno.mod.security.jose.internal.converter.DataConversionService dataConversionService, JWKService jwkService, Type type, List<JWEZip> zips) Creates a generic JSON JWE builder.
- Parameters:
mapper- an object mapperdataConversionService- a data conversion servicejwkService- a JWK servicetype- the payload typezips- a list of supported JWE compression algorithms
-
-
Method Details
-
additionalAuthenticationData
Description copied from interface:JsonJWEBuilderSpecifies the additional authentication data to use when encrypting the payload.
- Specified by:
additionalAuthenticationDatain interfaceJsonJWEBuilder<A,GenericJWEHeader, GenericJsonJWEBuilder<A>> - Parameters:
aad- additional authentication data- Returns:
- this builder
-
secureRandom
Description copied from interface:JsonJWEBuilderSpecifies the secure random to use when encrypting the payload.
- Specified by:
secureRandomin interfaceJsonJWEBuilder<A,GenericJWEHeader, GenericJsonJWEBuilder<A>> - Parameters:
secureRandom- a secure random- Returns:
- this builder
-
recipient
public GenericJsonJWEBuilder<A> recipient(Consumer<GenericJWEHeader> headerConfigurer, org.reactivestreams.Publisher<? extends JWK> keys) Description copied from interface:JsonJWEBuilderSpecifies a recipient to add to the resulting JSON JWE object using the specified keys.
The builder will use the specified keys to encrypt the content encryption key, the first succeeding key will be retained and remaining keys will be ignored. It will fail if no suitable key have been specified or if they are not consistent with the JWE JOSE header resulting from the merge of the protected, unprotected and recipient specific headers.
- Specified by:
recipientin interfaceJsonJWEBuilder<A,GenericJWEHeader, GenericJsonJWEBuilder<A>> - Parameters:
headerConfigurer- the recipient specific JWE JOSE headerkeys- the keys to consider to encrypt the recipient content encryption key- Returns:
- this builder
-
build
public reactor.core.publisher.Mono<JsonJWE<A,JsonJWE.BuiltRecipient<A>>> build(String contentType) throws JWEBuildException, JOSEObjectBuildException, JOSEProcessingException Description copied from interface:JsonJOSEObjectBuilderBuilds the JSON JOSE object using the specified payload media type.
The builder will use the specified media type to determine the converter to use to serialize the payload and ignore the content type specified in the JOSE headers. 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 build method
JsonJOSEObjectBuilder.build(java.util.function.Function)to provide a custom payload encoder.- Specified by:
buildin interfaceJsonJOSEObjectBuilder<A,JsonJWE<A, JsonJWE.BuiltRecipient<A>>, GenericJWEHeader, GenericJsonJWEBuilder<A>> - Parameters:
contentType- the payload media type- Returns:
- a single JSON JOSE object publisher
- Throws:
JOSEObjectBuildException- if there was an error building the JSON JOSE objectJOSEProcessingException- if there was a JOSE processing errorJWEBuildException
-
build
public reactor.core.publisher.Mono<JsonJWE<A,JsonJWE.BuiltRecipient<A>>> build(Function<A, reactor.core.publisher.Mono<String>> payloadEncoder) throws JWEBuildException, JOSEObjectBuildException, JOSEProcessingExceptionDescription copied from interface:JsonJOSEObjectBuilderBuilds the JSON JOSE object using the specified payload encoder.
The builder will use the specified payload encoder to serialize the payload and ignore the content type specified in the JOSE headers.
- Specified by:
buildin interfaceJsonJOSEObjectBuilder<A,JsonJWE<A, JsonJWE.BuiltRecipient<A>>, GenericJWEHeader, GenericJsonJWEBuilder<A>> - Parameters:
payloadEncoder- a payload encoder- Returns:
- a single JSON JOSE object publisher
- Throws:
JOSEObjectBuildException- if there was an error building the JSON JOSE objectJOSEProcessingException- if there was a JOSE processing errorJWEBuildException
-
build
public reactor.core.publisher.Mono<JsonJWE<A,JsonJWE.BuiltRecipient<A>>> build(Function<A, reactor.core.publisher.Mono<String>> overridingPayloadEncoder, String overridingContentType) throws JWEBuildException, JOSEObjectBuildException, JOSEProcessingExceptionBuilds a JSON JWE.
This method checks that the
typ,cty,encandzipheader parameters are consistent for all JSON JWS signatures.- Parameters:
overridingPayloadEncoder- an overriding payload encoderoverridingContentType- an overriding payload content type- Returns:
- a single JSON JWE publisher
- Throws:
JWEBuildException- if there was an error building the JSON JWEJOSEObjectBuildException- if there was an error building the JSON JWEJOSEProcessingException- if there was a JOSE processing error
-
buildProtectedJWEHeader
Builds the protected JSON JWE header.
- Returns:
- a JSON JWE header
- Throws:
JWEBuildException- if there was an error building the JWE header
-
buildUnprotectedJWEHeader
Builds the unprotected JSON JWE header.
- Returns:
- a JSON JWE header
- Throws:
JWEBuildException- if there was an error building the JWE header
-
buildJWEPayload
protected reactor.core.publisher.Mono<GenericJWEPayload<A>> buildJWEPayload(Function<A, reactor.core.publisher.Mono<String>> overridingPayloadEncoder, String overridingContentType, String cty) throws JWEBuildExceptionBuilds the JSON JWE payload
- Parameters:
overridingPayloadEncoder- an overriding payload encoderoverridingContentType- an overriding payload content typecty- the payload content type defined in JOSE headers- Returns:
- a single JWE payload publisher
- Throws:
JWEBuildException- if there was an error building the JWE payload
-