List of usage examples for org.apache.commons.vfs2.util UserAuthenticatorUtils authenticate
public static UserAuthenticationData authenticate(final UserAuthenticator auth, final UserAuthenticationData.Type[] authenticatorTypes)
From source file:fr.cls.atoll.motu.library.misc.vfs.provider.gsiftp.GridFTPClientWrapper.java
/** * Creates the client.//from w w w. java 2 s .c o m * * @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:org.pentaho.di.core.vfs.SftpFileSystemWindows.java
/** * {@link org.apache.commons.vfs2.provider.sftp.SftpFileSystem#getChannel() } * *//*www . j a va 2s . c o m*/ 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 w w w .j a v a 2 s .co 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); } }