public abstract class AbstractGeneratorHostKeyProvider extends AbstractKeyPairProvider implements AlgorithmNameProvider, KeySizeIndicator
KeyPair
which is generated the 1st time
loadKeys(SessionContext)
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.lang.Iterable<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
Modifier | Constructor and Description |
---|---|
protected |
AbstractGeneratorHostKeyProvider() |
Modifier and Type | Method and Description |
---|---|
void |
clearLoadedKeys() |
protected java.lang.Iterable<java.security.KeyPair> |
doReadKeyPairs(SessionContext session,
NamedResource resourceKey,
java.io.InputStream inputStream) |
protected abstract void |
doWriteKeyPair(NamedResource 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.lang.Iterable<java.security.KeyPair> |
loadFromFile(SessionContext session,
java.lang.String alg,
java.nio.file.Path keyPath) |
java.util.List<java.security.KeyPair> |
loadKeys(SessionContext session)
Load available keys.
|
protected java.lang.Iterable<java.security.KeyPair> |
readKeyPairs(SessionContext session,
java.nio.file.Path keyPath,
java.nio.file.OpenOption... options) |
protected java.lang.Iterable<java.security.KeyPair> |
resolveKeyPairs(SessionContext session,
java.nio.file.Path keyPath) |
void |
setAlgorithm(java.lang.String algorithm) |
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
exhaustCurrentIdentities, isEmpty, iterableOf, multiProvider, multiProvider, 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.lang.Iterable<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 setPath(java.nio.file.Path path)
public java.lang.String getAlgorithm()
getAlgorithm
in interface AlgorithmNameProvider
public void setAlgorithm(java.lang.String algorithm)
public int getKeySize()
getKeySize
in interface KeySizeIndicator
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(SessionContext session)
KeyIdentityProvider
loadKeys
in interface KeyIdentityProvider
session
- The SessionContext
for invoking this load command - may
be null
if not invoked within a session context (e.g., offline tool or session unknown).Iterable
instance of available keys - ignored if null
protected java.lang.Iterable<java.security.KeyPair> resolveKeyPairs(SessionContext session, java.nio.file.Path keyPath) throws java.io.IOException, java.security.GeneralSecurityException
java.io.IOException
java.security.GeneralSecurityException
protected java.lang.Iterable<java.security.KeyPair> loadFromFile(SessionContext session, java.lang.String alg, java.nio.file.Path keyPath) throws java.io.IOException, java.security.GeneralSecurityException
java.io.IOException
java.security.GeneralSecurityException
protected java.lang.Iterable<java.security.KeyPair> readKeyPairs(SessionContext session, 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.lang.Iterable<java.security.KeyPair> doReadKeyPairs(SessionContext session, NamedResource 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(NamedResource 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