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(); }
public ListBoxModel doFillCredentialsIdItems() { return new StandardListBoxModel() .withEmptySelection() .withMatching( instanceOf(UsernamePasswordCredentials.class), CredentialsProvider.lookupCredentials( StandardUsernamePasswordCredentials.class, (Item) null, ACL.SYSTEM, (DomainRequirement) null ) ); } }
public ListBoxModel doFillCloudCredentialsIdItems(@AncestorInPath ItemGroup context, @QueryParameter String currentValue) { if (!(context instanceof AccessControlled ? (AccessControlled) context : Jenkins.getInstance()).hasPermission(Computer.CONFIGURE)) { return new StandardUsernameListBoxModel().includeCurrentValue(currentValue); } return new StandardUsernameListBoxModel() .includeAs(ACL.SYSTEM, context, StandardUsernameCredentials.class).includeCurrentValue(currentValue); }
@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) ); }
@SuppressWarnings("unused") public ListBoxModel doFillCredentialsIdItems(@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, Collections.<DomainRequirement>emptyList(), CredentialsMatchers.always() ); } }
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath ItemGroup context, @QueryParameter String url) { AccessControlled _context = (context instanceof AccessControlled ? (AccessControlled) context : Jenkins.getInstance()); if (_context == null || !_context.hasPermission(Jenkins.ADMINISTER)) { return new StandardUsernameListBoxModel(); } return new StandardUsernameListBoxModel() .withEmptySelection() .withAll( CredentialsProvider.lookupCredentials( StandardUsernamePasswordCredentials.class, Jenkins.getInstance(), ACL.SYSTEM, URIRequirementBuilder.fromUri(url).build() ) ); }
public ListBoxModel doFillDockerRegistryCredentialsItems(@AncestorInPath Item item, @QueryParameter String uri) { return new StandardListBoxModel() .withEmptySelection() .withMatching(AuthenticationTokens.matcher(DockerRegistryToken.class), CredentialsProvider.lookupCredentials( StandardCredentials.class, item, null, Collections.<DomainRequirement>emptyList() ) ); }
@SuppressWarnings("unused") public ListBoxModel doFillCredentialsIdItems( @QueryParameter final String collectionUrl) { final Jenkins jenkins = Jenkins.getInstance(); String hostName = null; try { final URI uri = new URI(collectionUrl); hostName = uri.getHost(); } catch (final URISyntaxException ignored) { } if (hostName == null || !jenkins.hasPermission(Jenkins.ADMINISTER)) { return new ListBoxModel(); } final List<StandardUsernamePasswordCredentials> matches = findCredentials(hostName); return new StandardListBoxModel() .withEmptySelection() .withAll(matches); } }
@SuppressWarnings("unused") public ListBoxModel doFillCredentialsIdItems(@QueryParameter String apiUrl, @QueryParameter String credentialsId) { if (!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER)) { return new StandardUsernameListBoxModel().includeCurrentValue(credentialsId); } return new StandardUsernameListBoxModel() .includeEmptyValue() .includeMatchingAs( ACL.SYSTEM, Jenkins.getInstance(), StandardUsernamePasswordCredentials.class, fromUri(defaultIfBlank(apiUrl, GITHUB_URL)).build(), CredentialsMatchers.always() ) .includeMatchingAs( Jenkins.getAuthentication(), Jenkins.getInstance(), StandardUsernamePasswordCredentials.class, fromUri(defaultIfBlank(apiUrl, GITHUB_URL)).build(), CredentialsMatchers.always() ); }
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item project) { Jenkins jenkins = Jenkins.getInstance(); if (project != null && project.hasPermission(Item.CONFIGURE)) { return new StandardListBoxModel() .withEmptySelection() .withMatching( new StashCredentialMatcher(), CredentialsProvider.lookupCredentials( StandardCredentials.class, project, ACL.SYSTEM, new ArrayList<DomainRequirement>())); } else if (jenkins != null && jenkins.hasPermission(Item.CONFIGURE)) { return new StandardListBoxModel() .withEmptySelection() .withMatching( new StashCredentialMatcher(), CredentialsProvider.lookupCredentials( StandardCredentials.class, jenkins, ACL.SYSTEM, new ArrayList<DomainRequirement>())); } return new StandardListBoxModel(); }
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath ItemGroup context) { List<DockerRegistryAuthCredentials> credentials = CredentialsProvider.lookupCredentials(DockerRegistryAuthCredentials.class, context, ACL.SYSTEM, Collections.emptyList()); return new CredentialsListBoxModel() .includeEmptyValue() .withMatching(CredentialsMatchers.always(), credentials); }
@Restricted(DoNotUse.class) @RequirePOST public ListBoxModel doFillCredentialIdItems() { Jenkins jenkins = Jenkins.getInstance(); jenkins.checkPermission(Jenkins.ADMINISTER); List<StandardCredentials> credentials = CredentialsProvider.lookupCredentials( StandardCredentials.class, jenkins, ACL.SYSTEM, Collections.emptyList() ); return new StandardListBoxModel() .includeEmptyValue() .withMatching(CredentialsMatchers.instanceOf(OpenstackCredential.class), credentials) ; } }
/** * Populate the credentials dropdown box * @return A ListBoxModel containing all global credentials */ public ListBoxModel doFillCredentialsIdItems() { return new StandardListBoxModel() .withEmptySelection() .withMatching( CredentialsMatchers.allOf(CredentialsMatchers.instanceOf(StandardUsernamePasswordCredentials.class)), CredentialsProvider.lookupCredentials(StandardCredentials.class, Jenkins.getInstance(), ACL.SYSTEM, Collections.<DomainRequirement>emptyList()) ); } }
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath SCMSourceOwner owner, @QueryParameter String source) { if (!hasAccessToCredentialsMetadata(owner)) { return new ListBoxModel(); } return new StandardUsernameListBoxModel() .withEmptySelection() .withAll(availableCredentials(owner, source)); }
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath ItemGroup context, @QueryParameter String serverId) { AccessControlled _context = (context instanceof AccessControlled ? (AccessControlled) context : Jenkins.getActiveInstance()); if (_context == null || !_context.hasPermission(Item.CONFIGURE)) { return new StandardUsernameListBoxModel().includeCurrentValue(serverId); } List<DomainRequirement> domainRequirements = Collections.emptyList(); if (StringUtils.isNotBlank(serverId)) { domainRequirements = Collections.<DomainRequirement> singletonList(new MavenServerIdRequirement(serverId)); } // @formatter:off return new StandardUsernameListBoxModel().includeAs( context instanceof Queue.Task ? Tasks.getDefaultAuthenticationOf((Queue.Task)context) : ACL.SYSTEM, context, StandardUsernameCredentials.class, domainRequirements ) .includeCurrentValue(serverId); // @formatter:on }
public static ListBoxModel doFillCredentialsIdItems(ItemGroup context) { return new StandardListBoxModel() .withEmptySelection() .withMatching( CredentialsMatchers.always(), CredentialsProvider.lookupCredentials(AmazonWebServicesCredentials.class, context, ACL.SYSTEM, Collections.EMPTY_LIST)); } }
public ListBoxModel doFillJdbcCredentialsIdItems() { // use deprecated "withMatching" because, even after 20 mins of research, // I didn't understand how to use the new "recommended" API return new StandardListBoxModel() .includeEmptyValue() .withMatching( CredentialsMatchers.always(), CredentialsProvider.lookupCredentials(UsernamePasswordCredentials.class, Jenkins.getInstance(), ACL.SYSTEM, Collections.EMPTY_LIST)); } public FormValidation doValidateJdbcConnection(
public static ListBoxModel doFillCredentialsIdItems(Item item, String credentialsId, String uri) { StandardListBoxModel result = new StandardListBoxModel(); if (item == null) { if (!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER)) { return result.includeCurrentValue(credentialsId); } } else { if (!item.hasPermission(Item.EXTENDED_READ) && !item.hasPermission(CredentialsProvider.USE_ITEM)) { return result.includeCurrentValue(credentialsId); } } return result // .includeEmptyValue() // .includeMatchingAs( item instanceof Queue.Task ? Tasks.getAuthenticationOf((Queue.Task) item) : ACL.SYSTEM, item, StandardCredentials.class, URIRequirementBuilder.fromUri(uri).build(), CredentialsMatchers.anyOf( CredentialsMatchers.instanceOf(StandardUsernamePasswordCredentials.class), CredentialsMatchers.instanceOf(StringCredentials.class))) .includeCurrentValue(credentialsId); }
public static ListBoxModel doFillCredentialsIdItems(String credentialsId) { if (credentialsId == null) { credentialsId = ""; } if (!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER)) { // Important! Otherwise you expose credentials metadata to random // web requests. return new StandardListBoxModel() .includeCurrentValue(credentialsId); } return new StandardListBoxModel() .includeEmptyValue() .includeAs(ACL.SYSTEM, Jenkins.getInstance(), OpenShiftTokenCredentials.class) // .includeAs(ACL.SYSTEM, Jenkins.getInstance(), // StandardUsernamePasswordCredentials.class) // .includeAs(ACL.SYSTEM, Jenkins.getInstance(), // StandardCertificateCredentials.class) // TODO: Make own type for token or use the existing token // generator auth type used by sync plugin? or kubernetes? .includeCurrentValue(credentialsId); }
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() ); } }