Merge "Deliver expiresAt and providerId for access token"
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cfoauth/CFOAuthService.java b/src/main/java/com/googlesource/gerrit/plugins/cfoauth/CFOAuthService.java
index 4569a18..9647f1d 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cfoauth/CFOAuthService.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cfoauth/CFOAuthService.java
@@ -39,6 +39,7 @@
private static final String NAME = "Cloud Foundry UAA OAuth2";
private final UAAClient uaaClient;
+ private final String providerId;
@Inject
CFOAuthService(PluginConfigFactory cfgFactory,
@@ -56,6 +57,7 @@
cfg.getBoolean(InitOAuthConfig.VERIFIY_SIGNATURES, true),
authConfig.isUserNameToLowerCase(),
redirectUrl);
+ this.providerId = pluginName + ":" + OAuthModule.EXPORT_ID;
}
@Override
@@ -125,8 +127,9 @@
return NAME;
}
- private static OAuthToken getAsOAuthToken(AccessToken accessToken) {
- return new OAuthToken(accessToken.getValue(), null, null);
+ private OAuthToken getAsOAuthToken(AccessToken accessToken) {
+ return new OAuthToken(accessToken.getValue(), null, null,
+ accessToken.getExpiresAt() * 1000, providerId);
}
private OAuthUserInfo getAsOAuthUserInfo(AccessToken accessToken) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cfoauth/HttpModule.java b/src/main/java/com/googlesource/gerrit/plugins/cfoauth/HttpModule.java
index a8948dd..cfaaeb3 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cfoauth/HttpModule.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cfoauth/HttpModule.java
@@ -39,7 +39,7 @@
PluginConfig cfg = cfgFactory.getFromGerritConfig(pluginName);
if (cfg.getString(InitOAuthConfig.CLIENT_ID) != null) {
bind(OAuthServiceProvider.class)
- .annotatedWith(Exports.named(pluginName))
+ .annotatedWith(Exports.named(OAuthModule.EXPORT_ID))
.to(CFOAuthService.class);
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cfoauth/OAuthModule.java b/src/main/java/com/googlesource/gerrit/plugins/cfoauth/OAuthModule.java
index b1dcc8c..96735bd 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cfoauth/OAuthModule.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cfoauth/OAuthModule.java
@@ -24,6 +24,8 @@
class OAuthModule extends AbstractModule {
+ static final String EXPORT_ID = "cfoauth";
+
private final PluginConfigFactory cfgFactory;
private final String pluginName;
@@ -39,7 +41,7 @@
PluginConfig cfg = cfgFactory.getFromGerritConfig(pluginName);
if (cfg.getString(InitOAuthConfig.CLIENT_ID) != null) {
bind(OAuthLoginProvider.class)
- .annotatedWith(Exports.named(pluginName))
+ .annotatedWith(Exports.named(EXPORT_ID))
.to(CFOAuthService.class);
}
}