本文整理汇总了Java中com.cloudbees.plugins.credentials.CredentialsScope.SYSTEM属性的典型用法代码示例。如果您正苦于以下问题:Java CredentialsScope.SYSTEM属性的具体用法?Java CredentialsScope.SYSTEM怎么用?Java CredentialsScope.SYSTEM使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.cloudbees.plugins.credentials.CredentialsScope
的用法示例。
在下文中一共展示了CredentialsScope.SYSTEM属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: stop
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;
}
}
}
示例2: testAddStandardCredentials
@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);
}
示例3: testAddSslCredentials
@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());
}
示例4: testAddTicketCredentials
@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);
}
示例5: testAddTicketPathCredentials
@Test
public void testAddTicketPathCredentials() throws IOException {
TicketModeImpl ticket = new TicketModeImpl("ticketPathSet", null,
"~/.p4ticket");
P4TicketImpl credential = new P4TicketImpl(CredentialsScope.SYSTEM,
"id", "description", "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("~/.p4ticket", credential.getTicketPath());
AuthorisationConfig auth = new AuthorisationConfig(credential);
assertEquals(AuthorisationType.TICKETPATH, auth.getType());
assertEquals("~/.p4ticket", auth.getTicketPath());
}
示例6: testAvailableCredentialsAtRoot
@Test
public void testAvailableCredentialsAtRoot() throws IOException {
P4BaseCredentials systemCredentials = new P4PasswordImpl(
CredentialsScope.SYSTEM, "idSystem", "desc:passwd", "localhost:1666",
null, "user", "0", "0", null, "pass");
P4BaseCredentials globalCredentials = new P4PasswordImpl(
CredentialsScope.GLOBAL, "idInGlobal", "desc:passwd", "localhost:1666",
null, "user", "0", "0", null, "pass");
assertTrue(lookupCredentials().isEmpty());
SystemCredentialsProvider.getInstance().getCredentials().add(systemCredentials);
SystemCredentialsProvider.getInstance().getCredentials().add(globalCredentials);
SystemCredentialsProvider.getInstance().save();
assertFalse(new SystemCredentialsProvider().getCredentials().isEmpty());
List<P4BaseCredentials> list = lookupCredentials();
assertEquals(2, list.size());
}
示例7: testAvailableCredentialsInJob
@Test
public void testAvailableCredentialsInJob() throws IOException {
Job job = jenkins.createFreeStyleProject("testAvailableCredentialsInJob");
P4BaseCredentials systemCredentials = new P4PasswordImpl(
CredentialsScope.SYSTEM, "idSystem", "desc:passwd", "localhost:1666",
null, "user", "0", "0", null, "pass");
P4BaseCredentials globalCredentials = new P4PasswordImpl(
CredentialsScope.GLOBAL, "idInGlobal", "desc:passwd", "localhost:1666",
null, "user", "0", "0", null, "pass");
assertTrue(lookupCredentials().isEmpty());
SystemCredentialsProvider.getInstance().getCredentials().add(systemCredentials);
SystemCredentialsProvider.getInstance().getCredentials().add(globalCredentials);
SystemCredentialsProvider.getInstance().save();
assertFalse(new SystemCredentialsProvider().getCredentials().isEmpty());
List<P4BaseCredentials> list = CredentialsProvider.lookupCredentials(P4BaseCredentials.class,
job, ACL.SYSTEM, Collections.<DomainRequirement>emptyList());
assertEquals(1, list.size());
assertEquals(globalCredentials.getId(), list.get(0).getId());
}
示例8: createCredentials
private P4PasswordImpl createCredentials() throws IOException {
P4PasswordImpl auth = new P4PasswordImpl(CredentialsScope.SYSTEM,
credential, "desc", P4PORT, null, "jenkins", "0", "jenkins");
SystemCredentialsProvider.getInstance().getCredentials().add(auth);
SystemCredentialsProvider.getInstance().save();
return auth;
}
示例9: start
public void start() throws Exception {
CommandLine cmdLine = new CommandLine(p4d);
// cmdLine.addArgument("-vserver=5");
cmdLine.addArgument("-C1");
cmdLine.addArgument("-r");
cmdLine.addArgument(formatPath(p4root.getAbsolutePath()));
cmdLine.addArgument("-p");
cmdLine.addArgument(p4port);
cmdLine.addArgument("-Llog");
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
DefaultExecutor executor = new DefaultExecutor();
executor.execute(cmdLine, resultHandler);
logger.info("start signal sent...");
P4PasswordImpl auth = new P4PasswordImpl(CredentialsScope.SYSTEM, "id",
"desc", p4port, null, "admin", "0", "Password");
int retry = 0;
while (retry < 20) {
try {
p4 = new ConnectionHelper(auth);
break;
} catch (Exception e) {
Thread.sleep(100);
}
}
}
示例10: testAddPasswordCredentials
@Test
public void testAddPasswordCredentials() throws IOException {
P4PasswordImpl credential = new P4PasswordImpl(CredentialsScope.SYSTEM,
"id", "description", "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("pass", credential.getPassword().getPlainText());
assertFalse(credential.isSsl());
AuthorisationConfig auth = new AuthorisationConfig(credential);
assertEquals(AuthorisationType.PASSWORD, auth.getType());
assertEquals("user", auth.getUsername());
assertEquals("pass", auth.getPassword());
assertEquals("[email protected]", auth.toString());
// point less
auth.setClient("client");
assertEquals("client", auth.getClient());
assertEquals("[email protected]", auth.toString());
}
示例11: testAvailableCredentialsInFolder
@Test
public void testAvailableCredentialsInFolder() throws IOException {
Folder folder = createFolder();
CredentialsStore folderStore = getFolderStore(folder);
P4BaseCredentials systemCredentials = new P4PasswordImpl(
CredentialsScope.SYSTEM, "idSystem", "desc:passwd", "localhost:1666",
null, "user", "0", "0", null, "pass");
P4BaseCredentials globalCredentials = new P4PasswordImpl(
CredentialsScope.GLOBAL, "idInGlobal", "desc:passwd", "localhost:1666",
null, "user", "0", "0", null, "pass");
P4BaseCredentials inFolderCredentials = new P4PasswordImpl(
CredentialsScope.GLOBAL, "idSystem", "desc:passwd", "localhost:1666",
null, "user", "0", "0", null, "pass");
assertTrue(lookupCredentials().isEmpty());
SystemCredentialsProvider.getInstance().getCredentials().add(systemCredentials);
SystemCredentialsProvider.getInstance().getCredentials().add(globalCredentials);
SystemCredentialsProvider.getInstance().save();
assertFalse(new SystemCredentialsProvider().getCredentials().isEmpty());
folderStore.addCredentials(Domain.global(), inFolderCredentials);
folder.save();
assertFalse(folderStore.getCredentials(Domain.global()).isEmpty());
List<P4BaseCredentials> list = CredentialsProvider.lookupCredentials(P4BaseCredentials.class,
folder.getItemGroup(), ACL.SYSTEM, Collections.<DomainRequirement>emptyList());
assertEquals(2, list.size());
assertEquals(inFolderCredentials.getId(), list.get(0).getId());
assertEquals(globalCredentials.getId(), list.get(1).getId());
}
示例12: testInJobCredentialsList
@Test
public void testInJobCredentialsList() throws Exception {
String port = p4d.getRshPort();
P4BaseCredentials systemCredentials = new P4PasswordImpl(
CredentialsScope.SYSTEM, "idSystem", "desc:passwd", port,
null, "jenkins", "0", "0", null, "jenkins");
P4BaseCredentials globalCredentials = new P4PasswordImpl(
CredentialsScope.GLOBAL, "idInGlobal", "desc:passwd", port,
null, "jenkins", "0", "0", null, "jenkins");
SystemCredentialsProvider.getInstance().getCredentials().add(systemCredentials);
SystemCredentialsProvider.getInstance().getCredentials().add(globalCredentials);
SystemCredentialsProvider.getInstance().save();
FreeStyleProject project = jenkins.createProject(FreeStyleProject.class, "testInJobCredentialsList");
ListBoxModel list = P4CredentialsImpl.doFillCredentialItems(project, null);
assertEquals(2, list.size());
list = P4CredentialsImpl.doFillCredentialItems(project, globalCredentials.getId());
assertEquals(2, list.size());
FormValidation form = P4CredentialsImpl.doCheckCredential(project, null);
assertEquals(FormValidation.Kind.OK, form.kind);
form = P4CredentialsImpl.doCheckCredential(project, globalCredentials.getId());
assertEquals(FormValidation.Kind.OK, form.kind);
}
示例13: testInFolderCredentialsList
@Test
public void testInFolderCredentialsList() throws Exception {
String port = p4d.getRshPort();
// Create a folder with credentials in store
Folder folder = createFolder();
CredentialsStore folderStore = getFolderStore(folder);
P4BaseCredentials inFolderCredentials = new P4PasswordImpl(
CredentialsScope.GLOBAL, "idInFolder", "desc:passwd", port,
null, "jenkins", "0", "0", null, "jenkins");
folderStore.addCredentials(Domain.global(), inFolderCredentials);
P4BaseCredentials systemCredentials = new P4PasswordImpl(
CredentialsScope.SYSTEM, "idSystem", "desc:passwd", port,
null, "jenkins", "0", "0", null, "jenkins");
P4BaseCredentials globalCredentials = new P4PasswordImpl(
CredentialsScope.GLOBAL, "idInGlobal", "desc:passwd", port,
null, "jenkins", "0", "0", null, "jenkins");
SystemCredentialsProvider.getInstance().getCredentials().add(systemCredentials);
SystemCredentialsProvider.getInstance().getCredentials().add(globalCredentials);
SystemCredentialsProvider.getInstance().save();
FreeStyleProject project = folder.createProject(FreeStyleProject.class, "testInFolderCredentialsList");
ListBoxModel list = P4CredentialsImpl.doFillCredentialItems(project, null);
assertEquals(3, list.size());
list = P4CredentialsImpl.doFillCredentialItems(project, inFolderCredentials.getId());
assertEquals(3, list.size());
FormValidation form = P4CredentialsImpl.doCheckCredential(project, null);
assertEquals(FormValidation.Kind.OK, form.kind);
form = P4CredentialsImpl.doCheckCredential(project, inFolderCredentials.getId());
assertEquals(FormValidation.Kind.OK, form.kind);
}
示例14: migrateToCredentials
/**
* Migrate principal/secret to credentials
*/
private void migrateToCredentials() {
if (principal != null) {
List<DomainRequirement> domainRequirements = (master == null) ? Collections.<DomainRequirement>emptyList()
: URIRequirementBuilder.fromUri(master.trim()).build();
Jenkins jenkins = getJenkins();
// Look up existing credentials with the same username.
List<StandardUsernamePasswordCredentials> credentials = CredentialsMatchers.filter(CredentialsProvider
.lookupCredentials(StandardUsernamePasswordCredentials.class, jenkins, ACL.SYSTEM, domainRequirements),
CredentialsMatchers.withUsername(principal)
);
for (StandardUsernamePasswordCredentials cred: credentials) {
if (StringUtils.equals(secret, Secret.toString(cred.getPassword()))) {
// If some credentials have the same username/password, use those.
this.credentialsId = cred.getId();
break;
}
}
if (credentialsId == null) {
// If we couldn't find any existing credentials,
// create new credentials with the principal and secret and use it.
StandardUsernamePasswordCredentials newCredentials = new UsernamePasswordCredentialsImpl(
CredentialsScope.SYSTEM, null, null, principal, secret);
SystemCredentialsProvider.getInstance().getCredentials().add(newCredentials);
this.credentialsId = newCredentials.getId();
}
principal = null;
secret = null;
}
}
示例15: testDockerShellStep
@Test
public void testDockerShellStep() throws Throwable {
jRule.getInstance().setNumExecutors(0);
// jRule.createSlave();
// jRule.createSlave("my-slave", "remote-slave", new EnvVars());
final UsernamePasswordCredentialsImpl credentials = new UsernamePasswordCredentialsImpl(CredentialsScope.SYSTEM,
null, "description", "vagrant", "vagrant");
CredentialsStore store = CredentialsProvider.lookupStores(jRule.getInstance()).iterator().next();
store.addCredentials(Domain.global(), credentials);
final SSHLauncher sshLauncher = new SSHLauncher("192.168.33.10", 22, credentials.getId(),
"-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005", //jvmopts
"", // String javaPath,
"", // String prefixStartSlaveCmd,
"", // String suffixStartSlaveCmd,
20, // Integer launchTimeoutSeconds,
1, // Integer maxNumRetries,
3// Integer retryWaitTime
);
final DumbSlave dumbSlave = new DumbSlave("docker-daemon", "/home/vagrant/jenkins2", sshLauncher);
jRule.getInstance().addNode(dumbSlave);
await().timeout(60, SECONDS).until(() -> assertThat(dumbSlave.getChannel(), notNullValue()));
// String dockerfilePath = dumbSlave.getChannel().call(new DockerBuildImageStepTest.StringThrowableCallable());
final CredentialsYADockerConnector dockerConnector = new CredentialsYADockerConnector()
.withConnectorType(JERSEY)
.withServerUrl("tcp://127.0.0.1:2376")
.withSslConfig(new LocalDirectorySSLConfig("/home/vagrant/keys"));
// .withCredentials(new DockerDaemonFileCredentials(null, "docker-cert", "",
// "/home/vagrant/keys"));
DockerShellStep dockerShellStep = new DockerShellStep();
dockerShellStep.setShellScript("env && pwd");
dockerShellStep.setConnector(dockerConnector);
FreeStyleProject project = jRule.createFreeStyleProject("test");
project.getBuildersList().add(dockerShellStep);
project.save();
QueueTaskFuture<FreeStyleBuild> taskFuture = project.scheduleBuild2(0);
FreeStyleBuild freeStyleBuild = taskFuture.get();
jRule.waitForCompletion(freeStyleBuild);
jRule.assertBuildStatusSuccess(freeStyleBuild);
}