|
31 | 31 | import static java.nio.charset.StandardCharsets.UTF_8; |
32 | 32 |
|
33 | 33 | import com.google.api.services.storage.model.StorageObject; |
34 | | -import com.google.auth.oauth2.GoogleCredentials; |
35 | 34 | import com.google.auth.oauth2.ServiceAccountCredentials; |
36 | 35 | import com.google.common.base.Function; |
37 | 36 | import com.google.common.base.Functions; |
|
43 | 42 | import com.google.common.hash.Hashing; |
44 | 43 | import com.google.common.io.BaseEncoding; |
45 | 44 | import com.google.common.primitives.Ints; |
46 | | -import com.google.gcloud.AuthCredentials; |
47 | 45 | import com.google.gcloud.AuthCredentials.ServiceAccountAuthCredentials; |
48 | 46 | import com.google.gcloud.BaseService; |
49 | 47 | import com.google.gcloud.ExceptionHandler; |
@@ -562,18 +560,16 @@ public URL signUrl(BlobInfo blobInfo, long duration, TimeUnit unit, SignUrlOptio |
562 | 560 | for (SignUrlOption option : options) { |
563 | 561 | optionMap.put(option.option(), option.value()); |
564 | 562 | } |
565 | | - ServiceAccountAuthCredentials serviceAccountAuthCred = |
| 563 | + ServiceAccountAuthCredentials authCred = |
566 | 564 | (ServiceAccountAuthCredentials) optionMap.get(SignUrlOption.Option.SERVICE_ACCOUNT_CRED); |
567 | | - ServiceAccountCredentials cred = (ServiceAccountCredentials) (serviceAccountAuthCred != null |
568 | | - ? serviceAccountAuthCred.credentials() : null); |
569 | | - if (serviceAccountAuthCred == null) { |
570 | | - AuthCredentials authCred = this.options().authCredentials(); |
571 | | - GoogleCredentials serviceCred = |
572 | | - authCred != null ? authCred.credentials() : null; |
| 565 | + ServiceAccountCredentials cred = |
| 566 | + (ServiceAccountCredentials) (authCred != null ? authCred.credentials() : null); |
| 567 | + if (authCred == null) { |
573 | 568 | checkArgument( |
574 | | - serviceCred instanceof ServiceAccountCredentials, |
| 569 | + this.options().authCredentials() != null |
| 570 | + && this.options().authCredentials().credentials() instanceof ServiceAccountCredentials, |
575 | 571 | "Signing key was not provided and could not be derived"); |
576 | | - cred = (ServiceAccountCredentials) serviceCred; |
| 572 | + cred = (ServiceAccountCredentials) this.options().authCredentials().credentials(); |
577 | 573 | } |
578 | 574 | // construct signature - see https://cloud.google.com/storage/docs/access-control#Signed-URLs |
579 | 575 | StringBuilder stBuilder = new StringBuilder(); |
|
0 commit comments