/** * Adds the ids of the specified credential type that are available to the specified context as the specified * authentication. * * @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. * @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) { return includeAs(authentication, context, type, Collections.<DomainRequirement>emptyList()); }
/** * Adds the ids of the specified credential type that are available to the specified context as the specified * authentication. * * @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. * @return {@code this} for method chaining. * @see CredentialsProvider#listCredentials(Class, ItemGroup, Authentication, List, CredentialsMatcher) * @since 2.1.0 */ public AbstractIdCredentialsListBoxModel<T, C> includeAs(@NonNull Authentication authentication, @NonNull ItemGroup context, @NonNull Class<? extends C> type) { return includeAs(authentication, context, type, Collections.<DomainRequirement>emptyList()); }
/** * Adds the ids of the specified credential type that are available to the specified context as the specified * authentication. * * @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. * @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) { return includeAs(authentication, context, type, Collections.<DomainRequirement>emptyList()); }
/** * Adds the ids of the specified credential type that are available to the specified context as the specified * authentication. * * @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. * @return {@code this} for method chaining. * @see CredentialsProvider#listCredentials(Class, ItemGroup, Authentication, List, CredentialsMatcher) * @since 2.1.0 */ public AbstractIdCredentialsListBoxModel<T, C> includeAs(@NonNull Authentication authentication, @NonNull ItemGroup context, @NonNull Class<? extends C> type) { return includeAs(authentication, context, type, Collections.<DomainRequirement>emptyList()); }
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() ); } }
public static ListBoxModel fillAuthenticationItems(Item project, String url) { if (project == null || !project.hasPermission(Item.CONFIGURE)) { return new StandardListBoxModel(); } List<Option> options = new ArrayList<>(); for (BasicDigestAuthentication basic : HttpRequestGlobalConfig.get().getBasicDigestAuthentications()) { options.add(new Option("(deprecated - use Jenkins Credentials) " + basic.getKeyName(), basic.getKeyName())); } for (FormAuthentication formAuthentication : HttpRequestGlobalConfig.get().getFormAuthentications()) { options.add(new Option(formAuthentication.getKeyName())); } AbstractIdCredentialsListBoxModel<StandardListBoxModel, StandardCredentials> items = new StandardListBoxModel() .includeEmptyValue() .includeAs(ACL.SYSTEM, project, StandardUsernamePasswordCredentials.class, URIRequirementBuilder.fromUri(url).build()); items.addMissing(options); return items; }
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); }