Class SSHAgent

java.lang.Object
fr.ifremer.isisfish.util.ssh.SSHAgent

public class SSHAgent extends Object
Isis SSH agent. This class centralize, ssh key and passphrase management. This is a singleton class.
Version:
$Revision$ Last update : $Date$ By : $Author$
Author:
chatellier
  • Field Details

    • jsch

      protected com.jcraft.jsch.JSch jsch
      JSSch instance.
    • passphraseForKeys

      protected Map<String,char[]> passphraseForKeys
      Passphrase associated to key file path. private key file path =< passphrase. Ensure that passphrase are valid before add into.
  • Method Details

    • getAgent

      public static SSHAgent getAgent()
      Get agent instance.
      Returns:
      agent
    • getPassphrase

      public char[] getPassphrase(File privatekeyFile) throws InvalidPassphraseException
      Get passphrase for key.
      Parameters:
      privatekeyFile - private key file
      Returns:
      null if there is no passphrase
      Throws:
      InvalidPassphraseException - if user cancel authentication
    • getPassphrase

      public char[] getPassphrase(String privatekeyFile) throws InvalidPassphraseException
      Get passphrase for key.
      Parameters:
      privatekeyFile - private key file path
      Returns:
      null if there is no passphrase
      Throws:
      InvalidPassphraseException - if user cancel authentication
    • toBytes

      protected static byte[] toBytes(char[] chars)
      Transform char array to byte array without creating String instance. see http://stackoverflow.com/a/9670279/2038100 for details
      Parameters:
      chars - char array
      Returns:
      byte array