@Override public String tooltip(Host bookmark, final BookmarkColumn column) { return new HostUrlProvider().get(bookmark); }
public RedirectException(final Host target) { super(String.format("Redirect to %s", new HostUrlProvider().withUsername(false).get(target))); this.target = target; }
@Override public Proxy find(final Host target) { if(!preferences.getBoolean("connection.proxy.enable")) { return Proxy.DIRECT; } final String route = this.findNative(provider.get(target)); if(null == route) { if(log.isInfoEnabled()) { log.info(String.format("No poxy configuration found for target %s", target)); } // Direct return Proxy.DIRECT; } final URI proxy; try { proxy = new URI(route); try { // User info is never populated. Would have to lookup in keychain but we are unaware of the username return new Proxy(Proxy.Type.valueOf(StringUtils.upperCase(proxy.getScheme())), proxy.getHost(), proxy.getPort()); } catch(IllegalArgumentException e) { log.warn(String.format("Unsupported scheme for proxy %s", proxy)); } } catch(URISyntaxException e) { log.warn(String.format("Invalid proxy configuration %s", route)); } return Proxy.DIRECT; }
@Override public void change(final Host bookmark) { urlField.setAttributedStringValue(HyperlinkAttributedStringFactory.create(new HostUrlProvider().withUsername(false).withPath(true).get(bookmark))); } });
@Override public Proxy find(final Host target) { if(!preferences.getBoolean("connection.proxy.enable")) { return Proxy.DIRECT; } for(java.net.Proxy proxy : selector.select(URI.create(provider.get(target)))) { switch(proxy.type()) { case DIRECT: { return Proxy.DIRECT; } case HTTP: { if(proxy.address() instanceof InetSocketAddress) { final InetSocketAddress address = (InetSocketAddress) proxy.address(); return new Proxy(Proxy.Type.HTTP, address.getHostName(), address.getPort()); } } case SOCKS: { if(proxy.address() instanceof InetSocketAddress) { final InetSocketAddress address = (InetSocketAddress) proxy.address(); return new Proxy(Proxy.Type.SOCKS, address.getHostName(), address.getPort()); } } } } return Proxy.DIRECT; } }
@Override public DescriptiveUrlBag toUrl(final Path file) { try { final DescriptiveUrlBag set = delegate.toUrl(file); final Path encrypt = vault.encrypt(session, file); set.add(new DescriptiveUrl(URI.create(String.format("%s%s", new HostUrlProvider().withUsername(false).get(session.getHost()), URIEncoder.encode(encrypt.getAbsolute()))), DescriptiveUrl.Type.encrypted, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Encrypted", "Cryptomator"))) ); return set; } catch(BackgroundException e) { log.warn(String.format("Failure encrypting filename. %s", e.getMessage())); return DescriptiveUrlBag.empty(); } }
/** * @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 DAVClient connect(final Proxy proxy, final HostKeyCallback key, final LoginCallback prompt) { // Always inject new pool to builder on connect because the pool is shutdown on disconnect final HttpClientBuilder pool = builder.build(proxy, this, prompt); pool.setRedirectStrategy(new DAVRedirectStrategy(redirect)); return new DAVClient(new HostUrlProvider().withUsername(false).get(host), pool); }
@Override public DescriptiveUrlBag toUrl(final Path file) { final String nodeid = file.isDirectory() ? file.attributes().getVersionId() : file.getParent().attributes().getVersionId(); if(StringUtils.isBlank(nodeid)) { return DescriptiveUrlBag.empty(); } return new DescriptiveUrlBag(Collections.singletonList( new DescriptiveUrl(URI.create(String.format("%s/#/node/%s", new HostUrlProvider().withUsername(false).get(session.getHost()), URIEncoder.encode( nodeid ))), DescriptiveUrl.Type.http, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), session.getHost().getProtocol().getScheme().toString().toUpperCase(Locale.ROOT))) )); } }
@Override public DescriptiveUrlBag toUrl(final Path file) { final DescriptiveUrlBag list = new DescriptiveUrlBag(); if(file.attributes().getLink() != null) { list.add(file.attributes().getLink()); } list.add(new DescriptiveUrl(URI.create(String.format("%s%s", new HostUrlProvider().withUsername(false).get(host), URIEncoder.encode(file.getAbsolute()))), DescriptiveUrl.Type.provider, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), host.getProtocol().getScheme().toString().toUpperCase(Locale.ROOT)))); list.addAll(new WebUrlProvider(host).toUrl(file)); return list; } }
if(options.quarantine) { quarantine.setQuarantine(local, new HostUrlProvider().withUsername(false).get(session.getHost()), provider.getUrl());
dict.setObjectForKey(BookmarkNameProvider.toString(host), "Nickname"); dict.setObjectForKey(host.getHostname(), "Hostname"); dict.setObjectForKey(new HostUrlProvider().withUsername(true).withPath(true).get(host), "URL"); final String comment = this.getSource().getComment(host); if(StringUtils.isNotBlank(comment)) {
public OAuth2RequestInterceptor(final HttpClient client, final Host host) { this(client, Scheme.isURL(host.getProtocol().getOAuthTokenUrl()) ? host.getProtocol().getOAuthTokenUrl() : new HostUrlProvider().withUsername(false).withPath(true).get( host.getProtocol().getScheme(), host.getPort(), null, host.getHostname(), host.getProtocol().getOAuthTokenUrl()), Scheme.isURL(host.getProtocol().getOAuthAuthorizationUrl()) ? host.getProtocol().getOAuthAuthorizationUrl() : new HostUrlProvider().withUsername(false).withPath(true).get( host.getProtocol().getScheme(), host.getPort(), null, host.getHostname(), host.getProtocol().getOAuthAuthorizationUrl()), host.getProtocol().getOAuthClientId(), host.getProtocol().getOAuthClientSecret(), host.getProtocol().getOAuthScopes()); }
host).withRedirectUri(Scheme.isURL(host.getProtocol().getOAuthRedirectUrl()) ? host.getProtocol().getOAuthRedirectUrl() : new HostUrlProvider().withUsername(false).withPath(true).get( host.getProtocol().getScheme(), host.getPort(), null, host.getHostname(), host.getProtocol().getOAuthRedirectUrl()) ); client.setBasePath(new HostUrlProvider().withUsername(false).withPath(true).get(host.getProtocol().getScheme(), host.getPort(), null, host.getHostname(), host.getProtocol().getContext())); client.setHttpClient(ClientBuilder.newClient(new ClientConfig()