Top Description Fields Constructors Methods
org.apache.sshd.common.config.keys

public Class KeyRandomArt

extends Object
implements AlgorithmNameProvider, KeySizeIndicator
Class Inheritance
All Implemented Interfaces
org.apache.sshd.common.keyprovider.KeySizeIndicator, org.apache.sshd.common.AlgorithmNameProvider
Imports
java.io.IOException, .StreamCorruptedException, java.security.KeyPair, .PublicKey, java.util.ArrayList, .Collection, .Collections, .Iterator, .LinkedList, .List, .Objects, org.apache.sshd.common.AlgorithmNameProvider, .Factory, org.apache.sshd.common.digest.Digest, org.apache.sshd.common.keyprovider.KeyIdentityProvider, .KeySizeIndicator, org.apache.sshd.common.session.SessionContext, org.apache.sshd.common.util.GenericUtils, .ValidateUtils

Draw an ASCII-Art representing the fingerprint so human brain can profit from its built-in pattern recognition ability. This technique is called "random art" and can be found in some scientific publications like this original paper: "Hash Visualization: a New Technique to improve Real-World Security", Perrig A. and Song D., 1999, International Workshop on Cryptographic Techniques and E-Commerce (CrypTEC '99)
Author
Apache MINA SSHD Project
See Also
Original article, C implementation

Field Summary

Modifier and TypeField and Description
private final String
public static final String
private final char[][]
public static final int
public static final int
public static final int
private final int

Constructor Summary

AccessConstructor and Description
public
public
KeyRandomArt(PublicKey key, Factory<? extends Digest> f)

public
public
KeyRandomArt(String
The key algorithm
algorithm
,
int
The key size in bits
keySize
,
byte[]
The key digest
digest
)

Method Summary

Modifier and TypeMethod and Description
public <
The Appendable output writer
A extends Appendable
>
A

Returns:

The updated writer instance
append
(A
The writer
sb
)

Outputs the generated random art

public static String

Returns:

The combined result
combine
(char
The separator to use between the arts - if empty char ('\0') then no separation is done
separator
,
Collection<? extends KeyRandomArt>
The KeyRandomArts to combine - ignored if null/empty
arts
)

Combines the arts in a user-friendly way so they are aligned with each other

public static String

Returns:

The combined representation
combine
(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
,
char
The separator to use between the arts - if empty char ('\0') then no separation is done
separator
,
KeyIdentityProvider
The KeyIdentityProvider - ignored if null or has no keys to provide
provider
)

Creates the combined representation of the random art entries for the provided keys

public static <
The Appendable output writer
A extends Appendable
>
A

Returns:

The updated writer instance
combine
(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
,
A
The writer
sb
,
char
The separator to use between the arts - if empty char ('\0') then no separation is done
separator
,
KeyIdentityProvider
The KeyIdentityProvider - ignored if null or has no keys to provide
provider
)

Appends the combined random art entries for the provided keys

public static <
The Appendable output writer
A extends Appendable
>
A

Returns:

The updated writer instance
combine
(A
The writer
sb
,
char
The separator to use between the arts - if empty char ('\0') then no separation is done
separator
,
Collection<? extends KeyRandomArt>
The KeyRandomArts to combine - ignored if null/empty
arts
)

Combines the arts in a user-friendly way so they are aligned with each other

public static Collection<KeyRandomArt>

Returns:

The extracted KeyRandomArts
generate
(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
,
KeyIdentityProvider
The KeyIdentityProvider - ignored if null or has no keys to provide
provider
)

Extracts and generates random art entries for all key in the provider

public String

Returns:

The algorithm that was used to generate the key - e.g., "RSA", "DSA", "EC".
getAlgorithm
()

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

public int
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

algorithmback to summary
private final String algorithm
AUGMENTATION_STRINGback to summary
public static final String AUGMENTATION_STRING
fieldback to summary
private final char[][] field
FLDBASEback to summary
public static final int FLDBASE
FLDSIZE_Xback to summary
public static final int FLDSIZE_X
FLDSIZE_Yback to summary
public static final int FLDSIZE_Y
keySizeback to summary
private final int keySize

Constructor Detail

KeyRandomArtback to summary
public KeyRandomArt(PublicKey key) throws Exception
KeyRandomArtback to summary
public KeyRandomArt(PublicKey key, Factory<? extends Digest> f) throws Exception
KeyRandomArtback to summary
public KeyRandomArt(PublicKey key, Digest d) throws Exception
KeyRandomArtback to summary
public KeyRandomArt(String algorithm, int keySize, byte[] digest)
Parameters
algorithm:String

The key algorithm

keySize:int

The key size in bits

digest:byte[]

The key digest

Method Detail

appendback to summary
public <A extends Appendable> A append(A sb) throws IOException

Outputs the generated random art

Parameters
<A>
The Appendable output writer
sb:A

The writer

Returns:A

The updated writer instance

Exceptions
IOException:
If failed to write the combined result
combineback to summary
public static String combine(char separator, Collection<? extends KeyRandomArt> arts)

Combines the arts in a user-friendly way so they are aligned with each other

Parameters
separator:char

The separator to use between the arts - if empty char ('\0') then no separation is done

arts:Collection<? extends KeyRandomArt>

The KeyRandomArts to combine - ignored if null/empty

Returns:String

The combined result

combineback to summary
public static String combine(SessionContext session, char separator, KeyIdentityProvider provider) throws Exception

Creates the combined representation of the random art entries for the provided 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).

separator:char

The separator to use between the arts - if empty char ('\0') then no separation is done

provider:KeyIdentityProvider

The KeyIdentityProvider - ignored if null or has no keys to provide

Returns:String

The combined representation

Exceptions
Exception:
If failed to extract or combine the entries
See Also
combine(SessionContext, Appendable, char, KeyIdentityProvider)
combineback to summary
public static <A extends Appendable> A combine(SessionContext session, A sb, char separator, KeyIdentityProvider provider) throws Exception

Appends the combined random art entries for the provided keys

Parameters
<A>
The Appendable output writer
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).

sb:A

The writer

separator:char

The separator to use between the arts - if empty char ('\0') then no separation is done

provider:KeyIdentityProvider

The KeyIdentityProvider - ignored if null or has no keys to provide

Returns:A

The updated writer instance

Exceptions
Exception:
If failed to extract or write the entries
See Also
generate(SessionContext, KeyIdentityProvider), combine(Appendable, char, Collection)
combineback to summary
public static <A extends Appendable> A combine(A sb, char separator, Collection<? extends KeyRandomArt> arts) throws IOException

Combines the arts in a user-friendly way so they are aligned with each other

Parameters
<A>
The Appendable output writer
sb:A

The writer

separator:char

The separator to use between the arts - if empty char ('\0') then no separation is done

arts:Collection<? extends KeyRandomArt>

The KeyRandomArts to combine - ignored if null/empty

Returns:A

The updated writer instance

Exceptions
IOException:
If failed to write the combined result
generateback to summary
public static Collection<KeyRandomArt> generate(SessionContext session, KeyIdentityProvider provider) throws Exception

Extracts and generates random art entries for all key in the provider

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).

provider:KeyIdentityProvider

The KeyIdentityProvider - ignored if null or has no keys to provide

Returns:Collection<KeyRandomArt>

The extracted KeyRandomArts

Exceptions
Exception:
If failed to extract the entries
See Also
KeyIdentityProvider#loadKeys(SessionContext)
getAlgorithmback to summary
public String getAlgorithm()

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

Returns:String

The algorithm that was used to generate the key - e.g., "RSA", "DSA", "EC".

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
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override