Java Code Examples for com.cloudbees.plugins.credentials.common.StandardListBoxModel#includeCurrentValue()
The following examples show how to use
com.cloudbees.plugins.credentials.common.StandardListBoxModel#includeCurrentValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GitLabSCMSource.java From gitlab-branch-source-plugin with MIT License | 6 votes |
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath SCMSourceOwner context, @QueryParameter String serverName, @QueryParameter String credentialsId) { StandardListBoxModel result = new StandardListBoxModel(); if (context == null) { // must have admin if you want the list without a context if (!Jenkins.get().hasPermission(Jenkins.ADMINISTER)) { result.includeCurrentValue(credentialsId); return result; } } else { if (!context.hasPermission(Item.EXTENDED_READ) && !context.hasPermission(CredentialsProvider.USE_ITEM)) { // must be able to read the configuration or use the item credentials if you // want the list result.includeCurrentValue(credentialsId); return result; } } result.includeEmptyValue(); result.includeMatchingAs( context instanceof Queue.Task ? ((Queue.Task) context).getDefaultAuthentication() : ACL.SYSTEM, context, StandardUsernameCredentials.class, fromUri(getServerUrlFromName(serverName)).build(), GitClient.CREDENTIALS_MATCHER); return result; }
Example 2
Source File: AxivionSuite.java From warnings-ng-plugin with MIT License | 6 votes |
/** * Shows the user all available credential id items. * * @param item * jenkins configuration * @param credentialsId * current used credentials * * @return a list view of all credential ids */ public ListBoxModel doFillCredentialsIdItems( @AncestorInPath final Item item, @QueryParameter final String credentialsId) { StandardListBoxModel result = new StandardListBoxModel(); if (item == null) { if (!new JenkinsFacade().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.includeAs( ACL.SYSTEM, item, StandardUsernamePasswordCredentials.class, Collections.emptyList()) .includeCurrentValue(credentialsId); }
Example 3
Source File: GlobalKafkaConfiguration.java From remoting-kafka-plugin with MIT License | 6 votes |
private ListBoxModel fillCredentialsIdItems(@AncestorInPath Item item, @QueryParameter String credentialsId) { StandardListBoxModel result = new StandardListBoxModel(); if (item == null) { if (!Jenkins.get().hasPermission(Jenkins.ADMINISTER)) { return result.includeCurrentValue(credentialsId); } } return result .includeMatchingAs( ACL.SYSTEM, Jenkins.get(), StandardUsernamePasswordCredentials.class, Collections.singletonList(KAFKA_SCHEME), CredentialsMatchers.always() ) .includeCurrentValue(credentialsId); }
Example 4
Source File: BuildScanner.java From acunetix-plugin with MIT License | 6 votes |
public ListBoxModel doFillGApiKeyIDItems( @AncestorInPath Item item) { StandardListBoxModel result = new StandardListBoxModel(); if (item == null) { if (!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER)) { return result.includeCurrentValue(gApiKeyID); } } else { if (!item.hasPermission(Item.EXTENDED_READ) && !item.hasPermission(CredentialsProvider.USE_ITEM)) { return result.includeCurrentValue(gApiKeyID); } } if (gApiKeyID != null) { result.includeMatchingAs(ACL.SYSTEM, Jenkins.getInstance(), StringCredentials.class, Collections.<DomainRequirement> emptyList(), CredentialsMatchers.allOf(CredentialsMatchers.withId(gApiKeyID))); } return result .includeMatchingAs(ACL.SYSTEM, Jenkins.getInstance(), StringCredentials.class, Collections.<DomainRequirement> emptyList(), CredentialsMatchers.allOf(CredentialsMatchers.instanceOf(StringCredentials.class))); }
Example 5
Source File: CredentialsHelper.java From violation-comments-to-github-plugin with MIT License | 6 votes |
@SuppressFBWarnings("NP_NULL_PARAM_DEREF") public static ListBoxModel doFillCredentialsIdItems( final Item item, final String credentialsId, final String uri) { final 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); }
Example 6
Source File: CredentialsHelper.java From violation-comments-to-stash-plugin with MIT License | 6 votes |
@SuppressFBWarnings("NP_NULL_PARAM_DEREF") public static ListBoxModel doFillCredentialsIdItems( final Item item, final String credentialsId, final String uri) { final 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); }
Example 7
Source File: GitLabSCMNavigator.java From gitlab-branch-source-plugin with MIT License | 5 votes |
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath SCMSourceOwner context, @QueryParameter String serverName, @QueryParameter String credentialsId) { StandardListBoxModel result = new StandardListBoxModel(); if (context == null) { if (!Jenkins.get().hasPermission(Jenkins.ADMINISTER)) { // must have admin if you want the list without a context result.includeCurrentValue(credentialsId); return result; } } else { if (!context.hasPermission(Item.EXTENDED_READ) && !context.hasPermission(CredentialsProvider.USE_ITEM)) { // must be able to read the configuration or use the item credentials if you want the list result.includeCurrentValue(credentialsId); return result; } } result.includeEmptyValue(); result.includeMatchingAs( context instanceof Queue.Task ? ((Queue.Task) context).getDefaultAuthentication() : ACL.SYSTEM, context, StandardUsernameCredentials.class, fromUri(getServerUrlFromName(serverName)).build(), GitClient.CREDENTIALS_MATCHER ); return result; }
Example 8
Source File: SSHCheckoutTrait.java From gitlab-branch-source-plugin with MIT License | 5 votes |
@Restricted(NoExternalUse.class) @SuppressWarnings("unused") // stapler form binding public ListBoxModel doFillCredentialsIdItems(@CheckForNull @AncestorInPath Item context, @QueryParameter String serverUrl, @QueryParameter String credentialsId) { StandardListBoxModel result = new StandardListBoxModel(); if (context == null) { if (!Jenkins.get().hasPermission(Jenkins.ADMINISTER)) { // must have admin if you want the list without a context result.includeCurrentValue(credentialsId); return result; } } else { if (!context.hasPermission(Item.EXTENDED_READ) && !context.hasPermission(CredentialsProvider.USE_ITEM)) { // must be able to read the configuration or use the item credentials if you want the list result.includeCurrentValue(credentialsId); return result; } } result.includeEmptyValue(); result.includeMatchingAs( context instanceof Queue.Task ? ((Queue.Task) context).getDefaultAuthentication() : ACL.SYSTEM, context, StandardUsernameCredentials.class, URIRequirementBuilder.fromUri(serverUrl).build(), CredentialsMatchers.instanceOf(SSHUserPrivateKey.class) ); return result; }
Example 9
Source File: GiteaSCMNavigator.java From gitea-plugin with MIT License | 5 votes |
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath SCMSourceOwner context, @QueryParameter String serverUrl, @QueryParameter String credentialsId) { StandardListBoxModel result = new StandardListBoxModel(); if (context == null) { if (!Jenkins.get().hasPermission(Jenkins.ADMINISTER)) { // must have admin if you want the list without a context result.includeCurrentValue(credentialsId); return result; } } else { if (!context.hasPermission(Item.EXTENDED_READ) && !context.hasPermission(CredentialsProvider.USE_ITEM)) { // must be able to read the configuration or use the item credentials if you want the list result.includeCurrentValue(credentialsId); return result; } } result.includeEmptyValue(); result.includeMatchingAs( context instanceof Queue.Task ? ((Queue.Task) context).getDefaultAuthentication() : ACL.SYSTEM, context, StandardCredentials.class, URIRequirementBuilder.fromUri(serverUrl).build(), AuthenticationTokens.matcher(GiteaAuth.class) ); return result; }
Example 10
Source File: SSHCheckoutTrait.java From gitea-plugin with MIT License | 5 votes |
@Restricted(NoExternalUse.class) @SuppressWarnings("unused") // stapler form binding public ListBoxModel doFillCredentialsIdItems(@CheckForNull @AncestorInPath Item context, @QueryParameter String serverUrl, @QueryParameter String credentialsId) { StandardListBoxModel result = new StandardListBoxModel(); if (context == null) { if (!Jenkins.get().hasPermission(Jenkins.ADMINISTER)) { // must have admin if you want the list without a context result.includeCurrentValue(credentialsId); return result; } } else { if (!context.hasPermission(Item.EXTENDED_READ) && !context.hasPermission(CredentialsProvider.USE_ITEM)) { // must be able to read the configuration or use the item credentials if you want the list result.includeCurrentValue(credentialsId); return result; } } result.add(Messages.SSHCheckoutTrait_useAgentKey(), ""); result.includeMatchingAs( context instanceof Queue.Task ? ((Queue.Task) context).getDefaultAuthentication() : ACL.SYSTEM, context, StandardUsernameCredentials.class, URIRequirementBuilder.fromUri(serverUrl).build(), CredentialsMatchers.instanceOf(SSHUserPrivateKey.class) ); return result; }
Example 11
Source File: GiteaSCMSource.java From gitea-plugin with MIT License | 5 votes |
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath SCMSourceOwner context, @QueryParameter String serverUrl, @QueryParameter String credentialsId) { StandardListBoxModel result = new StandardListBoxModel(); if (context == null) { if (!Jenkins.get().hasPermission(Jenkins.ADMINISTER)) { // must have admin if you want the list without a context result.includeCurrentValue(credentialsId); return result; } } else { if (!context.hasPermission(Item.EXTENDED_READ) && !context.hasPermission(CredentialsProvider.USE_ITEM)) { // must be able to read the configuration or use the item credentials if you want the list result.includeCurrentValue(credentialsId); return result; } } result.includeEmptyValue(); result.includeMatchingAs( context instanceof Queue.Task ? ((Queue.Task) context).getDefaultAuthentication() : ACL.SYSTEM, context, StandardCredentials.class, URIRequirementBuilder.fromUri(serverUrl).build(), AuthenticationTokens.matcher(GiteaAuth.class) ); return result; }
Example 12
Source File: Site.java From jira-steps-plugin with Apache License 2.0 | 5 votes |
public ListBoxModel doFillCredentialsIdItems(final @AncestorInPath Item item, @QueryParameter String credentialsId, final @QueryParameter String url) { StandardListBoxModel result = new StandardListBoxModel(); credentialsId = StringUtils.trimToEmpty(credentialsId); if (item == null) { if (!Jenkins.get().hasPermission(Jenkins.ADMINISTER)) { return result.includeCurrentValue(credentialsId); } } else { if (!item.hasPermission(Item.EXTENDED_READ) && !item.hasPermission(CredentialsProvider.USE_ITEM)) { return result.includeCurrentValue(credentialsId); } } Authentication authentication = getAuthentication(item); List<DomainRequirement> domainRequirements = URIRequirementBuilder.fromUri(url).build(); CredentialsMatcher always = CredentialsMatchers.always(); Class<? extends StandardUsernameCredentials> type = UsernamePasswordCredentialsImpl.class; result.includeEmptyValue(); if (item != null) { result.includeMatchingAs(authentication, item, type, domainRequirements, always); } else { result.includeMatchingAs(authentication, Jenkins.get(), type, domainRequirements, always); } return result; }
Example 13
Source File: AnchoreBuilder.java From anchore-container-scanner-plugin with Apache License 2.0 | 5 votes |
@SuppressWarnings("unused") public ListBoxModel doFillEngineCredentialsIdItems(@QueryParameter String credentialsId) { StandardListBoxModel result = new StandardListBoxModel(); if (!Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER)) { return result.includeCurrentValue(credentialsId); } return result.includeEmptyValue() .includeMatchingAs(ACL.SYSTEM, Jenkins.getActiveInstance(), StandardUsernamePasswordCredentials.class, Collections.<DomainRequirement>emptyList(), CredentialsMatchers.always()); }