List of usage examples for org.apache.commons.vfs2.util UserAuthenticatorUtils toString
public static String toString(final char[] data)
From source file:com.sludev.commons.vfs2.provider.s3.SS3FileProvider.java
/** * Create FileSystem event hook//from ww w.j a va 2 s .c o 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.ja va 2 s .com*/ * @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.pentaho.reporting.libraries.pensol.PentahoSolutionFileProvider.java
private FileSystem createJCRFileSystem(final LayeredFileName genericRootName, final FileSystemOptions fileSystemOptions) { UserAuthenticationData authData = null; try {/* www. j a v a 2 s . c om*/ 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); } }