本文整理汇总了Java中org.eclipse.jgit.transport.CredentialItem.Password方法的典型用法代码示例。如果您正苦于以下问题:Java CredentialItem.Password方法的具体用法?Java CredentialItem.Password怎么用?Java CredentialItem.Password使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.transport.CredentialItem
的用法示例。
在下文中一共展示了CredentialItem.Password方法的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 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
示例6: 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());
}
示例7: 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;
}
示例8: get
import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
@Override
public boolean get (URIish uriish, CredentialItem... items) throws UnsupportedCredentialItem {
String user = uriish.getUser();
if (user == null) {
user = "";
}
String password = uriish.getPass();
if (password == null) {
password = "";
}
for (CredentialItem i : items) {
if (i instanceof CredentialItem.Username) {
((CredentialItem.Username) i).setValue(user);
continue;
}
if (i instanceof CredentialItem.Password) {
((CredentialItem.Password) i).setValue(password.toCharArray());
continue;
}
if (i instanceof CredentialItem.StringType) {
if (i.getPromptText().equals("Password: ")) { //NOI18N
((CredentialItem.StringType) i).setValue(password);
continue;
}
}
throw new UnsupportedCredentialItem(uriish, i.getClass().getName()
+ ":" + i.getPromptText()); //NOI18N
}
return true;
}
示例9: supports
import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
@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;
}
示例10: get
import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
@Override
public boolean get(URIish uri, CredentialItem... items) throws UnsupportedCredentialItem {
String username = uri.getUser();
if (username == null) {
username = cfgUser;
}
if (username == null) {
return false;
}
String password = uri.getPass();
if (password == null) {
password = cfgPass;
}
if (password == null) {
return false;
}
for (CredentialItem i : items) {
if (i instanceof CredentialItem.Username) {
((CredentialItem.Username) i).setValue(username);
} else if (i instanceof CredentialItem.Password) {
((CredentialItem.Password) i).setValue(password.toCharArray());
} else {
throw new UnsupportedCredentialItem(uri, i.getPromptText());
}
}
return true;
}
示例11: handle
import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
private void handle(URIish uri, CredentialItem.CharArrayType ci) {
if (ci instanceof CredentialItem.Password && uri.getPass() != null) {
ci.setValue(uri.getPass().toCharArray());
} else {
ci.setValue(blockingPrompt.request(prompt(String.class, uiNotificationFor(ci))).toCharArray());
}
}
示例12: usernamePasswordShouldSetCredentials
import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
@Test
public void usernamePasswordShouldSetCredentials() throws Exception {
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"));
final String username = "someuser";
final String password = "mypassword";
envRepository.setUsername(username);
envRepository.setPassword(password);
envRepository.setCloneOnStart(true);
envRepository.afterPropertiesSet();
assertTrue(mockCloneCommand.getCredentialsProvider() instanceof UsernamePasswordCredentialsProvider);
CredentialsProvider provider = mockCloneCommand.getCredentialsProvider();
CredentialItem.Username usernameCredential = new CredentialItem.Username();
CredentialItem.Password passwordCredential = new CredentialItem.Password();
assertTrue(provider.supports(usernameCredential));
assertTrue(provider.supports(passwordCredential));
provider.get(new URIish(), usernameCredential);
assertEquals(usernameCredential.getValue(), username);
provider.get(new URIish(), passwordCredential);
assertEquals(String.valueOf(passwordCredential.getValue()), password);
}
示例13: gitCredentialsProviderFactoryCreatesUsernamePasswordProvider
import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
@Test
public void gitCredentialsProviderFactoryCreatesUsernamePasswordProvider() throws Exception {
GitCredentialsProviderFactory credentialsFactory = new GitCredentialsProviderFactory();
Git mockGit = mock(Git.class);
MockCloneCommand mockCloneCommand = new MockCloneCommand(mockGit);
final String username = "someuser";
final String password = "mypassword";
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.setGitCredentialsProvider(
credentialsFactory.createFor(envRepository.getUri(), username, password, null));
envRepository.setCloneOnStart(true);
envRepository.afterPropertiesSet();
assertTrue(mockCloneCommand.getCredentialsProvider() instanceof UsernamePasswordCredentialsProvider);
CredentialsProvider provider = mockCloneCommand.getCredentialsProvider();
CredentialItem.Username usernameCredential = new CredentialItem.Username();
CredentialItem.Password passwordCredential = new CredentialItem.Password();
assertTrue(provider.supports(usernameCredential));
assertTrue(provider.supports(passwordCredential));
provider.get(new URIish(), usernameCredential);
assertEquals(usernameCredential.getValue(), username);
provider.get(new URIish(), passwordCredential);
assertEquals(String.valueOf(passwordCredential.getValue()), password);
}
示例14: supports
import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
@Override
public boolean supports(CredentialItem... items) {
for (CredentialItem item : items) {
if (item instanceof CredentialItem.Password) {
continue;
}
if (item instanceof CredentialItem.Username) {
continue;
}
return false;
}
return true;
}
示例15: supports
import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
private boolean supports(StandardCredentials c, CredentialItem i) {
if (c == null) {
return false;
}
if (i instanceof StandardUsernameCredentialsCredentialItem) {
return c instanceof StandardUsernameCredentials;
}
if (i instanceof CredentialItem.Username) {
return c instanceof UsernameCredentials;
}
if (i instanceof CredentialItem.Password) {
return c instanceof PasswordCredentials;
}
return false;
}