当前位置: 首页>>代码示例>>Java>>正文


Java StandardCredentials类代码示例

本文整理汇总了Java中com.cloudbees.plugins.credentials.common.StandardCredentials的典型用法代码示例。如果您正苦于以下问题:Java StandardCredentials类的具体用法?Java StandardCredentials怎么用?Java StandardCredentials使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StandardCredentials类属于com.cloudbees.plugins.credentials.common包,在下文中一共展示了StandardCredentials类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doFillCredentialsIdItems

import com.cloudbees.plugins.credentials.common.StandardCredentials; //导入依赖的package包/类
/**
 * Stapler form completion.
 *
 * @param serverUrl the server URL.
 * @return the available credentials.
 */
@Restricted(NoExternalUse.class) // stapler
@SuppressWarnings("unused")
public ListBoxModel doFillCredentialsIdItems(@QueryParameter String serverUrl) {
    Jenkins.getActiveInstance().checkPermission(Jenkins.ADMINISTER);
    StandardListBoxModel result = new StandardListBoxModel();
    serverUrl = GiteaServers.normalizeServerUrl(serverUrl);
    result.includeMatchingAs(
            ACL.SYSTEM,
            Jenkins.getActiveInstance(),
            StandardCredentials.class,
            URIRequirementBuilder.fromUri(serverUrl).build(),
            AuthenticationTokens.matcher(GiteaAuth.class)
    );
    return result;
}
 
开发者ID:jenkinsci,项目名称:gitea-plugin,代码行数:22,代码来源:GiteaServer.java

示例2: getCredentials

import com.cloudbees.plugins.credentials.common.StandardCredentials; //导入依赖的package包/类
/**
 * Get the {@link StandardCredentials}.
 *
 * @return the credentials matching the {@link #credentialsId} or {@code null} is {@code #credentialsId} is blank
 * @throws AbortException if no {@link StandardCredentials} matching {@link #credentialsId} is found
 */
private StandardCredentials getCredentials(Run<?, ?> build) throws AbortException {
    if (StringUtils.isBlank(credentialsId)) {
        return null;
    }
    StandardCredentials result = CredentialsProvider.findCredentialById(
            credentialsId,
            StandardCredentials.class,
            build,
            Collections.<DomainRequirement>emptyList());

    if (result == null) {
        throw new AbortException("No credentials found for id \"" + credentialsId + "\"");
    }
    return result;
}
 
开发者ID:maxlaverse,项目名称:kubernetes-cli-plugin,代码行数:22,代码来源:KubeConfigWriter.java

示例3: doFillCredentialsIDItems

import com.cloudbees.plugins.credentials.common.StandardCredentials; //导入依赖的package包/类
public static ListBoxModel doFillCredentialsIDItems(@AncestorInPath Jenkins context) {
    if (context == null || !context.hasPermission(Item.CONFIGURE)) {
        return new StandardListBoxModel();
    }

    List<DomainRequirement> domainRequirements = new ArrayList<DomainRequirement>();
    return new StandardListBoxModel()
            .withEmptySelection()
            .withMatching(
                    CredentialsMatchers.anyOf(
                            CredentialsMatchers.instanceOf(ConduitCredentials.class)),
                    CredentialsProvider.lookupCredentials(
                            StandardCredentials.class,
                            context,
                            ACL.SYSTEM,
                            domainRequirements));
}
 
开发者ID:uber,项目名称:phabricator-jenkins-plugin,代码行数:18,代码来源:ConduitCredentialsDescriptor.java

示例4: doFillCredentialsIdItems

import com.cloudbees.plugins.credentials.common.StandardCredentials; //导入依赖的package包/类
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item item) {
    if (item == null && !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER) ||
        item != null && !item.hasPermission(Item.EXTENDED_READ)) {
        return new StandardListBoxModel();
    }
    // TODO may also need to specify a specific authentication and domain requirements
    return new StandardListBoxModel()
            .withEmptySelection()
            .withMatching(AuthenticationTokens.matcher(DockerRegistryToken.class),
                    CredentialsProvider.lookupCredentials(
                            StandardCredentials.class,
                            item,
                            null,
                            Collections.<DomainRequirement>emptyList()
                    )
            );
}
 
开发者ID:jenkinsci,项目名称:docker-commons-plugin,代码行数:18,代码来源:DockerRegistryEndpoint.java

示例5: doFillCredentialsIdItems

import com.cloudbees.plugins.credentials.common.StandardCredentials; //导入依赖的package包/类
/**
 * Stapler helper method.
 *
 * @param context
 *            the context.
 * @param remoteBase
 *            the remote base.
 * @return list box model.
 * @throws URISyntaxException 
 */
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item context, @QueryParameter String serverAPIUrl) throws URISyntaxException {
    List<DomainRequirement> domainRequirements = URIRequirementBuilder.fromUri(serverAPIUrl).build();
    
    return new StandardListBoxModel()
            .withEmptySelection()
            .withMatching(
                    CredentialsMatchers.anyOf(
                    CredentialsMatchers.instanceOf(StandardUsernamePasswordCredentials.class),
                    CredentialsMatchers.instanceOf(StringCredentials.class)),
            CredentialsProvider.lookupCredentials(StandardCredentials.class,
                    context,
                    ACL.SYSTEM,
                    domainRequirements)
                    );
}
 
开发者ID:bratchenko,项目名称:jenkins-github-pull-request-comments,代码行数:26,代码来源:GhprcGitHubAuth.java

示例6: lookupCredentials

import com.cloudbees.plugins.credentials.common.StandardCredentials; //导入依赖的package包/类
public static StandardCredentials lookupCredentials(Item context, String credentialId, String uri) {
    String contextName = "(Jenkins.instance)";
    if (context != null) {
        contextName = context.getFullName();
    }
    logger.log(Level.INFO, "Looking up credentials for {0}, using context {1} for url {2}", new Object[] { credentialId, contextName, uri });
    
    List<StandardCredentials> credentials;
    
    if (context == null) {
        credentials = CredentialsProvider.lookupCredentials(StandardCredentials.class, Jenkins.getInstance(), ACL.SYSTEM,
                URIRequirementBuilder.fromUri(uri).build());
    } else {
        credentials = CredentialsProvider.lookupCredentials(StandardCredentials.class, context, ACL.SYSTEM,
                URIRequirementBuilder.fromUri(uri).build());
    }
    
    logger.log(Level.INFO, "Found {0} credentials", new Object[]{credentials.size()});
    
    return (credentialId == null) ? null : CredentialsMatchers.firstOrNull(credentials,
                CredentialsMatchers.withId(credentialId));
}
 
开发者ID:bratchenko,项目名称:jenkins-github-pull-request-comments,代码行数:23,代码来源:Ghprc.java

示例7: createCredentials

import com.cloudbees.plugins.credentials.common.StandardCredentials; //导入依赖的package包/类
private static String createCredentials(String serverAPIUrl, StandardCredentials credentials) throws Exception {
    List<DomainSpecification> specifications = new ArrayList<DomainSpecification>(2);
    
    URI serverUri = new URI(serverAPIUrl);
    
    if (serverUri.getPort() > 0) {
        specifications.add(new HostnamePortSpecification(serverUri.getHost() + ":" + serverUri.getPort(), null));
    } else {
        specifications.add(new HostnameSpecification(serverUri.getHost(), null));
    }
    
    specifications.add(new SchemeSpecification(serverUri.getScheme()));
    String path = serverUri.getPath();
    if (StringUtils.isEmpty(path)) {
        path = "/";
    }
    specifications.add(new PathSpecification(path, null, false));
    
    Domain domain = new Domain(serverUri.getHost(), "Auto generated credentials domain", specifications);
    CredentialsStore provider = new SystemCredentialsProvider.StoreImpl();
    provider.addDomain(domain, credentials);
    return credentials.getId();
}
 
开发者ID:bratchenko,项目名称:jenkins-github-pull-request-comments,代码行数:24,代码来源:Ghprc.java

示例8: getCredentials

import com.cloudbees.plugins.credentials.common.StandardCredentials; //导入依赖的package包/类
/**
 * Get the {@link StandardCredentials}.
 *
 * @return the credentials matching the {@link #credentialsId} or {@code null} is {@code #credentialsId} is blank
 * @throws AbortException if no {@link StandardCredentials} matching {@link #credentialsId} is found
 */
@CheckForNull
private StandardCredentials getCredentials() throws AbortException {
    if (StringUtils.isBlank(credentialsId)) {
        return null;
    }
    StandardCredentials result = CredentialsMatchers.firstOrNull(
            CredentialsProvider.lookupCredentials(StandardCredentials.class,
                    Jenkins.getInstance(), ACL.SYSTEM, Collections.<DomainRequirement>emptyList()),
            CredentialsMatchers.withId(credentialsId)
    );
    if (result == null) {
        throw new AbortException("No credentials found for id \"" + credentialsId + "\"");
    }
    return result;
}
 
开发者ID:carlossg,项目名称:jenkins-kubernetes-plugin,代码行数:22,代码来源:KubectlBuildWrapper.java

示例9: doFillCredentialsIdItems

import com.cloudbees.plugins.credentials.common.StandardCredentials; //导入依赖的package包/类
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item item, @QueryParameter String serverUrl) {
    return new StandardListBoxModel()
            .withEmptySelection()
            .withMatching(
                    CredentialsMatchers.anyOf(
                            CredentialsMatchers.instanceOf(StandardUsernamePasswordCredentials.class),
                            CredentialsMatchers.instanceOf(TokenProducer.class),
                            CredentialsMatchers.instanceOf(StandardCertificateCredentials.class)
                    ),
                    CredentialsProvider.lookupCredentials(
                            StandardCredentials.class,
                            item,
                            null,
                            URIRequirementBuilder.fromUri(serverUrl).build()
                    )
            );

}
 
开发者ID:carlossg,项目名称:jenkins-kubernetes-plugin,代码行数:19,代码来源:KubectlBuildWrapper.java

示例10: doFillCredentialsIdItems

import com.cloudbees.plugins.credentials.common.StandardCredentials; //导入依赖的package包/类
public ListBoxModel doFillCredentialsIdItems(@QueryParameter String serverUrl) {
    return new StandardListBoxModel().withEmptySelection() //
            .withMatching( //
                    CredentialsMatchers.anyOf(
                            CredentialsMatchers.instanceOf(StandardUsernamePasswordCredentials.class),
                            CredentialsMatchers.instanceOf(TokenProducer.class),
                            CredentialsMatchers.instanceOf(
                                    org.jenkinsci.plugins.kubernetes.credentials.TokenProducer.class),
                            CredentialsMatchers.instanceOf(StandardCertificateCredentials.class),
                            CredentialsMatchers.instanceOf(StringCredentials.class)), //
                    CredentialsProvider.lookupCredentials(StandardCredentials.class, //
                            Jenkins.getInstance(), //
                            ACL.SYSTEM, //
                            serverUrl != null ? URIRequirementBuilder.fromUri(serverUrl).build()
                                    : Collections.EMPTY_LIST //
                    ));

}
 
开发者ID:carlossg,项目名称:jenkins-kubernetes-plugin,代码行数:19,代码来源:KubernetesCloud.java

示例11: doFillApiTokenIdItems

import com.cloudbees.plugins.credentials.common.StandardCredentials; //导入依赖的package包/类
public ListBoxModel doFillApiTokenIdItems(@QueryParameter String name, @QueryParameter String url) {
    if (Jenkins.getInstance().hasPermission(Item.CONFIGURE)) {
        AbstractIdCredentialsListBoxModel<StandardListBoxModel, StandardCredentials> options = new StandardListBoxModel()
            .includeEmptyValue()
            .includeMatchingAs(ACL.SYSTEM,
                               Jenkins.getActiveInstance(),
                               StandardCredentials.class,
                               URIRequirementBuilder.fromUri(url).build(),
                               new GitLabCredentialMatcher());
        if (name != null && connectionMap.containsKey(name)) {
            String apiTokenId = connectionMap.get(name).getApiTokenId();
            options.includeCurrentValue(apiTokenId);
            for (ListBoxModel.Option option : options) {
                if (option.value.equals(apiTokenId)) {
                    option.selected = true;
                }
            }
        }
        return options;
    }
    return new StandardListBoxModel();
}
 
开发者ID:jenkinsci,项目名称:gitlab-plugin,代码行数:23,代码来源:GitLabConnectionConfig.java

示例12: fetch

import com.cloudbees.plugins.credentials.common.StandardCredentials; //导入依赖的package包/类
/** {@inheritDoc} */
public void fetch(String remoteName, RefSpec... refspec) throws GitException, InterruptedException {
    listener.getLogger().println(
                                 "Fetching upstream changes"
                                 + (remoteName != null ? " from " + remoteName : ""));

    ArgumentListBuilder args = new ArgumentListBuilder();
    args.add("fetch", "-t");

    if (remoteName == null)
        remoteName = getDefaultRemote();

    String url = getRemoteUrl(remoteName);
    if (url == null)
        throw new GitException("remote." + remoteName + ".url not defined");
    args.add(url);
    if (refspec != null && refspec.length > 0)
        for (RefSpec rs: refspec)
            if (rs != null)
                args.add(rs.toString());


    StandardCredentials cred = credentials.get(url);
    if (cred == null) cred = defaultCredentials;
    launchCommandWithCredentials(args, workspace, cred, url);
}
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:27,代码来源:CliGitAPIImpl.java

示例13: prune

import com.cloudbees.plugins.credentials.common.StandardCredentials; //导入依赖的package包/类
/** {@inheritDoc} */
public void prune(RemoteConfig repository) throws GitException, InterruptedException {
    String repoName = repository.getName();
    String repoUrl = getRemoteUrl(repoName);
    if (repoUrl != null && !repoUrl.isEmpty()) {
        ArgumentListBuilder args = new ArgumentListBuilder();
        args.add("remote", "prune", repoName);

        StandardCredentials cred = credentials.get(repoUrl);
        if (cred == null) cred = defaultCredentials;

        try {
            launchCommandWithCredentials(args, workspace, cred, new URIish(repoUrl));
        } catch (URISyntaxException ex) {
            throw new GitException("Invalid URL " + repoUrl, ex);
        }
    }
}
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:19,代码来源:CliGitAPIImpl.java

示例14: getHeadRev

import com.cloudbees.plugins.credentials.common.StandardCredentials; //导入依赖的package包/类
/** {@inheritDoc} */
public Map<String, ObjectId> getHeadRev(String url) throws GitException, InterruptedException {
    ArgumentListBuilder args = new ArgumentListBuilder("ls-remote");
    args.add("-h");
    args.add(url);

    StandardCredentials cred = credentials.get(url);
    if (cred == null) cred = defaultCredentials;

    String result = launchCommandWithCredentials(args, null, cred, url);

    Map<String, ObjectId> heads = new HashMap<>();
    String[] lines = result.split("\n");
    for (String line : lines) {
        if (line.length() >= 41) {
            heads.put(line.substring(41), ObjectId.fromString(line.substring(0, 40)));
        } else {
            listener.getLogger().println("Unexpected ls-remote output line '" + line + "'");
        }
    }
    return heads;
}
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:23,代码来源:CliGitAPIImpl.java

示例15: push

import com.cloudbees.plugins.credentials.common.StandardCredentials; //导入依赖的package包/类
/** {@inheritDoc} */
@Deprecated
public void push(RemoteConfig repository, String refspec) throws GitException, InterruptedException {
    ArgumentListBuilder args = new ArgumentListBuilder();
    URIish uri = repository.getURIs().get(0);
    String url = uri.toPrivateString();
    StandardCredentials cred = credentials.get(url);
    if (cred == null) cred = defaultCredentials;

    args.add("push", url);

    if (refspec != null)
        args.add(refspec);

    launchCommandWithCredentials(args, workspace, cred, uri);
    // Ignore output for now as there's many different formats
    // That are possible.

}
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:20,代码来源:CliGitAPIImpl.java


注:本文中的com.cloudbees.plugins.credentials.common.StandardCredentials类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。