public class ProviderContext extends Object
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.
| Modifier and Type | Class and Description |
|---|---|
class |
ProviderContext.Context
Allows for a provider to be named for various operations.
|
| Constructor and Description |
|---|
ProviderContext() |
| Modifier and Type | Method and Description |
|---|---|
ProviderContext.Context |
getGeneralProviderContext()
The Java Cryptography Architecture provider context to be used for operations
that do not directly involve the key supplied by the caller.
|
SecureRandom |
getSecureRandom()
Gets the secure random generator.
|
ProviderContext.Context |
getSuppliedKeyProviderContext()
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.
|
public ProviderContext.Context getSuppliedKeyProviderContext()
Context object on which various provider preferences can be setpublic ProviderContext.Context getGeneralProviderContext()
Context object on which various provider preferences can be setpublic SecureRandom getSecureRandom()
null for a default system one.public void setSecureRandom(SecureRandom secureRandom)
secureRandom - the SecureRandom to use or null for a default system one.Copyright © 2019. All rights reserved.