本文整理了Java中com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials()
方法的一些代码示例,展示了CredentialsProvider.lookupCredentials()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CredentialsProvider.lookupCredentials()
方法的具体详情如下:
包路径:com.cloudbees.plugins.credentials.CredentialsProvider
类名称:CredentialsProvider
方法名:lookupCredentials
[英]Returns all credentials which are available to the ACL#SYSTEM Authenticationwithin the jenkins.model.Jenkins#getInstance().
[中]返回jenkins中ACL#系统身份验证可用的所有凭据。模型Jenkins#getInstance()。
代码示例来源:origin: jenkinsci/gitlab-plugin
private String getApiToken(String apiTokenId) {
StandardCredentials credentials = CredentialsMatchers.firstOrNull(
lookupCredentials(StandardCredentials.class, (Item) null, ACL.SYSTEM, new ArrayList<DomainRequirement>()),
CredentialsMatchers.withId(apiTokenId));
if (credentials != null) {
if (credentials instanceof GitLabApiToken) {
return ((GitLabApiToken) credentials).getApiToken().getPlainText();
}
if (credentials instanceof StringCredentials) {
return ((StringCredentials) credentials).getSecret().getPlainText();
}
}
throw new IllegalStateException("No credentials found for credentialsId: " + apiTokenId);
}
代码示例来源:origin: jenkinsci/tfs-plugin
public static List<StandardUsernamePasswordCredentials> findCredentials(final String hostName, ItemGroup own) {
final HostnameRequirement requirement = new HostnameRequirement(hostName);
final List<StandardUsernamePasswordCredentials> matches =
CredentialsProvider.lookupCredentials(
StandardUsernamePasswordCredentials.class,
own,
ACL.SYSTEM,
requirement
);
return matches;
}
代码示例来源:origin: jenkinsci/tfs-plugin
public static List<StandardUsernamePasswordCredentials> findCredentials(final String hostName, Item own) {
final HostnameRequirement requirement = new HostnameRequirement(hostName);
final List<StandardUsernamePasswordCredentials> matches =
CredentialsProvider.lookupCredentials(
StandardUsernamePasswordCredentials.class,
own,
ACL.SYSTEM,
requirement
);
return matches;
}
代码示例来源:origin: org.jenkins-ci.plugins/aws-credentials
@CheckForNull
public static AmazonWebServicesCredentials getCredentials(@Nullable String credentialsId, ItemGroup context) {
if (StringUtils.isBlank(credentialsId)) {
return null;
}
return (AmazonWebServicesCredentials) CredentialsMatchers.firstOrNull(
CredentialsProvider.lookupCredentials(AmazonWebServicesCredentials.class, context,
ACL.SYSTEM, Collections.EMPTY_LIST),
CredentialsMatchers.withId(credentialsId));
}
代码示例来源:origin: jenkinsci/docker-plugin
private static SSLConfig toSSlConfig(String credentialsId) {
if (credentialsId == null) return null;
DockerServerCredentials credentials = firstOrNull(
lookupCredentials(
DockerServerCredentials.class,
Jenkins.getInstance(),
ACL.SYSTEM,
Collections.<DomainRequirement>emptyList()),
withId(credentialsId));
return credentials == null ? null :
new DockerServerCredentialsSSLConfig(credentials);
}
代码示例来源:origin: org.jenkins-ci.plugins/ssh-slaves
public static StandardUsernameCredentials lookupSystemCredentials(String credentialsId) {
return CredentialsMatchers.firstOrNull(
CredentialsProvider
.lookupCredentials(StandardUsernameCredentials.class, Jenkins.getInstance(), ACL.SYSTEM,
SSH_SCHEME),
CredentialsMatchers.withId(credentialsId)
);
}
代码示例来源:origin: jenkinsci/ec2-plugin
@CheckForNull
private static AmazonWebServicesCredentials getCredentials(@Nullable String credentialsId) {
if (StringUtils.isBlank(credentialsId)) {
return null;
}
return (AmazonWebServicesCredentials) CredentialsMatchers.firstOrNull(
CredentialsProvider.lookupCredentials(AmazonWebServicesCredentials.class, Jenkins.getInstance(),
ACL.SYSTEM, Collections.emptyList()),
CredentialsMatchers.withId(credentialsId));
}
代码示例来源:origin: jenkinsci/docker-custom-build-environment-plugin
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()
)
);
}
代码示例来源:origin: Argelbargel/gitlab-branch-source-plugin
private <T extends StandardCredentials> T credentials(AbstractGitSCMSource source, @Nonnull Class<T> type) {
String credentialsId = source.getCredentialsId();
if (credentialsId == null) {
return null;
}
return CredentialsMatchers.firstOrNull(CredentialsProvider.lookupCredentials(
type, source.getOwner(), ACL.SYSTEM,
Collections.<DomainRequirement>emptyList()), CredentialsMatchers.allOf(
CredentialsMatchers.withId(credentialsId),
CredentialsMatchers.instanceOf(type)));
}
}
代码示例来源:origin: jenkinsci/ec2-plugin
public ListBoxModel doFillCredentialsIdItems() {
return new StandardListBoxModel()
.withEmptySelection()
.withMatching(
CredentialsMatchers.always(),
CredentialsProvider.lookupCredentials(AmazonWebServicesCredentials.class,
Jenkins.getInstance(),
ACL.SYSTEM,
Collections.emptyList()));
}
}
代码示例来源:origin: KostyaSha/yet-another-docker-plugin
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);
}
代码示例来源:origin: KostyaSha/yet-another-docker-plugin
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath ItemGroup context) {
List<DockerRegistryAuthCredentials> credentials =
CredentialsProvider.lookupCredentials(DockerRegistryAuthCredentials.class, context, ACL.SYSTEM,
Collections.emptyList());
return new StandardListBoxModel().withEmptySelection()
.withMatching(CredentialsMatchers.instanceOf(DockerRegistryAuthCredentials.class), credentials);
}
}
代码示例来源:origin: org.jenkins-ci.plugins/ssh-slaves
public static StandardUsernameCredentials lookupSystemCredentials(String credentialsId, String host, int port) {
return CredentialsMatchers.firstOrNull(
CredentialsProvider
.lookupCredentials(StandardUsernameCredentials.class, Jenkins.getInstance(), ACL.SYSTEM,
SSH_SCHEME, new HostnamePortRequirement(host, port)),
CredentialsMatchers.withId(credentialsId)
);
}
代码示例来源:origin: org.jenkins-ci.plugins/aws-credentials
public static ListBoxModel doFillCredentialsIdItems(ItemGroup context) {
return new StandardListBoxModel()
.withEmptySelection()
.withMatching(
CredentialsMatchers.always(),
CredentialsProvider.lookupCredentials(AmazonWebServicesCredentials.class,
context,
ACL.SYSTEM,
Collections.EMPTY_LIST));
}
}
代码示例来源:origin: org.jenkins-ci.plugins/git
private static StandardCredentials lookupCredentials(@CheckForNull Item project, String credentialId, String uri) {
return (credentialId == null) ? null : CredentialsMatchers.firstOrNull(
CredentialsProvider.lookupCredentials(StandardCredentials.class, project, ACL.SYSTEM,
GitURIRequirementsBuilder.fromUri(uri).build()),
CredentialsMatchers.withId(credentialId));
}
代码示例来源:origin: jenkinsci/mesos-plugin
@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)
);
}
代码示例来源:origin: jenkinsci/jclouds-plugin
public String getJenkinsPrivateKey() {
if (isNullOrEmpty(credentialsId)) {
return getCloud().getGlobalPrivateKey();
}
SSHUserPrivateKey supk = CredentialsMatchers.firstOrNull(
CredentialsProvider.lookupCredentials(SSHUserPrivateKey.class, Jenkins.getInstance(), ACL.SYSTEM,
Collections.<DomainRequirement>emptyList()),
CredentialsMatchers.withId(credentialsId));
return CredentialsHelper.getPrivateKey(supk);
}
代码示例来源:origin: jenkinsci/bitbucket-build-status-notifier-plugin
public ListBoxModel doFillGlobalCredentialsIdItems() {
Job owner = null;
List<DomainRequirement> apiEndpoint = URIRequirementBuilder.fromUri(BitbucketApi.OAUTH_ENDPOINT).build();
return new StandardUsernameListBoxModel()
.withEmptySelection()
.withAll(CredentialsProvider.lookupCredentials(StandardUsernamePasswordCredentials.class, owner, null, apiEndpoint));
}
代码示例来源:origin: jenkinsci/docker-plugin
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath ItemGroup context) {
AccessControlled ac = (context instanceof AccessControlled ? (AccessControlled) context : Jenkins.getInstance());
if (!ac.hasPermission(Jenkins.ADMINISTER)) {
return new ListBoxModel();
}
return new SSHUserListBoxModel().withMatching(SSHAuthenticator.matcher(Connection.class),
CredentialsProvider.lookupCredentials(StandardUsernameCredentials.class, context,
ACL.SYSTEM, SSHLauncher.SSH_SCHEME));
}
}
代码示例来源:origin: jenkinsci/subversion-plugin
private SVNRepositoryView openSession(SVNURL repoURL) throws SVNException, IOException {
return new SVNRepositoryView(repoURL, credentialsId == null ? null : CredentialsMatchers
.firstOrNull(CredentialsProvider.lookupCredentials(StandardCredentials.class, getOwner(),
ACL.SYSTEM, URIRequirementBuilder.fromUri(repoURL.toString()).build()),
CredentialsMatchers.allOf(CredentialsMatchers.withId(credentialsId),
CredentialsMatchers.anyOf(CredentialsMatchers.instanceOf(StandardCredentials.class),
CredentialsMatchers.instanceOf(SSHUserPrivateKey.class)))));
}
内容来源于网络,如有侵权,请联系作者删除!