public abstract class AbstractGeneratorHostKeyProvider extends AbstractKeyPairProvider
KeyPair
which is generated the 1st time
loadKeys()
is called. If there is a file backing it up and the
file exists, the key is loaded from it. Otherwise a new key pair is
generated and saved (provided a path is configured and isOverwriteAllowed()
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
algorithm |
static java.lang.String |
DEFAULT_ALGORITHM |
static boolean |
DEFAULT_ALLOWED_TO_OVERWRITE |
private java.util.concurrent.atomic.AtomicReference<java.security.KeyPair> |
keyPairHolder |
private int |
keySize |
private java.security.spec.AlgorithmParameterSpec |
keySpec |
private boolean |
overwriteAllowed |
private java.nio.file.Path |
path |
log
ECDSA_SHA2_NISTP256, ECDSA_SHA2_NISTP384, ECDSA_SHA2_NISTP521, EMPTY_KEYPAIR_PROVIDER, SSH_DSS, SSH_ED25519, SSH_RSA
EMPTY_KEYS_PROVIDER, LOADER
Modifier | Constructor and Description |
---|---|
protected |
AbstractGeneratorHostKeyProvider() |
Modifier and Type | Method and Description |
---|---|
void |
clearLoadedKeys() |
protected java.security.KeyPair |
doReadKeyPair(java.lang.String resourceKey,
java.io.InputStream inputStream) |
protected abstract void |
doWriteKeyPair(java.lang.String resourceKey,
java.security.KeyPair kp,
java.io.OutputStream outputStream) |
protected java.security.KeyPair |
generateKeyPair(java.lang.String algorithm) |
java.lang.String |
getAlgorithm() |
int |
getKeySize() |
java.security.spec.AlgorithmParameterSpec |
getKeySpec() |
java.nio.file.Path |
getPath() |
boolean |
isOverwriteAllowed() |
protected java.security.KeyPair |
loadFromFile(java.lang.String alg,
java.nio.file.Path keyPath) |
java.util.List<java.security.KeyPair> |
loadKeys()
Load available keys.
|
protected java.security.KeyPair |
readKeyPair(java.nio.file.Path keyPath,
java.nio.file.OpenOption... options) |
protected java.security.KeyPair |
resolveKeyPair(java.nio.file.Path keyPath) |
void |
setAlgorithm(java.lang.String algorithm) |
void |
setFile(java.io.File file) |
void |
setKeySize(int keySize) |
void |
setKeySpec(java.security.spec.AlgorithmParameterSpec keySpec) |
void |
setOverwriteAllowed(boolean overwriteAllowed) |
void |
setPath(java.nio.file.Path path) |
protected void |
writeKeyPair(java.security.KeyPair kp,
java.nio.file.Path keyPath,
java.nio.file.OpenOption... options) |
getSimplifiedLogger
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getKeyTypes, loadKey, wrap, wrap
iterableOf, iteratorOf, iteratorOf, iteratorOf, multiProvider, multiProvider, providerOf, resolveKeyIdentityProvider, wrapKeyPairs, wrapKeyPairs
public static final java.lang.String DEFAULT_ALGORITHM
public static final boolean DEFAULT_ALLOWED_TO_OVERWRITE
private final java.util.concurrent.atomic.AtomicReference<java.security.KeyPair> keyPairHolder
private java.nio.file.Path path
private java.lang.String algorithm
private int keySize
private java.security.spec.AlgorithmParameterSpec keySpec
private boolean overwriteAllowed
public java.nio.file.Path getPath()
public void setFile(java.io.File file)
public void setPath(java.nio.file.Path path)
public java.lang.String getAlgorithm()
public void setAlgorithm(java.lang.String algorithm)
public int getKeySize()
public void setKeySize(int keySize)
public java.security.spec.AlgorithmParameterSpec getKeySpec()
public void setKeySpec(java.security.spec.AlgorithmParameterSpec keySpec)
public boolean isOverwriteAllowed()
public void setOverwriteAllowed(boolean overwriteAllowed)
public void clearLoadedKeys()
public java.util.List<java.security.KeyPair> loadKeys()
KeyIdentityProvider
Iterable
instance of available keys - ignored if null
protected java.security.KeyPair resolveKeyPair(java.nio.file.Path keyPath) throws java.io.IOException, java.security.GeneralSecurityException
java.io.IOException
java.security.GeneralSecurityException
protected java.security.KeyPair loadFromFile(java.lang.String alg, java.nio.file.Path keyPath) throws java.io.IOException, java.security.GeneralSecurityException
java.io.IOException
java.security.GeneralSecurityException
protected java.security.KeyPair readKeyPair(java.nio.file.Path keyPath, java.nio.file.OpenOption... options) throws java.io.IOException, java.security.GeneralSecurityException
java.io.IOException
java.security.GeneralSecurityException
protected java.security.KeyPair doReadKeyPair(java.lang.String resourceKey, java.io.InputStream inputStream) throws java.io.IOException, java.security.GeneralSecurityException
java.io.IOException
java.security.GeneralSecurityException
protected void writeKeyPair(java.security.KeyPair kp, java.nio.file.Path keyPath, java.nio.file.OpenOption... options) throws java.io.IOException, java.security.GeneralSecurityException
java.io.IOException
java.security.GeneralSecurityException
protected abstract void doWriteKeyPair(java.lang.String resourceKey, java.security.KeyPair kp, java.io.OutputStream outputStream) throws java.io.IOException, java.security.GeneralSecurityException
java.io.IOException
java.security.GeneralSecurityException
protected java.security.KeyPair generateKeyPair(java.lang.String algorithm) throws java.security.GeneralSecurityException
java.security.GeneralSecurityException