本文整理了Java中com.cloudbees.plugins.credentials.CredentialsProvider.listCredentials()
方法的一些代码示例,展示了CredentialsProvider.listCredentials()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CredentialsProvider.listCredentials()
方法的具体详情如下:
包路径:com.cloudbees.plugins.credentials.CredentialsProvider
类名称:CredentialsProvider
方法名:listCredentials
[英]Returns a ListBoxModel of all credentials which are available to the specified Authenticationfor use by the specified Item.
[中]返回可用于指定身份验证以供指定项使用的所有凭据的ListBoxModel。
代码示例来源:origin: org.jenkins-ci.plugins/ssh-slaves
public FormValidation doCheckCredentialsId(@AncestorInPath ItemGroup context,
@QueryParameter String value) {
AccessControlled _context =
(context instanceof AccessControlled ? (AccessControlled) context : Jenkins.getInstance());
if (_context == null || !_context.hasPermission(Computer.CONFIGURE)) {
return FormValidation.ok(); // no need to alarm a user that cannot configure
}
for (ListBoxModel.Option o : CredentialsProvider.listCredentials(StandardUsernameCredentials.class, context, ACL.SYSTEM,
Collections.<DomainRequirement>singletonList(SSHLauncher.SSH_SCHEME),
SSHAuthenticator.matcher(Connection.class))) {
if (StringUtils.equals(value, o.value)) {
return FormValidation.ok();
}
}
return FormValidation.error(Messages.SSHLauncher_SelectedCredentialsMissing());
}
代码示例来源:origin: jenkinsci/ssh-slaves-plugin
public FormValidation doCheckCredentialsId(@AncestorInPath ItemGroup context,
@QueryParameter String value) {
AccessControlled _context =
(context instanceof AccessControlled ? (AccessControlled) context : Jenkins.getInstance());
if (_context == null || !_context.hasPermission(Computer.CONFIGURE)) {
return FormValidation.ok(); // no need to alarm a user that cannot configure
}
for (ListBoxModel.Option o : CredentialsProvider.listCredentials(StandardUsernameCredentials.class, context, ACL.SYSTEM,
Collections.singletonList(SSHLauncher.SSH_SCHEME),
SSHAuthenticator.matcher(Connection.class))) {
if (StringUtils.equals(value, o.value)) {
return FormValidation.ok();
}
}
return FormValidation.error(Messages.SSHLauncher_SelectedCredentialsMissing());
}
代码示例来源:origin: org.jenkins-ci.plugins/ssh-slaves
public FormValidation doCheckCredentialsId(@AncestorInPath ItemGroup context,
@QueryParameter String host,
@QueryParameter String port,
@QueryParameter String value) {
AccessControlled _context =
(context instanceof AccessControlled ? (AccessControlled) context : Jenkins.getInstance());
if (_context == null || !_context.hasPermission(Computer.CONFIGURE)) {
return FormValidation.ok(); // no need to alarm a user that cannot configure
}
try {
int portValue = Integer.parseInt(port);
for (ListBoxModel.Option o : CredentialsProvider
.listCredentials(StandardUsernameCredentials.class, context, ACL.SYSTEM,
Collections.<DomainRequirement>singletonList(
new HostnamePortRequirement(host, portValue)
),
SSHAuthenticator.matcher(Connection.class))) {
if (StringUtils.equals(value, o.value)) {
return FormValidation.ok();
}
}
} catch (NumberFormatException e) {
return FormValidation.warning(e, Messages.SSHLauncher_PortNotANumber());
}
return FormValidation.error(Messages.SSHLauncher_SelectedCredentialsMissing());
}
代码示例来源:origin: jenkinsci/ssh-slaves-plugin
public FormValidation doCheckCredentialsId(@AncestorInPath ItemGroup context,
@AncestorInPath AccessControlled _context,
@QueryParameter String host,
@QueryParameter String port,
@QueryParameter String value) {
Jenkins jenkins = Jenkins.getInstance();
if ((_context == jenkins && !jenkins.hasPermission(Computer.CREATE)) || (_context != jenkins && !_context.hasPermission(Computer.CONFIGURE))) {
return FormValidation.ok(); // no need to alarm a user that cannot configure
}
try {
int portValue = Integer.parseInt(port);
for (ListBoxModel.Option o : CredentialsProvider
.listCredentials(StandardUsernameCredentials.class, context, ACL.SYSTEM,
Collections.singletonList(
new HostnamePortRequirement(host, portValue)
),
SSHAuthenticator.matcher(Connection.class))) {
if (StringUtils.equals(value, o.value)) {
return FormValidation.ok();
}
}
} catch (NumberFormatException e) {
return FormValidation.warning(e, Messages.SSHLauncher_PortNotANumber());
}
return FormValidation.error(Messages.SSHLauncher_SelectedCredentialsMissing());
}
代码示例来源:origin: jenkinsci/nodejs-plugin
public FormValidation doCheckCredentialsId(@CheckForNull @AncestorInPath Item item,
@QueryParameter String credentialsId, @QueryParameter String serverUrl) {
if (item == null) {
if (!Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER)) {
return FormValidation.ok();
}
} else if (!item.hasPermission(Item.EXTENDED_READ) && !item.hasPermission(CredentialsProvider.USE_ITEM)) {
return FormValidation.ok();
}
if (StringUtils.isBlank(credentialsId)) {
return FormValidation.warning(Messages.NPMRegistry_DescriptorImpl_emptyCredentialsId());
}
List<DomainRequirement> domainRequirement = URIRequirementBuilder.fromUri(serverUrl).build();
if (CredentialsProvider.listCredentials(StandardUsernameCredentials.class, item, getAuthentication(item),
domainRequirement, CredentialsMatchers.withId(credentialsId)).isEmpty()) {
return FormValidation.error(Messages.NPMRegistry_DescriptorImpl_invalidCredentialsId());
}
return FormValidation.ok();
}
代码示例来源:origin: org.jenkins-ci.plugins/git
.listCredentials(StandardUsernameCredentials.class, project, project instanceof Queue.Task
? Tasks.getAuthenticationOf((Queue.Task) project)
: ACL.SYSTEM,
代码示例来源:origin: org.jenkins-ci.plugins/git
for (ListBoxModel.Option o : CredentialsProvider.listCredentials(
StandardUsernameCredentials.class,
context,
代码示例来源:origin: org.jenkins-ci.plugins/credentials
return listCredentials(type, Jenkins.getInstance(), authentication, domainRequirements, matcher);
return listCredentials(type, (ItemGroup) item, authentication, domainRequirements, matcher);
LOGGER.log(Level.FINE, "Listing legacy credentials of type {0} identified by resolver {1}",
new Object[]{type, resolver});
return listCredentials((Class) resolver.getFromClass(), item, authentication,
domainRequirements, matcher);
代码示例来源:origin: jenkinsci/gitea-plugin
return FormValidation.ok();
if (CredentialsProvider.listCredentials(
StandardCredentials.class,
context,
代码示例来源:origin: jenkinsci/gitea-plugin
return FormValidation.ok();
if (CredentialsProvider.listCredentials(
StandardCredentials.class,
context,
代码示例来源:origin: jenkinsci/credentials-plugin
return listCredentials(type, Jenkins.getInstance(), authentication, domainRequirements, matcher);
return listCredentials(type, (ItemGroup) item, authentication, domainRequirements, matcher);
LOGGER.log(Level.FINE, "Listing legacy credentials of type {0} identified by resolver {1}",
new Object[]{type, resolver});
return listCredentials((Class) resolver.getFromClass(), item, authentication,
domainRequirements, matcher);
代码示例来源:origin: org.jenkins-ci.plugins/credentials
/**
* Adds the ids of the specified credential type that are available to the specified context as the specified
* authentication with the specified domain requirements and match the specified filter.
*
* @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.
* @param matcher the filter to apply to the credentials.
* @return {@code this} for method chaining.
* @see CredentialsProvider#listCredentials(Class, Item, Authentication, List, CredentialsMatcher)
* @since 2.1.0
*/
public AbstractIdCredentialsListBoxModel<T, C> includeMatchingAs(@NonNull Authentication authentication,
@Nullable Item context,
@NonNull Class<? extends C> type,
@NonNull
List<DomainRequirement> domainRequirements,
@NonNull CredentialsMatcher matcher) {
addMissing(CredentialsProvider.listCredentials(type, context, authentication, domainRequirements, matcher));
return this;
}
代码示例来源:origin: org.jenkins-ci.plugins/credentials
LOGGER.log(Level.FINE, "Listing legacy credentials of type {0} identified by resolver {1}",
new Object[]{type, resolver});
return listCredentials((Class) resolver.getFromClass(), itemGroup, authentication, domainRequirements,
matcher);
代码示例来源:origin: jenkinsci/credentials-plugin
LOGGER.log(Level.FINE, "Listing legacy credentials of type {0} identified by resolver {1}",
new Object[]{type, resolver});
return listCredentials((Class) resolver.getFromClass(), itemGroup, authentication, domainRequirements,
matcher);
代码示例来源:origin: jenkinsci/credentials-plugin
/**
* Adds the ids of the specified credential type that are available to the specified context as the specified
* authentication with the specified domain requirements and match the specified filter.
*
* @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.
* @param matcher the filter to apply to the credentials.
* @return {@code this} for method chaining.
* @see CredentialsProvider#listCredentials(Class, Item, Authentication, List, CredentialsMatcher)
* @since 2.1.0
*/
public AbstractIdCredentialsListBoxModel<T, C> includeMatchingAs(@NonNull Authentication authentication,
@Nullable Item context,
@NonNull Class<? extends C> type,
@NonNull
List<DomainRequirement> domainRequirements,
@NonNull CredentialsMatcher matcher) {
addMissing(CredentialsProvider.listCredentials(type, context, authentication, domainRequirements, matcher));
return this;
}
代码示例来源:origin: jenkinsci/credentials-plugin
/**
* Adds the ids of the specified credential type that are available to the specified context as the specified
* authentication with the specified domain requirements and match the specified filter.
*
* @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.
* @param matcher the filter to apply to the credentials.
* @return {@code this} for method chaining.
* @see CredentialsProvider#listCredentials(Class, ItemGroup, Authentication, List, CredentialsMatcher)
* @since 2.1.0
*/
public AbstractIdCredentialsListBoxModel<T, C> includeMatchingAs(@NonNull Authentication authentication,
@NonNull ItemGroup context,
@NonNull Class<? extends C> type,
@NonNull
List<DomainRequirement> domainRequirements,
@NonNull CredentialsMatcher matcher) {
addMissing(CredentialsProvider.listCredentials(type, context, authentication, domainRequirements, matcher));
return this;
}
代码示例来源:origin: org.jenkins-ci.plugins/credentials
/**
* Adds the ids of the specified credential type that are available to the specified context as the specified
* authentication with the specified domain requirements and match the specified filter.
*
* @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.
* @param matcher the filter to apply to the credentials.
* @return {@code this} for method chaining.
* @see CredentialsProvider#listCredentials(Class, ItemGroup, Authentication, List, CredentialsMatcher)
* @since 2.1.0
*/
public AbstractIdCredentialsListBoxModel<T, C> includeMatchingAs(@NonNull Authentication authentication,
@NonNull ItemGroup context,
@NonNull Class<? extends C> type,
@NonNull
List<DomainRequirement> domainRequirements,
@NonNull CredentialsMatcher matcher) {
addMissing(CredentialsProvider.listCredentials(type, context, authentication, domainRequirements, matcher));
return this;
}
代码示例来源:origin: jenkinsci/cloudbees-folder-plugin
@Test
public void credentialsListableAtFolderScope() throws Exception {
Folder f = createFolder();
ListBoxModel asGroup =
CredentialsProvider.listCredentials(StandardUsernamePasswordCredentials.class, (ItemGroup) f,
ACL.SYSTEM, Collections.emptyList(), CredentialsMatchers.always());
ListBoxModel asItem =
CredentialsProvider.listCredentials(StandardUsernamePasswordCredentials.class, (Item) f,
ACL.SYSTEM, Collections.emptyList(), CredentialsMatchers.always());
assertThat(asGroup, is(asItem));
assertThat(asGroup.size(), is(0));
assertThat(asItem.size(), is(0));
CredentialsStore folderStore = getFolderStore(f);
UsernamePasswordCredentialsImpl credentials =
new UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL, "test-id", "description", "test-user",
"secret");
folderStore.addCredentials(Domain.global(), credentials);
asGroup = CredentialsProvider.listCredentials(StandardUsernamePasswordCredentials.class, (ItemGroup) f,
ACL.SYSTEM, Collections.emptyList(), CredentialsMatchers.always());
asItem = CredentialsProvider.listCredentials(StandardUsernamePasswordCredentials.class, (Item) f,
ACL.SYSTEM, Collections.emptyList(), CredentialsMatchers.always());
assertThat(asGroup.size(), is(1));
assertThat(asGroup.get(0).value, is("test-id"));
assertThat(asItem.size(), is(1));
assertThat(asItem.get(0).value, is("test-id"));
}
内容来源于网络,如有侵权,请联系作者删除!