public class CloudHsmProvider
extends java.security.AuthProvider
implements java.io.Closeable
CloudHsmProvider defines the “CloudHSM” cryptographic service provider.
Refer to Supported mechanisms for Client SDK 5 for supported algorithms and their names.
CloudHsmProvider implements AuthProvider for authenticating explicitly with
HSMs. Otherwise, authentication may be done implicitly from system properties or environment
variables. See Provide credentials to the JCE provider.
AuthProvider,
Provide
credentials to the JCE provider,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CLOUDHSM_KEYSTORE_TYPE
Type name for creating KeyStores with the CloudHSM provider.
|
static java.lang.String |
PROVIDER_NAME
CloudHSM provider name.
|
| Constructor and Description |
|---|
CloudHsmProvider()
Constructs an instance of
CloudHsmProvider. |
CloudHsmProvider(CloudHsmProviderConfig providerConfig)
Constructs an instance of
CloudHsmProvider. |
CloudHsmProvider(java.lang.String path)
Constructs an instance of
CloudHsmProvider. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Queues the sockets and connections that the provider has taken to the HSM for closure.
|
java.lang.String |
getInfo()
getInfo() returns information about the underlying CloudHSM Provider. |
void |
login(javax.security.auth.Subject subject,
javax.security.auth.callback.CallbackHandler handler)
Logs in to the configured CloudHSM cluster.
|
void |
logout()
Logs out from the configured CloudHSM cluster.
|
void |
setCallbackHandler(javax.security.auth.callback.CallbackHandler handler)
Sets the login
CallbackHandler for the CloudHSM provider. |
clear, compute, computeIfAbsent, computeIfPresent, elements, entrySet, forEach, get, getName, getOrDefault, getProperty, getService, getServices, getVersion, keys, keySet, load, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, toString, valuesgetProperty, list, list, load, loadFromXML, propertyNames, save, setProperty, store, store, storeToXML, storeToXML, stringPropertyNamespublic static final java.lang.String CLOUDHSM_KEYSTORE_TYPE
KeyStore,
Constant Field Valuespublic static final java.lang.String PROVIDER_NAME
After registering the CloudHSM provider with Security, access the provider using
this name.
Security,
Provider,
Constant Field Valuespublic CloudHsmProvider()
throws java.io.IOException,
ProviderInitializationException,
javax.security.auth.login.LoginException
CloudHsmProvider.
The instance can be created to programmatically add CloudHsmProvider to Java Security Class. This constructor will try to use the configuration file from the default location that is installed with the CloudHSM SDK package installation.
This constructor will attempt to log in to the configured CloudHSM cluster if credentials are found in system properties or environment variables. See Provide credentials to the JCE provider.
java.io.IOException - if the CloudHSM configuration file does not exist or cannot be read.ProviderInitializationException - if there is an error initializing the Provider.javax.security.auth.login.LoginException - if implicit credentials are present, but there is an error logging in.java.lang.IllegalStateException - if a default CloudHSM provider instance has already been
initialized.public CloudHsmProvider(java.lang.String path)
throws java.io.IOException,
ProviderInitializationException,
javax.security.auth.login.LoginException
CloudHsmProvider.
The instance can be created to programmatically add CloudHsmProvider to Java Security
Class. This constructor will try to use the configuration file from the path
provided.
This constructor will attempt to log in to the configured CloudHSM cluster if credentials are found in system properties or environment variables. See Provide credentials to the JCE provider.
path - Filesystem location of the desired CloudHSM configuration file.java.io.IOException - if the CloudHSM configuration file does not exist or cannot be read.ProviderInitializationException - if there is an error initializing the Provider.javax.security.auth.login.LoginException - if implicit credentials are present, but there is an error logging in.java.lang.IllegalStateException - if a CloudHSM provider instance has already been initialized.public CloudHsmProvider(CloudHsmProviderConfig providerConfig) throws java.io.IOException, ProviderInitializationException, javax.security.auth.login.LoginException
CloudHsmProvider.
The instance can be created to programmatically add CloudHsmProvider to Java Security
Class. This constructor will try to use the configuration builder from the providerConfig provided.
This constructor will attempt to log in to the configured CloudHSM cluster if credentials are found in system properties or environment variables. See Provide credentials to the JCE provider.
providerConfig - an instance of com.amazonaws.cloudhsm.jce.provider.builder.CloudHsmProviderConfig which contains the
CloudHsm configuration.java.io.IOException - When there is an exception when reading or retrieving the configuration.ProviderInitializationException - if there is an error initializing the Provider.javax.security.auth.login.LoginException - if implicit credentials are present, but there is an error logging in.java.lang.IllegalStateException - if a CloudHSM provider with the same identifier has been
created already.public java.lang.String getInfo()
getInfo() returns information about the underlying CloudHSM Provider.
The response contains the following data:
getInfo in class java.security.Providerpublic void login(javax.security.auth.Subject subject,
javax.security.auth.callback.CallbackHandler handler)
throws javax.security.auth.login.LoginException
Calling this method is not required if credentials were found in system properties or environment variables at the time this provider was constructed. See Provide credentials to the JCE provider.
login in class java.security.AuthProvidersubject - the Subject that may contain principals/credentials used for
authentication or may be populated with additional principals/credentials after
successful authentication has completed. This parameter may be null.handler - the CallbackHandler used by this provider to obtain authentication
information from the caller, which may be null.javax.security.auth.login.LoginException - if the callback handler is not present or provides invalid
credentials.UsernamePasswordAuthHandlerpublic void logout()
throws LogoutException
This method is not available if login was performed implicitly using system properties or environment variables.
logout in class java.security.AuthProviderLogoutException - if the user is not logged injava.lang.IllegalStateException - if login was initially performed implicitlylogin(Subject, CallbackHandler)public void setCallbackHandler(javax.security.auth.callback.CallbackHandler handler)
CallbackHandler for the CloudHSM provider.
If login() is called with the handler parameter set to null, this
CallbackHandler is used.
setCallbackHandler in class java.security.AuthProviderhandler - CallbackHandler to be used for login.public void close()
close in interface java.io.Closeableclose in interface java.lang.AutoCloseable