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());
}
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("/");
}
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;
}
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;
}
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;
}
Aggregations