Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support to read S3 credentials from .aws/credentials and environm…
…ent variables `AWS_ACCESS_KEY_ID` and `AWS_SECRET_KEY`.
- Loading branch information
Showing
29 changed files
with
310 additions
and
81 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
core/dylib/src/main/java/ch/cyberduck/core/local/FinderIconService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package ch.cyberduck.core.local; | ||
|
||
/* | ||
* Copyright (c) 2002-2017 iterate GmbH. All rights reserved. | ||
* https://cyberduck.io/ | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
*/ | ||
|
||
import ch.cyberduck.core.Local; | ||
import ch.cyberduck.core.transfer.TransferStatus; | ||
|
||
public class FinderIconService implements IconService { | ||
|
||
private final IconService[] delegates; | ||
|
||
public FinderIconService() { | ||
this(new WorkspaceIconService(), new FoundationProgressIconService()); | ||
} | ||
|
||
public FinderIconService(final IconService... delegates) { | ||
this.delegates = delegates; | ||
} | ||
|
||
@Override | ||
public boolean set(final Local file, final String image) { | ||
for(IconService delegate : delegates) { | ||
delegate.set(file, image); | ||
} | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean set(final Local file, final TransferStatus progress) { | ||
for(IconService delegate : delegates) { | ||
delegate.set(file, progress); | ||
} | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean remove(final Local file) { | ||
for(IconService delegate : delegates) { | ||
delegate.remove(file); | ||
} | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
core/src/main/java/ch/cyberduck/core/DisabledCredentialsConfigurator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package ch.cyberduck.core; | ||
|
||
/* | ||
* Copyright (c) 2002-2017 iterate GmbH. All rights reserved. | ||
* https://cyberduck.io/ | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
*/ | ||
|
||
public final class DisabledCredentialsConfigurator implements CredentialsConfigurator { | ||
|
||
@Override | ||
public Credentials configure(final Host host) { | ||
return host.getCredentials(); | ||
} | ||
|
||
@Override | ||
public void reload() { | ||
// | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
core/src/main/java/ch/cyberduck/core/DisabledHostnameConfigurator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package ch.cyberduck.core; | ||
|
||
/* | ||
* Copyright (c) 2002-2017 iterate GmbH. All rights reserved. | ||
* https://cyberduck.io/ | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
*/ | ||
|
||
public final class DisabledHostnameConfigurator implements HostnameConfigurator { | ||
|
||
@Override | ||
public String getHostname(String alias) { | ||
return alias; | ||
} | ||
|
||
@Override | ||
public int getPort(final String alias) { | ||
return -1; | ||
} | ||
|
||
@Override | ||
public void reload() { | ||
// | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
s3/src/main/java/ch/cyberduck/core/auth/AWSCredentialsConfigurator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package ch.cyberduck.core.auth; | ||
|
||
/* | ||
* Copyright (c) 2002-2017 iterate GmbH. All rights reserved. | ||
* https://cyberduck.io/ | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
*/ | ||
|
||
import ch.cyberduck.core.Credentials; | ||
import ch.cyberduck.core.CredentialsConfigurator; | ||
import ch.cyberduck.core.Host; | ||
import ch.cyberduck.core.LoginOptions; | ||
|
||
import org.apache.log4j.Logger; | ||
|
||
import com.amazonaws.SdkClientException; | ||
import com.amazonaws.auth.AWSCredentials; | ||
import com.amazonaws.auth.AWSCredentialsProvider; | ||
|
||
public class AWSCredentialsConfigurator implements CredentialsConfigurator { | ||
private static final Logger log = Logger.getLogger(AWSCredentialsConfigurator.class); | ||
|
||
private final AWSCredentialsProvider[] providers; | ||
|
||
public AWSCredentialsConfigurator(final AWSCredentialsProvider... providers) { | ||
this.providers = providers; | ||
} | ||
|
||
@Override | ||
public Credentials configure(final Host host) { | ||
final Credentials credentials = host.getCredentials(); | ||
if(!credentials.validate(host.getProtocol(), new LoginOptions(host.getProtocol()))) { | ||
for(AWSCredentialsProvider provider : providers) { | ||
try { | ||
final AWSCredentials c = provider.getCredentials(); | ||
credentials.setUsername(c.getAWSAccessKeyId()); | ||
credentials.setPassword(c.getAWSSecretKey()); | ||
break; | ||
} | ||
catch(SdkClientException e) { | ||
log.debug(String.format("Ignore failure loading credentials from provider %s", provider)); | ||
// Continue searching with next provider | ||
} | ||
} | ||
} | ||
return credentials; | ||
} | ||
|
||
@Override | ||
public void reload() { | ||
for(AWSCredentialsProvider provider : providers) { | ||
provider.refresh(); | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
s3/src/main/java/ch/cyberduck/core/auth/AWSEnviromentCredentialsConfigurator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package ch.cyberduck.core.auth; | ||
|
||
/* | ||
* Copyright (c) 2002-2017 iterate GmbH. All rights reserved. | ||
* https://cyberduck.io/ | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
*/ | ||
|
||
import com.amazonaws.auth.EnvironmentVariableCredentialsProvider; | ||
|
||
public class AWSEnviromentCredentialsConfigurator extends AWSCredentialsConfigurator { | ||
|
||
public AWSEnviromentCredentialsConfigurator() { | ||
super(new EnvironmentVariableCredentialsProvider()); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
s3/src/main/java/ch/cyberduck/core/auth/AWSProfileCredentialsConfigurator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package ch.cyberduck.core.auth; | ||
|
||
/* | ||
* Copyright (c) 2002-2017 iterate GmbH. All rights reserved. | ||
* https://cyberduck.io/ | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
*/ | ||
|
||
import com.amazonaws.auth.profile.ProfileCredentialsProvider; | ||
|
||
public class AWSProfileCredentialsConfigurator extends AWSCredentialsConfigurator { | ||
|
||
public AWSProfileCredentialsConfigurator() { | ||
super(new ProfileCredentialsProvider()); | ||
} | ||
} |
Oops, something went wrong.