@Override public StandardCredentials toCredentials(ModelObject context, String description) throws IOException { String key = FileUtils.readFileToString(getKeyFile(), "iso-8859-1"); for (SSHUserPrivateKey c : CredentialsProvider.lookupCredentials( SSHUserPrivateKey.class, findItemGroup(context), ACL.SYSTEM, Collections.<DomainRequirement>emptyList())) { if (userName.equals(c.getUsername()) && c.getPrivateKeys().contains(key)) { return c; } } return null; } }
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()); }
username.setTextContent(sshUserPrivateKey.getUsername());
String sshAuthOpts = String.format(" -i %s -l %s", sshPrivateKey.getRemote(), cc.getUsername());
/** * Populates the credential of a JClouds ContextBuilder from a credentials record. * @param cb The {@link org.jclouds.ContextBuilder} which should get the credential. * @param id The Id of the credentials object. * @return The modified {@link org.jclouds.ContextBuilder} */ public static ContextBuilder setCredentials(final ContextBuilder cb, final String id) { StandardUsernameCredentials u = getCredentialsById(id); if (null != u) { if (u instanceof OpenstackKeystoneV3) { OpenstackKeystoneV3 ok3 = (OpenstackKeystoneV3)u; String domainname = ok3.getDomain().isEmpty() ? "default" : ok3.getDomain(); return cb.credentials(domainname + ":" + ok3.getUsername(), getPassword(ok3.getPassword())); } else if (u instanceof StandardUsernamePasswordCredentials) { StandardUsernamePasswordCredentials up = (StandardUsernamePasswordCredentials)u; return cb.credentials(up.getUsername(), getPassword(up.getPassword())); } else if (u instanceof SSHUserPrivateKey) { SSHUserPrivateKey up = (SSHUserPrivateKey)u; return cb.credentials(up.getUsername(), getPrivateKey(up)); } throw new RuntimeException("invalid credentials type"); } throw new RuntimeException("Could not retrieve credentials"); }
/** * {@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()); } }
userName = sshUser.getUsername();