Skip to content

Commit

Permalink
Add option to override username and password requirements in profile.
Browse files Browse the repository at this point in the history
Former-commit-id: 5ad373691a02426fb3e854a081aa194d8a2e0ccd
  • Loading branch information
dkocher committed Feb 26, 2015
1 parent 202a75e commit 49f5f32
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 1 deletion.
4 changes: 4 additions & 0 deletions profiles/S3 (Temporary Credentials).cyberduckprofile
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,9 @@
<string>S3 (Amazon Simple Storage Service)</string>
<key>Context</key>
<string>http://169.254.169.254/latest/meta-data/iam/security-credentials/s3access</string>
<key>Username Configurable</key>
<false/>
<key>Password Configurable</key>
<false/>
</dict>
</plist>
10 changes: 10 additions & 0 deletions source/ch/cyberduck/core/AbstractProtocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ public boolean isAnonymousConfigurable() {
return true;
}

@Override
public boolean isUsernameConfigurable() {
return true;
}

@Override
public boolean isPasswordConfigurable() {
return true;
}

@Override
public boolean isUTCTimezone() {
return true;
Expand Down
2 changes: 2 additions & 0 deletions source/ch/cyberduck/core/LoginOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ public boolean isAnonymous() {
public LoginOptions(final Protocol protocol) {
publickey = protocol.getType() == Protocol.Type.ssh;
anonymous = protocol.isAnonymousConfigurable();
user = protocol.isUsernameConfigurable();
password = protocol.isPasswordConfigurable();
}

@Override
Expand Down
16 changes: 16 additions & 0 deletions source/ch/cyberduck/core/Profile.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,22 @@ public boolean isAnonymousConfigurable() {
return parent.isAnonymousConfigurable();
}

@Override
public boolean isUsernameConfigurable() {
if(StringUtils.isBlank(this.value("Username Configurable"))) {
return parent.isUsernameConfigurable();
}
return this.bool("Username Configurable");
}

@Override
public boolean isPasswordConfigurable() {
if(StringUtils.isBlank(this.value("Password Configurable"))) {
return parent.isPasswordConfigurable();
}
return this.bool("Password Configurable");
}

@Override
public boolean isHostnameConfigurable() {
if(StringUtils.isBlank(this.value("Hostname Configurable"))) {
Expand Down
12 changes: 11 additions & 1 deletion source/ch/cyberduck/core/Protocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,20 @@ public boolean validate(final Credentials credentials, final LoginOptions option
}

/**
* @return True if anonymous logins are possible.
* @return True if anonymous login is possible.
*/
boolean isAnonymousConfigurable();

/**
* @return True if username is required
*/
boolean isUsernameConfigurable();

/**
* @return True if password is required
*/
boolean isPasswordConfigurable();

/**
* @return False if the hostname to connect is static.
*/
Expand Down
1 change: 1 addition & 0 deletions test/ch/cyberduck/core/s3/S3SessionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ public void testBucketVirtualHostStyleEucalyptusCustomDeployment() throws Except
public void testTemporaryAccessToken() throws Exception {
final Profile profile = ProfileReaderFactory.get().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(new DisabledHostKeyCallback(), new DisabledTranscriptListener());
Expand Down

0 comments on commit 49f5f32

Please sign in to comment.