List of usage examples for org.apache.commons.vfs UserAuthenticationData USERNAME
Type USERNAME
To view the source code for org.apache.commons.vfs UserAuthenticationData USERNAME.
Click Source Link
From source file:com.thinkberg.vfs.s3.S3FileProvider.java
/** * Create a file system with the S3 root provided. * * @param fileName the S3 file name that defines the root (bucket) * @param fileSystemOptions file system options * @return an S3 file system// w w w . j a v a2 s. c o m * @throws FileSystemException if te file system cannot be created */ protected FileSystem doCreateFileSystem(FileName fileName, FileSystemOptions fileSystemOptions) throws FileSystemException { LOG.debug(String.format("creating new file system '%s'", fileName)); if (null == service) { LOG.debug("creating new S3 service"); UserAuthenticationData authenticationInfo = UserAuthenticatorUtils.authenticate(fileSystemOptions, AUTHENTICATOR_TYPES); String accessKey = UserAuthenticatorUtils.toString( UserAuthenticatorUtils.getData(authenticationInfo, UserAuthenticationData.USERNAME, null)); String secretKey = UserAuthenticatorUtils.toString( UserAuthenticatorUtils.getData(authenticationInfo, UserAuthenticationData.PASSWORD, null)); try { service = new RestS3Service(new AWSCredentials(accessKey, secretKey)); } catch (S3ServiceException e) { throw new FileSystemException("Amazon S3 service initialization failed", e); } finally { authenticationInfo.cleanup(); } } return new Jets3tFileSystem(service, (S3FileName) fileName, fileSystemOptions); }
From source file:org.jclouds.vfs.provider.blobstore.BlobStoreFileProvider.java
protected FileSystem doCreateFileSystem(final FileName name, final FileSystemOptions fileSystemOptions) throws FileSystemException { BlobStoreFileName rootName = (BlobStoreFileName) name; UserAuthenticationData authData = null; BlobStoreContext context;//from w w w .j a va 2 s .c om try { String uriToParse = rootName.getFriendlyURI(); authData = UserAuthenticatorUtils.authenticate(fileSystemOptions, AUTHENTICATOR_TYPES); URI location = HttpUtils.createUri(uriToParse); context = new BlobStoreContextFactory().createContext(location.getHost(), UserAuthenticatorUtils .toString(UserAuthenticatorUtils.getData(authData, UserAuthenticationData.USERNAME, UserAuthenticatorUtils.toChar(rootName.getUserName()))), UserAuthenticatorUtils .toString(UserAuthenticatorUtils.getData(authData, UserAuthenticationData.PASSWORD, UserAuthenticatorUtils.toChar(rootName.getPassword()))), modules, new Properties()); } finally { UserAuthenticatorUtils.cleanup(authData); } return new BlobStoreFileSystem(rootName, context, fileSystemOptions); }
From source file:org.pentaho.s3.vfs.S3FileSystem.java
public S3Service getS3Service() { if (service == null || service.getProviderCredentials() == null || service.getProviderCredentials().getAccessKey() == null) { UserAuthenticator userAuthenticator = DefaultFileSystemConfigBuilder.getInstance() .getUserAuthenticator(getFileSystemOptions()); String awsAccessKey = null; String awsSecretKey = null; if (userAuthenticator != null) { UserAuthenticationData data = userAuthenticator .requestAuthentication(S3FileProvider.AUTHENTICATOR_TYPES); awsAccessKey = String.valueOf(data.getData(UserAuthenticationData.USERNAME)); awsSecretKey = String.valueOf(data.getData(UserAuthenticationData.PASSWORD)); } else {/*from ww w .ja v a 2 s . c o m*/ awsAccessKey = ((URLFileName) getRootName()).getUserName(); awsSecretKey = ((URLFileName) getRootName()).getPassword(); } ProviderCredentials awsCredentials = new AWSCredentials(awsAccessKey, awsSecretKey); try { service = new RestS3Service(awsCredentials); } catch (Throwable t) { System.out.println("Could not getS3Service() for " + awsCredentials.getLogString()); t.printStackTrace(); } } return service; }