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

public Class SimpleGeneratorHostKeyProvider

extends AbstractGeneratorHostKeyProvider
Class Inheritance
Imports
java.io.BufferedInputStream, .IOException, .InputStream, .ObjectInputStream, .ObjectStreamClass, .ObjectStreamConstants, .OutputStream, .StreamCorruptedException, java.nio.file.Path, java.security.GeneralSecurityException, .KeyPair, java.security.spec.InvalidKeySpecException, java.util.Collections, .HashSet, .Set, org.apache.sshd.common.NamedResource, org.apache.sshd.common.config.keys.writer.openssh.OpenSSHKeyPairResourceWriter, org.apache.sshd.common.session.SessionContext, org.apache.sshd.common.util.security.SecurityUtils

A simple implementation of an AbstractGeneratorHostKeyProvider that writes and reads host keys using the OpenSSH file format. Legacy keys written by earlier implementations used Java serialization. De-serializing is restricted to a small number of classes known to exist in serialized KeyPairs.
Author
Apache MINA SSHD Project

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Inherited from org.apache.sshd.server.keyprovider.AbstractGeneratorHostKeyProvider:
DEFAULT_ALGORITHMDEFAULT_ALLOWED_TO_OVERWRITE

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
protected Iterable<KeyPair>
protected void
private boolean
Inherited from org.apache.sshd.server.keyprovider.AbstractGeneratorHostKeyProvider:
clearLoadedKeysedDSAAlgorithmsMatchgenerateKeyPairgetAlgorithmgetKeySizegetKeySpecgetPathhasStrictFilePermissionsisOverwriteAllowedloadFromFileloadKeysreadKeyPairsresolveKeyPairssetAlgorithmsetFilePermissionssetKeySizesetKeySpecsetOverwriteAllowedsetPathsetStrictFilePermissionswriteKeyPair

Constructor Detail

SimpleGeneratorHostKeyProviderback to summary
public SimpleGeneratorHostKeyProvider()
SimpleGeneratorHostKeyProviderback to summary
public SimpleGeneratorHostKeyProvider(Path path)

Method Detail

doReadKeyPairsback to summary
protected Iterable<KeyPair> doReadKeyPairs(SessionContext session, NamedResource resourceKey, InputStream inputStream) throws IOException, GeneralSecurityException

Overrides org.apache.sshd.server.keyprovider.AbstractGeneratorHostKeyProvider.doReadKeyPairs.

Annotations
@Override
doWriteKeyPairback to summary
protected void doWriteKeyPair(NamedResource resourceKey, KeyPair kp, OutputStream outputStream) throws IOException, GeneralSecurityException

Implements abstract org.apache.sshd.server.keyprovider.AbstractGeneratorHostKeyProvider.doWriteKeyPair.

Annotations
@Override
isJavaSerializationback to summary
private boolean isJavaSerialization(BufferedInputStream in, NamedResource resourceKey) throws IOException
org.apache.sshd.server.keyprovider back to summary

private Class SimpleGeneratorHostKeyProvider.ValidatingObjectInputStream

extends ObjectInputStream
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final Set<String>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
protected Class<?>
resolveClass(ObjectStreamClass
an instance of class ObjectStreamClass
desc
)

Overrides java.io.ObjectInputStream.resolveClass.

Load the local class equivalent of the specified stream class description.

private void
validate(String className)

Inherited from java.io.ObjectInputStream:
availableclosedefaultReadObjectenableResolveObjectgetObjectInputFilterreadreadreadBooleanreadBytereadCharreadClassDescriptorreadDoublereadFieldsreadFloatreadFullyreadFullyreadIntreadLinereadLongreadObjectreadObjectOverridereadShortreadStreamHeaderreadUnsharedreadUnsignedBytereadUnsignedShortreadUTFregisterValidationresolveObjectresolveProxyClasssetObjectInputFilterskipBytes

Field Detail

ALLOWEDback to summary
private static final Set<String> ALLOWED

Constructor Detail

ValidatingObjectInputStreamback to summary
pack-priv ValidatingObjectInputStream(InputStream in) throws IOException

Method Detail

resolveClassback to summary
protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException

Overrides java.io.ObjectInputStream.resolveClass.

Doc from java.io.ObjectInputStream.resolveClass.

Load the local class equivalent of the specified stream class description. Subclasses may implement this method to allow classes to be fetched from an alternate source.

The corresponding method in ObjectOutputStream is annotateClass. This method will be invoked only once for each unique class in the stream. This method can be implemented by subclasses to use an alternate loading mechanism but must return a Class object. Once returned, if the class is not an array class, its serialVersionUID is compared to the serialVersionUID of the serialized class, and if there is a mismatch, the deserialization fails and an InvalidClassException is thrown.

The default implementation of this method in ObjectInputStream returns the result of calling

Class.forName(desc.getName(), false, loader)
Class.forName(desc.getName(), false, loader)
where loader is the first class loader on the current thread's stack (starting from the currently executing method) that is neither the platform class loader nor its ancestor; otherwise, loader is the platform class loader. If this call results in a ClassNotFoundException and the name of the passed ObjectStreamClass instance is the Java language keyword for a primitive type or void, then the Class object representing that primitive type or void will be returned (e.g., an ObjectStreamClass with the name "int" will be resolved to Integer.TYPE). Otherwise, the ClassNotFoundException will be thrown to the caller of this method.
Parameters
desc:ObjectStreamClass

an instance of class ObjectStreamClass

Returns:Class<?>

a Class object corresponding to desc

Annotations
@Override
Exceptions
IOException:
any of the usual Input/Output exceptions.
ClassNotFoundException:
if class of a serialized object cannot be found.
validateback to summary
private void validate(String className) throws IOException