Class AbstractGeneratorHostKeyProvider
- java.lang.Object
-
- org.apache.sshd.common.util.logging.AbstractLoggingBean
-
- org.apache.sshd.common.keyprovider.AbstractKeyPairProvider
-
- org.apache.sshd.server.keyprovider.AbstractGeneratorHostKeyProvider
-
- All Implemented Interfaces:
AlgorithmNameProvider
,KeyIdentityProvider
,KeyPairProvider
,KeySizeIndicator
- Direct Known Subclasses:
BouncyCastleGeneratorHostKeyProvider
,SimpleGeneratorHostKeyProvider
public abstract class AbstractGeneratorHostKeyProvider extends AbstractKeyPairProvider implements AlgorithmNameProvider, KeySizeIndicator
Holds a singleKeyPair
which is generated the 1st timeloadKeys(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 andisOverwriteAllowed()
- Author:
- Apache MINA SSHD Project
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_ALGORITHM
static boolean
DEFAULT_ALLOWED_TO_OVERWRITE
-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
Fields inherited from interface org.apache.sshd.common.keyprovider.KeyIdentityProvider
EMPTY_KEYS_PROVIDER
-
Fields inherited from interface org.apache.sshd.common.keyprovider.KeyPairProvider
ECDSA_SHA2_NISTP256, ECDSA_SHA2_NISTP384, ECDSA_SHA2_NISTP521, EMPTY_KEYPAIR_PROVIDER, SSH_DSS, SSH_ED25519, SSH_RSA
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractGeneratorHostKeyProvider()
-
Method Summary
-
Methods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
getSimplifiedLogger
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.sshd.common.keyprovider.KeyPairProvider
getKeyTypes, loadKey
-
-
-
-
Field Detail
-
DEFAULT_ALGORITHM
public static final String DEFAULT_ALGORITHM
- See Also:
- Constant Field Values
-
DEFAULT_ALLOWED_TO_OVERWRITE
public static final boolean DEFAULT_ALLOWED_TO_OVERWRITE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getPath
public Path getPath()
-
setPath
public void setPath(Path path)
-
getAlgorithm
public String getAlgorithm()
- Specified by:
getAlgorithm
in interfaceAlgorithmNameProvider
-
setAlgorithm
public void setAlgorithm(String algorithm)
-
getKeySize
public int getKeySize()
- Specified by:
getKeySize
in interfaceKeySizeIndicator
- Returns:
- The number of bits used in the key
-
setKeySize
public void setKeySize(int keySize)
-
getKeySpec
public AlgorithmParameterSpec getKeySpec()
-
setKeySpec
public void setKeySpec(AlgorithmParameterSpec keySpec)
-
isOverwriteAllowed
public boolean isOverwriteAllowed()
-
setOverwriteAllowed
public void setOverwriteAllowed(boolean overwriteAllowed)
-
clearLoadedKeys
public void clearLoadedKeys()
-
loadKeys
public List<KeyPair> loadKeys(SessionContext session)
Description copied from interface:KeyIdentityProvider
Load available keys.- Specified by:
loadKeys
in interfaceKeyIdentityProvider
- Parameters:
session
- TheSessionContext
for invoking this load command - may benull
if not invoked within a session context (e.g., offline tool or session unknown).- Returns:
- an
Iterable
instance of available keys - ignored ifnull
-
resolveKeyPairs
protected Iterable<KeyPair> resolveKeyPairs(SessionContext session, Path keyPath) throws IOException, GeneralSecurityException
- Throws:
IOException
GeneralSecurityException
-
loadFromFile
protected Iterable<KeyPair> loadFromFile(SessionContext session, String alg, Path keyPath) throws IOException, GeneralSecurityException
- Throws:
IOException
GeneralSecurityException
-
readKeyPairs
protected Iterable<KeyPair> readKeyPairs(SessionContext session, Path keyPath, OpenOption... options) throws IOException, GeneralSecurityException
- Throws:
IOException
GeneralSecurityException
-
doReadKeyPairs
protected Iterable<KeyPair> doReadKeyPairs(SessionContext session, NamedResource resourceKey, InputStream inputStream) throws IOException, GeneralSecurityException
- Throws:
IOException
GeneralSecurityException
-
writeKeyPair
protected void writeKeyPair(KeyPair kp, Path keyPath, OpenOption... options) throws IOException, GeneralSecurityException
- Throws:
IOException
GeneralSecurityException
-
doWriteKeyPair
protected abstract void doWriteKeyPair(NamedResource resourceKey, KeyPair kp, OutputStream outputStream) throws IOException, GeneralSecurityException
- Throws:
IOException
GeneralSecurityException
-
generateKeyPair
protected KeyPair generateKeyPair(String algorithm) throws GeneralSecurityException
- Throws:
GeneralSecurityException
-
-