Example usage for org.apache.commons.vfs2.provider GenericFileName getPassword

List of usage examples for org.apache.commons.vfs2.provider GenericFileName getPassword

Introduction

In this page you can find the example usage for org.apache.commons.vfs2.provider GenericFileName getPassword.

Prototype

public String getPassword() 

Source Link

Document

Returns the password part of this name.

Usage

From source file:fr.cls.atoll.motu.library.misc.vfs.provider.gsiftp.GsiFtpFileSystem.java

/**
 * Creates an FTP client to use.//  w w  w. j  av a  2s .  c  om
 * 
 * @return the client
 * 
 * @throws FileSystemException the file system exception
 */
public GridFTPClient getClient() throws FileSystemException {
    synchronized (idleClientSync) {
        if (idleClient == null) {
            final GenericFileName rootName = (GenericFileName) getRoot().getName();

            LOG.debug("Creating connection to GSIFTP Host: " + rootName.getHostName() + " Port:"
                    + rootName.getPort() + " User:" + rootName.getUserName() + " Path: " + rootName.getPath());

            return GsiFtpClientFactory.createConnection(rootName.getHostName(), rootName.getPort(),
                    rootName.getUserName(), rootName.getPassword(),
                    // rootName.getPath(),
                    getFileSystemOptions());
        } else {
            final GridFTPClient client = idleClient;
            idleClient = null;
            return client;
        }
    }
}

From source file:fr.cls.atoll.motu.library.misc.vfs.provider.gsiftp.GridFTPClientWrapper.java

/**
 * Creates the client.//  w w  w  .j  a va  2  s . co  m
 * 
 * @return the grid ftp client
 * 
 * @throws FileSystemException the file system exception
 */
protected GridFTPClient createClient() throws FileSystemException {
    final GenericFileName rootName = getRoot();

    UserAuthenticationData authData = null;
    try {
        authData = UserAuthenticatorUtils.authenticate(fileSystemOptions,
                GsiFtpFileProvider.AUTHENTICATOR_TYPES);

        String username = UserAuthenticatorUtils.getData(authData, UserAuthenticationData.USERNAME,
                UserAuthenticatorUtils.toChar(rootName.getUserName())).toString();
        String password = UserAuthenticatorUtils.getData(authData, UserAuthenticationData.PASSWORD,
                UserAuthenticatorUtils.toChar(rootName.getPassword())).toString();
        return GsiFtpClientFactory.createConnection(rootName.getHostName(), rootName.getPort(), username,
                password, getFileSystemOptions());
    } finally {
        UserAuthenticatorUtils.cleanup(authData);
    }
}

From source file:com.sludev.commons.vfs2.provider.azure.AzFileProvider.java

/**
 * Callback for handling the create File-System event
 * //from w  ww .  j ava2 s.com
 * @param rootName
 * @param fileSystemOptions
 * @return
 * @throws FileSystemException 
 */
@Override
protected FileSystem doCreateFileSystem(FileName rootName, FileSystemOptions fileSystemOptions)
        throws FileSystemException {
    AzFileSystem fileSystem = null;
    GenericFileName genRootName = (GenericFileName) rootName;

    StorageCredentials storageCreds;
    CloudStorageAccount storageAccount;
    CloudBlobClient client;

    FileSystemOptions currFSO = (fileSystemOptions != null) ? fileSystemOptions : getDefaultFileSystemOptions();
    UserAuthenticator ua = DefaultFileSystemConfigBuilder.getInstance().getUserAuthenticator(currFSO);

    UserAuthenticationData authData = null;
    try {
        authData = ua.requestAuthentication(AUTHENTICATOR_TYPES);

        String currAcct = UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData,
                UserAuthenticationData.USERNAME, UserAuthenticatorUtils.toChar(genRootName.getUserName())));

        String currKey = UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData,
                UserAuthenticationData.PASSWORD, UserAuthenticatorUtils.toChar(genRootName.getPassword())));

        storageCreds = new StorageCredentialsAccountAndKey(currAcct, currKey);
        storageAccount = new CloudStorageAccount(storageCreds);

        client = storageAccount.createCloudBlobClient();

        fileSystem = new AzFileSystem(genRootName, client, fileSystemOptions);
    } catch (URISyntaxException ex) {
        throw new FileSystemException(ex);
    } finally {
        UserAuthenticatorUtils.cleanup(authData);
    }

    return fileSystem;
}

From source file:com.sludev.commons.vfs2.provider.s3.SS3FileProvider.java

/**
 * Create FileSystem event hook//  w w w.  j  a va 2s  .  com
 * 
 * @param rootName
 * @param fileSystemOptions
 * @return
 * @throws FileSystemException 
 */
@Override
protected FileSystem doCreateFileSystem(FileName rootName, FileSystemOptions fileSystemOptions)
        throws FileSystemException {
    SS3FileSystem fileSystem = null;
    GenericFileName genRootName = (GenericFileName) rootName;

    AWSCredentials storageCreds;
    AmazonS3Client client;

    FileSystemOptions currFSO;
    UserAuthenticator ua;

    if (fileSystemOptions == null) {
        currFSO = getDefaultFileSystemOptions();
        ua = SS3FileSystemConfigBuilder.getInstance().getUserAuthenticator(currFSO);
    } else {
        currFSO = fileSystemOptions;
        ua = DefaultFileSystemConfigBuilder.getInstance().getUserAuthenticator(currFSO);
    }

    UserAuthenticationData authData = null;
    try {
        authData = ua.requestAuthentication(AUTHENTICATOR_TYPES);

        String currAcct = UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData,
                UserAuthenticationData.USERNAME, UserAuthenticatorUtils.toChar(genRootName.getUserName())));

        String currKey = UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData,
                UserAuthenticationData.PASSWORD, UserAuthenticatorUtils.toChar(genRootName.getPassword())));

        storageCreds = new BasicAWSCredentials(currAcct, currKey);

        client = new AmazonS3Client(storageCreds);

        if (StringUtils.isNoneBlank(endpoint)) {
            client.setEndpoint(endpoint);
        }

        if (region != null) {
            client.setRegion(region);
        }

        fileSystem = new SS3FileSystem(genRootName, client, fileSystemOptions);
    } finally {
        UserAuthenticatorUtils.cleanup(authData);
    }

    return fileSystem;
}

From source file:org.pentaho.di.core.vfs.SftpFileSystemWindows.java

/**
 * {@link  org.apache.commons.vfs2.provider.sftp.SftpFileSystem#getChannel() }
 *
 *///  w  ww. j  av  a  2 s .co  m
private void ensureSession() throws FileSystemException {
    if (this.session == null || !this.session.isConnected()) {
        this.doCloseCommunicationLink();
        UserAuthenticationData authData = null;

        Session session;
        try {
            GenericFileName e = (GenericFileName) this.getRootName();
            authData = UserAuthenticatorUtils.authenticate(this.getFileSystemOptions(),
                    SftpFileProvider.AUTHENTICATOR_TYPES);
            session = SftpClientFactory.createConnection(e.getHostName(), e.getPort(),
                    UserAuthenticatorUtils.getData(authData, UserAuthenticationData.USERNAME,
                            UserAuthenticatorUtils.toChar(e.getUserName())),
                    UserAuthenticatorUtils.getData(authData, UserAuthenticationData.PASSWORD,
                            UserAuthenticatorUtils.toChar(e.getPassword())),
                    this.getFileSystemOptions());
        } catch (Exception var7) {
            throw new FileSystemException("vfs.provider.sftp/connect.error", this.getRootName(), var7);
        } finally {
            UserAuthenticatorUtils.cleanup(authData);
        }

        this.session = session;
    }

}

From source file:org.pentaho.reporting.libraries.pensol.PentahoSolutionFileProvider.java

private FileSystem createJCRFileSystem(final LayeredFileName genericRootName,
        final FileSystemOptions fileSystemOptions) {
    UserAuthenticationData authData = null;
    try {/*  w  w  w .  j  ava2  s.com*/
        authData = UserAuthenticatorUtils.authenticate(fileSystemOptions, AUTHENTICATOR_TYPES);
        final GenericFileName outerName = (GenericFileName) genericRootName.getOuterName();

        final String username = UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData,
                UserAuthenticationData.USERNAME, UserAuthenticatorUtils.toChar(outerName.getUserName())));

        final String password = UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData,
                UserAuthenticationData.PASSWORD, UserAuthenticatorUtils.toChar(outerName.getPassword())));
        final PentahoSolutionsFileSystemConfigBuilder configBuilder = new PentahoSolutionsFileSystemConfigBuilder();
        final int timeOut = configBuilder.getTimeOut(fileSystemOptions);

        final JCRSolutionFileModel model = new JCRSolutionFileModel(outerName.getURI(), username, password,
                timeOut);
        return new JCRSolutionFileSystem(genericRootName, fileSystemOptions, model);
    } finally {
        UserAuthenticatorUtils.cleanup(authData);
    }
}

From source file:org.pentaho.reporting.libraries.pensol.PentahoSolutionFileProvider.java

private FileSystem createWebFileSystem(final LayeredFileName genericRootName,
        final FileSystemOptions fileSystemOptions) throws FileSystemException {
    final GenericFileName outerName = (GenericFileName) genericRootName.getOuterName();
    String scheme = outerName.getScheme();
    String hostName = outerName.getHostName();
    int port = outerName.getPort();
    String userName = outerName.getUserName();
    String password = outerName.getPassword();

    HttpClientManager.HttpClientBuilderFacade clientBuilder = HttpClientManager.getInstance().createBuilder();
    if (!StringUtil.isEmpty(hostName)) {
        clientBuilder.setProxy(hostName, port, scheme);
    }/*  w  w w.j  a v a2  s.c o m*/
    if (!StringUtil.isEmpty(userName)) {
        clientBuilder.setCredentials(userName, password);
    }
    final PentahoSolutionsFileSystemConfigBuilder configBuilder = new PentahoSolutionsFileSystemConfigBuilder();
    final int timeOut = configBuilder.getTimeOut(fileSystemOptions);
    clientBuilder.setSocketTimeout(Math.max(0, timeOut));

    return new WebSolutionFileSystem(genericRootName, fileSystemOptions,
            new LocalFileModel(outerName.getURI(), clientBuilder, userName, password, hostName, port));
}