use of org.apache.commons.vfs2.UserAuthenticator in project commons-vfs by apache.
the class StaticUserAuthenticatorTest method testAuthenticationRequest.
@Test
public void testAuthenticationRequest() {
final UserAuthenticator userAuthenticator = new StaticUserAuthenticator("DOMAIN", "USER", "PWD");
UserAuthenticationData authenticationData = userAuthenticator.requestAuthentication(ArrayUtils.toArray(UserAuthenticationData.DOMAIN));
assertArrayEquals("DOMAIN".toCharArray(), authenticationData.getData(UserAuthenticationData.DOMAIN));
assertNull(authenticationData.getData(UserAuthenticationData.USERNAME));
assertNull(authenticationData.getData(UserAuthenticationData.PASSWORD));
authenticationData = userAuthenticator.requestAuthentication(ArrayUtils.toArray(UserAuthenticationData.USERNAME, UserAuthenticationData.PASSWORD));
assertNull(authenticationData.getData(UserAuthenticationData.DOMAIN));
assertArrayEquals("USER".toCharArray(), authenticationData.getData(UserAuthenticationData.USERNAME));
assertArrayEquals("PWD".toCharArray(), authenticationData.getData(UserAuthenticationData.PASSWORD));
}
use of org.apache.commons.vfs2.UserAuthenticator in project big-data-plugin by pentaho.
the class S3FileOutputDialog method getFileSystemOptions.
protected FileSystemOptions getFileSystemOptions() throws FileSystemException {
FileSystemOptions opts = new FileSystemOptions();
S3Util.S3Keys keys = S3Util.getKeysFromURI(wFilename.getText());
if (keys == null) {
AWSCredentials credentials = S3CredentialsProvider.getAWSCredentials();
if (credentials != null) {
StaticUserAuthenticator userAuthenticator = new StaticUserAuthenticator(null, credentials.getAWSAccessKeyId(), credentials.getAWSSecretKey());
DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, userAuthenticator);
}
} else {
StaticUserAuthenticator userAuthenticator = new StaticUserAuthenticator(null, keys.getAccessKey(), keys.getSecretKey());
DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, userAuthenticator);
}
return opts;
}
use of org.apache.commons.vfs2.UserAuthenticator 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);
}
}
Aggregations