Example usage for org.apache.commons.vfs2.provider.sftp SftpFileSystemConfigBuilder setIdentities

List of usage examples for org.apache.commons.vfs2.provider.sftp SftpFileSystemConfigBuilder setIdentities

Introduction

In this page you can find the example usage for org.apache.commons.vfs2.provider.sftp SftpFileSystemConfigBuilder setIdentities.

Prototype

@Deprecated
public void setIdentities(final FileSystemOptions opts, final File... identityFiles)
        throws FileSystemException 

Source Link

Document

Sets the identity files (your private key files).

Usage

From source file:hadoopInstaller.installation.Installer.java

private void configureVFS2SFTP() throws InstallationFatalError {
    getLog().trace("HadoopInstaller.Configure.SFTP.Start"); //$NON-NLS-1$
    FileSystemOptions options;/*ww  w.j av a  2  s . c  o m*/
    options = new FileSystemOptions();
    SftpFileSystemConfigBuilder builder = SftpFileSystemConfigBuilder.getInstance();
    try {
        builder.setUserDirIsRoot(options, false);
        /*
         * TODO-- ssh-ask
         * 
         * In the case of ask, the UserInfo object should be passed with
         * builder.setUserInfo()
         */
        builder.setStrictHostKeyChecking(options, this.configuration.getStrictHostKeyChecking() ? "yes" : "no"); //$NON-NLS-1$//$NON-NLS-2$
        getLog().trace("HadoopInstaller.Configure.StrictHostKeyChecking", //$NON-NLS-1$
                this.configuration.getStrictHostKeyChecking());
        builder.setKnownHosts(options, new File(this.configuration.getSshKnownHosts()));
        getLog().trace("HadoopInstaller.Configure.KnownHosts", //$NON-NLS-1$
                this.configuration.getSshKnownHosts());
        File identities[] = { new File(getConfig().getSshKeyFile()) };
        getLog().trace("HadoopInstaller.Configure.PrivateKeyFile", //$NON-NLS-1$
                getConfig().getSshKeyFile());
        builder.setIdentities(options, identities);
        /*
         * TODO-- ssh-ask
         * 
         * what if the identities file is password protected? do we need to
         * use setUserInfo?
         */
    } catch (FileSystemException e) {
        throw new InstallationFatalError(e, "HadoopInstaller.Configure.SFTP.Fail"); //$NON-NLS-1$
    }
    this.sftpOptions = options;
    getLog().debug("HadoopInstaller.Configure.SFTP.Success"); //$NON-NLS-1$
}