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


Java CredentialsScope类代码示例

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


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

示例1: setupGlobalConfiguration

import com.cloudbees.plugins.credentials.CredentialsScope; //导入依赖的package包/类
/**
 * Setup the global configuration.
 * 
 * @throws IOException
 */
public static void setupGlobalConfiguration() throws IOException
{
	JSONObject hostConnection = new JSONObject();
	hostConnection.put(TestConstants.DESCRIPTION, "TestConnection");
	hostConnection.put(TestConstants.HOST_PORT, TestConstants.EXPECTED_HOST + ':' + TestConstants.EXPECTED_PORT);
	hostConnection.put(TestConstants.CODE_PAGE, TestConstants.EXPECTED_CODE_PAGE);
	hostConnection.put(TestConstants.TIMEOUT, TestConstants.EXPECTED_TIMEOUT);
	hostConnection.put(TestConstants.CONNECTION_ID, TestConstants.EXPECTED_CONNECTION_ID);
	hostConnection.put(TestConstants.CES_URL, TestConstants.EXPECTED_CES_URL);

	JSONArray hostConnections = new JSONArray();
	hostConnections.add(hostConnection);

	JSONObject json = new JSONObject();
	json.put("hostConn", hostConnections);
	json.put(TestConstants.TOPAZ_CLI_LOCATION_LINUX, "/opt/Compuware/TopazCLI");
	json.put(TestConstants.TOPAZ_CLI_LOCATION_WINDOWS, "C:\\Program Files\\Compuware\\Topaz Workbench CLI");

	CpwrGlobalConfiguration globalConfig = CpwrGlobalConfiguration.get();
	globalConfig.configure(Stapler.getCurrentRequest(), json);

	SystemCredentialsProvider.getInstance().getCredentials().add(new UsernamePasswordCredentialsImpl(CredentialsScope.USER,
			TestConstants.EXPECTED_CREDENTIALS_ID, null, TestConstants.EXPECTED_USER_ID, TestConstants.EXPECTED_PASSWORD));
	SystemCredentialsProvider.getInstance().save();
}
 
开发者ID:jenkinsci,项目名称:compuware-scm-downloader-plugin,代码行数:31,代码来源:ScmTestUtils.java

示例2: testRecorderInvalidToken

import com.cloudbees.plugins.credentials.CredentialsScope; //导入依赖的package包/类
/**
 * Test that a JSON credential without a "jenkins_token" field and without a proper DC/OS service account value
 * results in a 401 and only 1 web request.
 *
 * @throws Exception
 */
@Test
public void testRecorderInvalidToken() throws Exception {
    final FreeStyleProject                       project         = j.createFreeStyleProject();
    final SystemCredentialsProvider.ProviderImpl system          = ExtensionList.lookup(CredentialsProvider.class).get(SystemCredentialsProvider.ProviderImpl.class);
    final CredentialsStore                       systemStore     = system.getStore(j.getInstance());
    final String                                 credentialValue = "{\"field1\":\"some value\"}";
    final Secret                                 secret          = Secret.fromString(credentialValue);
    final StringCredentials                      credential      = new StringCredentialsImpl(CredentialsScope.GLOBAL, "invalidtoken", "a token for JSON token test", secret);
    TestUtils.enqueueFailureResponse(httpServer, 401);

    systemStore.addCredentials(Domain.global(), credential);

    addBuilders(TestUtils.loadFixture("idonly.json"), project);

    // add post-builder
    addPostBuilders(project, "invalidtoken");

    final FreeStyleBuild build = j.assertBuildStatus(Result.FAILURE, project.scheduleBuild2(0).get());
    j.assertLogContains("[Marathon] Authentication to Marathon instance failed:", build);
    j.assertLogContains("[Marathon] Invalid DC/OS service account JSON", build);
    assertEquals("Only 1 request should have been made.", 1, httpServer.getRequestCount());
}
 
开发者ID:jenkinsci,项目名称:marathon-plugin,代码行数:29,代码来源:MarathonRecorderTest.java

示例3: configRoundTrip

import com.cloudbees.plugins.credentials.CredentialsScope; //导入依赖的package包/类
@Test public void configRoundTrip() {
    story.addStep(new Statement() {
        @Override public void evaluate() throws Throwable {
            IdCredentials registryCredentials = new UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL, "registryCreds", null, "me", "pass");
            CredentialsProvider.lookupStores(story.j.jenkins).iterator().next().addCredentials(Domain.global(), registryCredentials);
            StepConfigTester sct = new StepConfigTester(story.j);
            Map<String,Object> registryConfig = new TreeMap<String,Object>();
            registryConfig.put("url", "https://docker.my.com/");
            registryConfig.put("credentialsId", registryCredentials.getId());
            Map<String,Object> config = Collections.<String,Object>singletonMap("registry", registryConfig);
            RegistryEndpointStep step = DescribableHelper.instantiate(RegistryEndpointStep.class, config);
            step = sct.configRoundTrip(step);
            DockerRegistryEndpoint registry = step.getRegistry();
            assertNotNull(registry);
            assertEquals("https://docker.my.com/", registry.getUrl());
            assertEquals(registryCredentials.getId(), registry.getCredentialsId());
            assertEquals(config, DescribableHelper.uninstantiate(step));
       }
    });
}
 
开发者ID:jenkinsci,项目名称:docker-workflow-plugin,代码行数:21,代码来源:RegistryEndpointStepTest.java

示例4: configRoundTrip

import com.cloudbees.plugins.credentials.CredentialsScope; //导入依赖的package包/类
@Test public void configRoundTrip() {
    story.addStep(new Statement() {
        @Override public void evaluate() throws Throwable {
            IdCredentials serverCredentials = new DockerServerCredentials(CredentialsScope.GLOBAL, "serverCreds", null, "clientKey", "clientCertificate", "serverCaCertificate");
            CredentialsProvider.lookupStores(story.j.jenkins).iterator().next().addCredentials(Domain.global(), serverCredentials);
            StepConfigTester sct = new StepConfigTester(story.j);
            Map<String,Object> serverConfig = new TreeMap<String,Object>();
            serverConfig.put("uri", "tcp://host:2375");
            serverConfig.put("credentialsId", serverCredentials.getId());
            Map<String,Object> config = Collections.<String,Object>singletonMap("server", serverConfig);
            ServerEndpointStep step = DescribableHelper.instantiate(ServerEndpointStep.class, config);
            step = sct.configRoundTrip(step);
            DockerServerEndpoint server = step.getServer();
            assertNotNull(server);
            assertEquals("tcp://host:2375", server.getUri());
            assertEquals(serverCredentials.getId(), server.getCredentialsId());
            assertEquals(config, DescribableHelper.uninstantiate(step));
       }
    });
}
 
开发者ID:jenkinsci,项目名称:docker-workflow-plugin,代码行数:21,代码来源:ServerEndpointStepTest.java

示例5: getDockerServerCredentials

import com.cloudbees.plugins.credentials.CredentialsScope; //导入依赖的package包/类
public DockerServerCredentials getDockerServerCredentials() throws IOException {
    final LocalDirectorySSLConfig sslContext = (LocalDirectorySSLConfig) clientConfig.getSSLConfig();

    assertThat("DockerCli must be connected via SSL", sslContext, notNullValue());

    String certPath = sslContext.getDockerCertPath();

    final String keypem = FileUtils.readFileToString(new File(certPath + "/" + "key.pem"));
    final String certpem = FileUtils.readFileToString(new File(certPath + "/" + "cert.pem"));
    final String capem = FileUtils.readFileToString(new File(certPath + "/" + "ca.pem"));

    return new DockerServerCredentials(
            CredentialsScope.GLOBAL, // scope
            null, // name
            null, //desc
            keypem,
            certpem,
            capem
    );
}
 
开发者ID:KostyaSha,项目名称:yet-another-docker-plugin,代码行数:21,代码来源:DockerRule.java

示例6: configRoundTrip

import com.cloudbees.plugins.credentials.CredentialsScope; //导入依赖的package包/类
@Test
public void configRoundTrip() throws Exception {
    story.addStep(new Statement() {
        @SuppressWarnings("rawtypes")
        @Override
        public void evaluate() throws Throwable {
            CredentialsStore store = CredentialsProvider.lookupStores(story.j.getInstance()).iterator().next();
            assertThat(store, instanceOf(SystemCredentialsProvider.StoreImpl.class));
            Domain domain = new Domain("docker", "A domain for docker credentials",
                    Collections.<DomainSpecification> singletonList(new DockerServerDomainSpecification()));
            DockerServerCredentials c = new DockerServerCredentials(CredentialsScope.GLOBAL,
                    "docker-client-cert", "desc", "clientKey", "clientCertificate", "serverCaCertificate");
            store.addDomain(domain, c);
            BindingStep s = new StepConfigTester(story.j)
                    .configRoundTrip(new BindingStep(Collections.<MultiBinding> singletonList(
                            new DockerServerCredentialsBinding("DOCKER_CERT_PATH", "docker-client-cert"))));
            story.j.assertEqualDataBoundBeans(s.getBindings(), Collections.singletonList(
                    new DockerServerCredentialsBinding("DOCKER_CERT_PATH", "docker-client-cert")));
        }
    });
}
 
开发者ID:jenkinsci,项目名称:docker-commons-plugin,代码行数:22,代码来源:DockerServerCredentialsBindingTest.java

示例7: stop

import com.cloudbees.plugins.credentials.CredentialsScope; //导入依赖的package包/类
public void stop() throws Exception {
	P4PasswordImpl auth = new P4PasswordImpl(CredentialsScope.SYSTEM, "id",
			"desc", p4port, null, "admin", "0", "Password");

	p4 = new ConnectionHelper(auth);
	p4.login();
	p4.stop();
	logger.info("stop signal sent...");

	int retry = 0;
	while (retry < 20) {
		try {
			if (!p4.login()) {
				break;
			} else {
				Thread.sleep(100);
			}
		} catch (Exception e) {
			break;
		}
	}
}
 
开发者ID:p4paul,项目名称:p4workflow,代码行数:23,代码来源:P4Server.java

示例8: prepareGitHubPlugin

import com.cloudbees.plugins.credentials.CredentialsScope; //导入依赖的package包/类
/**
 * Prepare global GitHub plugin configuration.
 * Nothing specific to job.
 */
public static GitHubServerConfig prepareGitHubPlugin() {
    // prepare global jRule settings
    final StringCredentialsImpl cred = new StringCredentialsImpl(
            CredentialsScope.GLOBAL,
            null,
            "description",
            Secret.fromString(GH_TOKEN)
    );

    SystemCredentialsProvider.getInstance().getCredentials().add(cred);

    final GitHubPluginConfig gitHubPluginConfig = GitHubPlugin.configuration();

    final List<GitHubServerConfig> gitHubServerConfigs = new ArrayList<>();
    final GitHubServerConfig gitHubServerConfig = new GitHubServerConfig(cred.getId());
    gitHubServerConfig.setManageHooks(false);
    gitHubServerConfig.setClientCacheSize(0);
    gitHubServerConfigs.add(gitHubServerConfig);

    gitHubPluginConfig.setConfigs(gitHubServerConfigs);

    return gitHubServerConfig;
}
 
开发者ID:KostyaSha,项目名称:github-integration-plugin,代码行数:28,代码来源:GHRule.java

示例9: sshagent

import com.cloudbees.plugins.credentials.CredentialsScope; //导入依赖的package包/类
@Issue({ "JENKINS-47225", "JENKINS-42582" })
@Test
public void sshagent() throws Exception {
    PrivateKeySource source = new BasicSSHUserPrivateKey.DirectEntryPrivateKeySource(
            new String(IOUtils.toByteArray(getClass().getResourceAsStream("id_rsa"))));
    BasicSSHUserPrivateKey credentials = new BasicSSHUserPrivateKey(CredentialsScope.GLOBAL,
            "ContainerExecDecoratorPipelineTest-sshagent", "bob", source, "secret_passphrase", "test credentials");
    SystemCredentialsProvider.getInstance().getCredentials().add(credentials);

    WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "sshagent");
    p.setDefinition(new CpsFlowDefinition(loadPipelineScript("sshagent.groovy"), true));
    WorkflowRun b = p.scheduleBuild2(0).waitForStart();
    assertNotNull(b);
    r.waitForCompletion(b);
    r.assertLogContains("Identity added:", b);
    //check that we don't accidentally start exporting sensitive info to the log
    r.assertLogNotContains("secret_passphrase", b);
}
 
开发者ID:carlossg,项目名称:jenkins-kubernetes-plugin,代码行数:19,代码来源:ContainerExecDecoratorPipelineTest.java

示例10: migrate

import com.cloudbees.plugins.credentials.CredentialsScope; //导入依赖的package包/类
@Initializer(after = InitMilestone.PLUGINS_STARTED)
public static void migrate() throws IOException {
    GitLabConnectionConfig descriptor = (GitLabConnectionConfig) Jenkins.getInstance().getDescriptor(GitLabConnectionConfig.class);
    for (GitLabConnection connection : descriptor.getConnections()) {
        if (connection.apiTokenId == null && connection.apiToken != null) {
            for (CredentialsStore credentialsStore : CredentialsProvider.lookupStores(Jenkins.getInstance())) {
                if (credentialsStore instanceof SystemCredentialsProvider.StoreImpl) {
                    List<Domain> domains = credentialsStore.getDomains();
                    connection.apiTokenId = UUID.randomUUID().toString();
                    credentialsStore.addCredentials(domains.get(0),
                        new GitLabApiTokenImpl(CredentialsScope.SYSTEM, connection.apiTokenId, "GitLab API Token", Secret.fromString(connection.apiToken)));
                }
            }
        }
    }
    descriptor.save();
}
 
开发者ID:jenkinsci,项目名称:gitlab-plugin,代码行数:18,代码来源:GitLabConnection.java

示例11: testMultiBranchClassicWithCredentialsInFolder

import com.cloudbees.plugins.credentials.CredentialsScope; //导入依赖的package包/类
@Test
public void testMultiBranchClassicWithCredentialsInFolder() throws Exception {

	WorkflowMultiBranchProject multi = jenkins.jenkins.createProject(WorkflowMultiBranchProject.class, "multi-classic-creds-in-folder");

	CredentialsStore folderStore = getFolderStore(multi);
	P4BaseCredentials inFolderCredentials = new P4PasswordImpl(
			CredentialsScope.GLOBAL, "idInFolder", "desc:passwd", p4d.getRshPort(),
			null, "jenkins", "0", "0", null, "jenkins");
	folderStore.addCredentials(Domain.global(), inFolderCredentials);

	String format = "jenkins-${NODE_NAME}-${JOB_NAME}";
	String includes = "//stream/...";
	SCMSource source = new BranchesScmSource(inFolderCredentials.getId(), includes, null, format);
	multi.getSourcesList().add(new BranchSource(source));
	multi.scheduleBuild2(0);
	jenkins.waitUntilNoActivity();

	assertEquals("Branch Indexing succeeded", Result.SUCCESS, multi.getComputation().getResult());
	assertThat("We now have branches", multi.getItems(), not(containsInAnyOrder()));
}
 
开发者ID:p4paul,项目名称:p4-jenkins,代码行数:22,代码来源:PerforceScmSourceTest.java

示例12: testMultiBranchStreamWithCredentialsInFolder

import com.cloudbees.plugins.credentials.CredentialsScope; //导入依赖的package包/类
@Test
public void testMultiBranchStreamWithCredentialsInFolder() throws Exception {

	WorkflowMultiBranchProject multi = jenkins.jenkins.createProject(WorkflowMultiBranchProject.class, "multi-streams-creds-in-folder");

	CredentialsStore folderStore = getFolderStore(multi);
	P4BaseCredentials inFolderCredentials = new P4PasswordImpl(
			CredentialsScope.GLOBAL, "idInFolder", "desc:passwd", p4d.getRshPort(),
			null, "jenkins", "0", "0", null, "jenkins");
	folderStore.addCredentials(Domain.global(), inFolderCredentials);

	String format = "jenkins-${NODE_NAME}-${JOB_NAME}";
	String includes = "//stream/...";
	SCMSource source = new StreamsScmSource(inFolderCredentials.getId(), includes, null, format);
	multi.getSourcesList().add(new BranchSource(source));
	multi.scheduleBuild2(0);
	jenkins.waitUntilNoActivity();

	assertEquals("Branch Indexing succeeded", Result.SUCCESS, multi.getComputation().getResult());
	assertThat("We now have branches", multi.getItems(), not(containsInAnyOrder()));
}
 
开发者ID:p4paul,项目名称:p4-jenkins,代码行数:22,代码来源:PerforceScmSourceTest.java

示例13: testAddStandardCredentials

import com.cloudbees.plugins.credentials.CredentialsScope; //导入依赖的package包/类
@Test
public void testAddStandardCredentials() throws IOException {
	P4BaseCredentials credential = new P4PasswordImpl(
			CredentialsScope.SYSTEM, "id", "desc:passwd", "localhost:1666",
			null, "user", "0", "0", null, "pass");

	assertTrue(lookupCredentials().isEmpty());
	SystemCredentialsProvider.getInstance().getCredentials()
			.add(credential);
	assertFalse(lookupCredentials().isEmpty());

	assertTrue(new SystemCredentialsProvider().getCredentials().isEmpty());
	SystemCredentialsProvider.getInstance().save();
	assertFalse(new SystemCredentialsProvider().getCredentials().isEmpty());

	assertEquals("desc:passwd", credential.getDescription());
	assertEquals("id", credential.getId());

	List<P4BaseCredentials> list = lookupCredentials();
	assertEquals("localhost:1666", list.get(0).getP4port());
	assertEquals("user", list.get(0).getUsername());
	assertFalse(list.get(0).isSsl());

	String name = CredentialsNameProvider.name(credential);
	assertEquals("user/****** (desc:passwd)", name);
}
 
开发者ID:p4paul,项目名称:p4-jenkins,代码行数:27,代码来源:PerforceCredentialsTest.java

示例14: testAddSslCredentials

import com.cloudbees.plugins.credentials.CredentialsScope; //导入依赖的package包/类
@Test
public void testAddSslCredentials() throws IOException {
	TrustImpl ssl = new TrustImpl("12345ABCD");
	P4PasswordImpl credential = new P4PasswordImpl(CredentialsScope.SYSTEM,
			"id", "description", "localhost:1666", ssl, "user", "0", "0", null, "pass");

	assertTrue(lookupCredentials().isEmpty());
	SystemCredentialsProvider.getInstance().getCredentials()
			.add(credential);
	assertFalse(lookupCredentials().isEmpty());

	assertTrue(new SystemCredentialsProvider().getCredentials().isEmpty());
	SystemCredentialsProvider.getInstance().save();
	assertFalse(new SystemCredentialsProvider().getCredentials().isEmpty());

	assertTrue(credential.isSsl());
	assertEquals("12345ABCD", credential.getTrust());
}
 
开发者ID:p4paul,项目名称:p4-jenkins,代码行数:19,代码来源:PerforceCredentialsTest.java

示例15: testAddTicketCredentials

import com.cloudbees.plugins.credentials.CredentialsScope; //导入依赖的package包/类
@Test
public void testAddTicketCredentials() throws IOException {
	TicketModeImpl ticket = new TicketModeImpl("ticketValueSet", "12345",
			null);

	P4TicketImpl credential = new P4TicketImpl(CredentialsScope.SYSTEM,
			"id", "desc:ticket", "localhost:1666", null, "user", "0", "0", null, ticket);

	assertTrue(lookupCredentials().isEmpty());
	SystemCredentialsProvider.getInstance().getCredentials()
			.add(credential);
	assertFalse(lookupCredentials().isEmpty());

	assertTrue(new SystemCredentialsProvider().getCredentials().isEmpty());
	SystemCredentialsProvider.getInstance().save();
	assertFalse(new SystemCredentialsProvider().getCredentials().isEmpty());

	assertEquals("12345", credential.getTicketValue());

	AuthorisationConfig auth = new AuthorisationConfig(credential);
	assertEquals(AuthorisationType.TICKET, auth.getType());
	assertEquals("12345", auth.getTicketValue());

	String name = CredentialsNameProvider.name(credential);
	assertEquals("user (desc:ticket)", name);
}
 
开发者ID:p4paul,项目名称:p4-jenkins,代码行数:27,代码来源:PerforceCredentialsTest.java


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