Skip to content
Permalink
Browse files

Merge pull request #17 from jglick/RemotableGoogleCredentials.expirat…

…ion-JENKINS-50216

[JENKINS-50216] - RemotableGoogleCredentials.expiration fix
  • Loading branch information
astroilov committed May 1, 2018
2 parents 62126a6 + fef8687 commit e68bbcc00395124e4b27e90b84e1edeaff33fc74
@@ -0,0 +1,2 @@
target
work
@@ -0,0 +1,2 @@
// Build the plugin using https://github.com/jenkins-infra/pipeline-library
buildPlugin(platforms: ['linux'], jenkinsVersions: [null, '2.107.2'], failFast: false)
@@ -1,5 +1,5 @@
^/\*$
^ \* Copyright 201(3|4|5) Google Inc\. All Rights Reserved\.$
^ \* Copyright 201(3|4|5|6|7|8) .*$
^ \*$
^ \* Licensed under the Apache License, Version 2\.0 \(the \"License\"\);$
^ \* you may not use this file except in compliance with the License\.$
65 pom.xml
@@ -18,7 +18,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>2.5</version>
<version>3.8</version>
</parent>

<!--
@@ -32,7 +32,7 @@
<description>
This plugin implements the OAuth Credentials interfaces to surface Google Service Account credentials to Jenkins.
</description>
<url>http://wiki.jenkins-ci.org/display/JENKINS/Google+OAuth+Plugin</url>
<url>https://wiki.jenkins.io/display/JENKINS/Google+OAuth+Plugin</url>
<licenses>
<license>
<name>The Apache V2 License</name>
@@ -58,37 +58,19 @@
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.jenkins-ci.tools</groupId>
<artifactId>maven-hpi-plugin</artifactId>
<version>1.96</version>
<extensions>true</extensions>
<configuration>
<disabledTestInjection>true</disabledTestInjection>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
@@ -109,24 +91,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<effort>Max</effort>
<threshold>Medium</threshold>
<xmlOutput>true</xmlOutput>
<excludeFilterFile>findbugs-exclude.xml</excludeFilterFile>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
@@ -160,6 +124,10 @@
<properties>
<jenkins.version>1.653</jenkins.version>
<google.api.version>1.22.0</google.api.version>
<java.level>7</java.level>
<findbugs.excludeFilterFile>findbugs-exclude.xml</findbugs.excludeFilterFile>
<findbugs.effort>Max</findbugs.effort>
<findbugs.threshold>Medium</findbugs.threshold>
</properties>

<dependencies>
@@ -197,12 +165,6 @@
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
@@ -251,6 +213,17 @@
<version>1.16.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<!-- Required to run P12ServiceAccountConfigTestUtil-dependent tests against newer Jenkins core versions.
Dependency on it does not cause issues in the baseline core even though the plugin is formally incompatible.
Should it break at some point, the core requirement can be bumped to 2.17.x.
The BC library can be also shaded if the core requirement needs to be retained.
-->
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>bouncycastle-api</artifactId>
<version>2.16.2</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
@@ -72,7 +72,8 @@ public RemotableGoogleCredentials(
}
this.accessToken = checkNotNull(credential.getAccessToken());
this.expiration = new DateTime().plusSeconds(
checkNotNull(credential.getExpiresInSeconds()).intValue());
checkNotNull(credential.getExpiresInSeconds()).intValue()).
getMillis();
}

/**
@@ -113,7 +114,7 @@ public Credential getGoogleCredential(
// TODO(mattmoor): Consider throwing an exception if the access token
// has expired.
long lifetimeSeconds =
(expiration.getMillis() - new DateTime().getMillis()) / 1000;
(expiration - new DateTime().getMillis()) / 1000;

return new GoogleCredential.Builder()
.setTransport(getModule().getHttpTransport())
@@ -136,7 +137,7 @@ public Credential getGoogleCredential(
/**
* The time at which the accessToken will expire.
*/
private final DateTime expiration;
private final long expiration;

/**
* The minimum duration to allow for an access token before attempting to
@@ -13,6 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define"
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<f:entry title="${%Project Name}" field="projectId">
@@ -13,6 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:f="/lib/form">
<f:entry title="${%Project Name}" field="projectId">
<f:textbox />
@@ -1,3 +1,4 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core"
xmlns:f="/lib/form">
<f:entry field="jsonKeyFile"
@@ -1,3 +1,4 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core"
xmlns:f="/lib/form">
<f:entry field="emailAddress"

0 comments on commit e68bbcc

Please sign in to comment.