public String[] promptKeyboardInteractive(String destination, String name, String instruction, String[] prompt, boolean[] echo) { // most SSH servers just use keyboard interactive to prompt for the password // match "assword" is safer than "password"... you don't *want* to know why! return prompt != null && prompt.length > 0 && prompt[0].toLowerCase().contains("assword") ? new String[]{getUser().getPassword().getPlainText()} : new String[0]; } }
public String[] promptKeyboardInteractive(String destination, String name, String instruction, String[] prompt, boolean[] echo) { // most SSH servers just use keyboard interactive to prompt for the password // match "assword" is safer than "password"... you don't *want* to know why! return prompt != null && prompt.length > 0 && prompt[0].toLowerCase().contains("assword") ? new String[]{getUser().getPassword().getPlainText()} : new String[0]; } }
static String createAuthorization(final StandardUsernamePasswordCredentials credentials) { final String username = credentials.getUsername(); final Secret secretPassword = credentials.getPassword(); final String password = secretPassword.getPlainText(); final String credPair = username + ":" + password; final byte[] credBytes = credPair.getBytes(MediaType.UTF_8); final String base64enc = DatatypeConverter.printBase64Binary(credBytes); final String result = "Basic " + base64enc; return result; }
private File createPasswordFile(StandardUsernamePasswordCredentials userPass) throws IOException { File passwordFile = createTempFile("password", ".txt"); try (PrintWriter w = new PrintWriter(passwordFile, "UTF-8")) { w.println(Secret.toString(userPass.getPassword())); } return passwordFile; }
/** * @deprecated Use MesosCloud#getCredentials().getPassword() instead. * @return */ @Deprecated public String getSecret() { StandardUsernamePasswordCredentials credentials = getCredentials(); return credentials == null ? "" : Secret.toString(credentials.getPassword()); }
public String getPassword() { return getUser().getPassword().getPlainText(); }
public String getPassword() { return getUser().getPassword().getPlainText(); }
public String getPassword() { return this.getCredentials().getPassword().getPlainText(); }
public boolean matches(@NonNull Credentials item) { if (item instanceof StandardUsernamePasswordCredentials && password != null && StandardUsernamePasswordCredentials.class.cast(item).getPassword().equals(password)) { return true; } if (privatekeyContent != null && item instanceof SSHUserPrivateKey) { for (String key : SSHUserPrivateKey.class.cast(item).getPrivateKeys()) { if (pemKeyEquals(key, privatekeyContent)) { return true; } } } return false; } }));
public boolean matches(@NonNull Credentials item) { if (item instanceof StandardUsernamePasswordCredentials && password != null && StandardUsernamePasswordCredentials.class.cast(item).getPassword().equals(password)) { return true; } if (privatekeyContent != null && item instanceof SSHUserPrivateKey) { for (String key : SSHUserPrivateKey.class.cast(item).getPrivateKeys()) { if (pemKeyEquals(key, privatekeyContent)) { return true; } } } return false; } }));
@DataBoundConstructor public ReleaseManagementCI(String collectionUrl, String projectName, String releaseDefinitionName, String credentialsId) { if (collectionUrl.endsWith("/")) { this.collectionUrl = collectionUrl; } else { this.collectionUrl = collectionUrl + "/"; } this.projectName = projectName; this.releaseDefinitionName = releaseDefinitionName; StandardUsernamePasswordCredentials credential = TeamCollectionConfiguration.findCredentialsById(credentialsId); this.username = credential == null ? "" : credential.getUsername(); this.password = credential == null ? Secret.fromString("") : credential.getPassword(); this.credentialsId = credentialsId; }
@Override public StandardCredentials toCredentials(ModelObject context, String description) throws IOException { for (StandardUsernamePasswordCredentials c : CredentialsProvider.lookupCredentials( StandardUsernamePasswordCredentials.class, findItemGroup(context), ACL.SYSTEM, Collections.<DomainRequirement>emptyList())) { if (userName.equals(c.getUsername()) && getPassword().equals(c.getPassword().getPlainText())) { return c; } } return null; }
@Override public CloseableHttpClient authenticate(HttpClientBuilder clientBuilder, HttpContext context, HttpRequestBase requestBase, PrintStream logger) throws IOException, InterruptedException { return auth(clientBuilder, context, requestBase, credential.getUsername(), credential.getPassword().getPlainText()); }
public static Server create(final Launcher launcher, final TaskListener taskListener, final String url, final StandardUsernamePasswordCredentials credentials, final WebProxySettings webProxySettings, final ExtraSettings extraSettings) throws IOException { final String username; final String userPassword; if (credentials == null) { username = null; userPassword = null; } else { username = credentials.getUsername(); final Secret password = credentials.getPassword(); userPassword = password.getPlainText(); } return new Server(launcher, taskListener, url, username, userPassword, webProxySettings, extraSettings); }
protected Object readResolve() { if (StringUtils.isNotBlank(collectionUrl) && password != null && StringUtils.isNotBlank(password.getPlainText())) { try { final URI uri = new URI(collectionUrl); String hostName = uri.getHost(); List<StandardUsernamePasswordCredentials> credentials = TeamCollectionConfiguration.findCredentials(hostName); for (StandardUsernamePasswordCredentials credential : credentials) { if ((StringUtils.isBlank(username) || credential.getUsername().equals(username)) && credential.getPassword().getPlainText().equals(password.getPlainText())) { this.credentialsId = credential.getId(); return this; } } this.credentialsId = TeamCollectionConfiguration.setCredentials(hostName, username, password.getPlainText()); } catch (Exception ex) { logger.log(Level.WARNING, String.format("Get or generate credentials for collection url: %s and username: %s failed.", collectionUrl, username), ex); } } return this; }
private static GitHubBuilder getBuilder(Item context, String serverAPIUrl, String credentialsId) { GitHubBuilder builder = new GitHubBuilder() .withEndpoint(serverAPIUrl) .withConnector(new HttpConnectorWithJenkinsProxy()); String contextName = context == null ? "(Jenkins.instance)" : context.getFullDisplayName(); if (StringUtils.isEmpty(credentialsId)) { LOGGER.log(Level.WARNING, "credentialsId not set for context {0}, using anonymous connection", contextName); return builder; } StandardCredentials credentials = Ghprb.lookupCredentials(context, credentialsId, serverAPIUrl); if (credentials == null) { LOGGER.log(Level.SEVERE, "Failed to look up credentials for context {0} using id: {1}", new Object[] {contextName, credentialsId}); } else if (credentials instanceof StandardUsernamePasswordCredentials) { LOGGER.log(Level.FINEST, "Using username/password for context {0}", contextName); StandardUsernamePasswordCredentials upCredentials = (StandardUsernamePasswordCredentials) credentials; builder.withPassword(upCredentials.getUsername(), upCredentials.getPassword().getPlainText()); } else if (credentials instanceof StringCredentials) { LOGGER.log(Level.FINEST, "Using OAuth token for context {0}", contextName); StringCredentials tokenCredentials = (StringCredentials) credentials; builder.withOAuthToken(tokenCredentials.getSecret().getPlainText()); } else { LOGGER.log(Level.SEVERE, "Unknown credential type for context {0} using id: {1}: {2}", new Object[] {contextName, credentialsId, credentials.getClass().getName()}); return null; } return builder; }
@Override protected boolean doAuthenticate() { final Session session = getConnection().getSession(); session.setUserInfo(new JSchUserInfo()); session.setPassword(getUser().getPassword().getPlainText()); return true; }
@Override protected boolean doAuthenticate() { final Session session = getConnection().getSession(); session.setUserInfo(new JSchUserInfo()); session.setPassword(getUser().getPassword().getPlainText()); return true; }
/** * 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"); }
public <T extends ApiClient.HttpClientFactory> void init(ApiClient client, T httpFactory) { this.trigger = this.builder.getTrigger(); if (client == null) { String username = trigger.getUsername(); String password = trigger.getPassword(); StandardUsernamePasswordCredentials credentials = getCredentials(trigger.getCredentialsId()); if (credentials != null) { username = credentials.getUsername(); password = credentials.getPassword().getPlainText(); } if (this.trigger.isCloud()) { this.client = createCloudClient(httpFactory, username, password); } else { this.client = createServerClient(httpFactory, username, password); } } else this.client = client; }