private File createPassphraseFile(SSHUserPrivateKey sshUser) throws IOException { File passphraseFile = createTempFile("phrase", ".txt"); try (PrintWriter w = new PrintWriter(passphraseFile, "UTF-8")) { w.println(Secret.toString(sshUser.getPassphrase())); } return passphraseFile; }
@Nonnull protected static Collection<String> toString(@Nonnull Iterable<Credentials> credentials) { List<String> result = new ArrayList<>(); for (Credentials creds : credentials) { if (creds instanceof PasswordCredentials) { PasswordCredentials passwordCredentials = (PasswordCredentials) creds; result.add(passwordCredentials.getPassword().getPlainText()); } else if (creds instanceof SSHUserPrivateKey) { SSHUserPrivateKey sshUserPrivateKey = (SSHUserPrivateKey) creds; Secret passphrase = sshUserPrivateKey.getPassphrase(); if (passphrase != null) { result.add(passphrase.getPlainText()); } // omit the private key, there } else { LOGGER.log(Level.FINE, "Skip masking of unsupported credentials type {0}: {1}", new Object[]{creds.getClass(), creds.getDescriptor().getDisplayName()}); } } return result; } }
public SVNUsernamePrivateKeysAuthenticationBuilder(SSHUserPrivateKey c) { username = c.getUsername(); Secret secret = c.getPassphrase(); this.passphrase = secret != null ? Scrambler.scramble(secret.getPlainText()) : null; privateKeys = new ArrayList<String>(c.getPrivateKeys()); }
passphrase.setTextContent(Secret.toString(sshUserPrivateKey.getPassphrase()));
final Secret passphrase = userPrivateKey.getPassphrase(); final String effectivePassphrase = passphrase == null ? null : passphrase.getPlainText(); for (String privateKey : userPrivateKey.getPrivateKeys()) {
final Secret passphrase = sshUserPrivateKey.getPassphrase(); final String effectivePassphrase = passphrase == null ? null : passphrase.getPlainText(); for (String privateKey : sshUserPrivateKey.getPrivateKeys()) {
final Secret passphrase = cc.getPassphrase(); if (passphrase != null && /* TODO JENKINS-21283 */ passphrase.getPlainText().length() > 0) { try {
/** * {@inheritDoc} */ @Override protected boolean doAuthenticate() { try { final SSHUserPrivateKey user = getUser(); final Secret userPassphrase = user.getPassphrase(); final String passphrase = userPassphrase == null ? null : userPassphrase.getPlainText(); byte[] passphraseBytes = passphrase == null ? null : passphrase.getBytes("UTF-8"); for (String privateKey : getPrivateKeys(user)) { getConnection().getJSch().addIdentity(getUsername(), privateKey.getBytes("UTF-8"), null, passphraseBytes); } return true; } catch (JSchException e) { e.printStackTrace(getListener().error("Failed to authenticate with public key")); return false; } catch (UnsupportedEncodingException e) { throw new SSHAuthenticatorException(e); } }
/** * {@inheritDoc} */ @Override protected boolean doAuthenticate() { try { final SSHUserPrivateKey user = getUser(); final Secret userPassphrase = user.getPassphrase(); final String passphrase = userPassphrase == null ? null : userPassphrase.getPlainText(); byte[] passphraseBytes = passphrase == null ? null : passphrase.getBytes("UTF-8"); for (String privateKey : getPrivateKeys(user)) { getConnection().getJSch().addIdentity(getUsername(), privateKey.getBytes("UTF-8"), null, passphraseBytes); } return true; } catch (JSchException e) { e.printStackTrace(getListener().error("Failed to authenticate with public key")); return false; } catch (UnsupportedEncodingException e) { throw new SSHAuthenticatorException(e); } }
try { final Connection connection = getConnection(); final Secret userPassphrase = user.getPassphrase(); final String passphrase = userPassphrase == null ? null : userPassphrase.getPlainText();
/** * {@inheritDoc} */ @Override public SSHUserPrivateKey snapshot(SSHUserPrivateKey credentials) { if (credentials instanceof BasicSSHUserPrivateKey) { final PrivateKeySource keySource = ((BasicSSHUserPrivateKey) credentials).getPrivateKeySource(); if (keySource.isSnapshotSource()) { return credentials; } } final Secret passphrase = credentials.getPassphrase(); return new BasicSSHUserPrivateKey(credentials.getScope(), credentials.getId(), credentials.getUsername(), new DirectEntryPrivateKeySource(credentials.getPrivateKeys()), passphrase == null ? null : passphrase.getEncryptedValue(), credentials.getDescription()); } }