Skip to content

Commit bf67608

Browse files
authored
Merge pull request #263 from basil/stringutils
Remove usages of `StringUtils`
2 parents 2191c4c + afd5514 commit bf67608

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import com.cloudbees.plugins.credentials.impl.BaseStandardCredentials;
77
import edu.umd.cs.findbugs.annotations.NonNull;
88
import edu.umd.cs.findbugs.annotations.Nullable;
9-
import org.apache.commons.lang.StringUtils;
109
import org.kohsuke.stapler.DataBoundSetter;
1110

1211
/**
@@ -45,7 +44,7 @@ protected Object readResolve() {
4544
*/
4645
@NonNull
4746
public String getUsername() {
48-
return StringUtils.isEmpty(username) ? System.getProperty("user.name") : username;
47+
return username == null || username.isEmpty() ? System.getProperty("user.name") : username;
4948
}
5049

5150
@Override

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
import jenkins.security.FIPS140;
5656
import net.jcip.annotations.GuardedBy;
5757
import org.apache.commons.io.FileUtils;
58-
import org.apache.commons.lang.StringUtils;
5958
import org.kohsuke.stapler.DataBoundConstructor;
6059
import org.kohsuke.stapler.QueryParameter;
6160
import org.kohsuke.stapler.interceptor.RequirePOST;
@@ -194,7 +193,7 @@ private static void checkKeyFipsCompliance(String privateKeySource, Secret passp
194193
if (!FIPS140.useCompliantAlgorithms()) {
195194
return; // maintain existing behaviour if not in FIPS mode
196195
}
197-
if (StringUtils.isBlank(privateKeySource)) {
196+
if (privateKeySource == null || privateKeySource.isBlank()) {
198197
return;
199198
}
200199
try {
@@ -313,7 +312,7 @@ public DirectEntryPrivateKeySource(Secret privateKey) {
313312
}
314313

315314
public DirectEntryPrivateKeySource(List<String> privateKeys) {
316-
this(StringUtils.join(privateKeys, "\f"));
315+
this(String.join("\f", privateKeys));
317316
}
318317

319318
/**
@@ -323,9 +322,9 @@ public DirectEntryPrivateKeySource(List<String> privateKeys) {
323322
@Override
324323
public List<String> getPrivateKeys() {
325324
String privateKeys = Secret.toString(privateKey);
326-
return StringUtils.isBlank(privateKeys)
325+
return privateKeys == null || privateKeys.isBlank()
327326
? Collections.emptyList()
328-
: Arrays.asList(StringUtils.split(privateKeys, "\f"));
327+
: Arrays.asList(privateKeys.split("\f"));
329328
}
330329

331330
/**

src/test/java/com/cloudbees/jenkins/plugins/sshcredentials/impl/BasicSSHUserPrivateKeyFIPSTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import hudson.security.ACL;
1111
import hudson.util.FormValidation;
1212
import org.apache.commons.io.FileUtils;
13-
import org.apache.commons.lang.StringUtils;
1413
import org.junit.Rule;
1514
import org.junit.Test;
1615
import org.jvnet.hudson.test.Issue;
@@ -115,9 +114,9 @@ public void formValidationTest() throws Throwable {
115114
private static void checkFormValidation(JenkinsRule r) throws IOException {
116115
BasicSSHUserPrivateKey.DirectEntryPrivateKeySource.DescriptorImpl descriptor = ExtensionList.lookupSingleton(BasicSSHUserPrivateKey.DirectEntryPrivateKeySource.DescriptorImpl.class);
117116
FormValidation result = descriptor.doCheckPrivateKey(getKey("rsa2048").getPrivateKey().getPlainText(), "fipsvalidpassword");
118-
assertTrue(StringUtils.isBlank(result.getMessage()));
117+
assertNull(result.getMessage());
119118
result = descriptor.doCheckPrivateKey(getKey("rsa1024").getPrivateKey().getPlainText(), "fipsvalidpassword");
120-
assertTrue(StringUtils.isNotBlank(result.getMessage()));
119+
assertFalse(result.getMessage().isBlank());
121120
}
122121

123122
private static BasicSSHUserPrivateKey.DirectEntryPrivateKeySource getKey(String file) throws IOException {

0 commit comments

Comments
 (0)