Top Description Fields Constructors Methods
org.apache.sshd.server.keyprovider

public abstract Class AbstractGeneratorHostKeyProvider

extends AbstractKeyPairProvider
implements AlgorithmNameProvider, KeySizeIndicator
Class Inheritance
All Implemented Interfaces
org.apache.sshd.common.keyprovider.KeySizeIndicator, org.apache.sshd.common.AlgorithmNameProvider
Known Direct Subclasses
org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider, org.apache.sshd.common.util.security.bouncycastle.BouncyCastleGeneratorHostKeyProvider
Imports
java.io.File, .IOException, .InputStream, .OutputStream, java.nio.file.Files, .LinkOption, .OpenOption, .Path, .StandardOpenOption, java.nio.file.attribute.AclEntry, .AclEntryPermission, .AclEntryType, .AclFileAttributeView, .UserPrincipal, java.security.GeneralSecurityException, .InvalidKeyException, .KeyPair, .KeyPairGenerator, .PublicKey, java.security.spec.AlgorithmParameterSpec, java.util.ArrayList, .Collections, .EnumSet, .List, .Objects, java.util.concurrent.atomic.AtomicReference, org.apache.sshd.common.AlgorithmNameProvider, .NamedResource, org.apache.sshd.common.cipher.ECCurves, org.apache.sshd.common.config.keys.BuiltinIdentities, .KeyUtils, org.apache.sshd.common.keyprovider.AbstractKeyPairProvider, .KeySizeIndicator, org.apache.sshd.common.session.SessionContext, org.apache.sshd.common.util.GenericUtils, .OsUtils, org.apache.sshd.common.util.io.IoUtils, org.apache.sshd.common.util.io.resource.PathResource, org.apache.sshd.common.util.security.SecurityUtils

Holds a single 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()
Author
Apache MINA SSHD Project

Field Summary

Modifier and TypeField and Description
private String
public static final String
public static final boolean
private boolean
private final AtomicReference<Iterable<KeyPair>>
private int
private AlgorithmParameterSpec
private boolean
private Path

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public void
protected Iterable<KeyPair>
doReadKeyPairs(SessionContext session, NamedResource resourceKey, InputStream inputStream)

protected abstract void
doWriteKeyPair(NamedResource resourceKey, KeyPair kp, OutputStream outputStream)

pack-priv boolean
edDSAAlgorithmsMatch(String expectedAlgorithm, String keyAlgorithm)

protected KeyPair
public String
public int
public AlgorithmParameterSpec
public Path
public boolean
public boolean
protected Iterable<KeyPair>
loadFromFile(SessionContext session, String alg, Path keyPath)

public synchronized List<KeyPair>
loadKeys(SessionContext
The SessionContext for invoking this load command - may be null if not invoked within a session context (e.g., offline tool or session unknown).
session
)

Implements org.apache.sshd.common.keyprovider.KeyIdentityProvider.loadKeys.

Load available keys.

protected Iterable<KeyPair>
readKeyPairs(SessionContext session, Path keyPath, OpenOption... options)

protected Iterable<KeyPair>
public void
setAlgorithm(String algorithm)

protected void
setFilePermissions(Path
Path of a newly created (empty) host key file
path
)

Restricts the file permissions such that only the owner can access the file.

public void
setKeySize(int keySize)

public void
public void
setOverwriteAllowed(boolean overwriteAllowed)

public void
setPath(Path path)

public void
setStrictFilePermissions(boolean
whether to restrict file permissions to owner-only access
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)

Field Detail

algorithmback to summary
private String algorithm
DEFAULT_ALGORITHMback to summary
public static final String DEFAULT_ALGORITHM
DEFAULT_ALLOWED_TO_OVERWRITEback to summary
public static final boolean DEFAULT_ALLOWED_TO_OVERWRITE
enforceFilePermissionsback to summary
private boolean enforceFilePermissions
keyPairHolderback to summary
private final AtomicReference<Iterable<KeyPair>> keyPairHolder
keySizeback to summary
private int keySize
keySpecback to summary
private AlgorithmParameterSpec keySpec
overwriteAllowedback to summary
private boolean overwriteAllowed
pathback to summary
private Path path

Constructor Detail

AbstractGeneratorHostKeyProviderback to summary
protected AbstractGeneratorHostKeyProvider()

Method Detail

clearLoadedKeysback to summary
public void clearLoadedKeys()
doReadKeyPairsback to summary
protected Iterable<KeyPair> doReadKeyPairs(SessionContext session, NamedResource resourceKey, InputStream inputStream) throws IOException, GeneralSecurityException
doWriteKeyPairback to summary
protected abstract void doWriteKeyPair(NamedResource resourceKey, KeyPair kp, OutputStream outputStream) throws IOException, GeneralSecurityException
edDSAAlgorithmsMatchback to summary
pack-priv boolean edDSAAlgorithmsMatch(String expectedAlgorithm, String keyAlgorithm)
generateKeyPairback to summary
protected KeyPair generateKeyPair(String algorithm) throws GeneralSecurityException
getAlgorithmback to summary
public String getAlgorithm()

Implements org.apache.sshd.common.AlgorithmNameProvider.getAlgorithm.

Annotations
@Override
getKeySizeback to summary
public int getKeySize()

Implements org.apache.sshd.common.keyprovider.KeySizeIndicator.getKeySize.

Returns:int

Doc from org.apache.sshd.common.keyprovider.KeySizeIndicator.getKeySize.

The number of bits used in the key

Annotations
@Override
getKeySpecback to summary
public AlgorithmParameterSpec getKeySpec()
getPathback to summary
public Path getPath()
hasStrictFilePermissionsback to summary
public boolean hasStrictFilePermissions()
isOverwriteAllowedback to summary
public boolean isOverwriteAllowed()
loadFromFileback to summary
protected Iterable<KeyPair> loadFromFile(SessionContext session, String alg, Path keyPath) throws IOException, GeneralSecurityException
loadKeysback to summary
public synchronized List<KeyPair> loadKeys(SessionContext session)

Implements org.apache.sshd.common.keyprovider.KeyIdentityProvider.loadKeys.

Doc from org.apache.sshd.common.keyprovider.KeyIdentityProvider.loadKeys.

Load available keys.

Parameters
session:SessionContext

The SessionContext for invoking this load command - may be null if not invoked within a session context (e.g., offline tool or session unknown).

Returns:List<KeyPair>

an Iterable instance of available keys - ignored if null

Annotations
@Override
readKeyPairsback to summary
protected Iterable<KeyPair> readKeyPairs(SessionContext session, Path keyPath, OpenOption... options) throws IOException, GeneralSecurityException
resolveKeyPairsback to summary
protected Iterable<KeyPair> resolveKeyPairs(SessionContext session, Path keyPath) throws IOException, GeneralSecurityException
setAlgorithmback to summary
public void setAlgorithm(String algorithm)
setFilePermissionsback to summary
protected void setFilePermissions(Path path) throws IOException

Restricts the file permissions such that only the owner can access the file.

Parameters
path:Path

Path of a newly created (empty) host key file

Exceptions
IOException:
on errors
setKeySizeback to summary
public void setKeySize(int keySize)
setKeySpecback to summary
public void setKeySpec(AlgorithmParameterSpec keySpec)
setOverwriteAllowedback to summary
public void setOverwriteAllowed(boolean overwriteAllowed)
setPathback to summary
public void setPath(Path path)
setStrictFilePermissionsback to summary
public 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. By default true.

Parameters
strict:boolean

whether to restrict file permissions to owner-only access

writeKeyPairback to summary
protected void writeKeyPair(KeyPair kp, Path keyPath) throws IOException, GeneralSecurityException