Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-37899] RemoteGitImpl: Take a snapshot of the credentials bef…
…ore passing them to the git client proxy

We need to snapshot of the credentials before passing them to the git client proxy so that the credentials are snapshotted before being serialised and transferred to the build agent through Jenkins remoting.
  • Loading branch information
cyrille-leclerc committed Feb 22, 2017
1 parent 7f53acf commit 0381412
Showing 1 changed file with 4 additions and 3 deletions.
@@ -1,5 +1,6 @@
package org.jenkinsci.plugins.gitclient;

import com.cloudbees.plugins.credentials.CredentialsProvider;
import com.cloudbees.plugins.credentials.common.StandardCredentials;
import com.cloudbees.plugins.credentials.common.StandardUsernameCredentials;
import edu.umd.cs.findbugs.annotations.NonNull;
Expand Down Expand Up @@ -196,17 +197,17 @@ public void clearCredentials() {

/** {@inheritDoc} */
public void addCredentials(String url, StandardCredentials credentials) {
proxy.addCredentials(url, credentials); // credentials are Serializable
proxy.addCredentials(url, CredentialsProvider.snapshot(StandardCredentials.class, credentials)); // credentials are Serializable
}

/** {@inheritDoc} */
public void setCredentials(StandardUsernameCredentials cred) {
proxy.setCredentials(cred);
proxy.setCredentials(CredentialsProvider.snapshot(StandardUsernameCredentials.class, cred)); // credentials are Serializable
}

/** {@inheritDoc} */
public void addDefaultCredentials(StandardCredentials credentials) {
proxy.addDefaultCredentials(credentials); // credentials are Serializable
proxy.addDefaultCredentials(CredentialsProvider.snapshot(StandardCredentials.class, credentials)); // credentials are Serializable
}

/** {@inheritDoc} */
Expand Down

0 comments on commit 0381412

Please sign in to comment.