/** * @param bookmark The bookmark to edit */ public BookmarkController(final Host bookmark) { this(bookmark, bookmark.getCredentials()); }
@Override protected StorageBucket[] listAllBucketsImpl() throws ServiceException { return super.listAllBucketsImpl( Collections.singletonMap("x-goog-project-id", host.getCredentials().getUsername())); }
@Override protected StorageBucket createBucketImpl(String bucketName, String location, AccessControlList acl) throws ServiceException { return super.createBucketImpl(bucketName, location, acl, Collections.singletonMap("x-goog-project-id", host.getCredentials().getUsername())); }
protected boolean userIsOwner() { final MantaAccountHomeInfo account = new MantaAccountHomeInfo(host.getCredentials().getUsername(), host.getDefaultPath()); return StringUtils.equals(host.getCredentials().getUsername(), account.getAccountOwner()); }
private String getOAuthPrefix(final Host bookmark) { if(StringUtils.isNotBlank(bookmark.getCredentials().getUsername())) { return String.format("%s (%s)", bookmark.getProtocol().getDescription(), bookmark.getCredentials().getUsername()); } return bookmark.getProtocol().getDescription(); }
@Override public boolean accept(Host host) { return StringUtils.lowerCase(BookmarkNameProvider.toString(host)).contains(searchString.toLowerCase(Locale.ROOT)) || ((null != host.getComment()) && StringUtils.lowerCase(host.getComment()).contains(searchString.toLowerCase(Locale.ROOT))) || ((null != host.getCredentials().getUsername()) && StringUtils.lowerCase(host.getCredentials().getUsername()).contains(searchString.toLowerCase(Locale.ROOT))) || StringUtils.lowerCase(host.getHostname()).contains(searchString.toLowerCase(Locale.ROOT)); } });
@Override public void startElement(String name, Attributes attrs) { if(name.equals("FavoriteItem")) { current = new Host(protocols.forScheme(Scheme.ftp)); current.getCredentials().setUsername( PreferencesFactory.get().getProperty("connection.login.anon.name")); } }
public Credentials unlock(final PasswordCallback callback, final Host bookmark, final UserKeyPair keypair) throws CryptoException, LoginCanceledException { final String passphrase = keychain.getPassword(String.format("Triple-Crypt Encryption Password (%s)", bookmark.getCredentials().getUsername()), new DefaultUrlProvider(bookmark).toUrl(new Path(String.valueOf(Path.DELIMITER), EnumSet.of(Path.Type.volume, Path.Type.directory))).find(DescriptiveUrl.Type.provider).getUrl()); return this.unlock(callback, bookmark, keypair, passphrase, LocaleFactory.localizedString("Enter your decryption password to access encrypted data rooms.", "SDS")); }
@Override public Credentials getCredentials(final String username) { // Ignore user but use username from host credentials final String user = host.getCredentials().getUsername(); final String password = store.getPassword(host.getProtocol().getScheme(), host.getPort(), host.getHostname(), user); if(StringUtils.isEmpty(password)) { return null; } return new Credentials(user, password); } }
private AmazonIdentityManagement client() { final AmazonIdentityManagementClientBuilder builder = AmazonIdentityManagementClientBuilder.standard() .withCredentials(AWSCredentialsConfigurator.toAWSCredentialsProvider(bookmark.getCredentials())) .withClientConfiguration(configuration) .withRegion(Regions.DEFAULT_REGION); return builder.build(); } }
protected boolean isWorldReadable(final MantaObject object) { final MantaAccountHomeInfo accountHomeInfo = new MantaAccountHomeInfo(host.getCredentials().getUsername(), host.getDefaultPath()); return StringUtils.startsWithAny( object.getPath(), accountHomeInfo.getAccountPublicRoot().getAbsolute()); }
@Override public Path find() throws BackgroundException { final Path home = super.find(); if(home == DEFAULT_HOME) { return new MantaAccountHomeInfo(session.getHost().getCredentials().getUsername(), session.getHost().getDefaultPath()).getNormalizedHomePath(); } return home; } }
/** * @return URL */ public String get(final Host bookmark) { final Scheme scheme = bookmark.getProtocol().getScheme(); final int port = bookmark.getPort(); final String username = bookmark.getCredentials().getUsername(); final String hostname = bookmark.getHostname(); final String path = bookmark.getDefaultPath(); return this.get(scheme, port, username, hostname, path); }
@Override public String get(final Host bookmark) { switch(bookmark.getProtocol().getScheme()) { case sftp: return super.get(Scheme.ftp, bookmark.getPort(), bookmark.getCredentials().getUsername(), bookmark.getHostname(), bookmark.getDefaultPath()); } return super.get(bookmark); } }
protected boolean isUserWritable(final MantaObject object) { final MantaAccountHomeInfo account = new MantaAccountHomeInfo(host.getCredentials().getUsername(), host.getDefaultPath()); return StringUtils.startsWithAny( object.getPath(), account.getAccountPublicRoot().getAbsolute(), account.getAccountPrivateRoot().getAbsolute()); }
private AmazonCloudFront client(final Path container) throws BackgroundException { final AmazonCloudFrontClientBuilder builder = AmazonCloudFrontClientBuilder.standard() .withCredentials(AWSCredentialsConfigurator.toAWSCredentialsProvider(bookmark.getCredentials())) .withClientConfiguration(configuration); final Location.Name region = this.getRegion(container); if(Location.unknown.equals(region)) { builder.withRegion(Regions.DEFAULT_REGION); } else { builder.withRegion(region.getIdentifier()); } return builder.build(); }
private AWSKMS client(final Path container) throws BackgroundException { final AWSKMSClientBuilder builder = AWSKMSClientBuilder.standard() .withCredentials(AWSCredentialsConfigurator.toAWSCredentialsProvider(bookmark.getCredentials())) .withClientConfiguration(configuration); final Location.Name region = locationFeature.getLocation(container); if(Location.unknown.equals(region)) { builder.withRegion(Regions.DEFAULT_REGION); } else { builder.withRegion(region.getIdentifier()); } return builder.build(); }
protected boolean isUserWritable(final Path file) { final MantaAccountHomeInfo account = new MantaAccountHomeInfo(host.getCredentials().getUsername(), host.getDefaultPath()); return file.equals(account.getAccountPublicRoot()) || file.equals(account.getAccountPrivateRoot()) || file.isChild(account.getAccountPublicRoot()) || file.isChild(account.getAccountPrivateRoot()); }
private <T> T authenticated(final Authenticated<T> run, final LoginCallback prompt) throws BackgroundException { final LoginOptions options = new LoginOptions(bookmark.getProtocol()); try { final LoginService login = new KeychainLoginService(PasswordStoreFactory.get()); login.validate(bookmark, LocaleFactory.localizedString("AWS Identity and Access Management", "S3"), prompt, options); return run.call(); } catch(LoginFailureException failure) { bookmark.setCredentials(prompt.prompt(bookmark, bookmark.getCredentials().getUsername(), LocaleFactory.localizedString("Login failed", "Credentials"), failure.getMessage(), options)); return this.authenticated(run, prompt); } }
public MantaSession(final Host host, final X509TrustManager trust, final X509KeyManager key) { super(host, new ThreadLocalHostnameDelegatingTrustManager(new DisabledX509TrustManager(), host.getHostname()), key); config = new AuthAwareConfigContext(new ChainedConfigContext( new DefaultsConfigContext(), new StandardConfigContext() .setNoAuth(true) .setMantaKeyPath(null) .setHttpsProtocols(PreferencesFactory.get().getProperty("connection.ssl.protocols")) .setDisableNativeSignatures(true) .setMantaUser(host.getCredentials().getUsername()) .setMantaURL(String.format("%s://%s", host.getProtocol().getScheme().name(), host.getHostname())) )); }