public ListBoxModel doFillApiTokenIdItems(@QueryParameter String name, @QueryParameter String url) { if (Jenkins.getInstance().hasPermission(Item.CONFIGURE)) { AbstractIdCredentialsListBoxModel<StandardListBoxModel, StandardCredentials> options = new StandardListBoxModel() .includeEmptyValue() .includeMatchingAs(ACL.SYSTEM, Jenkins.getActiveInstance(), StandardCredentials.class, URIRequirementBuilder.fromUri(url).build(), new GitLabCredentialMatcher()); if (name != null && connectionMap.containsKey(name)) { String apiTokenId = connectionMap.get(name).getApiTokenId(); options.includeCurrentValue(apiTokenId); for (ListBoxModel.Option option : options) { if (option.value.equals(apiTokenId)) { option.selected = true; } } } return options; } return new StandardListBoxModel(); }
private static @Nonnull List<? extends StandardUsernameCredentials> availableCredentials( @CheckForNull SCMSourceOwner owner, @CheckForNull String source) { return CredentialsProvider.lookupCredentials(StandardUsernameCredentials.class, owner, null, URIRequirementBuilder.fromUri(source).build()); }
private static List<? extends StandardUsernameCredentials> availableCredentials(Job<?,?> owner, String source) { // TODO implement support for SSHUserPrivateKey return CredentialsProvider.lookupCredentials(StandardUsernameCredentials.class, owner, null, URIRequirementBuilder.fromUri(source).build()); }
static List<DomainRequirement> githubDomainRequirements(String apiUri) { return URIRequirementBuilder.fromUri(StringUtils.defaultIfEmpty(apiUri, "https://github.com")).build(); }
public static StandardUsernamePasswordCredentials getCredentials(String credentialsId, Job<?,?> owner) { if (credentialsId != null) { for (StandardUsernamePasswordCredentials c : CredentialsProvider.lookupCredentials( StandardUsernamePasswordCredentials.class, owner, null, URIRequirementBuilder.fromUri(BitbucketApi.OAUTH_ENDPOINT).build())) { if (c.getId().equals(credentialsId)) { return c; } } } return null; } }
@Restricted(DoNotUse.class) // Stapler only. @SuppressWarnings("unused") // Used by stapler. @RequirePOST public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item item, @QueryParameter String master) { Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER); List<DomainRequirement> domainRequirements = (master == null) ? Collections.<DomainRequirement>emptyList() : URIRequirementBuilder.fromUri(master.trim()).build(); return new StandardListBoxModel().withEmptySelection().withMatching( CredentialsMatchers.instanceOf(UsernamePasswordCredentials.class), CredentialsProvider.lookupCredentials(StandardUsernamePasswordCredentials.class, item, null, domainRequirements) ); }
public ListBoxModel doFillGlobalCredentialsIdItems() { Job owner = null; List<DomainRequirement> apiEndpoint = URIRequirementBuilder.fromUri(BitbucketApi.OAUTH_ENDPOINT).build(); return new StandardUsernameListBoxModel() .withEmptySelection() .withAll(CredentialsProvider.lookupCredentials(StandardUsernamePasswordCredentials.class, owner, null, apiEndpoint)); }
@SuppressWarnings("unused") public ListBoxModel doFillCredentialsIdItems(@QueryParameter String apiUrl, @QueryParameter String credentialsId) { if (!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER)) { return new StandardListBoxModel().includeCurrentValue(credentialsId); } return new StandardListBoxModel() .includeEmptyValue() .includeMatchingAs(ACL.SYSTEM, Jenkins.getInstance(), StringCredentials.class, fromUri(defaultIfBlank(apiUrl, GITHUB_URL)).build(), CredentialsMatchers.always() ); }
private static StandardCredentials lookupCredentials(Item context, String credentialsId, SVNURL repoURL) { return credentialsId == null ? null : CredentialsMatchers.firstOrNull(CredentialsProvider .lookupCredentials(StandardCredentials.class, context, ACL.SYSTEM, URIRequirementBuilder.fromUri(repoURL.toString()).build()), CredentialsMatchers.withId(credentialsId)); }
/** * This method is called to populate the credentials list on the Jenkins * config page. */ public ListBoxModel doFillCredentialsIdItems(@AncestorInPath ItemGroup context, @QueryParameter("target") final String target) { StandardListBoxModel result = new StandardListBoxModel(); result.includeEmptyValue(); result.withMatching(CredentialsMatchers.instanceOf(StandardCredentials.class), CredentialsProvider.lookupCredentials(StandardCredentials.class, context, ACL.SYSTEM, URIRequirementBuilder.fromUri(target).build())); return result; }
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item context, @QueryParameter String source) { if (context == null || !context.hasPermission(Item.CONFIGURE)) { return new ListBoxModel(); } return new StandardUsernameListBoxModel() .includeEmptyValue() .includeAs(context instanceof Queue.Task ? Tasks.getDefaultAuthenticationOf((Queue.Task) context) : ACL.SYSTEM, context, StandardUsernamePasswordCredentials.class, URIRequirementBuilder.fromUri(source).build() ); } }
private StandardUsernamePasswordCredentials getCredentials() { Authentication defaultAuth = null; if (job instanceof Queue.Task) { defaultAuth = Tasks.getDefaultAuthenticationOf((Queue.Task)this.job); } return CredentialsMatchers.firstOrNull( CredentialsProvider.lookupCredentials( StandardUsernamePasswordCredentials.class, this.job, defaultAuth, URIRequirementBuilder.fromUri(stashHost).build() ), CredentialsMatchers.allOf(CredentialsMatchers.withId(credentialsId))); }
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item project, @QueryParameter String serverAddress) { if (project == null || !project.hasPermission(Item.CONFIGURE)) { return new StandardListBoxModel(); } return new StandardListBoxModel() .withEmptySelection() .withMatching( DockerCommand.CREDENTIALS_MATCHER, CredentialsProvider.lookupCredentials(StandardCredentials.class, project, ACL.SYSTEM, URIRequirementBuilder.fromUri(serverAddress).build())); }
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item item, @QueryParameter String uri) { if (item == null && !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER) || item != null && !item.hasPermission(Item.EXTENDED_READ)) { return new StandardListBoxModel(); } List<DomainRequirement> domainRequirements = URIRequirementBuilder.fromUri(uri).build(); domainRequirements.add(new DockerServerDomainRequirement()); return new StandardListBoxModel() .withEmptySelection() .withMatching( AuthenticationTokens.matcher(KeyMaterialFactory.class), CredentialsProvider .lookupCredentials(BASE_CREDENTIAL_TYPE, item, null, domainRequirements) ); }
public StandardCredentials credentials(SCMSourceOwner owner) { return CredentialsMatchers.firstOrNull( CredentialsProvider.lookupCredentials( StandardCredentials.class, owner, Jenkins.getAuthentication(), URIRequirementBuilder.fromUri(serverUrl).build() ), CredentialsMatchers.allOf( AuthenticationTokens.matcher(GiteaAuth.class), CredentialsMatchers.withId(credentialsId) ) ); }
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Job<?,?> owner) { if (owner == null || !owner.hasPermission(Item.CONFIGURE)) { return new ListBoxModel(); } List<DomainRequirement> apiEndpoint = URIRequirementBuilder.fromUri(BitbucketApi.OAUTH_ENDPOINT).build(); return new StandardUsernameListBoxModel() .withEmptySelection() .withAll(CredentialsProvider.lookupCredentials(StandardUsernamePasswordCredentials.class, owner, null, apiEndpoint)); }
public StandardCredentials credentials() { return CredentialsMatchers.firstOrNull( CredentialsProvider.lookupCredentials( StandardCredentials.class, getOwner(), Jenkins.getAuthentication(), URIRequirementBuilder.fromUri(serverUrl).build() ), CredentialsMatchers.allOf( AuthenticationTokens.matcher(GiteaAuth.class), CredentialsMatchers.withId(credentialsId) ) ); }
@CheckForNull protected StandardUsernameCredentials getCredentials() { String credentialsId = getCredentialsId(); if (credentialsId == null) { return null; } return CredentialsMatchers .firstOrNull( CredentialsProvider.lookupCredentials(StandardUsernameCredentials.class, getOwner(), ACL.SYSTEM, URIRequirementBuilder.fromUri(getRemote()).build()), CredentialsMatchers.allOf(CredentialsMatchers.withId(credentialsId), GitClient.CREDENTIALS_MATCHER)); }
public static ListBoxModel doFillCredentialsIdItems(String endpointUrl) { return new StandardListBoxModel() .withEmptySelection() .withMatching( CredentialsMatchers.anyOf(CredentialsMatchers.instanceOf(TokenCredentialsImpl.class), CredentialsMatchers.instanceOf(UsernamePasswordCredentials.class)), CredentialsProvider.lookupCredentials(StandardCredentials.class, Jenkins.getInstance(), ACL.SYSTEM, URIRequirementBuilder.fromUri(endpointUrl).build())); }
private SVNRepositoryView openSession(SVNURL repoURL) throws SVNException, IOException { return new SVNRepositoryView(repoURL, credentialsId == null ? null : CredentialsMatchers .firstOrNull(CredentialsProvider.lookupCredentials(StandardCredentials.class, getOwner(), ACL.SYSTEM, URIRequirementBuilder.fromUri(repoURL.toString()).build()), CredentialsMatchers.allOf(CredentialsMatchers.withId(credentialsId), CredentialsMatchers.anyOf(CredentialsMatchers.instanceOf(StandardCredentials.class), CredentialsMatchers.instanceOf(SSHUserPrivateKey.class))))); }