本文整理汇总了Java中org.eclipse.jgit.transport.CredentialItem.YesNoType方法的典型用法代码示例。如果您正苦于以下问题:Java CredentialItem.YesNoType方法的具体用法?Java CredentialItem.YesNoType怎么用?Java CredentialItem.YesNoType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.transport.CredentialItem
的用法示例。
在下文中一共展示了CredentialItem.YesNoType方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例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.YesNoType){
((CredentialItem.YesNoType) item).setValue(true);
return true;
}
}
return false;
}
示例5: 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;
}
示例6: apply
import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
@Override
public Boolean apply(CredentialItem credentialItem) {
String input = readInput(credentialItem);
CredentialItem.YesNoType casted = (CredentialItem.YesNoType) credentialItem;
casted.setValue(input.toLowerCase().equals("y"));
return true;
}
示例7: setUp
import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
item = new CredentialItem.YesNoType("test");
handlers.put(CredentialItem.YesNoType.class, function);
provider = new GitCredentialsProvider(handlers);
}
示例8: 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;
}
示例9: testThrowsUnsupportedCredentialException
import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的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());
}
}
示例10: 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;
}
示例11: get
import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
/**
* @see org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider#get(org.eclipse.jgit.transport.URIish, org.eclipse.jgit.transport.CredentialItem[])
*/
@Override
public boolean get(URIish uri, CredentialItem... items) {
if (logger.isDebugEnabled()) {
logger.debug("Credential query, uri " + uri);
}
for (CredentialItem item : items) {
// TODO Should handle item.isValueSecure()
if (logger.isDebugEnabled()) {
logger.debug(item.getClass() + ", secure value: " + item.isValueSecure());
logger.debug("Message: |" + item.getPromptText() + "|");
}
if (item instanceof CredentialItem.StringType
&& item.getPromptText().startsWith("Passphrase")) {
// A not so great method to check that the pass phrase is requested.
passphaseRequested = true;
((CredentialItem.StringType) item).setValue(passphrase);
// true tells the engine that we supplied the value.
// The engine will look inside the given item for the response.
return true;
}
if (item instanceof CredentialItem.YesNoType) {
if (logger.isDebugEnabled()) {
logger.debug("YesNoType");
}
// Present the question to the user.
boolean userResponse = askUser(item.getPromptText());
((CredentialItem.YesNoType) item).setValue(userResponse);
// true tells the engine that we supplied the value.
// The engine will look inside the given item for the response.
return true;
}
}
return super.get(uri, items);
}
示例12: get
import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
@Override
public boolean get(URIish urIish, CredentialItem... credentialItems) throws UnsupportedCredentialItem {
if (conversation == null) return false;
for (CredentialItem credentialItem : credentialItems) {
String message = ChatColor.GOLD + ">>> " + ChatColor.RESET + credentialItem.getPromptText();
if (credentialItem instanceof CredentialItem.InformationalMessage){
scheduler.runTask(plugin,new MessageSender(caller, message, callerWorkspaceName,0));
continue;
}
boolean wrongInput = false;
do {
String inputMessage;
synchronized (sync) {
lastInputMessage = null;
scheduler.runTask(plugin, new MessageSender(caller, message, callerWorkspaceName, 2));
awaitInput = true;
while (!finished && lastInputMessage == null) {
try {
sync.wait(1000);
if (conversation.getState().equals(ABANDONED)) {
finished = true;
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
awaitInput = false;
if (finished) return false;
inputMessage = lastInputMessage;
}
if (credentialItem instanceof CredentialItem.YesNoType) {
if (inputMessage.matches("yes|true|1|on|y|\\+|valid|correct|right")) {
((CredentialItem.YesNoType) credentialItem).setValue(true);
} else if (inputMessage.matches("no|false|n|0|-|invalid|incorrect|wrong")) {
((CredentialItem.YesNoType) credentialItem).setValue(false);
} else {
wrongInput = true;
}
} else if (credentialItem instanceof CredentialItem.StringType) {
((CredentialItem.StringType) credentialItem).setValue(inputMessage);
} else if (credentialItem instanceof CredentialItem.CharArrayType) {
((CredentialItem.CharArrayType) credentialItem).setValue(inputMessage.toCharArray());
}
} while (wrongInput);
}
return true;
}
示例13: handle
import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
private void handle(CredentialItem.YesNoType ci) {
ci.setValue(blockingPrompt.request(promptYesOrNo(uiNotificationFor(ci))));
}