Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

import com.cloudbees.jenkins.plugins.sshcredentials.SSHUserPrivateKey;
import com.cloudbees.plugins.credentials.CredentialsScope;
import com.cloudbees.plugins.credentials.CredentialsSnapshotTaker;

import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.DescriptorExtensionList;
Expand Down Expand Up @@ -531,4 +533,5 @@ private Object readResolve() {
// the critical field allow the permission check to make the XML read to fail completely in case of violation
Items.XSTREAM2.addCriticalField(BasicSSHUserPrivateKey.class, "privateKeySource");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.cloudbees.jenkins.plugins.sshcredentials.impl;

import com.cloudbees.jenkins.plugins.sshcredentials.SSHUserPrivateKey;
import com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey.DirectEntryPrivateKeySource;
import com.cloudbees.plugins.credentials.CredentialsSnapshotTaker;

import hudson.Extension;
import hudson.util.Secret;

@Extension
public class SSHUserPrivateKeySnapshotTaker extends CredentialsSnapshotTaker<SSHUserPrivateKey> {
/**
* {@inheritDoc}
*/
@Override
public Class<SSHUserPrivateKey> type() {
return SSHUserPrivateKey.class;
}

/**
* {@inheritDoc}
*/
@Override
public SSHUserPrivateKey snapshot(SSHUserPrivateKey credentials) {
final Secret passphrase = credentials.getPassphrase();
return new BasicSSHUserPrivateKey(credentials.getScope(), credentials.getId(), credentials.getUsername(),
new DirectEntryPrivateKeySource(credentials.getPrivateKeys()),
passphrase == null ? null : passphrase.getEncryptedValue(), credentials.getDescription());
}
}