Class ProviderContext
SecureRandom
source of randomness.
Use getSuppliedKeyProviderContext()
to indicate the provider to be used for cryptographic operations
directly involve the key supplied by the caller.
Use getGeneralProviderContext()
to indicate the provider to be used for other operations that do not directly involve the key supplied by the caller.
Signing and verification are operations that use the supplied key as do
key encryption and key agreement methods used to transmit or arrive at the content encryption key. Content encryption, however,
is done with that content encryption key rather than the supplied key. So, other than when using direct (alg=dir) encryption,
set the cipher provider name on the general provider to control the provider used in content encryption.
For example, to specify the provider for an RSA signature when producing a JWS, create a new ProviderContext
and set the name of the provider using
ProviderContext.Context.setSignatureProvider(String)
on the ProviderContext.Context
obtained from calling
getSuppliedKeyProviderContext()
. To specify the provider for an HMAC when producing a JWS, set the name of the provider using
ProviderContext.Context.setMacProvider(String)
on the Context
obtained from calling getSuppliedKeyProviderContext()
.
To specify the provider for decrypting a key with RSA when consuming a JWE, use ProviderContext.Context.setCipherProvider(String)
on the Context obtained from getSuppliedKeyProviderContext()
. To specify the provider for decrypting the content of the message, on the other hand,
set the cipher provider on the Context obtained from getGeneralProviderContext()
.
A ProviderContext can be set on a JsonWebSignature
or JsonWebEncryption
as well as a
JwtConsumer
via the JwtConsumerBuilder
.
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
Allows for a provider to be named for various operations.static enum
The cipher mode to use when deciphering/decrypting/unwrapping an encrypted content encryption keystatic class
Signature Algorithm info used to override normal defaults. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionThe Java Cryptography Architecture provider context to be used for operations that do not directly involve the key supplied by the caller.Gets the secure random generator.The Java Cryptography Architecture provider context to be used for operations that directly involve the key supplied by the caller.void
setSecureRandom
(SecureRandom secureRandom) Sets the secure random generator.
-
Constructor Details
-
ProviderContext
public ProviderContext()
-
-
Method Details
-
getSuppliedKeyProviderContext
The Java Cryptography Architecture provider context to be used for operations that directly involve the key supplied by the caller.- Returns:
- the
Context
object on which various provider preferences can be set
-
getGeneralProviderContext
The Java Cryptography Architecture provider context to be used for operations that do not directly involve the key supplied by the caller.- Returns:
- the
Context
object on which various provider preferences can be set
-
getSecureRandom
Gets the secure random generator.- Returns:
- The specific secure random generator if set, otherwise
null
for a default system one.
-
setSecureRandom
Sets the secure random generator.- Parameters:
secureRandom
- the SecureRandom to use ornull
for a default system one.
-