Skip to content

Commit 746375b

Browse files
ajkannanaozarov
authored andcommitted
---
yaml --- r: 4777 b: refs/heads/logging-alpha c: 099ada0 h: refs/heads/master i: 4775: ca012ba
1 parent ffeaff1 commit 746375b

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ refs/heads/compute-alpha: 969cba2627f1d53d352cc4a5ffe0879dacf65e6c
1212
refs/heads/dns-alpha: 2f90e7e338349287ace33375896907af0f032ca1
1313
refs/heads/dns-alpha-batch: 17442b07867021b85d0452f5f3eda29a3413288f
1414
refs/heads/gcs-nio: 283aeaf15efdcf3621eb6859f05e55ad7764375d
15-
refs/heads/logging-alpha: 5dadf6a85a8bd65f64500b123b7b7cc352bf17de
15+
refs/heads/logging-alpha: 099ada0000cb7731d1b99f0ff1744420e18df9bb
1616
refs/tags/v0.1.0: a615317f7424ed58621b1f65d5c4d8cbbe8a6ed8
1717
refs/tags/v0.1.1: 7a7f6985fe465e9dd6a075af55493f42b4933be0
1818
refs/tags/v0.1.2: 3eb3fe866ba22487686048f45d927b8c8638ea3f

branches/logging-alpha/gcloud-java-core/src/main/java/com/google/gcloud/AuthCredentials.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.security.Signature;
3434
import java.security.SignatureException;
3535
import java.util.Collection;
36+
import java.util.Date;
3637
import java.util.Objects;
3738

3839
/**
@@ -58,6 +59,7 @@ private static class AppEngineCredentials extends GoogleCredentials
5859
private final String account;
5960
private final Method getAccessToken;
6061
private final Method getAccessTokenResult;
62+
private final Method getExpirationTime;
6163
private final Method signForApp;
6264
private final Method getSignature;
6365
private final Collection<String> scopes;
@@ -74,6 +76,7 @@ private static class AppEngineCredentials extends GoogleCredentials
7476
"com.google.appengine.api.appidentity.AppIdentityService$GetAccessTokenResult");
7577
this.getAccessTokenResult = serviceClass.getMethod("getAccessToken", Iterable.class);
7678
this.getAccessToken = tokenResultClass.getMethod("getAccessToken");
79+
this.getExpirationTime = tokenResultClass.getMethod("getExpirationTime");
7780
this.account = (String) serviceClass.getMethod("getServiceAccountName")
7881
.invoke(appIdentityService);
7982
this.signForApp = serviceClass.getMethod("signForApp", byte[].class);
@@ -90,6 +93,7 @@ private static class AppEngineCredentials extends GoogleCredentials
9093
this.appIdentityService = unscoped.appIdentityService;
9194
this.getAccessToken = unscoped.getAccessToken;
9295
this.getAccessTokenResult = unscoped.getAccessTokenResult;
96+
this.getExpirationTime = unscoped.getExpirationTime;
9397
this.account = unscoped.account;
9498
this.signForApp = unscoped.signForApp;
9599
this.getSignature = unscoped.getSignature;
@@ -107,7 +111,8 @@ public AccessToken refreshAccessToken() throws IOException {
107111
try {
108112
Object accessTokenResult = getAccessTokenResult.invoke(appIdentityService, scopes);
109113
String accessToken = (String) getAccessToken.invoke(accessTokenResult);
110-
return new AccessToken(accessToken, null);
114+
Date expirationTime = (Date) getExpirationTime.invoke(accessTokenResult);
115+
return new AccessToken(accessToken, expirationTime);
111116
} catch (Exception e) {
112117
throw new IOException("Could not get the access token.", e);
113118
}
@@ -131,7 +136,7 @@ public String account() {
131136
@Override
132137
public byte[] sign(byte[] toSign) {
133138
try {
134-
Object signingResult = signForApp.invoke(appIdentityService, (Object) toSign);
139+
Object signingResult = signForApp.invoke(appIdentityService, toSign);
135140
return (byte[]) getSignature.invoke(signingResult);
136141
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
137142
throw new SigningException("Failed to sign the provided bytes", ex);

0 commit comments

Comments
 (0)