Package org.wildfly.security.keystore
Class AtomicLoadKeyStore
- java.lang.Object
-
- java.security.KeyStore
-
- org.wildfly.security.keystore.AtomicLoadKeyStore
-
public class AtomicLoadKeyStore extends KeyStore
AKeyStore
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 Classes Modifier and Type Class Description static class
AtomicLoadKeyStore.LoadKey
An 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 AtomicLoadKeyStoreSpi
keyStoreSpi
-
Constructor Summary
Constructors Modifier Constructor Description private
AtomicLoadKeyStore(AtomicLoadKeyStoreSpi keyStoreSpi, Provider provider, String type)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static AtomicLoadKeyStore
atomize(KeyStore keyStore)
Create a newAtomicLoadKeyStore
instance that wraps specifiedKeyStore
.static AtomicLoadKeyStore
newInstance(String type)
Create a newAtomicLoadKeyStore
wrapping aKeyStore
of the type specified.static AtomicLoadKeyStore
newInstance(String type, String provider)
Create a newAtomicLoadKeyStore
wrapping aKeyStore
of the type specified.static AtomicLoadKeyStore
newInstance(String type, Provider provider)
void
revert(AtomicLoadKeyStore.LoadKey key)
Atomically evert the keystore to a previous state.AtomicLoadKeyStore.LoadKey
revertibleLoad(InputStream inputStream, char[] password)
Performs the same action asKeyStore.load(InputStream, char[])
except aAtomicLoadKeyStore.LoadKey
is returned that can be used to revert the load.private void
setKeyStore(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 newAtomicLoadKeyStore
wrapping aKeyStore
or the specified type, obtained from the suppliedProvider
.- Parameters:
type
- the type of theKeyStore
to wrapprovider
- theProvider
to use to create theKeyStore
instance.- Returns:
- the new
AtomicLoadKeyStore
instance
-
newInstance
public static AtomicLoadKeyStore newInstance(String type, String provider) throws KeyStoreException, NoSuchProviderException
Create a newAtomicLoadKeyStore
wrapping aKeyStore
of the type specified.- Parameters:
type
- the type ofKeyStore
to be wrappedprovider
- the provide to use to create theKeyStore
- Returns:
- the new
AtomicLoadKeyStore
instance - Throws:
KeyStoreException
- If there is a problem creating theKeyStore
NoSuchProviderException
- if the provider specified can not be found.
-
newInstance
public static AtomicLoadKeyStore newInstance(String type) throws KeyStoreException
Create a newAtomicLoadKeyStore
wrapping aKeyStore
of the type specified.- Parameters:
type
- the type ofKeyStore
to be wrapped- Returns:
- the new
AtomicLoadKeyStore
instance - Throws:
KeyStoreException
- If there is a problem creating theKeyStore
-
atomize
public static AtomicLoadKeyStore atomize(KeyStore keyStore) throws CertificateException, NoSuchAlgorithmException, IOException
Create a newAtomicLoadKeyStore
instance that wraps specifiedKeyStore
.- Parameters:
keyStore
- theKeyStore
to be wrapped- Returns:
- the new
AtomicLoadKeyStore
instance - Throws:
CertificateException
NoSuchAlgorithmException
IOException
-
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.LoadKey
is returned that can be used to revert the load.- Parameters:
inputStream
- the stream to load from ornull
password
- the password used to protect the contents of theKeyStore
ornull
- Returns:
- a
AtomicLoadKeyStore.LoadKey
that can be used to revert the load and restore the previousKeyStore
state - 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
-
-