本文整理汇总了Java中org.eclipse.jgit.transport.URIish.getUser方法的典型用法代码示例。如果您正苦于以下问题:Java URIish.getUser方法的具体用法?Java URIish.getUser怎么用?Java URIish.getUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.transport.URIish
的用法示例。
在下文中一共展示了URIish.getUser方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUsernamePassword
import org.eclipse.jgit.transport.URIish; //导入方法依赖的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.URIish; //导入方法依赖的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;
}
示例3: get
import org.eclipse.jgit.transport.URIish; //导入方法依赖的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;
}
示例4: getRepoUrl
import org.eclipse.jgit.transport.URIish; //导入方法依赖的package包/类
private String getRepoUrl(Repository repository) {
try {
RemoteConfig config = new RemoteConfig(repository.getConfig(), "origin"); //$NON-NLS-1$
for (URIish uri: config.getURIs()) {
if (uri.getUser() != null) {
return uri.setUser("user-name").toASCIIString(); //$NON-NLS-1$
}
return uri.toASCIIString();
}
} catch (Exception e) {
GerritToolsPlugin.getDefault().log(e);
}
return null;
}
示例5: handle
import org.eclipse.jgit.transport.URIish; //导入方法依赖的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))));
}
}
示例6: JGitWrapper
import org.eclipse.jgit.transport.URIish; //导入方法依赖的package包/类
public JGitWrapper(SharedPreferences preferences) throws Exception {
localPath = preferences.getString("git_local_path", "");
if (TextUtils.isEmpty(localPath))
throw new IllegalArgumentException("Must specify local git path");
String url = preferences.getString("git_url", "");
if (TextUtils.isEmpty(url))
throw new IllegalArgumentException("Must specify remote git url");
try {
URIish urIish = new URIish(url);
if (urIish.getUser() == null) {
String username = preferences.getString("git_username", "");
urIish = urIish.setUser(username);
}
remotePath = urIish.toString();
} catch (URISyntaxException e) {
throw new IllegalArgumentException("Invalid remote git url");
}
branch = preferences.getString("git_branch", "master");
if (branch.isEmpty())
throw new IllegalArgumentException("Must specify a git branch");
commitAuthor = preferences.getString("git_commit_author", "");
commitEmail = preferences.getString("git_commit_email", "");
String mergeStrategyString = preferences.getString("git_merge_strategy", "theirs");
mergeStrategy = MergeStrategy.get(mergeStrategyString);
if (mergeStrategy == null)
throw new IllegalArgumentException("Invalid merge strategy: " + mergeStrategyString);
setupJGitAuthentication(preferences);
}
示例7: GitRepository
import org.eclipse.jgit.transport.URIish; //导入方法依赖的package包/类
private GitRepository(URIish uri) throws RotationLoadException, IOException {
super(Cardinal.getNewRepoPath(DigestUtils.md5Hex(format(uri))));
this.gitUrl = uri;
if (uri.getUser() != null && uri.getPass() != null)
this.credentials = new UsernamePasswordCredentialsProvider(uri.getUser(), uri.getPass());
}