@Test public void testSigned() throws Exception { final Map<Region, AccountInfo> accounts = new SwiftAccountLoader(session).operate(new DisabledPasswordCallback(), new Path(String.valueOf(Path.DELIMITER), EnumSet.of(Path.Type.volume, Path.Type.directory))); final UrlProvider provider = new SwiftUrlProvider(session, accounts); final Path container = new Path("test.cyberduck.ch", EnumSet.of(Path.Type.directory, Path.Type.volume)); container.attributes().setRegion("IAD"); final Path file = new Path(container, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); container.attributes().setRegion("IAD"); new SwiftTouchFeature(session, new SwiftRegionService(session)).touch(file, new TransferStatus()); final DescriptiveUrlBag list = provider.toUrl(file); final DescriptiveUrl signed = list.find(DescriptiveUrl.Type.signed); assertNotNull(signed); assertNotEquals(DescriptiveUrl.EMPTY, signed); assertFalse(list.filter(DescriptiveUrl.Type.signed).isEmpty()); for(DescriptiveUrl s : list.filter(DescriptiveUrl.Type.signed)) { assertNotNull(s); assertNotEquals(DescriptiveUrl.EMPTY, s); } new SwiftDeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
@Override public DescriptiveUrlBag toUrl(final Path file) { final DescriptiveUrlBag list = new DescriptiveUrlBag(); if(file.isFile()) { Region region = null; try { region = regionService.lookup(file); } catch(BackgroundException e) { log.warn(String.format("Failure looking up region for %s %s", file, e.getMessage())); } if(null == region) { list.addAll(new DefaultUrlProvider(session.getHost()).toUrl(file)); } else { 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, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), session.getHost().getProtocol().getScheme().name().toUpperCase(Locale.ROOT)) )); 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)))); } } return list; }
SwiftUrlProvider implements UrlProvider { @Override public DescriptiveUrlBag toUrl(final Path file) { final DescriptiveUrlBag list = new DescriptiveUrlBag(); if(file.isFile()) { Region region = null; try { region = regionService.lookup(file); } catch(BackgroundException e) { log.warn(String.format("Failure looking up region for %s %s", file, e.getMessage())); } if(null == region) { list.addAll(new DefaultUrlProvider(session.getHost()).toUrl(file)); } else { 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, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), session.getHost().getProtocol().getScheme().name().toUpperCase(Locale.ROOT)) )); 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)))); } } return list; } }
SwiftUrlProvider implements UrlProvider { @Override public DescriptiveUrlBag toUrl(final Path file) { final DescriptiveUrlBag list = new DescriptiveUrlBag(); if(file.isFile()) { Region region = null; try { region = regionService.lookup(file); } catch(BackgroundException e) { log.warn(String.format("Failure looking up region for %s %s", file, e.getMessage())); } if(null == region) { list.addAll(new DefaultUrlProvider(session.getHost()).toUrl(file)); } else { 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, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), session.getHost().getProtocol().getScheme().name().toUpperCase(Locale.ROOT)) )); 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)))); } } return list; } SwiftUrlProvider(final SwiftSession session);  SwiftUrlProvider(final SwiftSession session, final Map<Region, AccountInfo> accounts);  SwiftUrlProvider(final SwiftSession session, final Map<Region, AccountInfo> accounts, final SwiftRegionService regionService); }
SwiftUrlProvider implements UrlProvider { @Override public DescriptiveUrlBag toUrl(final Path file) { final DescriptiveUrlBag list = new DescriptiveUrlBag(); if(file.isFile()) { Region region = null; try { region = regionService.lookup(file); } catch(BackgroundException e) { log.warn(String.format("Failure looking up region for %s %s", file, e.getMessage())); } if(null == region) { list.addAll(new DefaultUrlProvider(session.getHost()).toUrl(file)); } else { 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, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), session.getHost().getProtocol().getScheme().name().toUpperCase(Locale.ROOT)) )); 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)))); } } return list; } SwiftUrlProvider(final SwiftSession session);  SwiftUrlProvider(final SwiftSession session, final Map<Region, AccountInfo> accounts);  SwiftUrlProvider(final SwiftSession session, final Map<Region, AccountInfo> accounts, final SwiftRegionService regionService); @Override DescriptiveUrlBag toUrl(final Path file); }
SwiftUrlProvider implements UrlProvider { @Override public DescriptiveUrlBag toUrl(final Path file) { final DescriptiveUrlBag list = new DescriptiveUrlBag(); if(file.isFile()) { Region region = null; try { region = regionService.lookup(file); } catch(BackgroundException e) { log.warn(String.format("Failure looking up region for %s %s", file, e.getMessage())); } if(null == region) { list.addAll(new DefaultUrlProvider(session.getHost()).toUrl(file)); } else { 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, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), session.getHost().getProtocol().getScheme().name().toUpperCase(Locale.ROOT)) )); 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)))); } } return list; } SwiftUrlProvider(final SwiftSession session);  SwiftUrlProvider(final SwiftSession session, final Map<Region, AccountInfo> accounts);  SwiftUrlProvider(final SwiftSession session, final Map<Region, AccountInfo> accounts, final SwiftRegionService regionService); @Override DescriptiveUrlBag toUrl(final Path file);  }