本文整理汇总了Java中com.cloudbees.plugins.credentials.SystemCredentialsProvider类的典型用法代码示例。如果您正苦于以下问题:Java SystemCredentialsProvider类的具体用法?Java SystemCredentialsProvider怎么用?Java SystemCredentialsProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SystemCredentialsProvider类属于com.cloudbees.plugins.credentials包,在下文中一共展示了SystemCredentialsProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupGlobalConfiguration
import com.cloudbees.plugins.credentials.SystemCredentialsProvider; //导入依赖的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();
}
示例2: setUp
import com.cloudbees.plugins.credentials.SystemCredentialsProvider; //导入依赖的package包/类
@Before
public void setUp() {
PowerMockito.mockStatic(CredentialsMatchers.class);
PowerMockito.mockStatic(SystemCredentialsProvider.class);
PowerMockito.mockStatic(DefaultAWSCredentialsProviderChain.class);
when(CredentialsMatchers.firstOrNull(any(Iterable.class), any(CredentialsMatcher.class))).thenReturn(mockCBCreds);
when(mockCBCreds.getCredentials()).thenReturn(mockAWSCreds);
when(mockCBCreds.getCredentialsDescriptor()).thenReturn(codeBuildDescriptor);
when(mockCBCreds.getProxyHost()).thenReturn(proxyHost);
when(mockCBCreds.getProxyPort()).thenReturn(proxyPort);
when(mockAWSCreds.getAWSAccessKeyId()).thenReturn("a");
when(mockAWSCreds.getAWSSecretKey()).thenReturn("s");
when(SystemCredentialsProvider.getInstance()).thenReturn(mockSysCreds);
when(DefaultAWSCredentialsProviderChain.getInstance()).thenReturn(cpChain);
}
示例3: testRecorderInvalidToken
import com.cloudbees.plugins.credentials.SystemCredentialsProvider; //导入依赖的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());
}
示例4: setUp
import com.cloudbees.plugins.credentials.SystemCredentialsProvider; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
when(credentials.getProjectId()).thenReturn(PROJECT_ID);
when(credentials.getId()).thenReturn(CREDENTIALS_ID);
SystemCredentialsProvider.getInstance().getCredentials().add(credentials);
// Create a project to which we may attach our uploader.
this.project = jenkins.createFreeStyleProject("test");
this.workspace = new FilePath(PathUtils.makeTempDir(dir, "the", "workspace"));
this.configFilePath = workspace.child("tmpl.yaml");
this.importPaths = ImmutableList.of(workspace.child(TestFixture.IMPORT_PATH_1),
workspace.child(TestFixture.IMPORT_PATH_2));
}
开发者ID:GoogleCloudPlatform,项目名称:jenkins-deployment-manager-plugin,代码行数:17,代码来源:GoogleCloudManagerBuildWrapperTest.java
示例5: setUp
import com.cloudbees.plugins.credentials.SystemCredentialsProvider; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
when(credentials.getProjectId()).thenReturn(PROJECT_ID);
when(credentials.getId()).thenReturn(CREDENTIALS_ID);
SystemCredentialsProvider.getInstance().getCredentials().add(credentials);
notFoundException = new NotFoundException();
// Create a project to which we may attach our uploader.
this.project = jenkins.createFreeStyleProject("test");
this.configFilePath = new FilePath(dir.newFile("tmpl.yaml"));
this.importPaths = ImmutableList.of(new FilePath(dir.newFile(IMPORT_PATH_1)),
new FilePath(dir.newFile(IMPORT_PATH_2)));
}
开发者ID:GoogleCloudPlatform,项目名称:jenkins-deployment-manager-plugin,代码行数:18,代码来源:GoogleCloudManagerDeployerTest.java
示例6: setUp
import com.cloudbees.plugins.credentials.SystemCredentialsProvider; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
this.workspace = new FilePath(PathUtils.makeTempDir(dir, "the", "workspace"));
// TODO: Add some values for testing
this.environment = new EnvVars();
when(credentials.getId()).thenReturn(ROBOT_ID);
when(credentials.getProjectId()).thenReturn(PROJECT_ID);
// Allow for @WithoutJenkins
if (jenkins.jenkins != null) {
SystemCredentialsProvider.getInstance().getCredentials().add(credentials);
}
notFoundException = new NotFoundException();
}
开发者ID:GoogleCloudPlatform,项目名称:jenkins-deployment-manager-plugin,代码行数:19,代码来源:CloudDeploymentDeleterTest.java
示例7: setUp
import com.cloudbees.plugins.credentials.SystemCredentialsProvider; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
this.workspace = new FilePath(PathUtils.makeTempDir(dir, "the", "workspace"));
this.configFilePath = workspace.child(CONFIG_FILE);
this.importPaths = ImmutableList.of(workspace.child(TestFixture.IMPORT_PATH_1),
workspace.child(TestFixture.IMPORT_PATH_2));
// TODO: Add some values for testing
this.environment = new EnvVars();
when(credentials.getId()).thenReturn(ROBOT_ID);
when(credentials.getProjectId()).thenReturn(PROJECT_ID);
SystemCredentialsProvider.getInstance().getCredentials().add(credentials);
notFoundException = new NotFoundException();
executorException = new ExecutorException() {};
forbiddenJsonException =
new HttpResponseException.Builder(STATUS_CODE_FORBIDDEN, STATUS_MESSAGE, headers).build();
}
开发者ID:GoogleCloudPlatform,项目名称:jenkins-deployment-manager-plugin,代码行数:24,代码来源:TemplatedCloudDeploymentTest.java
示例8: configRoundTrip
import com.cloudbees.plugins.credentials.SystemCredentialsProvider; //导入依赖的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")));
}
});
}
示例9: prepareGitHubPlugin
import com.cloudbees.plugins.credentials.SystemCredentialsProvider; //导入依赖的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;
}
示例10: createCredentials
import com.cloudbees.plugins.credentials.SystemCredentialsProvider; //导入依赖的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();
}
示例11: setUp
import com.cloudbees.plugins.credentials.SystemCredentialsProvider; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
when(descriptor.getDisplayName()).thenReturn("Credentials Name");
when(credentials.getId()).thenReturn(CREDENTIALS_ID);
when(credentials.getProjectId()).thenReturn(PROJECT_ID);
when(credentials.getDescriptor()).thenReturn(descriptor);
if (jenkins.jenkins != null) {
SystemCredentialsProvider.getInstance().getCredentials().add(credentials);
}
credential = new GoogleCredential();
when(credentials.getGoogleCredential(isA(
GoogleOAuth2ScopeRequirement.class)))
.thenReturn(credential);
// Return ourselves as remotable
when(credentials.forRemote(isA(GoogleOAuth2ScopeRequirement.class)))
.thenReturn(credentials);
}
示例12: setUp
import com.cloudbees.plugins.credentials.SystemCredentialsProvider; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
when(descriptor.getDisplayName()).thenReturn("Credentials Name");
when(credentials.getId()).thenReturn(CREDENTIALS_ID);
when(credentials.getProjectId()).thenReturn(PROJECT_ID);
when(credentials.getDescriptor()).thenReturn(descriptor);
if (jenkins.jenkins != null) {
SystemCredentialsProvider.getInstance().getCredentials().add(credentials);
}
credential = new GoogleCredential();
when(credentials.getGoogleCredential(isA(
GoogleOAuth2ScopeRequirement.class)))
.thenReturn(credential);
when(credentials.forRemote(isA(GoogleOAuth2ScopeRequirement.class)))
.thenReturn(credentials);
}
示例13: sshagent
import com.cloudbees.plugins.credentials.SystemCredentialsProvider; //导入依赖的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);
}
示例14: testListBoxEmpty
import com.cloudbees.plugins.credentials.SystemCredentialsProvider; //导入依赖的package包/类
@Test
public void testListBoxEmpty() throws Exception {
ListBoxModel list = GoogleRobotCredentials.getCredentialsListBox(
FakeGoogleCredentials.class);
assertEquals(0, list.size());
FakeGoogleCredentials credentials = new FakeGoogleCredentials(PROJECT_ID,
fakeCredential);
SystemCredentialsProvider.getInstance().getCredentials().add(credentials);
list = GoogleRobotCredentials.getCredentialsListBox(
FakeGoogleCredentials.class);
assertEquals(1, list.size());
for (ListBoxModel.Option option : list) {
assertEquals(NAME, option.name);
assertEquals(credentials.getId(), option.value);
}
}
示例15: migrate
import com.cloudbees.plugins.credentials.SystemCredentialsProvider; //导入依赖的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();
}