@Test(expected = LoginFailureException.class) @Ignore public void testTemporaryAccessToken() throws Exception { final ProtocolFactory factory = new ProtocolFactory(new HashSet<>(Collections.singleton(new S3Protocol()))); final Profile profile = new ProfilePlistReader(factory).read( new Local("../profiles/S3 (Temporary Credentials).cyberduckprofile")); assertTrue(profile.validate(new Credentials(), new LoginOptions(profile))); final Host host = new Host(profile); final S3Session s = new S3Session(host); s.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback()); try { s.login(Proxy.DIRECT, new DisabledLoginCallback(), new DisabledCancelCallback()); } catch(LoginFailureException e) { assertEquals(ConnectionTimeoutException.class, e.getCause().getClass()); throw e; } }
@Override public void login(final Proxy proxy, final LoginCallback prompt, final CancelCallback cancel) throws BackgroundException { if(Scheme.isURL(host.getProtocol().getContext())) { try { final Credentials temporary = new AWSSessionCredentialsRetriever(trust, key, this, host.getProtocol().getContext()).get(); client.setProviderCredentials(new AWSSessionCredentials(temporary.getUsername(), temporary.getPassword(), temporary.getToken())); } catch(ConnectionTimeoutException | ConnectionRefusedException | ResolveFailedException | NotfoundException | InteroperabilityException e) { log.warn(String.format("Failure to retrieve session credentials from . %s", e.getMessage())); throw new LoginFailureException(e.getDetail(false), e); } } else { final Credentials credentials; if(isAwsHostname(host.getHostname())) { credentials = new STSCredentialsConfigurator( new ThreadLocalHostnameDelegatingTrustManager(trust, host.getHostname()), key, prompt).configure(host); } else { credentials = host.getCredentials(); } if(StringUtils.isNotBlank(credentials.getToken())) { client.setProviderCredentials(credentials.isAnonymousLogin() ? null : new AWSSessionCredentials(credentials.getUsername(), credentials.getPassword(), credentials.getToken())); } else { client.setProviderCredentials(credentials.isAnonymousLogin() ? null : new AWSCredentials(credentials.getUsername(), credentials.getPassword())); } } if(host.getCredentials().isPassed()) { log.warn(String.format("Skip verifying credentials with previous successful authentication event for %s", this)); return; } try { this.getFeature(ListService.class).list(new S3HomeFinderService(this).find(), new DisabledListProgressListener() { @Override public void chunk(final Path parent, final AttributedList<Path> list) throws ListCanceledException { throw new ListCanceledException(list); } }); } catch(ListCanceledException e) { } }
S3Session extends HttpSession<RequestEntityRestStorageService> { @Override public void login(final Proxy proxy, final LoginCallback prompt, final CancelCallback cancel) throws BackgroundException { if(Scheme.isURL(host.getProtocol().getContext())) { try { final Credentials temporary = new AWSSessionCredentialsRetriever(trust, key, this, host.getProtocol().getContext()).get(); client.setProviderCredentials(new AWSSessionCredentials(temporary.getUsername(), temporary.getPassword(), temporary.getToken())); } catch(ConnectionTimeoutException | ConnectionRefusedException | ResolveFailedException | NotfoundException | InteroperabilityException e) { log.warn(String.format("Failure to retrieve session credentials from . %s", e.getMessage())); throw new LoginFailureException(e.getDetail(false), e); } } else { final Credentials credentials; if(isAwsHostname(host.getHostname())) { credentials = new STSCredentialsConfigurator( new ThreadLocalHostnameDelegatingTrustManager(trust, host.getHostname()), key, prompt).configure(host); } else { credentials = host.getCredentials(); } if(StringUtils.isNotBlank(credentials.getToken())) { client.setProviderCredentials(credentials.isAnonymousLogin() ? null : new AWSSessionCredentials(credentials.getUsername(), credentials.getPassword(), credentials.getToken())); } else { client.setProviderCredentials(credentials.isAnonymousLogin() ? null : new AWSCredentials(credentials.getUsername(), credentials.getPassword())); } } if(host.getCredentials().isPassed()) { log.warn(String.format("Skip verifying credentials with previous successful authentication event for %s", this)); return; } try { this.getFeature(ListService.class).list(new S3HomeFinderService(this).find(), new DisabledListProgressListener() { @Override public void chunk(final Path parent, final AttributedList<Path> list) throws ListCanceledException { throw new ListCanceledException(list); } }); } catch(ListCanceledException e) { } } }
S3Session extends HttpSession<RequestEntityRestStorageService> { @Override public void login(final Proxy proxy, final LoginCallback prompt, final CancelCallback cancel) throws BackgroundException { if(Scheme.isURL(host.getProtocol().getContext())) { try { final Credentials temporary = new AWSSessionCredentialsRetriever(trust, key, this, host.getProtocol().getContext()).get(); client.setProviderCredentials(new AWSSessionCredentials(temporary.getUsername(), temporary.getPassword(), temporary.getToken())); } catch(ConnectionTimeoutException | ConnectionRefusedException | ResolveFailedException | NotfoundException | InteroperabilityException e) { log.warn(String.format("Failure to retrieve session credentials from . %s", e.getMessage())); throw new LoginFailureException(e.getDetail(false), e); } } else { final Credentials credentials; if(isAwsHostname(host.getHostname())) { credentials = new STSCredentialsConfigurator( new ThreadLocalHostnameDelegatingTrustManager(trust, host.getHostname()), key, prompt).configure(host); } else { credentials = host.getCredentials(); } if(StringUtils.isNotBlank(credentials.getToken())) { client.setProviderCredentials(credentials.isAnonymousLogin() ? null : new AWSSessionCredentials(credentials.getUsername(), credentials.getPassword(), credentials.getToken())); } else { client.setProviderCredentials(credentials.isAnonymousLogin() ? null : new AWSCredentials(credentials.getUsername(), credentials.getPassword())); } } if(host.getCredentials().isPassed()) { log.warn(String.format("Skip verifying credentials with previous successful authentication event for %s", this)); return; } try { this.getFeature(ListService.class).list(new S3HomeFinderService(this).find(), new DisabledListProgressListener() { @Override public void chunk(final Path parent, final AttributedList<Path> list) throws ListCanceledException { throw new ListCanceledException(list); } }); } catch(ListCanceledException e) { } } S3Session(final Host host);  S3Session(final Host host, final X509TrustManager trust, final X509KeyManager key); }
S3Session extends HttpSession<RequestEntityRestStorageService> { @Override public void login(final Proxy proxy, final LoginCallback prompt, final CancelCallback cancel) throws BackgroundException { if(Scheme.isURL(host.getProtocol().getContext())) { try { final Credentials temporary = new AWSSessionCredentialsRetriever(trust, key, this, host.getProtocol().getContext()).get(); client.setProviderCredentials(new AWSSessionCredentials(temporary.getUsername(), temporary.getPassword(), temporary.getToken())); } catch(ConnectionTimeoutException | ConnectionRefusedException | ResolveFailedException | NotfoundException | InteroperabilityException e) { log.warn(String.format("Failure to retrieve session credentials from . %s", e.getMessage())); throw new LoginFailureException(e.getDetail(false), e); } } else { final Credentials credentials; if(isAwsHostname(host.getHostname())) { credentials = new STSCredentialsConfigurator( new ThreadLocalHostnameDelegatingTrustManager(trust, host.getHostname()), key, prompt).configure(host); } else { credentials = host.getCredentials(); } if(StringUtils.isNotBlank(credentials.getToken())) { client.setProviderCredentials(credentials.isAnonymousLogin() ? null : new AWSSessionCredentials(credentials.getUsername(), credentials.getPassword(), credentials.getToken())); } else { client.setProviderCredentials(credentials.isAnonymousLogin() ? null : new AWSCredentials(credentials.getUsername(), credentials.getPassword())); } } if(host.getCredentials().isPassed()) { log.warn(String.format("Skip verifying credentials with previous successful authentication event for %s", this)); return; } try { this.getFeature(ListService.class).list(new S3HomeFinderService(this).find(), new DisabledListProgressListener() { @Override public void chunk(final Path parent, final AttributedList<Path> list) throws ListCanceledException { throw new ListCanceledException(list); } }); } catch(ListCanceledException e) { } } S3Session(final Host host);  S3Session(final Host host, final X509TrustManager trust, final X509KeyManager key); S3Protocol.AuthenticationHeaderSignatureVersion getSignatureVersion(); void setSignatureVersion(final S3Protocol.AuthenticationHeaderSignatureVersion authenticationHeaderSignatureVersion); @Override RequestEntityRestStorageService connect(final Proxy proxy, final HostKeyCallback hostkey, final LoginCallback prompt); @Override void login(final Proxy proxy, final LoginCallback prompt, final CancelCallback cancel); static boolean isAwsHostname(final String hostname); @Override @SuppressWarnings("unchecked") T _getFeature(final Class<T> type); }
S3Session extends HttpSession<RequestEntityRestStorageService> { @Override public void login(final Proxy proxy, final LoginCallback prompt, final CancelCallback cancel) throws BackgroundException { if(Scheme.isURL(host.getProtocol().getContext())) { try { final Credentials temporary = new AWSSessionCredentialsRetriever(trust, key, this, host.getProtocol().getContext()).get(); client.setProviderCredentials(new AWSSessionCredentials(temporary.getUsername(), temporary.getPassword(), temporary.getToken())); } catch(ConnectionTimeoutException | ConnectionRefusedException | ResolveFailedException | NotfoundException | InteroperabilityException e) { log.warn(String.format("Failure to retrieve session credentials from . %s", e.getMessage())); throw new LoginFailureException(e.getDetail(false), e); } } else { final Credentials credentials; if(isAwsHostname(host.getHostname())) { credentials = new STSCredentialsConfigurator( new ThreadLocalHostnameDelegatingTrustManager(trust, host.getHostname()), key, prompt).configure(host); } else { credentials = host.getCredentials(); } if(StringUtils.isNotBlank(credentials.getToken())) { client.setProviderCredentials(credentials.isAnonymousLogin() ? null : new AWSSessionCredentials(credentials.getUsername(), credentials.getPassword(), credentials.getToken())); } else { client.setProviderCredentials(credentials.isAnonymousLogin() ? null : new AWSCredentials(credentials.getUsername(), credentials.getPassword())); } } if(host.getCredentials().isPassed()) { log.warn(String.format("Skip verifying credentials with previous successful authentication event for %s", this)); return; } try { this.getFeature(ListService.class).list(new S3HomeFinderService(this).find(), new DisabledListProgressListener() { @Override public void chunk(final Path parent, final AttributedList<Path> list) throws ListCanceledException { throw new ListCanceledException(list); } }); } catch(ListCanceledException e) { } } S3Session(final Host host);  S3Session(final Host host, final X509TrustManager trust, final X509KeyManager key); S3Protocol.AuthenticationHeaderSignatureVersion getSignatureVersion(); void setSignatureVersion(final S3Protocol.AuthenticationHeaderSignatureVersion authenticationHeaderSignatureVersion); @Override RequestEntityRestStorageService connect(final Proxy proxy, final HostKeyCallback hostkey, final LoginCallback prompt); @Override void login(final Proxy proxy, final LoginCallback prompt, final CancelCallback cancel); static boolean isAwsHostname(final String hostname); @Override @SuppressWarnings("unchecked") T _getFeature(final Class<T> type);  }