Package org.wildfly.security.keystore
Class AtomicLoadKeyStore
- java.lang.Object
-
- java.security.KeyStore
-
- org.wildfly.security.keystore.AtomicLoadKeyStore
-
public class AtomicLoadKeyStore extends KeyStore
AKeyStorewrapper 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 Classes Modifier and Type Class Description static classAtomicLoadKeyStore.LoadKeyAn 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
-
-
Field Summary
Fields Modifier and Type Field Description private AtomicLoadKeyStoreSpikeyStoreSpi
-
Constructor Summary
Constructors Modifier Constructor Description privateAtomicLoadKeyStore(AtomicLoadKeyStoreSpi keyStoreSpi, Provider provider, String type)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static AtomicLoadKeyStoreatomize(KeyStore keyStore)Create 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)voidrevert(AtomicLoadKeyStore.LoadKey key)Atomically evert the keystore to a previous state.AtomicLoadKeyStore.LoadKeyrevertibleLoad(InputStream inputStream, char[] password)Performs the same action asKeyStore.load(InputStream, char[])except aAtomicLoadKeyStore.LoadKeyis returned that can be used to revert the load.private voidsetKeyStore(KeyStore keyStore)-
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
-
-
-
-
Field Detail
-
keyStoreSpi
private final AtomicLoadKeyStoreSpi keyStoreSpi
-
-
Constructor Detail
-
AtomicLoadKeyStore
private AtomicLoadKeyStore(AtomicLoadKeyStoreSpi keyStoreSpi, Provider provider, String type)
-
-
Method Detail
-
newInstance
public static AtomicLoadKeyStore newInstance(String type, Provider provider)
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
public static AtomicLoadKeyStore newInstance(String type) throws KeyStoreException
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
-
setKeyStore
private void setKeyStore(KeyStore keyStore)
-
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
public void revert(AtomicLoadKeyStore.LoadKey key)
Atomically evert the keystore to a previous state.- Parameters:
key- the load key
-
-