Logo Search packages:      
Sourcecode: jenkins-trilead-ssh2 version File versions  Download package

synchronized boolean com::trilead::ssh2::Connection::authenticateWithPublicKey ( String  user,
File  pemFile,
String  password 
) throws IOException [inline]

A convenience wrapper function which reads in a private key (PEM format, either DSA or RSA) and then calls authenticateWithPublicKey(String, char[], String).

NOTE PUTTY USERS: Event though your key file may start with "-----BEGIN..." it is not in the expected format. You have to convert it to the OpenSSH key format by using the "puttygen" tool (can be downloaded from the Putty website). Simply load your key and then use the "Conversions/Export OpenSSH key" functionality to get a proper PEM file.

Parameters:
userA String holding the username.
pemFileA File object pointing to a file containing a DSA or RSA private key of the user in OpenSSH key format (PEM, you can't miss the "-----BEGIN DSA PRIVATE KEY-----" or "-----BEGIN RSA PRIVATE KEY-----" tag).
passwordIf the PEM file is encrypted then you must specify the password. Otherwise, this argument will be ignored and can be set to null.
Returns:
whether the connection is now authenticated.
Exceptions:
IOException

Definition at line 462 of file Connection.java.

References authenticateWithPublicKey().

      {
            if (pemFile == null)
                  throw new IllegalArgumentException("pemFile argument is null");

            char[] buff = new char[256];

            CharArrayWriter cw = new CharArrayWriter();

            FileReader fr = new FileReader(pemFile);

            while (true)
            {
                  int len = fr.read(buff);
                  if (len < 0)
                        break;
                  cw.write(buff, 0, len);
            }

            fr.close();

            return authenticateWithPublicKey(user, cw.toCharArray(), password);
      }

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index