@Test public void testProviderUriRoot() { final S3Session session = new S3Session(new Host(new S3Protocol(), new S3Protocol().getDefaultHostname())); final Iterator<DescriptiveUrl> provider = new S3UrlProvider(session).toUrl(new Path("/test-us-east-1-cyberduck", EnumSet.of(Path.Type.directory))).filter(DescriptiveUrl.Type.provider).iterator(); assertEquals("https: assertEquals("s3: }
@Override public DescriptiveUrlBag toUrl(final Path file) { final DescriptiveUrlBag list = new DescriptiveUrlBag(); if(file.isFile()) { list.add(this.toUrl(file, session.getHost().getProtocol().getScheme(), session.getHost().getPort())); list.add(this.toUrl(file, Scheme.http, 80)); if(!session.getHost().getCredentials().isAnonymousLogin()) { list.add(this.sign(file, (int) TimeUnit.HOURS.toSeconds(1))); list.add(this.sign(file, (int) TimeUnit.SECONDS.toSeconds(PreferencesFactory.get().getInteger("s3.url.expire.seconds")))); list.add(this.sign(file, (int) TimeUnit.DAYS.toSeconds(7))); switch(session.getSignatureVersion()) { case AWS2: list.add(this.sign(file, (int) TimeUnit.DAYS.toSeconds(30))); list.add(this.sign(file, (int) TimeUnit.DAYS.toSeconds(365))); break; case AWS4HMACSHA256: break; } } list.add(new DescriptiveUrl(URI.create(new S3TorrentUrlProvider(session.getHost()).create( containerService.getContainer(file).getName(), containerService.getKey(file))), DescriptiveUrl.Type.torrent, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Torrent")))); } list.addAll(new DefaultUrlProvider(session.getHost()).toUrl(file)); if(!file.isRoot()) { list.add(new DescriptiveUrl(URI.create(String.format("s3: containerService.getContainer(file).getName(), containerService.isContainer(file) ? "/" : String.format("/%s", URIEncoder.encode(containerService.getKey(file))))), DescriptiveUrl.Type.provider, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), "S3"))); } return list; }
S3UrlProvider implements UrlProvider { @Override public DescriptiveUrlBag toUrl(final Path file) { final DescriptiveUrlBag list = new DescriptiveUrlBag(); if(file.isFile()) { list.add(this.toUrl(file, session.getHost().getProtocol().getScheme(), session.getHost().getPort())); list.add(this.toUrl(file, Scheme.http, 80)); if(!session.getHost().getCredentials().isAnonymousLogin()) { list.add(this.sign(file, (int) TimeUnit.HOURS.toSeconds(1))); list.add(this.sign(file, (int) TimeUnit.SECONDS.toSeconds(PreferencesFactory.get().getInteger("s3.url.expire.seconds")))); list.add(this.sign(file, (int) TimeUnit.DAYS.toSeconds(7))); switch(session.getSignatureVersion()) { case AWS2: list.add(this.sign(file, (int) TimeUnit.DAYS.toSeconds(30))); list.add(this.sign(file, (int) TimeUnit.DAYS.toSeconds(365))); break; case AWS4HMACSHA256: break; } } list.add(new DescriptiveUrl(URI.create(new S3TorrentUrlProvider(session.getHost()).create( containerService.getContainer(file).getName(), containerService.getKey(file))), DescriptiveUrl.Type.torrent, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Torrent")))); } list.addAll(new DefaultUrlProvider(session.getHost()).toUrl(file)); if(!file.isRoot()) { list.add(new DescriptiveUrl(URI.create(String.format("s3: containerService.getContainer(file).getName(), containerService.isContainer(file) ? "/" : String.format("/%s", URIEncoder.encode(containerService.getKey(file))))), DescriptiveUrl.Type.provider, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), "S3"))); } return list; } }
S3UrlProvider implements UrlProvider { @Override public DescriptiveUrlBag toUrl(final Path file) { final DescriptiveUrlBag list = new DescriptiveUrlBag(); if(file.isFile()) { list.add(this.toUrl(file, session.getHost().getProtocol().getScheme(), session.getHost().getPort())); list.add(this.toUrl(file, Scheme.http, 80)); if(!session.getHost().getCredentials().isAnonymousLogin()) { list.add(this.sign(file, (int) TimeUnit.HOURS.toSeconds(1))); list.add(this.sign(file, (int) TimeUnit.SECONDS.toSeconds(PreferencesFactory.get().getInteger("s3.url.expire.seconds")))); list.add(this.sign(file, (int) TimeUnit.DAYS.toSeconds(7))); switch(session.getSignatureVersion()) { case AWS2: list.add(this.sign(file, (int) TimeUnit.DAYS.toSeconds(30))); list.add(this.sign(file, (int) TimeUnit.DAYS.toSeconds(365))); break; case AWS4HMACSHA256: break; } } list.add(new DescriptiveUrl(URI.create(new S3TorrentUrlProvider(session.getHost()).create( containerService.getContainer(file).getName(), containerService.getKey(file))), DescriptiveUrl.Type.torrent, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Torrent")))); } list.addAll(new DefaultUrlProvider(session.getHost()).toUrl(file)); if(!file.isRoot()) { list.add(new DescriptiveUrl(URI.create(String.format("s3: containerService.getContainer(file).getName(), containerService.isContainer(file) ? "/" : String.format("/%s", URIEncoder.encode(containerService.getKey(file))))), DescriptiveUrl.Type.provider, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), "S3"))); } return list; } S3UrlProvider(final S3Session session);  S3UrlProvider(final S3Session session, final HostPasswordStore store); }
S3UrlProvider implements UrlProvider { @Override public DescriptiveUrlBag toUrl(final Path file) { final DescriptiveUrlBag list = new DescriptiveUrlBag(); if(file.isFile()) { list.add(this.toUrl(file, session.getHost().getProtocol().getScheme(), session.getHost().getPort())); list.add(this.toUrl(file, Scheme.http, 80)); if(!session.getHost().getCredentials().isAnonymousLogin()) { list.add(this.sign(file, (int) TimeUnit.HOURS.toSeconds(1))); list.add(this.sign(file, (int) TimeUnit.SECONDS.toSeconds(PreferencesFactory.get().getInteger("s3.url.expire.seconds")))); list.add(this.sign(file, (int) TimeUnit.DAYS.toSeconds(7))); switch(session.getSignatureVersion()) { case AWS2: list.add(this.sign(file, (int) TimeUnit.DAYS.toSeconds(30))); list.add(this.sign(file, (int) TimeUnit.DAYS.toSeconds(365))); break; case AWS4HMACSHA256: break; } } list.add(new DescriptiveUrl(URI.create(new S3TorrentUrlProvider(session.getHost()).create( containerService.getContainer(file).getName(), containerService.getKey(file))), DescriptiveUrl.Type.torrent, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Torrent")))); } list.addAll(new DefaultUrlProvider(session.getHost()).toUrl(file)); if(!file.isRoot()) { list.add(new DescriptiveUrl(URI.create(String.format("s3: containerService.getContainer(file).getName(), containerService.isContainer(file) ? "/" : String.format("/%s", URIEncoder.encode(containerService.getKey(file))))), DescriptiveUrl.Type.provider, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), "S3"))); } return list; } S3UrlProvider(final S3Session session);  S3UrlProvider(final S3Session session, final HostPasswordStore store); @Override DescriptiveUrlBag toUrl(final Path file); }
S3UrlProvider implements UrlProvider { @Override public DescriptiveUrlBag toUrl(final Path file) { final DescriptiveUrlBag list = new DescriptiveUrlBag(); if(file.isFile()) { list.add(this.toUrl(file, session.getHost().getProtocol().getScheme(), session.getHost().getPort())); list.add(this.toUrl(file, Scheme.http, 80)); if(!session.getHost().getCredentials().isAnonymousLogin()) { list.add(this.sign(file, (int) TimeUnit.HOURS.toSeconds(1))); list.add(this.sign(file, (int) TimeUnit.SECONDS.toSeconds(PreferencesFactory.get().getInteger("s3.url.expire.seconds")))); list.add(this.sign(file, (int) TimeUnit.DAYS.toSeconds(7))); switch(session.getSignatureVersion()) { case AWS2: list.add(this.sign(file, (int) TimeUnit.DAYS.toSeconds(30))); list.add(this.sign(file, (int) TimeUnit.DAYS.toSeconds(365))); break; case AWS4HMACSHA256: break; } } list.add(new DescriptiveUrl(URI.create(new S3TorrentUrlProvider(session.getHost()).create( containerService.getContainer(file).getName(), containerService.getKey(file))), DescriptiveUrl.Type.torrent, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Torrent")))); } list.addAll(new DefaultUrlProvider(session.getHost()).toUrl(file)); if(!file.isRoot()) { list.add(new DescriptiveUrl(URI.create(String.format("s3: containerService.getContainer(file).getName(), containerService.isContainer(file) ? "/" : String.format("/%s", URIEncoder.encode(containerService.getKey(file))))), DescriptiveUrl.Type.provider, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), "S3"))); } return list; } S3UrlProvider(final S3Session session);  S3UrlProvider(final S3Session session, final HostPasswordStore store); @Override DescriptiveUrlBag toUrl(final Path file);  }