Skip to content

Commit 7732563

Browse files
authored
Merge pull request #200 from olamy/make-triled-putty-key-optional
Remove usage of obsolete trilead-putty key
2 parents 7fcbaef + a76823e commit 7732563

File tree

2 files changed

+4
-24
lines changed

2 files changed

+4
-24
lines changed

src/main/java/com/cloudbees/jenkins/plugins/sshcredentials/SSHUserPrivateKey.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import edu.umd.cs.findbugs.annotations.CheckForNull;
2727
import edu.umd.cs.findbugs.annotations.NonNull;
2828
import hudson.util.Secret;
29-
3029
import java.util.List;
3130

3231
/**

src/main/java/com/cloudbees/jenkins/plugins/sshcredentials/impl/BasicSSHUserPrivateKey.java

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,19 @@
3636
import java.io.File;
3737
import java.io.IOException;
3838
import java.io.Serializable;
39-
import java.io.StringReader;
4039
import java.util.ArrayList;
4140
import java.util.Arrays;
4241
import java.util.Collections;
4342
import java.util.List;
4443
import java.util.concurrent.TimeUnit;
4544
import java.util.logging.Level;
4645
import java.util.logging.Logger;
46+
import java.util.stream.Collectors;
4747

4848
import jenkins.model.Jenkins;
4949
import net.jcip.annotations.GuardedBy;
5050
import org.apache.commons.io.FileUtils;
5151
import org.apache.commons.lang.StringUtils;
52-
import org.jenkins.ui.icon.Icon;
53-
import org.jenkins.ui.icon.IconSet;
54-
import org.jenkins.ui.icon.IconType;
55-
import org.kohsuke.putty.PuTTYKey;
5652
import org.kohsuke.stapler.DataBoundConstructor;
5753

5854
/**
@@ -154,24 +150,9 @@ public synchronized List<String> getPrivateKeys() {
154150
}
155151
long lastModified = privateKeySource.getPrivateKeysLastModified();
156152
if (privateKeys == null || privateKeys.isEmpty() || lastModified > privateKeysLastModified) {
157-
List<String> privateKeys = new ArrayList<>();
158-
for (String privateKey : privateKeySource.getPrivateKeys()) {
159-
try {
160-
if (PuTTYKey.isPuTTYKeyFile(new StringReader(privateKey))) {
161-
// strictly we should be encrypting the openssh version with the passphrase, but
162-
// if the key we pass back does not have a passphrase, then the passphrase will not be
163-
// checked, so not an issue.
164-
privateKeys.add(new PuTTYKey(new StringReader(privateKey),
165-
passphrase == null ? "" : passphrase.getPlainText())
166-
.toOpenSSH());
167-
} else {
168-
privateKeys.add(privateKey.endsWith("\n") ? privateKey : privateKey + "\n");
169-
}
170-
} catch (IOException e) {
171-
// ignore
172-
}
173-
}
174-
this.privateKeys = privateKeys;
153+
this.privateKeys = privateKeySource.getPrivateKeys().stream()
154+
.map(privateKey -> privateKey.endsWith("\n") ? privateKey : privateKey + "\n")
155+
.collect(Collectors.toList());
175156
this.privateKeysLastModified = lastModified;
176157
}
177158
return privateKeys;

0 commit comments

Comments
 (0)