public FormValidation doCheckCredentialsId(@QueryParameter String value) { UsernamePasswordCredentials c = getCredentialsById(value); if (c == null) { return FormValidation.error("Please enter a Username with Password credentials id"); } if(c.getUsername().length() == 0) return FormValidation.error("This credential should have a username"); if(c.getUsername().indexOf('@') == -1) return FormValidation.warning("Username's usually have an @ in them, e.g. hudson@example.org"); if (Secret.toString(c.getPassword()).length() == 0) { return FormValidation.error("This credential should have a password"); } return FormValidation.ok(); }
@NonNull @Override public DockerRegistryToken convert(UsernamePasswordCredentials c) throws AuthenticationTokenException { return new DockerRegistryToken(c.getUsername(), Base64.encodeBase64String((c.getUsername() + ":" + c.getPassword().getPlainText()) .getBytes(Charsets.UTF_8))); } }
@NonNull @Override public DockerRegistryToken convert(UsernamePasswordCredentials c) throws AuthenticationTokenException { return new DockerRegistryToken(c.getUsername(), Base64.encodeBase64String((c.getUsername() + ":" + c.getPassword().getPlainText()) .getBytes(Charsets.UTF_8))); } }
/** * {@inheritDoc} */ @NonNull @Override public String getName(@NonNull UsernamePasswordCredentials credentials) { return credentials.getUsername() + "/******"; } }
/** * {@inheritDoc} */ @NonNull @Override public String getName(@NonNull UsernamePasswordCredentials credentials) { return credentials.getUsername() + "/******"; } }
private String retrieveCredentialInfo(boolean getUsername){ StandardCredentials credentials = retrieveCredential(credentialId); if (credentials != null && credentials instanceof UsernamePasswordCredentials) { UsernamePasswordCredentials c = (UsernamePasswordCredentials)credentials; if (getUsername){ return c.getUsername(); } else{ return c.getPassword().getPlainText(); } } return StringUtils.EMPTY; }
username = c.getUsername(); password = Secret.toString(c.getPassword());
private FormValidation checkCredentials(UsernamePasswordCredentials credentials) { try { OAuthConfig config = new OAuthConfig(credentials.getUsername(), credentials.getPassword().getPlainText()); BitbucketApiService apiService = (BitbucketApiService) new BitbucketApi().createService(config); Verifier verifier = null; Token token = apiService.getAccessToken(OAuthConstants.EMPTY_TOKEN, verifier); if (token.isEmpty()) { return FormValidation.error("Invalid Bitbucket OAuth credentials"); } } catch (Exception e) { return FormValidation.error(e.getClass() + e.getMessage()); } return FormValidation.ok(); } }
req.addHeader(new BasicScheme().authenticate( new org.apache.http.auth.UsernamePasswordCredentials( usernamePasswordCredentials.getUsername(), usernamePasswordCredentials.getPassword().getPlainText()), req,
public SVNUsernamePasswordAuthenticationBuilder(UsernamePasswordCredentials c) { this.username = c.getUsername(); this.password = Scrambler.scramble(c.getPassword().getPlainText()); }
/** * 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()); }
/** * {@inheritDoc} */ @NonNull @Override public GiteaAuthUser convert(@NonNull UsernamePasswordCredentials credential) throws AuthenticationTokenException { return new GiteaAuthUser(credential.getUsername(), credential.getPassword().getPlainText()); } }
public static Credentials credentialsLookup(String credentialsId, Item item) { UsernamePasswordCredentials usernamePasswordCredentials = CredentialsMatchers.firstOrNull( CredentialsProvider.lookupCredentials( UsernamePasswordCredentials.class, item, ACL.SYSTEM, Collections.<DomainRequirement>emptyList()), CredentialsMatchers.allOf(CredentialsMatchers.withId(credentialsId)) ); if (usernamePasswordCredentials != null) { return new Credentials(usernamePasswordCredentials.getUsername(), usernamePasswordCredentials.getPassword().getPlainText()); } return Credentials.EMPTY_CREDENTIALS; }
public static void sendBuildStatusNotification(final UsernamePasswordCredentials credentials, final Run<?, ?> build, final BitbucketBuildStatusResource buildStatusResource, final BitbucketBuildStatus buildStatus, final TaskListener listener) throws Exception { if (credentials == null) { throw new Exception("Credentials could not be found!"); } OAuthConfig config = new OAuthConfig(credentials.getUsername(), credentials.getPassword().getPlainText()); BitbucketApiService apiService = (BitbucketApiService) new BitbucketApi().createService(config); GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapter(BitbucketBuildStatus.class, new BitbucketBuildStatusSerializer()); gsonBuilder.setPrettyPrinting(); Gson gson = gsonBuilder.create(); OAuthRequest request = new OAuthRequest(Verb.POST, buildStatusResource.generateUrl(Verb.POST)); request.addHeader("Content-type", "application/json"); request.addPayload(gson.toJson(buildStatus)); Token token = apiService.getAccessToken(OAuthConstants.EMPTY_TOKEN, null); apiService.signRequest(token, request); Response response = request.send(); logger.info("This request was sent: " + request.getBodyContents()); logger.info("This response was received: " + response.getBody()); listener.getLogger().println("Sending build status " + buildStatus.getState() + " for commit " + buildStatusResource.getCommitId() + " to BitBucket is done!"); }
String userName = credentials.getUsername(); Secret password = credentials.getPassword(); final HttpClientOptions options = new HttpClientOptions();
public static Authentication getAuthenticationData(String credentialsId) { if (StringUtils.isBlank(credentialsId) ) { return null; } Authentication authData = null; final StandardCredentials credentials = CredentialsMatchers.firstOrNull( CredentialsProvider.lookupCredentials(StandardCredentials.class, Jenkins.getInstance(), ACL.SYSTEM, Collections.<DomainRequirement>emptyList() ), CredentialsMatchers.withId(credentialsId) ); if (credentials instanceof TokenCredentialsImpl) { TokenCredentialsImpl tokenCredentials = (TokenCredentialsImpl)credentials; authData = new TokenAuthentication(tokenCredentials.getSecret().getPlainText() ); } else if (credentials instanceof UsernamePasswordCredentials) { UsernamePasswordCredentials userPw = (UsernamePasswordCredentials)credentials; authData = new UserAndPasswordAuthentication(userPw.getUsername(), userPw.getPassword().getPlainText() ); } return authData; }
new ChatterClient(c.getUsername(), Secret.toString(c.getPassword()), server).postBuild(recordId, title, url, testHealth, suspects); } catch (Exception ex) { ps.print("error posting to chatter : " + ex.getMessage());
UsernamePasswordCredentials upc = (UsernamePasswordCredentials) credentials; b.add("--config", "auth.jenkins.prefix=*", "--config"); b.addMasked("auth.jenkins.username=" + upc.getUsername()); b.add("--config"); b.addMasked("auth.jenkins.password=" + upc.getPassword().getPlainText());
} else if (credentials instanceof UsernamePasswordCredentials) { UsernamePasswordCredentials usernamePassword = (UsernamePasswordCredentials) credentials; builder.withUsername(usernamePassword.getUsername()) .withPassword(Secret.toString(usernamePassword.getPassword())); } else if (credentials instanceof StandardCertificateCredentials) {
} else if (c instanceof UsernamePasswordCredentials) { UsernamePasswordCredentials upc = (UsernamePasswordCredentials) c; login = "--username=" + upc.getUsername() + " --password=" + Secret.toString(upc.getPassword()); } else if (c instanceof StandardCertificateCredentials) { StandardCertificateCredentials scc = (StandardCertificateCredentials) c;