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


Java StandardUsernamePasswordCredentials类代码示例

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


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

示例1: doFillMirrorgateCredentialsIdItems

import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; //导入依赖的package包/类
public ListBoxModel doFillMirrorgateCredentialsIdItems(
        @AncestorInPath Item item,
        @QueryParameter("mirrorgateCredentialsId") String credentialsId) {

    StandardListBoxModel result = new StandardListBoxModel();
    if (item == null) {
        if (!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER)) {
            return result.includeCurrentValue(credentialsId);
        }
    } else if (!item.hasPermission(Item.EXTENDED_READ)
            && !item.hasPermission(CredentialsProvider.USE_ITEM)) {
        return result.includeCurrentValue(credentialsId);
    }
    return result
            .includeEmptyValue()
            .includeAs(ACL.SYSTEM, item, StandardUsernamePasswordCredentials.class);
}
 
开发者ID:BBVA,项目名称:mirrorgate-jenkins-builds-collector,代码行数:18,代码来源:MirrorGatePublisher.java

示例2: doFillCredentialsIdItems

import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; //导入依赖的package包/类
/**
 * Fills in the Login Credentials selection box with applicable connections.
 * 
 * @param context
 *            filter for login credentials
 * @param credentialsId
 *            existing login credentials; can be null
 * @param project
 *            the Jenkins project
 * 
 * @return login credentials selection
 */
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Jenkins context, @QueryParameter String credentialsId,
		@AncestorInPath Item project)
{
	List<StandardUsernamePasswordCredentials> creds = CredentialsProvider.lookupCredentials(
			StandardUsernamePasswordCredentials.class, project, ACL.SYSTEM,
			Collections.<DomainRequirement> emptyList());

	ListBoxModel model = new ListBoxModel();
	model.add(new Option(StringUtils.EMPTY, StringUtils.EMPTY, false));

	for (StandardUsernamePasswordCredentials c : creds)
	{
		boolean isSelected = false;
		if (credentialsId != null)
		{
			isSelected = credentialsId.matches(c.getId());
		}

		String description = Util.fixEmptyAndTrim(c.getDescription());
		model.add(new Option(c.getUsername() + (description != null ? " (" + description + ')' : StringUtils.EMPTY), //$NON-NLS-1$
				c.getId(), isSelected));
	}

	return model;
}
 
开发者ID:Compuware-Corp,项目名称:CPWR-CodeCoverage,代码行数:38,代码来源:CodeCoverageBuilder.java

示例3: doFillCredentialsIdItems

import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; //导入依赖的package包/类
/**
 * Fills in the Login Credentials selection box with applicable Jenkins credentials.
 * 
 * @param context
 *            filter for credentials
 * @param credentialsId
 *            existing login credentials; can be null
 * @param project
 *            the Jenkins project
 * 
 * @return credential selections
 */
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Jenkins context, @QueryParameter String credentialsId, @AncestorInPath Item project)
{
	List<StandardUsernamePasswordCredentials> creds = CredentialsProvider.lookupCredentials(
			StandardUsernamePasswordCredentials.class, project, ACL.SYSTEM,
			Collections.<DomainRequirement> emptyList());

	StandardListBoxModel model = new StandardListBoxModel();
	model.add(new Option(StringUtils.EMPTY, StringUtils.EMPTY, false));

	for (StandardUsernamePasswordCredentials c : creds)
	{
		boolean isSelected = false;
		if (credentialsId != null)
		{
			isSelected = credentialsId.matches(c.getId());
		}

		String description = Util.fixEmptyAndTrim(c.getDescription());
		model.add(new Option(c.getUsername() + (description != null ? " (" + description + ')' : StringUtils.EMPTY), //$NON-NLS-1$
				c.getId(), isSelected));
	}

	return model;
}
 
开发者ID:jenkinsci,项目名称:compuware-scm-downloader-plugin,代码行数:37,代码来源:PdsConfiguration.java

示例4: getLoginInformation

import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; //导入依赖的package包/类
/**
 * Retrieves login information given a credential ID.
 * 
 * @param project
 *            the Jenkins project
 *
 * @return a Jenkins credential with login information
 */
protected StandardUsernamePasswordCredentials getLoginInformation(Item project)
{
	StandardUsernamePasswordCredentials credential = null;

	List<StandardUsernamePasswordCredentials> credentials = CredentialsProvider.lookupCredentials(
			StandardUsernamePasswordCredentials.class, project, ACL.SYSTEM, Collections.<DomainRequirement> emptyList());

	IdMatcher matcher = new IdMatcher(getCredentialsId());
	for (StandardUsernamePasswordCredentials c : credentials)
	{
		if (matcher.matches(c))
		{
			credential = c;
		}
	}

	return credential;
}
 
开发者ID:jenkinsci,项目名称:compuware-scm-downloader-plugin,代码行数:27,代码来源:CpwrScmConfiguration.java

示例5: getLoginInformation

import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; //导入依赖的package包/类
/**
 * Retrieves login information given a credential ID
 * 
 * @param project
 *            the Jenkins project
 *
 * @return a Jenkins credential with login information
 */
protected StandardUsernamePasswordCredentials getLoginInformation(Item project)
{
	StandardUsernamePasswordCredentials credential = null;

	List<StandardUsernamePasswordCredentials> credentials = CredentialsProvider.lookupCredentials(
			StandardUsernamePasswordCredentials.class, project, ACL.SYSTEM, Collections.<DomainRequirement> emptyList());

	IdMatcher matcher = new IdMatcher(getCredentialsId());
	for (StandardUsernamePasswordCredentials c : credentials)
	{
		if (matcher.matches(c))
		{
			credential = c;
		}
	}

	return credential;
}
 
开发者ID:jenkinsci,项目名称:compuware-scm-downloader-plugin,代码行数:27,代码来源:IspwConfiguration.java

示例6: doFillCredentialsIdItems

import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; //导入依赖的package包/类
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item item, @QueryParameter String credentialsId) {
    StandardListBoxModel result = new StandardListBoxModel();
    if (item == null) {
        if (!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER)) {
            return result.add(credentialsId);
        }
    } else {
        if (!item.hasPermission(Item.EXTENDED_READ)
                && !item.hasPermission(CredentialsProvider.USE_ITEM)) {
            return result.add(credentialsId);
        }
    }

    return result
            .withEmptySelection()
            .withAll(CredentialsProvider.lookupCredentials(StandardUsernamePasswordCredentials.class, item, null, Collections.<DomainRequirement>emptyList()))
            .withMatching(CredentialsMatchers.withId(credentialsId));
}
 
开发者ID:jenkinsci,项目名称:checkmarx-plugin,代码行数:19,代码来源:CxScanBuilder.java

示例7: doFillCredentialsIdItems

import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; //导入依赖的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

示例8: doFillCredentialsIdItems

import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; //导入依赖的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

示例9: doFillCredentialsIdItems

import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; //导入依赖的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

示例10: init

import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; //导入依赖的package包/类
public <T extends ApiClient.HttpClientFactory> void init(ApiClient client, T httpFactory) {
    this.trigger = this.builder.getTrigger();
    
    if (client == null) {                      
        String username = trigger.getUsername();
        String password = trigger.getPassword();            
        StandardUsernamePasswordCredentials credentials = getCredentials(trigger.getCredentialsId());
        if (credentials != null) {
            username = credentials.getUsername();
            password = credentials.getPassword().getPlainText();
        }            
        this.client = new ApiClient(
            username,
            password,
            trigger.getRepositoryOwner(),
            trigger.getRepositoryName(),
            trigger.getCiKey(),
            trigger.getCiName(),
            httpFactory
        );
        
    } else this.client = client;
}
 
开发者ID:nishio-dens,项目名称:bitbucket-pullrequest-builder-plugin,代码行数:24,代码来源:BitbucketRepository.java

示例11: doTestConnection

import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; //导入依赖的package包/类
public FormValidation doTestConnection(@QueryParameter("serverUrl") final String serverUrl,
                                       @QueryParameter("proxyUrl") final String proxyUrl,
                                       @QueryParameter("credentialsId") final String credentialsId
) {
    try {
        if (credentialsId == null || credentialsId.isEmpty()) {
            return FormValidation.error("No credentials specified");
        }
        StandardUsernamePasswordCredentials credentials = XLTestView.lookupSystemCredentials(credentialsId);
        if (credentials == null) {
            return FormValidation.error(String.format("Could not find credential with id '%s'", credentialsId));
        }
        if (serverUrl == null || serverUrl.isEmpty()) {
            return FormValidation.error("No server URL specified");
        }
        // see if we can create a new instance
        XLTestServer srv = XLTestServerFactory.newInstance(serverUrl, proxyUrl, credentials);
        srv.checkConnection();
        return FormValidation.ok("Success");
    } catch (RuntimeException e) {
        return FormValidation.error("Client error : " + e.getMessage());
    }
}
 
开发者ID:jenkinsci,项目名称:xltestview-plugin,代码行数:24,代码来源:XLTestView.java

示例12: prebuild

import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; //导入依赖的package包/类
@Override
public boolean prebuild(AbstractBuild<?, ?> build, BuildListener listener) {
    checkArgument(build instanceof SpoonBuild, requireInstanceOf("build", SpoonBuild.class));

    try {
        SpoonBuild spoonBuild = (SpoonBuild) build;
        Optional<StandardUsernamePasswordCredentials> credentials = this.getCredentials();
        if (credentials.isPresent()) {
            spoonBuild.setCredentials(credentials.get());
        }

        EnvVars env = this.getEnvironment(build, listener);
        spoonBuild.setEnv(env);

        FilePath scriptPath = this.resolveScriptFilePath(build, env, listener);
        spoonBuild.setScript(scriptPath);

        this.checkMountSettings();

        return super.prebuild(build, listener);
    } catch (IllegalStateException ex) {
        TaskListeners.logFatalError(listener, ex);
        return false;
    }
}
 
开发者ID:spoonapps,项目名称:jenkins,代码行数:26,代码来源:ScriptBuilder.java

示例13: perform

import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; //导入依赖的package包/类
@Override
public boolean perform(AbstractBuild abstractBuild, Launcher launcher, BuildListener listener) throws IOException, InterruptedException {
    try {
        SpoonBuild build = (SpoonBuild) abstractBuild;
        SpoonClient client = SpoonClient.builder(build).launcher(launcher).listener(listener).build();

        checkSpoonPluginIsRunning(client);

        Optional<StandardUsernamePasswordCredentials> credentials = build.getCredentials();
        if (credentials.isPresent()) {
            login(client, credentials.get());
        }

        String outputImage = build(client, build.getScript().get());
        build.setBuiltImage(outputImage);
        return true;
    } catch (IllegalStateException ex) {
        TaskListeners.logFatalError(listener, ex);
        return false;
    }
}
 
开发者ID:spoonapps,项目名称:jenkins,代码行数:22,代码来源:ScriptBuilder.java

示例14: doFillCredentialsIdItems

import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; //导入依赖的package包/类
/**
 * This method is called to populate the credentials list on the Jenkins config page.
 */
@SuppressWarnings("unused")
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath ItemGroup context,
                                             @QueryParameter("target") final String target) {
    StandardListBoxModel result = new StandardListBoxModel();
    result.withEmptySelection();
    result.withMatching(CredentialsMatchers.instanceOf(StandardUsernamePasswordCredentials.class),
            CredentialsProvider.lookupCredentials(
                    StandardUsernameCredentials.class,
                    context,
                    ACL.SYSTEM,
                    URIRequirementBuilder.fromUri(target).build()
            )
    );
    return result;
}
 
开发者ID:hpcloud,项目名称:cloudfoundry-jenkins,代码行数:19,代码来源:CloudFoundryPushPublisher.java

示例15: credentialsForScm

import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; //导入依赖的package包/类
private String credentialsForScm(ScmNode scm) {
    String url;
    if (scm == null) {
        url = JobProfilesConfiguration.get().getProfileRootDir();
    } else {
        url = scm.uri();
    }
    List<DomainRequirement> domainRequirements = URIRequirementBuilder.fromUri(url).build();
    Item item = null;
    StandardUsernamePasswordCredentials credentials = CredentialsMatchers.firstOrNull(
      CredentialsProvider.lookupCredentials(StandardUsernamePasswordCredentials.class, item, ACL.SYSTEM, domainRequirements),
      CredentialsMatchers.always());
    if (credentials != null) {
        return credentials.getId();
    }
    return "";
}
 
开发者ID:maxbraun,项目名称:job-profiles,代码行数:18,代码来源:JobContextBuilder.java


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