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 |
|---|---|
static String |
DEFAULT_ALGORITHM |
static boolean |
DEFAULT_ALLOWED_TO_OVERWRITE |
logECDSA_SHA2_NISTP256, ECDSA_SHA2_NISTP384, ECDSA_SHA2_NISTP521, EMPTY_KEYPAIR_PROVIDER, SSH_DSS, SSH_DSS_CERT, SSH_ECDSA_SHA2_NISTP256_CERT, SSH_ECDSA_SHA2_NISTP384_CERT, SSH_ECDSA_SHA2_NISTP521_CERT, SSH_ED25519, SSH_ED25519_CERT, SSH_RSA, SSH_RSA_CERTEMPTY_KEYS_PROVIDER| Modifier | Constructor and Description |
|---|---|
protected |
AbstractGeneratorHostKeyProvider() |
| Modifier and Type | Method and Description |
|---|---|
void |
clearLoadedKeys() |
protected Iterable<KeyPair> |
doReadKeyPairs(SessionContext session,
NamedResource resourceKey,
InputStream inputStream) |
protected abstract void |
doWriteKeyPair(NamedResource resourceKey,
KeyPair kp,
OutputStream outputStream) |
protected KeyPair |
generateKeyPair(String algorithm) |
String |
getAlgorithm() |
int |
getKeySize() |
AlgorithmParameterSpec |
getKeySpec() |
Path |
getPath() |
boolean |
hasStrictFilePermissions() |
boolean |
isOverwriteAllowed() |
protected Iterable<KeyPair> |
loadFromFile(SessionContext session,
String alg,
Path keyPath) |
List<KeyPair> |
loadKeys(SessionContext session)
Load available keys.
|
protected Iterable<KeyPair> |
readKeyPairs(SessionContext session,
Path keyPath,
OpenOption... options) |
protected Iterable<KeyPair> |
resolveKeyPairs(SessionContext session,
Path keyPath) |
void |
setAlgorithm(String algorithm) |
protected void |
setFilePermissions(Path path)
Restricts the file permissions such that only the owner can access the file.
|
void |
setKeySize(int keySize) |
void |
setKeySpec(AlgorithmParameterSpec keySpec) |
void |
setOverwriteAllowed(boolean overwriteAllowed) |
void |
setPath(Path path) |
void |
setStrictFilePermissions(boolean strict)
Sets whether this
AbstractGeneratorHostKeyProvider shall enforce that a newly created host key file has
file access permissions that allow only the owner to access it. |
protected void |
writeKeyPair(KeyPair kp,
Path keyPath) |
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warnclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetKeyTypes, loadKey, wrap, wrapexhaustCurrentIdentities, isEmpty, iterableOf, multiProvider, multiProvider, resolveKeyIdentityProvider, wrapKeyPairs, wrapKeyPairspublic static final String DEFAULT_ALGORITHM
public static final boolean DEFAULT_ALLOWED_TO_OVERWRITE
public Path getPath()
public void setPath(Path path)
public String getAlgorithm()
getAlgorithm in interface AlgorithmNameProviderpublic void setAlgorithm(String algorithm)
public int getKeySize()
getKeySize in interface KeySizeIndicatorpublic void setKeySize(int keySize)
public AlgorithmParameterSpec getKeySpec()
public void setKeySpec(AlgorithmParameterSpec keySpec)
public boolean isOverwriteAllowed()
public void setOverwriteAllowed(boolean overwriteAllowed)
public boolean hasStrictFilePermissions()
public void setStrictFilePermissions(boolean strict)
AbstractGeneratorHostKeyProvider shall enforce that a newly created host key file has
file access permissions that allow only the owner to access it. By default true.strict - whether to restrict file permissions to owner-only accesspublic void clearLoadedKeys()
public List<KeyPair> loadKeys(SessionContext session)
KeyIdentityProviderloadKeys in interface KeyIdentityProvidersession - 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 nullprotected Iterable<KeyPair> resolveKeyPairs(SessionContext session, Path keyPath) throws IOException, GeneralSecurityException
IOExceptionGeneralSecurityExceptionprotected Iterable<KeyPair> loadFromFile(SessionContext session, String alg, Path keyPath) throws IOException, GeneralSecurityException
IOExceptionGeneralSecurityExceptionprotected Iterable<KeyPair> readKeyPairs(SessionContext session, Path keyPath, OpenOption... options) throws IOException, GeneralSecurityException
IOExceptionGeneralSecurityExceptionprotected Iterable<KeyPair> doReadKeyPairs(SessionContext session, NamedResource resourceKey, InputStream inputStream) throws IOException, GeneralSecurityException
IOExceptionGeneralSecurityExceptionprotected void writeKeyPair(KeyPair kp, Path keyPath) throws IOException, GeneralSecurityException
IOExceptionGeneralSecurityExceptionprotected void setFilePermissions(Path path) throws IOException
path - Path of a newly created (empty) host key fileIOException - on errorsprotected abstract void doWriteKeyPair(NamedResource resourceKey, KeyPair kp, OutputStream outputStream) throws IOException, GeneralSecurityException
IOExceptionGeneralSecurityExceptionprotected KeyPair generateKeyPair(String algorithm) throws GeneralSecurityException
GeneralSecurityExceptionCopyright © 2018–2024 The Apache Software Foundation. All rights reserved.