本文整理汇总了Java中org.eclipse.jgit.transport.CredentialItem.StringType方法的典型用法代码示例。如果您正苦于以下问题:Java CredentialItem.StringType方法的具体用法?Java CredentialItem.StringType怎么用?Java CredentialItem.StringType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.transport.CredentialItem
的用法示例。
在下文中一共展示了CredentialItem.StringType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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);
}
示例3: 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;
}
示例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: 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());
}
示例6: 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;
}
示例7: getSession
import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
@Override
public synchronized RemoteSession getSession (URIish uri, CredentialsProvider credentialsProvider, FS fs, int tms) throws TransportException {
boolean agentUsed = false;
String host = uri.getHost();
CredentialItem.StringType identityFile = null;
if (credentialsProvider != null) {
identityFile = new JGitCredentialsProvider.IdentityFileItem("Identity file for " + host, false);
if (credentialsProvider.isInteractive() && credentialsProvider.get(uri, identityFile) && identityFile.getValue() != null) {
LOG.log(Level.FINE, "Identity file for {0}: {1}", new Object[] { host, identityFile.getValue() }); //NOI18N
agentUsed = setupJSch(fs, host, identityFile, uri, true);
LOG.log(Level.FINE, "Setting cert auth for {0}, agent={1}", new Object[] { host, agentUsed }); //NOI18N
}
}
try {
LOG.log(Level.FINE, "Trying to connect to {0}, agent={1}", new Object[] { host, agentUsed }); //NOI18N
return super.getSession(uri, credentialsProvider, fs, tms);
} catch (Exception ex) {
// catch rather all exceptions. In case jsch-agent-proxy is broken again we should
// at least fall back on key/pasphrase
if (agentUsed) {
LOG.log(ex instanceof TransportException ? Level.FINE : Level.INFO, null, ex);
setupJSch(fs, host, identityFile, uri, false);
LOG.log(Level.FINE, "Trying to connect to {0}, agent={1}", new Object[] { host, false }); //NOI18N
return super.getSession(uri, credentialsProvider, fs, tms);
} else {
LOG.log(Level.FINE, "Connection failed: {0}", host); //NOI18N
throw ex;
}
}
}
示例8: setupJSch
import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
private boolean setupJSch (FS fs, String host, CredentialItem.StringType identityFile, URIish uri, boolean preferAgent) throws TransportException {
boolean agentUsed;
if (sshConfig == null) {
sshConfig = OpenSshConfig.get(fs);
}
final OpenSshConfig.Host hc = sshConfig.lookup(host);
try {
JSch jsch = getJSch(hc, fs);
agentUsed = setupJSchIdentityRepository(jsch, identityFile.getValue(), preferAgent);
} catch (JSchException ex) {
throw new TransportException(uri, ex.getMessage(), ex);
}
return agentUsed;
}
示例9: get
import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
@Override
public boolean get(URIish uri, CredentialItem... items) throws UnsupportedCredentialItem {
for (CredentialItem ci : items) {
if (ci instanceof CredentialItem.YesNoType) {
handle((CredentialItem.YesNoType) ci);
} else if (ci instanceof CredentialItem.StringType) {
handle(uri, (CredentialItem.StringType) ci);
} else if (ci instanceof CredentialItem.CharArrayType) {
handle(uri, (CredentialItem.CharArrayType) ci);
} else {
return false;
}
}
return true;
}
示例10: handle
import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
private void handle(URIish uri, CredentialItem.StringType ci) {
if (ci instanceof CredentialItem.Username && uri.getUser() != null) {
ci.setValue(uri.getUser());
} else {
ci.setValue(blockingPrompt.request(prompt(String.class, uiNotificationFor(ci))));
}
}
示例11: supports
import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
/**
* {@inheritDoc}
* @return
*/
@Override
public boolean supports(CredentialItem... items) {
for (final CredentialItem item : items) {
if (item instanceof CredentialItem.StringType && item.getPromptText().startsWith(PROMPT)) {
continue;
} else {
return false;
}
}
return true;
}
示例12: gitCredentialsProviderFactoryCreatesPassphraseProvider
import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
@Test
public void gitCredentialsProviderFactoryCreatesPassphraseProvider() throws Exception {
final String passphrase = "mypassphrase";
final String gitUri = "git+ssh://[email protected]/somegitrepo";
GitCredentialsProviderFactory credentialsFactory = new GitCredentialsProviderFactory();
Git mockGit = mock(Git.class);
MockCloneCommand mockCloneCommand = new MockCloneCommand(mockGit);
JGitEnvironmentRepository envRepository = new JGitEnvironmentRepository(this.environment);
envRepository.setGitFactory(new MockGitFactory(mockGit, mockCloneCommand));
envRepository.setUri(gitUri);
envRepository.setBasedir(new File("./mybasedir"));
envRepository.setGitCredentialsProvider(credentialsFactory.createFor(gitUri, null, null, 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);
}
示例13: supports
import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*
* @return <code>true</code> when items contains a {@link CredentialItem}
* .StringType or .YesNoType
*/
@Override
public boolean supports(final CredentialItem... items) {
for (final CredentialItem item : items) {
if (item instanceof CredentialItem.StringType) {
return true;
}
if (item instanceof CredentialItem.YesNoType) {
return true;
}
}
return false;
}
示例14: testCredentials
import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
@Test
public void testCredentials() throws Exception {
final CredentialItem.StringType i = new CredentialItem.StringType("enter passphrase", true);
final CredentialItem i2 = new CredentialItem.InformationalMessage("info");
final PassphraseCredentialsProvider provider = new PassphraseCredentialsProvider("passphrase");
assertTrue(provider.get(null, i, i2));
assertEquals("passphrase", i.getValue());
assertFalse(provider.isInteractive());
assertTrue(provider.supports(i, i2));
assertTrue(provider.supports(i));
assertFalse(provider.supports(i2));
assertFalse(provider.supports());
}
示例15: get
import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public synchronized boolean get(URIish uri, CredentialItem... credentialItems) throws UnsupportedCredentialItem {
StandardCredentials c = specificCredentials.get(uri == null ? null : uri.toString());
if (c == null) {
c = defaultCredentials;
}
if (c == null) {
return false;
}
for (CredentialItem i : credentialItems) {
if (i instanceof StandardUsernameCredentialsCredentialItem && c instanceof StandardUsernameCredentials) {
((StandardUsernameCredentialsCredentialItem) i).setValue((StandardUsernameCredentials) c);
continue;
}
if (i instanceof CredentialItem.Username && c instanceof UsernameCredentials) {
((CredentialItem.Username) i).setValue(((UsernameCredentials)c).getUsername());
continue;
}
if (i instanceof CredentialItem.Password && c instanceof PasswordCredentials) {
((CredentialItem.Password) i).setValue(
((PasswordCredentials) c).getPassword().getPlainText().toCharArray());
continue;
}
if (i instanceof CredentialItem.StringType) {
if (i.getPromptText().equals("Password: ") && c instanceof PasswordCredentials) {
((CredentialItem.StringType) i).setValue(((PasswordCredentials) c).getPassword().getPlainText());
continue;
}
}
throw new UnsupportedCredentialItem(uri, i.getClass().getName()
+ ":" + i.getPromptText());
}
return true;
}