Class KeyRandomArt

java.lang.Object
org.apache.sshd.common.config.keys.KeyRandomArt
All Implemented Interfaces:
AlgorithmNameProvider, KeySizeIndicator

public class KeyRandomArt extends Object implements AlgorithmNameProvider, KeySizeIndicator
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)
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • getAlgorithm

      public String getAlgorithm()
      Specified by:
      getAlgorithm in interface AlgorithmNameProvider
      Returns:
      The algorithm that was used to generate the key - e.g., "RSA", "DSA", "EC".
    • getKeySize

      public int getKeySize()
      Specified by:
      getKeySize in interface KeySizeIndicator
      Returns:
      The number of bits used in the key
    • append

      public <A extends Appendable> A append(A sb) throws IOException
      Outputs the generated random art
      Type Parameters:
      A - The Appendable output writer
      Parameters:
      sb - The writer
      Returns:
      The updated writer instance
      Throws:
      IOException - If failed to write the combined result
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • combine

      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 - The separator to use between the arts - if empty char ('\0') then no separation is done
      arts - The KeyRandomArts to combine - ignored if null/empty
      Returns:
      The combined result
    • combine

      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 - 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 - The separator to use between the arts - if empty char ('\0') then no separation is done
      provider - The KeyIdentityProvider - ignored if null or has no keys to provide
      Returns:
      The combined representation
      Throws:
      Exception - If failed to extract or combine the entries
      See Also:
    • combine

      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
      Type Parameters:
      A - The Appendable output writer
      Parameters:
      session - 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 - The writer
      separator - The separator to use between the arts - if empty char ('\0') then no separation is done
      provider - The KeyIdentityProvider - ignored if null or has no keys to provide
      Returns:
      The updated writer instance
      Throws:
      Exception - If failed to extract or write the entries
      See Also:
    • generate

      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 - 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 - The KeyIdentityProvider - ignored if null or has no keys to provide
      Returns:
      The extracted KeyRandomArts
      Throws:
      Exception - If failed to extract the entries
      See Also:
    • combine

      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
      Type Parameters:
      A - The Appendable output writer
      Parameters:
      sb - The writer
      separator - The separator to use between the arts - if empty char ('\0') then no separation is done
      arts - The KeyRandomArts to combine - ignored if null/empty
      Returns:
      The updated writer instance
      Throws:
      IOException - If failed to write the combined result