Package org.wildfly.security.keystore
Class AtomicLoadKeyStore
java.lang.Object
java.security.KeyStore
org.wildfly.security.keystore.AtomicLoadKeyStore
A
KeyStore wrapper that makes the load operation atomic, in addition it also gives the ability to reverse the load
call.- Author:
- Darran Lofthouse
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAn opaque key representing an atomic keystore state.Nested classes/interfaces inherited from class java.security.KeyStore
KeyStore.Builder, KeyStore.CallbackHandlerProtection, KeyStore.Entry, KeyStore.LoadStoreParameter, KeyStore.PasswordProtection, KeyStore.PrivateKeyEntry, KeyStore.ProtectionParameter, KeyStore.SecretKeyEntry, KeyStore.TrustedCertificateEntry -
Method Summary
Modifier and TypeMethodDescriptionstatic AtomicLoadKeyStoreCreate a newAtomicLoadKeyStoreinstance that wraps specifiedKeyStore.static AtomicLoadKeyStorenewInstance(String type) Create a newAtomicLoadKeyStorewrapping aKeyStoreof the type specified.static AtomicLoadKeyStorenewInstance(String type, String provider) Create a newAtomicLoadKeyStorewrapping aKeyStoreof the type specified.static AtomicLoadKeyStorenewInstance(String type, Provider provider) voidAtomically evert the keystore to a previous state.revertibleLoad(InputStream inputStream, char[] password) Performs the same action asKeyStore.load(InputStream, char[])except aAtomicLoadKeyStore.LoadKeyis returned that can be used to revert the load.Methods inherited from class java.security.KeyStore
aliases, containsAlias, deleteEntry, entryInstanceOf, getCertificate, getCertificateAlias, getCertificateChain, getCreationDate, getDefaultType, getEntry, getInstance, getInstance, getInstance, getInstance, getInstance, getKey, getProvider, getType, isCertificateEntry, isKeyEntry, load, load, setCertificateEntry, setEntry, setKeyEntry, setKeyEntry, size, store, store
-
Method Details
-
newInstance
Create a newAtomicLoadKeyStorewrapping aKeyStoreor the specified type, obtained from the suppliedProvider.- Parameters:
type- the type of theKeyStoreto wrapprovider- theProviderto use to create theKeyStoreinstance.- Returns:
- the new
AtomicLoadKeyStoreinstance
-
newInstance
public static AtomicLoadKeyStore newInstance(String type, String provider) throws KeyStoreException, NoSuchProviderException Create a newAtomicLoadKeyStorewrapping aKeyStoreof the type specified.- Parameters:
type- the type ofKeyStoreto be wrappedprovider- the provide to use to create theKeyStore- Returns:
- the new
AtomicLoadKeyStoreinstance - Throws:
KeyStoreException- If there is a problem creating theKeyStoreNoSuchProviderException- if the provider specified can not be found.
-
newInstance
Create a newAtomicLoadKeyStorewrapping aKeyStoreof the type specified.- Parameters:
type- the type ofKeyStoreto be wrapped- Returns:
- the new
AtomicLoadKeyStoreinstance - Throws:
KeyStoreException- If there is a problem creating theKeyStore
-
atomize
public static AtomicLoadKeyStore atomize(KeyStore keyStore) throws CertificateException, NoSuchAlgorithmException, IOException Create a newAtomicLoadKeyStoreinstance that wraps specifiedKeyStore.- Parameters:
keyStore- theKeyStoreto be wrapped- Returns:
- the new
AtomicLoadKeyStoreinstance - Throws:
CertificateExceptionNoSuchAlgorithmExceptionIOException
-
revertibleLoad
public AtomicLoadKeyStore.LoadKey revertibleLoad(InputStream inputStream, char[] password) throws NoSuchAlgorithmException, CertificateException, IOException Performs the same action asKeyStore.load(InputStream, char[])except aAtomicLoadKeyStore.LoadKeyis returned that can be used to revert the load.- Parameters:
inputStream- the stream to load from ornullpassword- the password used to protect the contents of theKeyStoreornull- Returns:
- a
AtomicLoadKeyStore.LoadKeythat can be used to revert the load and restore the previousKeyStorestate - Throws:
NoSuchAlgorithmException- if the keystore cannot be read due to a missing algorithmCertificateException- if the keystore cannot be read due to a certificate problemIOException- if the keystore cannot be read due to an I/O problem
-
revert
Atomically evert the keystore to a previous state.- Parameters:
key- the load key
-