File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
main/java/ch/cyberduck/core/s3
test/java/ch/cyberduck/core/s3 Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 1818 */
1919
2020import ch .cyberduck .core .AbstractProtocol ;
21+ import ch .cyberduck .core .Credentials ;
2122import ch .cyberduck .core .CredentialsConfigurator ;
2223import ch .cyberduck .core .DirectoryDelimiterPathContainerService ;
2324import ch .cyberduck .core .LocaleFactory ;
25+ import ch .cyberduck .core .LoginOptions ;
2426import ch .cyberduck .core .PathContainerService ;
2527import ch .cyberduck .core .Protocol ;
2628import ch .cyberduck .core .Scheme ;
3133import ch .cyberduck .core .synchronization .DefaultComparisonService ;
3234import ch .cyberduck .core .synchronization .ETagComparisonService ;
3335
36+ import org .apache .commons .lang3 .StringUtils ;
3437import org .apache .logging .log4j .LogManager ;
3538import org .apache .logging .log4j .Logger ;
3639
@@ -117,6 +120,21 @@ public String getAuthorization() {
117120 return PreferencesFactory .get ().getProperty ("s3.signature.version" );
118121 }
119122
123+ @ Override
124+ public boolean validate (final Credentials credentials , final LoginOptions options ) {
125+ if (options .token ) {
126+ if (credentials .isTokenAuthentication ()) {
127+ if (StringUtils .isBlank (credentials .getTokens ().getAccessKeyId ())) {
128+ return false ;
129+ }
130+ if (StringUtils .isBlank (credentials .getTokens ().getSecretAccessKey ())) {
131+ return false ;
132+ }
133+ }
134+ }
135+ return super .validate (credentials , options );
136+ }
137+
120138 public enum AuthenticationHeaderSignatureVersion {
121139 AWS2 {
122140 @ Override
Original file line number Diff line number Diff line change 55import ch .cyberduck .core .Profile ;
66import ch .cyberduck .core .ProtocolFactory ;
77import ch .cyberduck .core .Scheme ;
8+ import ch .cyberduck .core .TemporaryAccessTokens ;
89import ch .cyberduck .core .TestProtocol ;
910import ch .cyberduck .core .serializer .impl .dd .ProfilePlistReader ;
1011
@@ -88,5 +89,11 @@ public void testValidateCredentials() {
8889 assertFalse (new Credentials ("user" , "" ).validate (new S3Protocol (), new LoginOptions (new S3Protocol ())));
8990 assertFalse (new Credentials ("user" , " " ).validate (new S3Protocol (), new LoginOptions (new S3Protocol ())));
9091 assertTrue (new Credentials ("user" , "key" ).validate (new S3Protocol (), new LoginOptions (new S3Protocol ())));
92+ assertFalse (new Credentials ("alias" ).setTokens (new TemporaryAccessTokens ("a" , "b" ))
93+ .validate (new S3Protocol (), new LoginOptions (new S3Protocol ())));
94+ assertTrue (new Credentials ("alias" ).setTokens (new TemporaryAccessTokens ("a" , "b" ))
95+ .validate (new S3Protocol (), new LoginOptions (new S3Protocol ()).password (false ).token (true )));
96+ assertTrue (new Credentials ("alias" ).setTokens (new TemporaryAccessTokens ("a" , "b" , "c" ))
97+ .validate (new S3Protocol (), new LoginOptions (new S3Protocol ()).password (false ).token (true )));
9198 }
9299}
You can’t perform that action at this time.
0 commit comments