Skip to content

Commit

Permalink
[FIXED JENKINS-27391] Properly display secret text credentials name
Browse files Browse the repository at this point in the history
  • Loading branch information
armfergom committed May 18, 2016
1 parent 792b70b commit c738192
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Expand Up @@ -29,6 +29,9 @@
import com.cloudbees.plugins.credentials.common.StandardCredentials;
import hudson.Util;
import hudson.util.Secret;

import java.util.UUID;

import javax.annotation.Nonnull;

/**
Expand All @@ -47,9 +50,24 @@ class NameProvider extends CredentialsNameProvider<StringCredentials> {

@Override public String getName(StringCredentials c) {
String description = Util.fixEmptyAndTrim(c.getDescription());
return Messages.StringCredentials_some_text() + (description != null ? " (" + description + ")" : "");
String ID = c.getId();
return description != null ? description : (!isUUID(ID) ? ID : Messages.StringCredentials_string_credentials());
}

/**
* Checks whether an ID has UUID format
*
* @param ID the ID to check
* @return true if the ID has UUID format. False otherwise.
*/
private static boolean isUUID(String ID) {
try {
UUID.fromString(ID);
return true;
} catch (IllegalArgumentException ex) {
return false;
}
}
}

}
@@ -1 +1 @@
StringCredentials.some_text=some text
StringCredentials.string_credentials=Secret text

0 comments on commit c738192

Please sign in to comment.