本文整理汇总了Java中com.intellij.vcsUtil.AuthDialog类的典型用法代码示例。如果您正苦于以下问题:Java AuthDialog类的具体用法?Java AuthDialog怎么用?Java AuthDialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AuthDialog类属于com.intellij.vcsUtil包,在下文中一共展示了AuthDialog类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: askUsername
import com.intellij.vcsUtil.AuthDialog; //导入依赖的package包/类
@Override
@NotNull
public String askUsername(@NotNull String url) {
myUnifiedUrl = getUnifiedUrl(url);
Pair<GitHttpAuthDataProvider, AuthData> authData = findBestAuthData(getUnifiedUrl(url));
String login = null;
String password = null;
if (authData != null) {
login = authData.second.getLogin();
password = authData.second.getPassword();
myDataProvider = authData.first;
}
LOG.debug("askUsername. dataProvider=" + getCurrentDataProviderName() + ", unifiedUrl= " + getUnifiedUrl(url) +
", login=" + login + ", passwordKnown=" + (password != null));
if (login != null && password != null) {
myPassword = password;
return login;
}
AuthDialog dialog = showAuthDialog(getDisplayableUrl(url), login);
LOG.debug("askUsername. Showed dialog:" + (dialog == null ? "NULL" : dialog.isOK() ? "OK" : "Cancel"));
if (dialog == null || !dialog.isOK()) {
myWasCancelled = true;
return "";
}
// remember values to store in the database afterwards, if authentication succeeds
myPassword = dialog.getPassword();
myLogin = dialog.getUsername();
mySaveOnDisk = dialog.isRememberPassword();
myPasswordKey = makeKey(myUnifiedUrl, myLogin);
return myLogin;
}
示例2: showAuthDialog
import com.intellij.vcsUtil.AuthDialog; //导入依赖的package包/类
@Nullable
private AuthDialog showAuthDialog(final String url, final String login) {
final Ref<AuthDialog> dialog = Ref.create();
ApplicationManager.getApplication().invokeAndWait(new Runnable() {
@Override
public void run() {
dialog.set(new AuthDialog(myProject, myTitle, "Enter credentials for " + url, login, null, true));
dialog.get().show();
}
}, ModalityState.any());
return dialog.get();
}
示例3: promptInternal
import com.intellij.vcsUtil.AuthDialog; //导入依赖的package包/类
private boolean promptInternal(final String serverUrl, final String defaultUserName) {
final AuthDialog authDialog = new AuthDialog(ProjectManager.getInstance().getDefaultProject(),
TfPluginBundle.message(TfPluginBundle.KEY_PROMPT_CREDENTIALS_TITLE),
TfPluginBundle.message(TfPluginBundle.KEY_PROMPT_CREDENTIALS_MESSAGE, serverUrl),
defaultUserName, null, true);
if (authDialog.showAndGet()) {
userName = authDialog.getUsername();
password = authDialog.getPassword();
return true;
}
return false;
}
示例4: askUsername
import com.intellij.vcsUtil.AuthDialog; //导入依赖的package包/类
@Override
@NotNull
public String askUsername(@NotNull String url) {
url = adjustUrl(url);
AuthData authData = getSavedAuthData(myProject, url);
String login = null;
String password = null;
if (authData != null) {
login = authData.getLogin();
password = authData.getPassword();
}
if (login != null && password != null) {
myPassword = password;
return login;
}
final AuthDialog dialog = new AuthDialog(myProject, myTitle, "Enter credentials for " + url, login, null, true);
ApplicationManager.getApplication().invokeAndWait(new Runnable() {
@Override
public void run() {
dialog.show();
}
}, myModalityState == null ? ModalityState.defaultModalityState() : myModalityState);
if (!dialog.isOK()) {
return "";
}
// remember values to store in the database afterwards, if authentication succeeds
myPassword = dialog.getPassword();
myLogin = dialog.getUsername();
myUrl = url;
myRememberOnDisk = dialog.isRememberPassword();
myPasswordKey = makeKey(myUrl, myLogin);
return myLogin;
}
示例5: getAuthDialog
import com.intellij.vcsUtil.AuthDialog; //导入依赖的package包/类
private AuthDialog getAuthDialog(final String location) {
final Ref<AuthDialog> dialog = Ref.create();
ApplicationManager.getApplication().invokeAndWait(new Runnable() {
@Override
public void run() {
dialog.set(new AuthDialog(project, "ALM credentials", "Enter credentials for " + location, username, null, true));
dialog.get().show();
}
}, ModalityState.any());
if (dialog.get().isOK()) {
return dialog.get();
} else {
return null;
}
}
示例6: run
import com.intellij.vcsUtil.AuthDialog; //导入依赖的package包/类
public void run() {
// find if we've already been here
final HgVcs vcs = HgVcs.getInstance(myProject);
if (vcs == null) {
return;
}
@NotNull final HgGlobalSettings hgGlobalSettings = vcs.getGlobalSettings();
@Nullable String rememberedLoginsForUrl = null;
if (!StringUtil.isEmptyOrSpaces(myURL)) {
rememberedLoginsForUrl = hgGlobalSettings.getRememberedUserName(VirtualFileManager.extractPath(myURL));
}
String login = myProposedLogin;
if (StringUtil.isEmptyOrSpaces(login)) {
// find the last used login
login = rememberedLoginsForUrl;
}
String password = null;
if (!StringUtil.isEmptyOrSpaces(login) && myURL != null) {
// if we've logged in with this login, search for password
final String key = keyForUrlAndLogin(myURL, login);
try {
final PasswordSafeImpl passwordSafe = (PasswordSafeImpl)PasswordSafe.getInstance();
if (mySilent) {
password = passwordSafe.getMemoryProvider().getPassword(myProject, HgCommandAuthenticator.class, key);
}
else {
password = passwordSafe.getPassword(myProject, HgCommandAuthenticator.class, key);
}
}
catch (PasswordSafeException e) {
LOG.info("Couldn't get password for key [" + key + "]", e);
}
}
// don't show dialog if we don't have to (both fields are known) except force authorization required
if (!myForceAuthorization && !StringUtil.isEmptyOrSpaces(
password) && !StringUtil.isEmptyOrSpaces(login)) {
myUserName = login;
myPassword = password;
ok = true;
return;
}
if (mySilent) {
ok = false;
return;
}
final AuthDialog dialog = new AuthDialog(myProject, HgVcsMessages.message("hg4idea.dialog.login.password.required"),
HgVcsMessages.message("hg4idea.dialog.login.description", myURL),
login, password, true);
if (dialog.showAndGet()) {
myUserName = dialog.getUsername();
myPassword = dialog.getPassword();
myRememberPassword = dialog.isRememberPassword();
ok = true;
}
}
示例7: get
import com.intellij.vcsUtil.AuthDialog; //导入依赖的package包/类
@Override
public boolean get(URIish uri, CredentialItem... items) throws UnsupportedCredentialItem {
CredentialItem.Username userNameItem = null;
CredentialItem.Password passwordItem = null;
for (CredentialItem item : items) {
if (item instanceof CredentialItem.Username) {
userNameItem = (CredentialItem.Username)item;
} else if (item instanceof CredentialItem.Password) {
passwordItem = (CredentialItem.Password)item;
}
}
if (userNameItem != null || passwordItem != null) {
String username = getUserNameFromUrl(myRemoteUrl);
String password = null;
if (username == null) { // username is not in the url => reading pre-filled value from the password storage
username = myUserName;
password = myPassword;
} else if (username.equals(myUserName)) { // username is in url => read password only if it is for the same user
password = myPassword;
}
boolean rememberPassword = myRememberPassword;
boolean ok;
if (username != null && password != null && !myShowDialog) {
ok = true;
myDialogShown = false;
} else {
final AuthDialog dialog = new AuthDialog(myProject, "Login required", "Login to " + myRemoteUrl, username, password, false);
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
dialog.show();
}
});
ok = dialog.isOK();
myDialogShown = true;
if (ok) {
username = dialog.getUsername();
password = dialog.getPassword();
rememberPassword = dialog.isRememberPassword();
}
}
if (ok) {
if (userNameItem != null) {
userNameItem.setValue(username);
}
if (passwordItem != null) {
passwordItem.setValue(password.toCharArray());
}
myRememberPassword = rememberPassword;
myPassword = password;
myUserName = username;
}
else {
myCancelled = true;
myRememberPassword = false; // in case of re-usage of the provider
}
return ok;
}
return true;
}
示例8: run
import com.intellij.vcsUtil.AuthDialog; //导入依赖的package包/类
public void run() {
// find if we've already been here
final HgVcs vcs = HgVcs.getInstance(myProject);
if (vcs == null) { return; }
@NotNull final HgGlobalSettings hgGlobalSettings = vcs.getGlobalSettings();
@Nullable String rememberedLoginsForUrl = null;
if (!StringUtil.isEmptyOrSpaces(myURL)) {
rememberedLoginsForUrl = hgGlobalSettings.getRememberedUserName(VirtualFileManager.extractPath(myURL));
}
String login = myProposedLogin;
if (StringUtil.isEmptyOrSpaces(login)) {
// find the last used login
login = rememberedLoginsForUrl;
}
String password = null;
if (!StringUtil.isEmptyOrSpaces(login) && myURL != null) {
// if we've logged in with this login, search for password
final String key = keyForUrlAndLogin(myURL, login);
try {
final PasswordSafeImpl passwordSafe = (PasswordSafeImpl)PasswordSafe.getInstance();
password = passwordSafe.getMemoryProvider().getPassword(myProject, HgCommandAuthenticator.class, key);
if (password == null) {
final MasterKeyPasswordSafe masterKeyProvider = passwordSafe.getMasterKeyProvider();
if (!masterKeyProvider.isEmpty()) {
// workaround for: don't ask for master password, if the requested password is not there.
// this should be fixed in PasswordSafe: don't ask master password to look for keys
// until then we assume that is PasswordSafe was used (there is anything there), then it makes sense to look there.
password = masterKeyProvider.getPassword(myProject, HgCommandAuthenticator.class, key);
}
}
} catch (PasswordSafeException e) {
LOG.info("Couldn't get password for key [" + key + "]", e);
}
}
// don't show dialog if we don't have to (both fields are known) except force authorization required
if (!myForceAuthorization && !StringUtil.isEmptyOrSpaces(
password) && !StringUtil.isEmptyOrSpaces(login)) {
myUserName = login;
myPassword = password;
ok = true;
return;
}
final AuthDialog dialog = new AuthDialog(myProject, HgVcsMessages.message("hg4idea.dialog.login.password.required"), HgVcsMessages.message("hg4idea.dialog.login.description", myURL),
login, password, true);
dialog.show();
if (dialog.isOK()) {
myUserName = dialog.getUsername();
myPassword = dialog.getPassword();
myRememberPassword = dialog.isRememberPassword();
ok = true;
}
}