Search in sources :

Example 11 with StaticUserAuthenticator

use of org.apache.commons.vfs2.auth.StaticUserAuthenticator in project big-data-plugin by pentaho.

the class AbstractAmazonJobExecutorController method resolveFile.

public FileObject resolveFile(String fileUri) throws FileSystemException, KettleFileException {
    VariableSpace vs = getVariableSpace();
    FileSystemOptions opts = new FileSystemOptions();
    DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, new StaticUserAuthenticator(null, getAccessKey(), getSecretKey()));
    FileObject file = KettleVFS.getFileObject(fileUri, vs, opts);
    return file;
}
Also used : VariableSpace(org.pentaho.di.core.variables.VariableSpace) StaticUserAuthenticator(org.apache.commons.vfs2.auth.StaticUserAuthenticator) FileObject(org.apache.commons.vfs2.FileObject) FileSystemOptions(org.apache.commons.vfs2.FileSystemOptions)

Example 12 with StaticUserAuthenticator

use of org.apache.commons.vfs2.auth.StaticUserAuthenticator in project meveo by meveo-org.

the class FtpAdapterJobBean method initialize.

/**
 * Creates the download directory localDir if it does not exist and makes a connection to the remote SFTP server.
 *
 * @param localDir the local dir
 * @param userName the user name
 * @param password the password
 * @param filePatternString the file pattern string
 * @param isSftp the is sftp
 * @throws FileSystemException the file system exception
 */
private void initialize(String localDir, String userName, String password, String filePatternString, boolean isSftp) throws FileSystemException {
    localDirFile = new File(localDir);
    if (!localDirFile.exists()) {
        localDirFile.mkdirs();
    }
    try {
        fsManager = VFS.getManager();
    } catch (FileSystemException ex) {
        throw new RuntimeException("failed to get fsManager from VFS", ex);
    }
    UserAuthenticator auth = new StaticUserAuthenticator(null, userName, password);
    opts = getSftpOptions(isSftp);
    try {
        DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth);
    } catch (FileSystemException ex) {
        throw new RuntimeException("setUserAuthenticator failed", ex);
    }
    if ("false".equals(paramBeanFactory.getInstance().getProperty("ftpAdapter.useExtentionAsRegex", "false"))) {
        filePattern = Pattern.compile(".*" + filePatternString);
    } else {
        filePattern = Pattern.compile(filePatternString);
    }
}
Also used : FileSystemException(org.apache.commons.vfs2.FileSystemException) UserAuthenticator(org.apache.commons.vfs2.UserAuthenticator) StaticUserAuthenticator(org.apache.commons.vfs2.auth.StaticUserAuthenticator) StaticUserAuthenticator(org.apache.commons.vfs2.auth.StaticUserAuthenticator) FtpImportedFile(org.meveo.model.jobs.FtpImportedFile) LocalFile(org.apache.commons.vfs2.provider.local.LocalFile) File(java.io.File)

Aggregations

StaticUserAuthenticator (org.apache.commons.vfs2.auth.StaticUserAuthenticator)10 FileSystemOptions (org.apache.commons.vfs2.FileSystemOptions)9 FileObject (org.apache.commons.vfs2.FileObject)3 FileSystemException (org.apache.commons.vfs2.FileSystemException)3 UserAuthenticator (org.apache.commons.vfs2.UserAuthenticator)3 AWSCredentials (com.amazonaws.auth.AWSCredentials)2 URL (java.net.URL)2 Test (org.junit.jupiter.api.Test)2 SdkClientException (com.amazonaws.SdkClientException)1 File (java.io.File)1 UserAuthenticationData (org.apache.commons.vfs2.UserAuthenticationData)1 LocalFile (org.apache.commons.vfs2.provider.local.LocalFile)1 FtpImportedFile (org.meveo.model.jobs.FtpImportedFile)1 VariableSpace (org.pentaho.di.core.variables.VariableSpace)1