Skip to content

Commit

Permalink
Merge pull request #200 from olamy/make-triled-putty-key-optional
Browse files Browse the repository at this point in the history
Remove usage of obsolete trilead-putty key
  • Loading branch information
jglick committed Mar 27, 2024
2 parents 7fcbaef + a76823e commit 7732563
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.util.Secret;

import java.util.List;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,19 @@
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;

import jenkins.model.Jenkins;
import net.jcip.annotations.GuardedBy;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.jenkins.ui.icon.Icon;
import org.jenkins.ui.icon.IconSet;
import org.jenkins.ui.icon.IconType;
import org.kohsuke.putty.PuTTYKey;
import org.kohsuke.stapler.DataBoundConstructor;

/**
Expand Down Expand Up @@ -154,24 +150,9 @@ public synchronized List<String> getPrivateKeys() {
}
long lastModified = privateKeySource.getPrivateKeysLastModified();
if (privateKeys == null || privateKeys.isEmpty() || lastModified > privateKeysLastModified) {
List<String> privateKeys = new ArrayList<>();
for (String privateKey : privateKeySource.getPrivateKeys()) {
try {
if (PuTTYKey.isPuTTYKeyFile(new StringReader(privateKey))) {
// strictly we should be encrypting the openssh version with the passphrase, but
// if the key we pass back does not have a passphrase, then the passphrase will not be
// checked, so not an issue.
privateKeys.add(new PuTTYKey(new StringReader(privateKey),
passphrase == null ? "" : passphrase.getPlainText())
.toOpenSSH());
} else {
privateKeys.add(privateKey.endsWith("\n") ? privateKey : privateKey + "\n");
}
} catch (IOException e) {
// ignore
}
}
this.privateKeys = privateKeys;
this.privateKeys = privateKeySource.getPrivateKeys().stream()
.map(privateKey -> privateKey.endsWith("\n") ? privateKey : privateKey + "\n")

Check warning on line 154 in src/main/java/com/cloudbees/jenkins/plugins/sshcredentials/impl/BasicSSHUserPrivateKey.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 154 is only partially covered, one branch is missing
.collect(Collectors.toList());
this.privateKeysLastModified = lastModified;
}
return privateKeys;
Expand Down

0 comments on commit 7732563

Please sign in to comment.