/** * Adds supplied credentials to the model. * * @param credentials the credentials. * @return {@code this} for method chaining. * @deprecated prefer using the {@link #include(Item, Class)} or {@link #includeAs(Authentication, Item, Class)} * methods to build the list box contents in order to allow credentials providers to not have to instantiate * a full credential instance where those credential providers store the secrets external from Jenkins. */ @Deprecated @NonNull public AbstractIdCredentialsListBoxModel<T, C> withAll(@NonNull Iterable<? extends C> credentials) { return withMatching(CredentialsMatchers.always(), credentials.iterator()); }
/** * Adds supplied credentials to the model. * * @param credentials the credentials. * @return {@code this} for method chaining. * @deprecated prefer using the {@link #include(Item, Class)} or {@link #includeAs(Authentication, Item, Class)} * methods to build the list box contents in order to allow credentials providers to not have to instantiate * a full credential instance where those credential providers store the secrets external from Jenkins. */ @Deprecated @NonNull public AbstractIdCredentialsListBoxModel<T, C> withAll(@NonNull C... credentials) { return withMatching(CredentialsMatchers.always(), Arrays.asList(credentials)); }
/** * Adds supplied credentials to the model. * * @param credentials the credentials. * @return {@code this} for method chaining. * @deprecated prefer using the {@link #include(Item, Class)} or {@link #includeAs(Authentication, Item, Class)} * methods to build the list box contents in order to allow credentials providers to not have to instantiate * a full credential instance where those credential providers store the secrets external from Jenkins. */ @Deprecated @NonNull public AbstractIdCredentialsListBoxModel<T, C> withAll(@NonNull Iterable<? extends C> credentials) { return withMatching(CredentialsMatchers.always(), credentials.iterator()); }
/** * Adds supplied credentials to the model. * * @param credentials the credentials. * @return {@code this} for method chaining. * @deprecated prefer using the {@link #include(Item, Class)} or {@link #includeAs(Authentication, Item, Class)} * methods to build the list box contents in order to allow credentials providers to not have to instantiate * a full credential instance where those credential providers store the secrets external from Jenkins. */ @Deprecated @NonNull public AbstractIdCredentialsListBoxModel<T, C> withAll(@NonNull C... credentials) { return withMatching(CredentialsMatchers.always(), Arrays.asList(credentials)); }
/** * Adds supplied credentials to the model. * * @param credentials the credentials. * @return {@code this} for method chaining. * @deprecated prefer using the {@link #include(Item, Class)} or {@link #includeAs(Authentication, Item, Class)} * methods to build the list box contents in order to allow credentials providers to not have to instantiate * a full credential instance where those credential providers store the secrets external from Jenkins. */ @Deprecated @NonNull public AbstractIdCredentialsListBoxModel<T, C> withAll(@NonNull Iterator<? extends C> credentials) { return withMatching(CredentialsMatchers.always(), credentials); }
/** * Adds supplied credentials to the model. * * @param credentials the credentials. * @return {@code this} for method chaining. * @deprecated prefer using the {@link #include(Item, Class)} or {@link #includeAs(Authentication, Item, Class)} * methods to build the list box contents in order to allow credentials providers to not have to instantiate * a full credential instance where those credential providers store the secrets external from Jenkins. */ @Deprecated @NonNull public AbstractIdCredentialsListBoxModel<T, C> withAll(@NonNull Iterator<? extends C> credentials) { return withMatching(CredentialsMatchers.always(), credentials); }
public ListBoxModel doFillCredentialsIdItems() { return new StandardListBoxModel() .withEmptySelection() .withMatching( CredentialsMatchers.always(), CredentialsProvider.lookupCredentials(AmazonWebServicesCredentials.class, Jenkins.getInstance(), ACL.SYSTEM, Collections.emptyList())); } }
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); }
public static ListBoxModel doFillCredentialsIdItems(ItemGroup context) { return new StandardListBoxModel() .withEmptySelection() .withMatching( CredentialsMatchers.always(), CredentialsProvider.lookupCredentials(AmazonWebServicesCredentials.class, context, ACL.SYSTEM, Collections.EMPTY_LIST)); } }
/** * Adds the ids of the specified credential type that are available to the specified context as the current * authentication with the specified domain requirements. * * @param context the context to add credentials from. * @param type the base class of the credentials to add. * @param domainRequirements the domain requirements. * @return {@code this} for method chaining. * @see CredentialsProvider#listCredentials(Class, Item, Authentication, List, CredentialsMatcher) * @since 2.1.0 */ public AbstractIdCredentialsListBoxModel<T, C> include(@Nullable Item context, @NonNull Class<? extends C> type, @NonNull List<DomainRequirement> domainRequirements) { return includeMatching(context, type, domainRequirements, CredentialsMatchers.always()); }
/** * Adds the ids of the specified credential type that are available to the specified context as the current * authentication with the specified domain requirements. * * @param context the context to add credentials from. * @param type the base class of the credentials to add. * @param domainRequirements the domain requirements. * @return {@code this} for method chaining. * @see CredentialsProvider#listCredentials(Class, Item, Authentication, List, CredentialsMatcher) * @since 2.1.0 */ public AbstractIdCredentialsListBoxModel<T, C> include(@Nullable Item context, @NonNull Class<? extends C> type, @NonNull List<DomainRequirement> domainRequirements) { return includeMatching(context, type, domainRequirements, CredentialsMatchers.always()); }
/** * Adds the ids of the specified credential type that are available to the specified context as the current * authentication with the specified domain requirements. * * @param context the context to add credentials from. * @param type the base class of the credentials to add. * @param domainRequirements the domain requirements. * @return {@code this} for method chaining. * @see CredentialsProvider#listCredentials(Class, ItemGroup, Authentication, List, CredentialsMatcher) * @since 2.1.0 */ public AbstractIdCredentialsListBoxModel<T, C> include(@NonNull ItemGroup context, @NonNull Class<? extends C> type, @NonNull List<DomainRequirement> domainRequirements) { return includeMatching(context, type, domainRequirements, CredentialsMatchers.always()); }
/** * Adds the ids of the specified credential type that are available to the specified context as the current * authentication with the specified domain requirements. * * @param context the context to add credentials from. * @param type the base class of the credentials to add. * @param domainRequirements the domain requirements. * @return {@code this} for method chaining. * @see CredentialsProvider#listCredentials(Class, ItemGroup, Authentication, List, CredentialsMatcher) * @since 2.1.0 */ public AbstractIdCredentialsListBoxModel<T, C> include(@NonNull ItemGroup context, @NonNull Class<? extends C> type, @NonNull List<DomainRequirement> domainRequirements) { return includeMatching(context, type, domainRequirements, CredentialsMatchers.always()); }
@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() ); } }
@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() ); }
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(
/** * Adds the ids of the specified credential type that are available to the specified context as the specified * authentication with the specified domain requirements. * * @param authentication the authentication to search with * @param context the context to add credentials from. * @param type the base class of the credentials to add. * @param domainRequirements the domain requirements. * @return {@code this} for method chaining. * @see CredentialsProvider#listCredentials(Class, Item, Authentication, List, CredentialsMatcher) * @since 2.1.0 */ public AbstractIdCredentialsListBoxModel<T, C> includeAs(@NonNull Authentication authentication, @Nullable Item context, @NonNull Class<? extends C> type, @NonNull List<DomainRequirement> domainRequirements) { return includeMatchingAs(authentication, context, type, domainRequirements, CredentialsMatchers.always()); }
/** * {@inheritDoc} */ @NonNull @Override public <C extends Credentials> List<C> getCredentials(@NonNull Class<C> type, @Nullable ItemGroup itemGroup, @Nullable Authentication authentication, @NonNull List<DomainRequirement> domainRequirements) { if (ACL.SYSTEM.equals(authentication)) { CredentialsMatcher matcher = Jenkins.getInstance() == itemGroup ? always() : not(withScope(SYSTEM)); return DomainCredentials.getCredentials(SystemCredentialsProvider.getInstance() .getDomainCredentialsMap(), type, domainRequirements, matcher); } return new ArrayList<C>(); }
/** * {@inheritDoc} */ @NonNull @Override public <C extends Credentials> List<C> getCredentials(@NonNull Class<C> type, @Nullable ItemGroup itemGroup, @Nullable Authentication authentication, @NonNull List<DomainRequirement> domainRequirements) { if (ACL.SYSTEM.equals(authentication)) { CredentialsMatcher matcher = Jenkins.getInstance() == itemGroup ? always() : not(withScope(SYSTEM)); return DomainCredentials.getCredentials(SystemCredentialsProvider.getInstance() .getDomainCredentialsMap(), type, domainRequirements, matcher); } return new ArrayList<C>(); }
@RequirePOST public ListBoxModel doFillCredentialsIdItems(@AncestorInPath ItemGroup context) { AccessControlled ac = (context instanceof AccessControlled ? (AccessControlled) context : Jenkins.getInstance()); if (!ac.hasPermission(Jenkins.ADMINISTER)) { return new ListBoxModel(); } List<StandardCredentials> credentials = CredentialsProvider.lookupCredentials(StandardCredentials.class, context, ACL.SYSTEM, Collections.emptyList()); return new CredentialsListBoxModel() .includeEmptyValue() .withMatching(CredentialsMatchers.always(), credentials); }