本文整理汇总了Java中org.eclipse.jgit.transport.CredentialItem类的典型用法代码示例。如果您正苦于以下问题:Java CredentialItem类的具体用法?Java CredentialItem怎么用?Java CredentialItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CredentialItem类属于org.eclipse.jgit.transport包,在下文中一共展示了CredentialItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUsernamePassword
import org.eclipse.jgit.transport.CredentialItem; //导入依赖的package包/类
public UsernamePassword getUsernamePassword(URIish uri) {
addDefaultCredentials(credentials);
String username = uri.getUser();
String password = uri.getPass();
CredentialItem.Username u = new CredentialItem.Username();
CredentialItem.Password p = new CredentialItem.Password();
if (supports(u, p) && get(uri, u, p)) {
username = u.getValue();
char[] v = p.getValue();
password = (v == null) ? null : new String(p.getValue());
p.clear();
}
return new UsernamePassword(username, password);
}
示例2: get
import org.eclipse.jgit.transport.CredentialItem; //导入依赖的package包/类
@Override
public boolean get(URIish uri, CredentialItem... items) throws UnsupportedCredentialItem {
for (CredentialItem i : items) {
if (i instanceof Identity) {
((Identity) i).setValue(identityFile);
continue;
}
if (i instanceof KnownHosts) {
((KnownHosts) i).setValue(knownHostsFile);
continue;
}
throw new UnsupportedCredentialItem(uri, i.getClass().getName()
+ ":" + i.getPromptText()); //$NON-NLS-1$
}
return true;
}
示例3: get
import org.eclipse.jgit.transport.CredentialItem; //导入依赖的package包/类
@Override
public boolean get(URIish urIish, CredentialItem... credentialItems) throws UnsupportedCredentialItem {
if (userCredentials != null) {
Iterator<String> userCredentialsIterator = userCredentials.iterator();
for(CredentialItem item : credentialItems) {
String nextValue = userCredentialsIterator.next();
if (item instanceof CredentialItem.Username) {
((CredentialItem.Username)item).setValue(nextValue);
} else if (item instanceof CredentialItem.Password) {
((CredentialItem.Password)item).setValue(nextValue.toCharArray());
} else if (item instanceof CredentialItem.StringType) {
((CredentialItem.StringType)item).setValue(nextValue);
} else {
System.out.println(item);
System.out.println(item.getPromptText());
throw new UnsupportedCredentialItem(urIish, "Case not covered in ElegitCredentialsProvider");
}
}
}
return true;
}
示例4: get
import org.eclipse.jgit.transport.CredentialItem; //导入依赖的package包/类
@Override
public boolean get(final URIish uri,
final CredentialItem... items) throws UnsupportedCredentialItem {
try {
return super.get(uri,
items);
} catch (UnsupportedCredentialItem e) {
for (CredentialItem i : items) {
if (i instanceof CredentialItem.YesNoType) {
((CredentialItem.YesNoType) i).setValue(true);
return true;
} else {
continue;
}
}
}
return false;
}
示例5: supports
import org.eclipse.jgit.transport.CredentialItem; //导入依赖的package包/类
/**
* We support username and password credential items only.
* @see org.eclipse.jgit.transport.CredentialsProvider#supports(org.eclipse.jgit.transport.CredentialItem[])
*/
@Override
public boolean supports(CredentialItem... items) {
for (CredentialItem i : items) {
if (i instanceof CredentialItem.Username) {
continue;
}
else if (i instanceof CredentialItem.Password) {
continue;
}
else {
return false;
}
}
return true;
}
示例6: passphraseShouldSetCredentials
import org.eclipse.jgit.transport.CredentialItem; //导入依赖的package包/类
@Test
public void passphraseShouldSetCredentials() throws Exception {
final String passphrase = "mypassphrase";
Git mockGit = mock(Git.class);
MockCloneCommand mockCloneCommand = new MockCloneCommand(mockGit);
JGitEnvironmentRepository envRepository = new JGitEnvironmentRepository(this.environment);
envRepository.setGitFactory(new MockGitFactory(mockGit, mockCloneCommand));
envRepository.setUri("git+ssh://[email protected]/somegitrepo");
envRepository.setBasedir(new File("./mybasedir"));
envRepository.setPassphrase(passphrase);
envRepository.setCloneOnStart(true);
envRepository.afterPropertiesSet();
assertTrue(mockCloneCommand.hasPassphraseCredentialsProvider());
CredentialsProvider provider = mockCloneCommand.getCredentialsProvider();
assertFalse(provider.isInteractive());
CredentialItem.StringType stringCredential = new CredentialItem.StringType(PassphraseCredentialsProvider.PROMPT,
true);
assertTrue(provider.supports(stringCredential));
provider.get(new URIish(), stringCredential);
assertEquals(stringCredential.getValue(), passphrase);
}
示例7: testReturnsCredentials
import org.eclipse.jgit.transport.CredentialItem; //导入依赖的package包/类
@Test
public void testReturnsCredentials() throws URISyntaxException {
CredentialItem[] credentialItems = makeCredentialItems();
assertTrue(provider.get(new URIish(AWS_REPO), credentialItems));
String theUsername = ((CredentialItem.Username) credentialItems[0]).getValue();
char[] thePassword = ((CredentialItem.Password) credentialItems[1]).getValue();
assertEquals(USER, theUsername);
assertNotNull(thePassword);
// The password will always begin with a timestamp like
// 20161113T121314Z
assertTrue(thePassword.length > 16);
assertEquals('T', thePassword[8]);
assertEquals('Z', thePassword[15]);
}
示例8: get
import org.eclipse.jgit.transport.CredentialItem; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public boolean get(final URIish uriish,
final CredentialItem... items) {
for (final CredentialItem item : items) {
if (item instanceof CredentialItem.StringType) {
((CredentialItem.StringType) item).setValue(passphrase);
}
// This will automatically say "yes" to prompts
// TODO make this explicit to just accept host
// TODO make this configurable
if (item instanceof CredentialItem.YesNoType) {
((CredentialItem.YesNoType) item).setValue(true);
}
}
return true;
}
示例9: get
import org.eclipse.jgit.transport.CredentialItem; //导入依赖的package包/类
@Override
public boolean get(URIish uri, CredentialItem... items)
throws UnsupportedCredentialItem {
for (CredentialItem item : items) {
if (item instanceof CredentialItem.Username) {
((CredentialItem.Username) item).setValue(username);
} else if (item instanceof CredentialItem.Password) {
((CredentialItem.Password) item).setValue(password.toCharArray());
} else if (item instanceof CredentialItem.StringType) {
((CredentialItem.StringType) item).setValue(password);
} else if (item instanceof CredentialItem.InformationalMessage) {
throw new UnsupportedCredentialItem(uri, "Not supported");
} else if (item instanceof CredentialItem.YesNoType) {
// TODO handle strict host key checking here
throw new UnsupportedCredentialItem(uri, "Not supported");
} else {
throw new UnsupportedCredentialItem(uri, "Not supported");
}
}
return true;
}
示例10: supports
import org.eclipse.jgit.transport.CredentialItem; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public synchronized boolean supports(CredentialItem... credentialItems) {
items:
for (CredentialItem item : credentialItems) {
if (supports(defaultCredentials, item)) {
continue;
}
for (StandardCredentials c : specificCredentials.values()) {
if (supports(c, item)) {
continue items;
}
}
return false;
}
return true;
}
示例11: supports
import org.eclipse.jgit.transport.CredentialItem; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* If username/password is given, use it for HTTP auth.
*/
@Override
public boolean supports(CredentialItem... items) {
if (!(cred instanceof StandardUsernamePasswordCredentials))
return false;
for (CredentialItem i : items) {
if (i instanceof CredentialItem.Username)
continue;
else if (i instanceof CredentialItem.Password)
continue;
else
return false;
}
return true;
}
示例12: setUp
import org.eclipse.jgit.transport.CredentialItem; //导入依赖的package包/类
@Before
public void setUp() {
listener = StreamTaskListener.fromStdout();
provider = new SmartCredentialsProvider(listener);
username = new CredentialItem.Username();
password = new CredentialItem.Password();
maskedUsername = new StandardUsernameCredentialsCredentialItem(MASKED_USER_NAME_PROMPT, true);
unmaskedUsername = new StandardUsernameCredentialsCredentialItem(UNMASKED_USER_NAME_PROMPT, false);
maskedStringType = new CredentialItem.StringType(MASKED_STRING_TYPE_PROMPT, true);
unmaskedStringType = new CredentialItem.StringType(UNMASKED_STRING_TYPE_PROMPT, false);
specialStringType = new CredentialItem.StringType(SPECIAL_STRING_TYPE_PROMPT, false);
assertNull(username.getValue());
assertNull(password.getValue());
assertNull(maskedUsername.getValue());
assertNull(unmaskedUsername.getValue());
assertNull(maskedStringType.getValue());
assertNull(unmaskedStringType.getValue());
}
示例13: get
import org.eclipse.jgit.transport.CredentialItem; //导入依赖的package包/类
@Override
public boolean get(URIish uri, CredentialItem... items) throws UnsupportedCredentialItem {
for(CredentialItem item : items){
if(item instanceof CredentialItem.YesNoType){
((CredentialItem.YesNoType) item).setValue(true);
return true;
}
}
return false;
}
示例14: supports
import org.eclipse.jgit.transport.CredentialItem; //导入依赖的package包/类
@Override
public boolean supports(CredentialItem... items) {
for(CredentialItem item : items){
if(item instanceof CredentialItem.YesNoType){
return true;
}
}
return false;
}
示例15: supports
import org.eclipse.jgit.transport.CredentialItem; //导入依赖的package包/类
@Override
public boolean supports (CredentialItem... items) {
for (CredentialItem i : items) {
if (!(i instanceof CredentialItem.Username
|| i instanceof CredentialItem.Password)) {
return false;
}
}
return true;
}