@Override public int compare(Host o1, Host o2) { return comparator.compare(o1.getProtocol().getIdentifier(), o2.getProtocol().getIdentifier()); } });
/** * @param method Distribution method * @return Origin server hostname. This is not the same as the container for * custom origin configurations and website endpoints. <bucketname>.s3.amazonaws.com */ protected URI getOrigin(final Path container, final Distribution.Method method) { return URI.create(String.format("http://%s.%s", container.getName(), bookmark.getProtocol().getDefaultHostname())); }
@Override public void change(final Host bookmark) { protocolPopup.selectItemAtIndex(protocolPopup.indexOfItemWithRepresentedObject(String.valueOf(bookmark.getProtocol().hashCode()))); } });
@Override public void process(final HttpRequest request, final HttpContext context) { request.addHeader(HttpHeaders.AUTHORIZATION, String.format("Basic %s", Base64.encodeToString(String.format("%s:%s", host.getProtocol().getOAuthClientId(), host.getProtocol().getOAuthClientSecret()).getBytes(StandardCharsets.UTF_8), false))); } }).build(),
@Override public boolean isSupported(final Path source, final Path target) { switch(from.getHost().getProtocol().getType()) { case ftp: case irods: // Stateful return !Objects.equals(from, to); } return true; }
@Override public void change(final Host bookmark) { usernameLabel.setAttributedStringValue(NSAttributedString.attributedStringWithAttributes( StringUtils.isNotBlank(bookmark.getProtocol().getUsernamePlaceholder()) ? String.format("%s:", bookmark.getProtocol().getUsernamePlaceholder()) : StringUtils.EMPTY, TRUNCATE_TAIL_ATTRIBUTES )); } });
@Override public OAuthTokens findOAuthTokens(final Host bookmark) { final long expiry = preferences.getLong(String.format("%s.oauth.expiry", bookmark.getProtocol().getIdentifier())); final String prefix = this.getOAuthPrefix(bookmark); return new OAuthTokens(this.getPassword(bookmark.getProtocol().getScheme(), bookmark.getPort(), URI.create(bookmark.getProtocol().getOAuthTokenUrl()).getHost(), String.format("%s OAuth2 Access Token", prefix)), this.getPassword(bookmark.getProtocol().getScheme(), bookmark.getPort(), URI.create(bookmark.getProtocol().getOAuthTokenUrl()).getHost(), String.format("%s OAuth2 Refresh Token", prefix)), expiry); }
@Override protected String help() { return ProviderHelpServiceFactory.get().help(host.getProtocol()); } }
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 void change(final Host bookmark) { updateField(pathField, bookmark.getDefaultPath()); pathField.setEnabled(bookmark.getProtocol().isPathConfigurable()); } });
@Override public void change(final Host bookmark) { updateField(hostField, bookmark.getHostname()); hostField.setEnabled(bookmark.getProtocol().isHostnameConfigurable()); hostField.cell().setPlaceholderString(bookmark.getProtocol().getDefaultHostname()); } });
@Override public Client connect(final Proxy proxy, final HostKeyCallback key, final LoginCallback prompt) { authorizationService = new OAuth2RequestInterceptor(builder.build(proxy, this, prompt).build(), host.getProtocol()) .withRedirectUri(host.getProtocol().getOAuthRedirectUrl()); final HttpClientBuilder configuration = builder.build(proxy, this, prompt); configuration.addInterceptorLast(authorizationService); configuration.setServiceUnavailableRetryStrategy(new OAuth2ErrorResponseInterceptor(authorizationService)); return new Client(configuration.build()); }
@Override public void change(Host bookmark) { connectmodePopup.setEnabled(bookmark.getProtocol().getType() == Protocol.Type.ftp); if(bookmark.getProtocol().getType() == Protocol.Type.ftp) { connectmodePopup.selectItemAtIndex(connectmodePopup.indexOfItemWithRepresentedObject(bookmark.getFTPConnectMode().name())); } } });
public static SessionPool create(final Controller controller, final Cache<Path> cache, final Host bookmark, final ProgressListener listener, final Usage... usage) { return create(cache, bookmark, PasswordStoreFactory.get(), LoginCallbackFactory.get(controller), HostKeyCallbackFactory.get(controller, bookmark.getProtocol()), listener, controller, usage); }
@Override public Socket createSocket(final HttpContext context) throws IOException { return new ProxySocketFactory(host.getProtocol(), new TrustManagerHostnameCallback() { @Override public String getTarget() { return ((HttpHost) context.getAttribute(HttpCoreContext.HTTP_TARGET_HOST)).getHostName(); } }, proxy).disable(Proxy.Type.HTTP).disable(Proxy.Type.HTTPS).createSocket(); }
@Override public RequestEntityRestStorageService connect(final Proxy proxy, final HostKeyCallback key, final LoginCallback prompt) { authorizationService = new OAuth2RequestInterceptor(builder.build(proxy, this, prompt).build(), host.getProtocol()) .withRedirectUri(host.getProtocol().getOAuthRedirectUrl()); final HttpClientBuilder configuration = builder.build(proxy, this, prompt); configuration.addInterceptorLast(authorizationService); configuration.setServiceUnavailableRetryStrategy(new OAuth2ErrorResponseInterceptor(authorizationService)); return new OAuth2RequestEntityRestStorageService(this, this.configure(), configuration); }
@Override public Set<Name> getLocations() { if(StringUtils.isNotBlank(session.getHost().getRegion())) { return Collections.singleton(new S3Region(session.getHost().getRegion())); } // Only for AWS if(session.getHost().getHostname().endsWith(PreferencesFactory.get().getProperty("s3.hostname.default"))) { return session.getHost().getProtocol().getRegions(); } return Collections.emptySet(); }
/** * @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); }
private String getHostnameForContainer(final Path bucket) { if(!ServiceUtils.isBucketNameValidDNSName(containerService.getContainer(bucket).getName())) { return session.getHost().getHostname(); } if(session.getHost().getHostname().equals(session.getHost().getProtocol().getDefaultHostname())) { return String.format("%s.%s", bucket.getName(), session.getHost().getHostname()); } return session.getHost().getHostname(); } }
private void addNavigation(final Path p) { pathPopupButton.addItemWithTitle(p.getAbsolute()); pathPopupButton.lastItem().setRepresentedObject(p.getAbsolute()); if(p.isVolume()) { pathPopupButton.lastItem().setImage(IconCacheFactory.<NSImage>get().volumeIcon(pool.getHost().getProtocol(), 16)); } else { pathPopupButton.lastItem().setImage(IconCacheFactory.<NSImage>get().fileIcon(p, 16)); } }