Search in sources :

Example 1 with StaticUserAuthenticator

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

the class StaticUserAuthenticatorTest method testEquality.

@Test
public void testEquality() {
    final UserAuthenticator userAuthenticator = new StaticUserAuthenticator("DOMAIN", "USER", "PWD");
    assertEquals(new StaticUserAuthenticator("DOMAIN", "USER", "PWD"), userAuthenticator);
    assertNotEquals(new StaticUserAuthenticator("DOMAIN", "USER", null), userAuthenticator);
    assertNotEquals(new StaticUserAuthenticator("DOMAIN", null, "PWD"), userAuthenticator);
    assertNotEquals(new StaticUserAuthenticator(null, "USER", "PWD"), userAuthenticator);
    assertEquals(new StaticUserAuthenticator("DOMAIN", "USER", "PWD").hashCode(), userAuthenticator.hashCode());
}
Also used : UserAuthenticator(org.apache.commons.vfs2.UserAuthenticator) Test(org.junit.jupiter.api.Test)

Example 2 with StaticUserAuthenticator

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

the class NestedTarTestCase method getBaseTestFolder.

/**
 * Returns the base folder for tests.
 */
@Override
public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception {
    // We test with non-empty FS options to make sure they are propagated
    final FileSystemOptions opts = new FileSystemOptions();
    DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, new StaticUserAuthenticator("domain", null, null));
    // Locate the base Tar file
    final String tarFilePath = getTestResource("nested.tar").getAbsolutePath();
    // Now build the nested file system
    final String uri = "tar:file:" + tarFilePath + "!/test.tar";
    final FileObject tarFile = manager.resolveFile(uri, opts);
    final FileObject nestedFS = manager.createFileSystem(tarFile);
    return nestedFS.resolveFile("/");
}
Also used : StaticUserAuthenticator(org.apache.commons.vfs2.auth.StaticUserAuthenticator) FileObject(org.apache.commons.vfs2.FileObject) FileSystemOptions(org.apache.commons.vfs2.FileSystemOptions)

Example 3 with StaticUserAuthenticator

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

the class S3VfsFileChooserBaseDialog method getFileSystemOptions.

private FileSystemOptions getFileSystemOptions() throws FileSystemException {
    FileSystemOptions opts = new FileSystemOptions();
    try {
        String accessKey = "";
        String secretKey = "";
        /* For legacy transformations containing AWS S3 access credentials, {@link Const#KETTLE_USE_AWS_DEFAULT_CREDENTIALS} can force Spoon to use
       * the Amazon Default Credentials Provider Chain instead of using the credentials embedded in the transformation metadata. */
        if (!ValueMetaBase.convertStringToBoolean(Const.NVL(EnvUtil.getSystemProperty(Const.KETTLE_USE_AWS_DEFAULT_CREDENTIALS), "N"))) {
            accessKey = System.getProperty(S3Util.ACCESS_KEY_SYSTEM_PROPERTY);
            secretKey = System.getProperty(S3Util.SECRET_KEY_SYSTEM_PROPERTY);
        } else {
            AWSCredentials credentials = S3CredentialsProvider.getAWSCredentials();
            if (credentials != null) {
                accessKey = credentials.getAWSAccessKeyId();
                secretKey = credentials.getAWSSecretKey();
            }
        }
        StaticUserAuthenticator userAuthenticator = new StaticUserAuthenticator(null, secretKey, accessKey);
        DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, userAuthenticator);
    } catch (SdkClientException e) {
        throw new FileSystemException(e);
    }
    return opts;
}
Also used : FileSystemException(org.apache.commons.vfs2.FileSystemException) SdkClientException(com.amazonaws.SdkClientException) StaticUserAuthenticator(org.apache.commons.vfs2.auth.StaticUserAuthenticator) AWSCredentials(com.amazonaws.auth.AWSCredentials) FileSystemOptions(org.apache.commons.vfs2.FileSystemOptions)

Example 4 with StaticUserAuthenticator

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

the class AbstractAmazonJobExecutorController method getFileSystemOptions.

protected FileSystemOptions getFileSystemOptions() throws FileSystemException {
    FileSystemOptions opts = new FileSystemOptions();
    if (!Const.isEmpty(getAccessKey()) || !Const.isEmpty(getSecretKey())) {
        // create a FileSystemOptions with user & password
        StaticUserAuthenticator userAuthenticator = new StaticUserAuthenticator(null, getVariableSpace().environmentSubstitute(getAccessKey()), getVariableSpace().environmentSubstitute(getSecretKey()));
        DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, userAuthenticator);
    }
    return opts;
}
Also used : StaticUserAuthenticator(org.apache.commons.vfs2.auth.StaticUserAuthenticator) FileSystemOptions(org.apache.commons.vfs2.FileSystemOptions)

Example 5 with StaticUserAuthenticator

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

the class OtherConnectionDetailsProvider method getOpts.

@Override
public FileSystemOptions getOpts(OtherConnectionDetails otherConnectionDetails) {
    if (otherConnectionDetails == null) {
        return null;
    }
    StaticUserAuthenticator auth = new StaticUserAuthenticator(otherConnectionDetails.getHost(), otherConnectionDetails.getUsername(), otherConnectionDetails.getPassword());
    FileSystemOptions opts = new FileSystemOptions();
    try {
        DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth);
    } catch (FileSystemException fse) {
    // Ignore and return default options
    }
    return opts;
}
Also used : FileSystemException(org.apache.commons.vfs2.FileSystemException) StaticUserAuthenticator(org.apache.commons.vfs2.auth.StaticUserAuthenticator) FileSystemOptions(org.apache.commons.vfs2.FileSystemOptions)

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