• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java AuthDialog类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:GitHttpGuiAuthenticator.java


示例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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:GitHttpGuiAuthenticator.java


示例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;
}
 
开发者ID:Microsoft,项目名称:vso-intellij,代码行数:15,代码来源:CredentialsPromptImpl.java


示例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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:38,代码来源:GitHttpGuiAuthenticator.java


示例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;
    }
}
 
开发者ID:janotav,项目名称:ali-idea-plugin,代码行数:16,代码来源:AttachmentAgmLinkDownloadTask.java


示例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;
      }
    }
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:63,代码来源:HgCommandAuthenticator.java


示例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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:64,代码来源:GitHttpCredentialsProvider.java


示例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;
      }
    }
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:59,代码来源:HgCommandAuthenticator.java



注:本文中的com.intellij.vcsUtil.AuthDialog类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JavaScriptUtil类代码示例发布时间:2022-05-15
下一篇:
Java LogicalPlan类代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap