List of usage examples for org.apache.commons.vfs2.util UserAuthenticatorUtils toChar
public static char[] toChar(final String string)
From source file:maspack.fileutil.vfs.ConsoleUserAuthenticator.java
public UserAuthenticationData requestAuthentication(Type[] types) { UserAuthenticationData data = new UserAuthenticationData(); System.out.println("Authentication requested..."); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); for (int i = 0; i < types.length; i++) { if (types[i] == UserAuthenticationData.DOMAIN) { System.out.print("Domain: "); String domain = storage.get(UserAuthenticationData.DOMAIN); if (domain == null) { try { domain = in.readLine(); // storage.put(UserAuthenticationData.DOMAIN, domain); } catch (IOException e) { e.printStackTrace(); continue; }/* www . j a v a2 s.c o m*/ } data.setData(UserAuthenticationData.DOMAIN, UserAuthenticatorUtils.toChar(domain)); } else if (types[i] == UserAuthenticationData.USERNAME) { System.out.print("Username: "); String user = storage.get(UserAuthenticationData.DOMAIN); if (user == null) { try { user = in.readLine(); // storage.put(UserAuthenticationData.USERNAME, user); } catch (IOException e) { e.printStackTrace(); continue; } } data.setData(UserAuthenticationData.USERNAME, UserAuthenticatorUtils.toChar(user)); } else if (types[i] == UserAuthenticationData.PASSWORD) { System.out.print("Password: "); String pass = storage.get(UserAuthenticationData.PASSWORD); if (pass == null) { try { pass = in.readLine(); // storage.put(UserAuthenticationData.PASSWORD, pass); } catch (IOException e) { e.printStackTrace(); continue; } } data.setData(UserAuthenticationData.PASSWORD, UserAuthenticatorUtils.toChar(pass)); } } return data; }
From source file:maspack.fileutil.vfs.SimpleUserAuthenticator.java
public UserAuthenticationData requestAuthentication(UserAuthenticationData.Type[] types) { UserAuthenticationData data = new UserAuthenticationData(); for (Type type : types) { if (type == UserAuthenticationData.DOMAIN) { data.setData(UserAuthenticationData.DOMAIN, UserAuthenticatorUtils.toChar(domain)); } else if (type == UserAuthenticationData.USERNAME) { data.setData(UserAuthenticationData.USERNAME, UserAuthenticatorUtils.toChar(username)); } else if (type == UserAuthenticationData.PASSWORD) { try { // unfortunately, we seem to have to pass it in plaintext data.setData(UserAuthenticationData.PASSWORD, UserAuthenticatorUtils.toChar(password)); } catch (Exception e) { e.printStackTrace();/*from w ww. j ava 2s . c o m*/ } } } return data; }
From source file:maspack.fileutil.vfs.EncryptedUserAuthenticator.java
public UserAuthenticationData requestAuthentication(UserAuthenticationData.Type[] types) { UserAuthenticationData data = new UserAuthenticationData(); for (Type type : types) { if (type == UserAuthenticationData.DOMAIN) { data.setData(UserAuthenticationData.DOMAIN, UserAuthenticatorUtils.toChar(domain)); } else if (type == UserAuthenticationData.USERNAME) { data.setData(UserAuthenticationData.USERNAME, UserAuthenticatorUtils.toChar(username)); } else if (type == UserAuthenticationData.PASSWORD) { try { // unfortunately, we have to pass it in plaintext, but the original password // could be encrypted from the get-go using the global Cryptor String passwd = getCryptor().decrypt(encryptedPassword); char[] chars = UserAuthenticatorUtils.toChar(passwd); data.setData(UserAuthenticationData.PASSWORD, chars); } catch (Exception e) { e.printStackTrace();//from ww w . j a v a 2 s.co m } } } return data; }
From source file:fr.cls.atoll.motu.library.misc.vfs.provider.gsiftp.GridFTPClientWrapper.java
/** * Creates the client.// w w w .ja v a2 s. c om * * @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.s3.SS3FileProvider.java
/** * Create FileSystem event hook/*from w w w . j a v a 2s .co m*/ * * @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:com.sludev.commons.vfs2.provider.azure.AzFileProvider.java
/** * Callback for handling the create File-System event * //from w w w . j a v a 2 s. c o m * @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:org.esupportail.portlet.filemanager.services.vfs.auth.DynamicUserAuthenticator.java
public UserAuthenticationData requestAuthentication(Type[] types) { UserPassword userPassword = null;/* ww w.j av a2 s .c o m*/ if (authenticatorService != null) { userPassword = authenticatorService.getUserPassword(userParameters); } if (userPassword == null) return null; UserAuthenticationData data = new UserAuthenticationData(); data.setData(UserAuthenticationData.DOMAIN, UserAuthenticatorUtils.toChar(userPassword.getDomain())); data.setData(UserAuthenticationData.USERNAME, UserAuthenticatorUtils.toChar(userPassword.getUsername())); data.setData(UserAuthenticationData.PASSWORD, UserAuthenticatorUtils.toChar(userPassword.getPassword())); return data; }
From source file:org.pentaho.di.core.vfs.SftpFileSystemWindows.java
/** * {@link org.apache.commons.vfs2.provider.sftp.SftpFileSystem#getChannel() } * *//* w w w. ja v a 2s .com*/ 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 {/*from www.jav a 2s . c o m*/ 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); } }