@Override public DescriptiveUrlBag toUrl(final Path file) { final DescriptiveUrlBag list = new DescriptiveUrlBag(); list.addAll(new DefaultUrlProvider(session.getHost()).toUrl(file)); if(file.isFile()) { list.add(this.createSignedUrl(file, 60 * 60)); // Default signed URL expiring in 24 hours. list.add(this.createSignedUrl(file, PreferencesFactory.get().getInteger("s3.url.expire.seconds"))); // Week list.add(this.createSignedUrl(file, 7 * 24 * 60 * 60)); // Month list.add(this.createSignedUrl(file, 7 * 24 * 60 * 60 * 4)); } return list; }
@Override public DescriptiveUrlBag toUrl(final Path file) { if(file.isVolume()) { return DescriptiveUrlBag.empty(); } final DescriptiveUrlBag list = new DescriptiveUrlBag(); if(file.isFile()) { final String download = String.format("%s/file/%s/%s", session.getClient().getDownloadUrl(), URIEncoder.encode(containerService.getContainer(file).getName()), URIEncoder.encode(containerService.getKey(file))); list.add(new DescriptiveUrl(URI.create(download), DescriptiveUrl.Type.http, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), Scheme.https.name().toUpperCase(Locale.ROOT)))); } return list; } }
/** * @param types Include * @return Copy of modified list */ public DescriptiveUrlBag filter(DescriptiveUrl.Type... types) { final DescriptiveUrlBag filtered = new DescriptiveUrlBag(this); for(Iterator<DescriptiveUrl> iter = filtered.iterator(); iter.hasNext(); ) { final DescriptiveUrl url = iter.next(); boolean remove = true; for(DescriptiveUrl.Type type : types) { if(url.getType().equals(type)) { remove = false; break; } } if(remove) { iter.remove(); } } return filtered; }
@Override public DescriptiveUrlBag toUrl(final Path file) { final DescriptiveUrlBag list = new DescriptiveUrlBag(); if(file.attributes().getLink() != null) { list.add(file.attributes().getLink()); } return list; } }
@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(); } }
@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))) )); } }
public static DescriptiveUrlBag empty() { return new DescriptiveUrlBag(); }
/** * This creates an URL that uses Cookie-based Authentication. The ACLs for the given Google user account * has to be setup first. * <p> * Google Storage lets you provide browser-based authenticated downloads to users who do not have * Google Storage accounts. To do this, you apply Google account-based ACLs to the object and then * you provide users with a URL that is scoped to the object. */ @Override public DescriptiveUrlBag toUrl(final Path file) { final DescriptiveUrlBag list = new DefaultUrlProvider(session.getHost()).toUrl(file); if(file.isFile()) { // Authenticated browser download using cookie-based Google account authentication in conjunction with ACL list.add(new DescriptiveUrl(URI.create(String.format("https://storage.cloud.google.com%s", URIEncoder.encode(file.getAbsolute()))), DescriptiveUrl.Type.authenticated, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Authenticated")))); } return list; } }
@Override public DescriptiveUrlBag toUrl(final Path file) { return DescriptiveUrlBag.empty(); } }
@Action public void openBrowserButtonClicked(final ID sender) { final DescriptiveUrlBag list; if(this.getSelectionCount() == 1) { list = pool.getFeature(UrlProvider.class).toUrl(this.getSelectedPath()); } else { list = pool.getFeature(UrlProvider.class).toUrl(this.workdir()); } if(!list.isEmpty()) { BrowserLauncherFactory.get().open(list.find(DescriptiveUrl.Type.http).getUrl()); } }
@Override public DescriptiveUrlBag toUrl(final Path file) { final DescriptiveUrlBag list = new DescriptiveUrlBag(); if(file.isFile()) { if(file.attributes().getLink() != null) { list.add(file.attributes().getLink()); } } return list; } }
@Override public DescriptiveUrlBag toUrl(final Path file) { final Path container = containerService.getContainer(file); if(distributions.containsKey(container)) { return new DistributionUrlProvider(distributions.get(container)).toUrl(file); } return DescriptiveUrlBag.empty(); }
@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; } }
@Override public DescriptiveUrlBag toUrl(final Path file) { final DescriptiveUrlBag list = new DescriptiveUrlBag(); if(file.isFile()) { try { // This link will expire in four hours and afterwards you will get 410 Gone. final String link = new DbxUserFilesRequests(session.getClient()).getTemporaryLink(file.getAbsolute()).getLink(); // Determine expiry time for URL final Calendar expiry = Calendar.getInstance(TimeZone.getTimeZone("UTC")); expiry.add(Calendar.HOUR, 4); list.add(new DescriptiveUrl(URI.create(link), DescriptiveUrl.Type.http, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Temporary", "S3")) + " (" + MessageFormat.format(LocaleFactory.localizedString("Expires {0}", "S3") + ")", UserDateFormatterFactory.get().getMediumFormat(expiry.getTimeInMillis())) )); } catch(DbxException e) { log.warn(String.format("Failure retrieving shared link. %s", e.getMessage())); } } return list; } }
if(!accounts.containsKey(region)) { log.warn(String.format("No account info for region %s available required to sign temporary URL", region)); return DescriptiveUrlBag.empty(); if(StringUtils.isBlank(info.getTempUrlKey())) { log.warn("Missing X-Account-Meta-Temp-URL-Key header value to sign temporary URL"); return DescriptiveUrlBag.empty(); containerService.getKey(file)))); final DescriptiveUrlBag list = new DescriptiveUrlBag(); for(Scheme scheme : Collections.singletonList(Scheme.valueOf(region.getStorageUrl().getScheme()))) { final int port = region.getStorageUrl().getPort(); list.add(new DescriptiveUrl(URI.create(String.format("%s://%s%s%s?temp_url_sig=%s&temp_url_expires=%d", scheme.name(), region.getStorageUrl().getHost(), port == -1 ? StringUtils.EMPTY : port == scheme.getPort() ? StringUtils.EMPTY : String.format(":%d", port),
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 DescriptiveUrlBag toUrl(final Path file) { if(distributions.containsKey(containerService.getContainer(file))) { return new DistributionUrlProvider(distributions.get(containerService.getContainer(file))).toUrl(file); } return DescriptiveUrlBag.empty(); }
@Override public DescriptiveUrlBag toUrl(final Path file) { final DescriptiveUrlBag list = new DescriptiveUrlBag(); if(file.isFile()) { Region region = null; list.addAll(new DefaultUrlProvider(session.getHost()).toUrl(file)); list.addAll(new WebUrlProvider(session.getHost()).toUrl(file)); list.add(new DescriptiveUrl( URI.create(region.getStorageUrl(containerService.getContainer(file).getName(), containerService.getKey(file)).toString()), DescriptiveUrl.Type.provider, )); list.addAll(this.sign(region, file, this.getExpiry((int) TimeUnit.HOURS.toSeconds(1)))); list.addAll(this.sign(region, file, this.getExpiry((int) TimeUnit.SECONDS.toSeconds( PreferencesFactory.get().getInteger("s3.url.expire.seconds"))))); list.addAll(this.sign(region, file, this.getExpiry((int) TimeUnit.DAYS.toSeconds(7)))); list.addAll(this.sign(region, file, this.getExpiry((int) TimeUnit.DAYS.toSeconds(30)))); list.addAll(this.sign(region, file, this.getExpiry((int) TimeUnit.DAYS.toSeconds(365))));
@Override public DescriptiveUrlBag toUrl(final Path file) { final DescriptiveUrlBag list = new DescriptiveUrlBag(); final DescriptiveUrl base = this.toUrl(); list.add(new DescriptiveUrl(URI.create(String.format("%s%s", base.getUrl(), URIEncoder.encode( PathNormalizer.normalize(PathRelativizer.relativize(PathNormalizer.normalize(host.getDefaultPath(), true), file.getAbsolute())) ))).normalize(), base.getType(), base.getHelp()) ); return list; }