public String getSecretToken() { return secretToken == null ? null : secretToken.getPlainText(); }
private Credentials createCredentials(String userName, String password) { if (userName.indexOf('\\') >= 0){ final String domain = userName.substring(0, userName.indexOf('\\')); final String user = userName.substring(userName.indexOf('\\') + 1); return new NTCredentials(user, Secret.fromString(password).getPlainText(), "", domain); } else { return new UsernamePasswordCredentials(userName, Secret.fromString(password).getPlainText()); } } }
LOGGER.log(Level.FINE, "Ignoring insecure stored CLI authentication for {0}", oldSecret.getPlainText()); return Jenkins.ANONYMOUS;
private void addLegacyToken(@Nonnull Secret legacyToken, boolean migrationFromExistingLegacy) { String tokenUserUseNormally = Util.getDigestOf(legacyToken.getPlainText()); String secretValueHashed = this.plainSecretToHashInHex(tokenUserUseNormally); HashValue hashValue = new HashValue(LEGACY_VERSION, secretValueHashed); HashedToken token = HashedToken.buildNewFromLegacy(hashValue, migrationFromExistingLegacy); this.addToken(token); }
private String getApiToken(String apiTokenId) { StandardCredentials credentials = CredentialsMatchers.firstOrNull( lookupCredentials(StandardCredentials.class, (Item) null, ACL.SYSTEM, new ArrayList<DomainRequirement>()), CredentialsMatchers.withId(apiTokenId)); if (credentials != null) { if (credentials instanceof GitLabApiToken) { return ((GitLabApiToken) credentials).getApiToken().getPlainText(); } if (credentials instanceof StringCredentials) { return ((StringCredentials) credentials).getSecret().getPlainText(); } } throw new IllegalStateException("No credentials found for credentialsId: " + apiTokenId); }
@Override public PasswordParameterValue createValue(StaplerRequest req, JSONObject jo) { PasswordParameterValue value = req.bindJSON(PasswordParameterValue.class, jo); if (value.getValue().getPlainText().equals(DEFAULT_VALUE)) { value = new PasswordParameterValue(getName(), getDefaultValue()); } value.setDescription(getDescription()); return value; }
@Nonnull @Restricted(NoExternalUse.class) /*package*/ String getApiTokenInsecure() { if(apiToken == null){ return Messages.ApiTokenProperty_NoLegacyToken(); } String p = apiToken.getPlainText(); if (p.equals(Util.getDigestOf(Jenkins.getInstance().getSecretKey()+":"+user.getId()))) { // if the current token is the initial value created by pre SECURITY-49 Jenkins, we can't use that. // force using the newer value apiToken = Secret.fromString(p=API_KEY_SEED.mac(user.getId())); } return Util.getDigestOf(p); }
/** * Whether there is actually a password protecting the certificate's private key in {@link #getKeyStore()}. * * @return {@code true} if there is a password protecting the certificate's private key in {@link #getKeyStore()}. */ public boolean isPasswordEmpty() { return StringUtils.isEmpty(password.getPlainText()); }
@Override public String apply(EnvInjectPasswordEntry envInjectPasswordEntry) { if (envInjectPasswordEntry == null) { throw new NullPointerException("Received null EnvInject password entry"); } return envInjectPasswordEntry.getValue().getPlainText(); } };
private Credentials createCredentials(String userName, String password) { if (userName.indexOf('\\') >= 0){ final String domain = userName.substring(0, userName.indexOf('\\')); final String user = userName.substring(userName.indexOf('\\') + 1); return new NTCredentials(user, Secret.fromString(password).getPlainText(), "", domain); } else { return new UsernamePasswordCredentials(userName, Secret.fromString(password).getPlainText()); } } }
@Nonnull @Override public DockerRegistryToken convert(@Nonnull DockerRegistryAuthCredentials c) throws AuthenticationTokenException { return new DockerRegistryToken(c.getEmail(), Base64.encodeBase64String((c.getUsername() + ":" + c.getPassword().getPlainText()) .getBytes(Charsets.UTF_8))); } }
/** * Helper to convert a {@link Secret} password into a {@code char[]} * * @param password the password. * @return a {@code char[]} containing the password or {@code null} */ @CheckForNull private static char[] toCharArray(@NonNull Secret password) { String plainText = Util.fixEmpty(password.getPlainText()); return plainText == null ? null : plainText.toCharArray(); }
/** * Helper to convert a {@link Secret} password into a {@code char[]} * * @param password the password. * @return a {@code char[]} containing the password or {@code null} */ @CheckForNull private static char[] toCharArray(@NonNull Secret password) { String plainText = Util.fixEmpty(password.getPlainText()); return plainText == null ? null : plainText.toCharArray(); }
private static String gitLabApiToken(String id) { StandardCredentials credentials = CredentialsMatchers.firstOrNull( lookupCredentials(StandardCredentials.class, (Item) null, ACL.SYSTEM, new ArrayList<DomainRequirement>()), CredentialsMatchers.withId(id)); if (credentials != null) { if (credentials instanceof GitLabApiToken) { return ((GitLabApiToken) credentials).getApiToken().getPlainText(); } } throw new IllegalStateException("No gitlab-api-token found for id: " + id); } }
@Override public @Nonnull IOSClientBuilder.V2 getBuilder(String endPointUrl) { return OSFactory.builderV2().endpoint(endPointUrl) .credentials(username, getPassword().getPlainText()) .tenantName(tenant); }
/** * Get a Marathon client with basic auth using the username and password within the provided credentials. * * @param credentials Username and password credentials * @return Marathon client with basic authentication filled in */ private Marathon getMarathonClient(UsernamePasswordCredentials credentials) { return MarathonClient .getInstanceWithBasicAuth(getURL(), credentials.getUsername(), credentials.getPassword().getPlainText()); }
@Override public PasswordParameterValue createValue(StaplerRequest req, JSONObject jo) { PasswordParameterValue value = req.bindJSON(PasswordParameterValue.class, jo); if (value.getValue().getPlainText().equals(DEFAULT_VALUE)) { value = new PasswordParameterValue(getName(), getDefaultValue()); } value.setDescription(getDescription()); return value; }
@Nonnull @Restricted(NoExternalUse.class) /*package*/ String getApiTokenInsecure() { String p = apiToken.getPlainText(); if (p.equals(Util.getDigestOf(Jenkins.getInstance().getSecretKey()+":"+user.getId()))) { // if the current token is the initial value created by pre SECURITY-49 Jenkins, we can't use that. // force using the newer value apiToken = Secret.fromString(p=API_KEY_SEED.mac(user.getId())); } return Util.getDigestOf(p); }
@Override protected boolean doAuthenticate() { final Session session = getConnection().getSession(); session.setUserInfo(new JSchUserInfo()); session.setPassword(getUser().getPassword().getPlainText()); return true; }
private void connect() { String privateToken = GitlabBuildTrigger.getDesc().getBotApiTokenSecret().getPlainText(); String apiUrl = GitlabBuildTrigger.getDesc().getGitlabHostUrl(); api = GitlabAPI.connect(apiUrl, privateToken); api.ignoreCertificateErrors(GitlabBuildTrigger.getDesc().isIgnoreCertificateErrors()); }