本文整理汇总了Java中org.eclipse.jgit.errors.UnsupportedCredentialItem类的典型用法代码示例。如果您正苦于以下问题:Java UnsupportedCredentialItem类的具体用法?Java UnsupportedCredentialItem怎么用?Java UnsupportedCredentialItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UnsupportedCredentialItem类属于org.eclipse.jgit.errors包,在下文中一共展示了UnsupportedCredentialItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
import org.eclipse.jgit.errors.UnsupportedCredentialItem; //导入依赖的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;
}
示例2: get
import org.eclipse.jgit.errors.UnsupportedCredentialItem; //导入依赖的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: get
import org.eclipse.jgit.errors.UnsupportedCredentialItem; //导入依赖的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;
}
示例4: get
import org.eclipse.jgit.errors.UnsupportedCredentialItem; //导入依赖的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: get
import org.eclipse.jgit.errors.UnsupportedCredentialItem; //导入依赖的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;
}
示例6: get
import org.eclipse.jgit.errors.UnsupportedCredentialItem; //导入依赖的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: get
import org.eclipse.jgit.errors.UnsupportedCredentialItem; //导入依赖的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;
}
示例8: get
import org.eclipse.jgit.errors.UnsupportedCredentialItem; //导入依赖的package包/类
@Override
public boolean get(URIish uri, CredentialItem... items) throws UnsupportedCredentialItem {
System.out.println("Credentials are required to clone " + uri.toString());
for (CredentialItem item : items) {
if (!handle(item)) {
return false;
}
}
return true;
}
示例9: get
import org.eclipse.jgit.errors.UnsupportedCredentialItem; //导入依赖的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: testUriWithCurlyBracesReturnsTrue
import org.eclipse.jgit.errors.UnsupportedCredentialItem; //导入依赖的package包/类
@Test
public void testUriWithCurlyBracesReturnsTrue() throws UnsupportedCredentialItem, URISyntaxException {
GitCredentialsProviderFactory factory = new GitCredentialsProviderFactory();
provider = (AwsCodeCommitCredentialProvider)
factory.createFor(CURLY_BRACES_REPO, USER, PASSWORD, null);
CredentialItem[] credentialItems = makeCredentialItems();
assertTrue(provider.get(new URIish(CURLY_BRACES_REPO), credentialItems));
}
示例11: testThrowsUnsupportedCredentialException
import org.eclipse.jgit.errors.UnsupportedCredentialItem; //导入依赖的package包/类
@Test
public void testThrowsUnsupportedCredentialException() throws URISyntaxException {
CredentialItem[] goodCredentialItems = makeCredentialItems();
CredentialItem[] badCredentialItems = new CredentialItem[] {
goodCredentialItems[0],
goodCredentialItems[1],
new CredentialItem.YesNoType("OK?")
};
try {
provider.get(new URIish(AWS_REPO), badCredentialItems);
fail("Expected UnsupportedCredentialItem exception");
} catch (UnsupportedCredentialItem e) {
assertNotNull(e.getMessage());
}
}
示例12: get
import org.eclipse.jgit.errors.UnsupportedCredentialItem; //导入依赖的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;
}
示例13: get
import org.eclipse.jgit.errors.UnsupportedCredentialItem; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* If username/password is given, use it for HTTP auth.
*/
@Override
public boolean get(URIish uri, CredentialItem... items) throws UnsupportedCredentialItem {
if (!(cred instanceof StandardUsernamePasswordCredentials))
return false;
StandardUsernamePasswordCredentials _cred = (StandardUsernamePasswordCredentials) cred;
for (CredentialItem i : items) {
if (i instanceof CredentialItem.Username) {
((CredentialItem.Username) i).setValue(_cred.getUsername());
continue;
}
if (i instanceof CredentialItem.Password) {
((CredentialItem.Password) i).setValue(
_cred.getPassword().getPlainText().toCharArray());
continue;
}
if (i instanceof CredentialItem.StringType) {
if (i.getPromptText().equals("Password: ")) {
((CredentialItem.StringType) i).setValue(
_cred.getPassword().getPlainText());
continue;
}
}
throw new UnsupportedCredentialItem(uri, i.getClass().getName()
+ ":" + i.getPromptText());
}
return true;
}
示例14: getSession
import org.eclipse.jgit.errors.UnsupportedCredentialItem; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public RemoteSession getSession(URIish uri, CredentialsProvider credentialsProvider, FS fs, int tms) throws TransportException {
try {
int p = uri.getPort();
if (p<0) p = 22;
Connection con = new Connection(uri.getHost(), p);
con.setTCPNoDelay(true);
con.connect(); // TODO: host key check
boolean authenticated;
if (credentialsProvider instanceof SmartCredentialsProvider) {
final SmartCredentialsProvider smart = (SmartCredentialsProvider) credentialsProvider;
StandardUsernameCredentialsCredentialItem
item = new StandardUsernameCredentialsCredentialItem("Credentials for " + uri, false);
authenticated = smart.supports(item)
&& smart.get(uri, item)
&& SSHAuthenticator.newInstance(con, item.getValue(), uri.getUser())
.authenticate(smart.listener);
} else if (credentialsProvider instanceof CredentialsProviderImpl) {
CredentialsProviderImpl sshcp = (CredentialsProviderImpl) credentialsProvider;
authenticated = SSHAuthenticator.newInstance(con, sshcp.cred).authenticate(sshcp.listener);
} else {
authenticated = false;
}
if (!authenticated && con.isAuthenticationComplete())
throw new TransportException("Authentication failure");
return wrap(con);
} catch (UnsupportedCredentialItem | IOException | InterruptedException e) {
throw new TransportException(uri,"Failed to connect",e);
}
}
示例15: testGetThrowsException
import org.eclipse.jgit.errors.UnsupportedCredentialItem; //导入依赖的package包/类
@Test
public void testGetThrowsException() {
String expectedUsername = "expected-add-credentials-username";
Secret secret = Secret.fromString("password-secret");
StandardUsernamePasswordCredentials credentials = new StandardUsernamePasswordCredentialsImpl(expectedUsername, secret);
provider.addCredentials(gitURI.toString(), credentials);
exception.expect(UnsupportedCredentialItem.class);
assertTrue(provider.get(gitURI, username, password, maskedUsername, unmaskedUsername, maskedStringType));
}