当前位置: 首页>>代码示例>>Java>>正文


Java PasswordSafe.getInstance方法代码示例

本文整理汇总了Java中com.intellij.ide.passwordSafe.PasswordSafe.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java PasswordSafe.getInstance方法的具体用法?Java PasswordSafe.getInstance怎么用?Java PasswordSafe.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.ide.passwordSafe.PasswordSafe的用法示例。


在下文中一共展示了PasswordSafe.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setPassword

import com.intellij.ide.passwordSafe.PasswordSafe; //导入方法依赖的package包/类
private void setPassword(@NotNull String password, boolean rememberPassword) {
  try {
    if (rememberPassword) {
      PasswordSafe.getInstance().storePassword(null, GithubSettings.class, GITHUB_SETTINGS_PASSWORD_KEY, password);
    }
    else {
      final PasswordSafeImpl passwordSafe = (PasswordSafeImpl)PasswordSafe.getInstance();
      if (passwordSafe.getSettings().getProviderType() != PasswordSafeSettings.ProviderType.DO_NOT_STORE) {
        passwordSafe.getMemoryProvider().storePassword(null, GithubSettings.class, GITHUB_SETTINGS_PASSWORD_KEY, password);
      }
    }
  }
  catch (PasswordSafeException e) {
    LOG.info("Couldn't set password for key [" + GITHUB_SETTINGS_PASSWORD_KEY + "]", e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:GithubSettings.java

示例2: saveAuthData

import com.intellij.ide.passwordSafe.PasswordSafe; //导入方法依赖的package包/类
@Override
public void saveAuthData() {
  // save login and url
  if (myUnifiedUrl != null && myLogin != null) {
    GitRememberedInputs.getInstance().addUrl(myUnifiedUrl, myLogin);
  }

  // save password
  if (myPasswordKey != null && myPassword != null) {
    PasswordSafeImpl passwordSafe = (PasswordSafeImpl)PasswordSafe.getInstance();
    try {
      passwordSafe.getMemoryProvider().storePassword(myProject, PASS_REQUESTER, myPasswordKey, myPassword);
      if (mySaveOnDisk) {
        passwordSafe.getMasterKeyProvider().storePassword(myProject, PASS_REQUESTER, myPasswordKey, myPassword);
      }
    }
    catch (MasterPasswordUnavailableException ignored) {
    }
    catch (PasswordSafeException e) {
      LOG.error("Couldn't remember password for " + myPasswordKey, e);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:GitHttpGuiAuthenticator.java

示例3: saveCredentials

import com.intellij.ide.passwordSafe.PasswordSafe; //导入方法依赖的package包/类
public void saveCredentials() {
  if (myGetPassword == null) return;

  // if checkbox is selected, save on disk. Otherwise in memory. Don't read password safe settings.

  final PasswordSafeImpl passwordSafe = (PasswordSafeImpl)PasswordSafe.getInstance();
  final String url = VirtualFileManager.extractPath(myGetPassword.getURL());
  final String key = keyForUrlAndLogin(url, myGetPassword.getUserName());
  try {
    if (myGetPassword.isRememberPassword()) {
      PasswordSafe.getInstance().storePassword(myProject, HgCommandAuthenticator.class, key, myGetPassword.getPassword());
    }
    else if (passwordSafe.getSettings().getProviderType() != PasswordSafeSettings.ProviderType.DO_NOT_STORE) {
      passwordSafe.getMemoryProvider().storePassword(myProject, HgCommandAuthenticator.class, key, myGetPassword.getPassword());
    }
    final HgVcs vcs = HgVcs.getInstance(myProject);
    if (vcs != null) {
      vcs.getGlobalSettings().addRememberedUrl(url, myGetPassword.getUserName());
    }
  }
  catch (PasswordSafeException e) {
    LOG.info("Couldn't store the password for key [" + key + "]", e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:HgCommandAuthenticator.java

示例4: saveAuthData

import com.intellij.ide.passwordSafe.PasswordSafe; //导入方法依赖的package包/类
@Override
public void saveAuthData() {
  // save login and url
  if (myUrl != null && myLogin != null) {
    GitRememberedInputs.getInstance().addUrl(myUrl, myLogin);
  }

  // save password
  if (myPasswordKey != null && myPassword != null) {
    PasswordSafeImpl passwordSafe = (PasswordSafeImpl)PasswordSafe.getInstance();
    try {
      passwordSafe.getMemoryProvider().storePassword(myProject, PASS_REQUESTER, myPasswordKey, myPassword);
      if (myRememberOnDisk) {
        passwordSafe.getMasterKeyProvider().storePassword(myProject, PASS_REQUESTER, myPasswordKey, myPassword);
      }
    }
    catch (PasswordSafeException e) {
      LOG.error("Couldn't remember password for " + myPasswordKey, e);
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:22,代码来源:GitHttpGuiAuthenticator.java

示例5: getSavedAuthData

import com.intellij.ide.passwordSafe.PasswordSafe; //导入方法依赖的package包/类
@Nullable
private static AuthData getSavedAuthData(@NotNull Project project, @NotNull String url) {
  String userName = GitRememberedInputs.getInstance().getUserNameForUrl(url);
  if (userName == null) {
    return trySavedAuthDataFromProviders(url);
  }
  String key = makeKey(url, userName);
  final PasswordSafe passwordSafe = PasswordSafe.getInstance();
  try {
    String password = passwordSafe.getPassword(project, PASS_REQUESTER, key);
    if (password != null) {
      return new AuthData(userName, password);
    }
    return trySavedAuthDataFromProviders(url);
  }
  catch (PasswordSafeException e) {
    LOG.info("Couldn't get the password for key [" + key + "]", e);
    return null;
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:GitHttpGuiAuthenticator.java

示例6: getUsernameAndPassword

import com.intellij.ide.passwordSafe.PasswordSafe; //导入方法依赖的package包/类
@Nullable
private static AuthData getUsernameAndPassword(Project project, String url) {
  url = adjustHttpUrl(url);
  String userName = GitRememberedInputs.getInstance().getUserNameForUrl(url);
  if (userName == null) {
    return trySavedAuthDataFromProviders(url);
  }
  String key = keyForUrlAndLogin(url, userName);
  final PasswordSafe passwordSafe = PasswordSafe.getInstance();
  try {
    String password = passwordSafe.getPassword(project, GitHttpCredentialsProvider.class, key);
    if (password != null) {
      return new AuthData(userName, password);
    }
    return null;
  }
  catch (PasswordSafeException e) {
    LOG.info("Couldn't get the password for key [" + key + "]", e);
    return null;
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:22,代码来源:GitHttpAdapter.java

示例7: saveCredentials

import com.intellij.ide.passwordSafe.PasswordSafe; //导入方法依赖的package包/类
public void saveCredentials() {
  if (myRunnable == null) return;

  // if checkbox is selected, remember on disk. Otherwise in memory. Don't read password safe settings.

  final PasswordSafeImpl passwordSafe = (PasswordSafeImpl)PasswordSafe.getInstance();
  final String url = VirtualFileManager.extractPath(myRunnable.getURL());
  final String key = keyForUrlAndLogin(url, myRunnable.getUserName());

  final PasswordSafeProvider provider =
    myRunnable.isRememberPassword() ? passwordSafe.getMasterKeyProvider() : passwordSafe.getMemoryProvider();
  try {
    provider.storePassword(myProject, HgCommandAuthenticator.class, key, myRunnable.getPassword());
    final HgVcs vcs = HgVcs.getInstance(myProject);
    if (vcs != null) {
      vcs.getGlobalSettings().addRememberedUrl(url, myRunnable.getUserName());
    }
  }
  catch (PasswordSafeException e) {
    LOG.info("Couldn't store the password for key [" + key + "]", e);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:HgCommandAuthenticator.java

示例8: decideOnShowRememberPasswordOption

import com.intellij.ide.passwordSafe.PasswordSafe; //导入方法依赖的package包/类
@Nullable
private static Boolean decideOnShowRememberPasswordOption(@Nullable String password, boolean rememberByDefault) {
  final PasswordSafeImpl passwordSafe = (PasswordSafeImpl)PasswordSafe.getInstance();
  // if password saving is disabled, don't show the checkbox.
  if (passwordSafe.getSettings().getProviderType().equals(PasswordSafeSettings.ProviderType.DO_NOT_STORE)) {
    return null;
  }
  // if password is prefilled, it is expected to continue remembering it.
  if (!StringUtil.isEmptyOrSpaces(password)) {
    return true;
  }
  return rememberByDefault;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:AuthDialog.java

示例9: KeystoreStep

import com.intellij.ide.passwordSafe.PasswordSafe; //导入方法依赖的package包/类
public KeystoreStep(ExportSignedPackageWizard wizard, boolean useGradleForSigning) {
  myWizard = wizard;
  myUseGradleForSigning = useGradleForSigning;
  final Project project = wizard.getProject();

  final GenerateSignedApkSettings settings = GenerateSignedApkSettings.getInstance(project);
  myKeyStorePathField.setText(settings.KEY_STORE_PATH);
  myKeyAliasField.setText(settings.KEY_ALIAS);
  myRememberPasswordCheckBox.setSelected(settings.REMEMBER_PASSWORDS);

  if (settings.REMEMBER_PASSWORDS) {
    final PasswordSafe passwordSafe = PasswordSafe.getInstance();
    try {
      String password = passwordSafe.getPassword(project, KeystoreStep.class, makePasswordKey(
        KEY_STORE_PASSWORD_KEY, settings.KEY_STORE_PATH, null));
      if (password != null) {
        myKeyStorePasswordField.setText(password);
      }
      password = passwordSafe.getPassword(project, KeystoreStep.class, makePasswordKey(
        KEY_PASSWORD_KEY, settings.KEY_STORE_PATH, settings.KEY_ALIAS));
      if (password != null) {
        myKeyPasswordField.setText(password);
      }
    }
    catch (PasswordSafeException e) {
      LOG.debug(e);
      myKeyStorePasswordField.setText("");
      myKeyPasswordField.setText("");
    }
  }
  AndroidUiUtil.initSigningSettingsForm(project, this);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:KeystoreStep.java

示例10: getAuthData

import com.intellij.ide.passwordSafe.PasswordSafe; //导入方法依赖的package包/类
@Nullable
@Override
public AuthData getAuthData(@NotNull String url) {
  String userName = getUsername(url);
  String key = makeKey(url, userName);
  final PasswordSafe passwordSafe = PasswordSafe.getInstance();
  try {
    String password = passwordSafe.getPassword(myProject, PASS_REQUESTER, key);
    return new AuthData(StringUtil.notNullize(userName), password);
  }
  catch (PasswordSafeException e) {
    LOG.info("Couldn't get the password for key [" + key + "]", e);
    return null;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:GitHttpGuiAuthenticator.java

示例11: decideOnShowRememberPasswordOption

import com.intellij.ide.passwordSafe.PasswordSafe; //导入方法依赖的package包/类
private static boolean decideOnShowRememberPasswordOption(@Nullable String password, boolean rememberByDefault) {
  final PasswordSafeImpl passwordSafe = (PasswordSafeImpl)PasswordSafe.getInstance();
  // if password saving is disabled, don't show the checkbox.
  if (passwordSafe.getSettings().getProviderType().equals(PasswordSafeSettings.ProviderType.DO_NOT_STORE)) {
    return false;
  }
  // if password is prefilled, it is expected to continue remembering it.
  if (!StringUtil.isEmptyOrSpaces(password)) {
    return true;
  }
  return rememberByDefault;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:13,代码来源:AuthDialog.java

示例12: rememberPassword

import com.intellij.ide.passwordSafe.PasswordSafe; //导入方法依赖的package包/类
private static void rememberPassword(@NotNull GitHttpCredentialsProvider credentialsProvider) {
  if (!credentialsProvider.wasDialogShown()) { // the dialog is not shown => everything is already stored
    return;
  }
  final PasswordSafeImpl passwordSafe = (PasswordSafeImpl)PasswordSafe.getInstance();
  if (passwordSafe.getSettings().getProviderType() == PasswordSafeSettings.ProviderType.DO_NOT_STORE) {
    return;
  }
  String login = credentialsProvider.getUserName();
  if (login == null || credentialsProvider.getPassword() == null) {
    return;
  }

  String url = adjustHttpUrl(credentialsProvider.getUrl());
  String key = keyForUrlAndLogin(url, login);
  try {
    // store in memory always
    storePassword(passwordSafe.getMemoryProvider(), credentialsProvider, key);
    if (credentialsProvider.isRememberPassword()) {
      storePassword(passwordSafe.getMasterKeyProvider(), credentialsProvider, key);
    }
    GitRememberedInputs.getInstance().addUrl(url, login);
  }
  catch (PasswordSafeException e) {
    LOG.info("Couldn't store the password for key [" + key + "]", e);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:28,代码来源:GitHttpAdapter.java

示例13: getAuthData

import com.intellij.ide.passwordSafe.PasswordSafe; //导入方法依赖的package包/类
private AuthData getAuthData(String url) {
    String userName = AlmRememberedInputs.getInstance().getUserNameForUrl(url);
    String key = makeKey(userName, url);
    final PasswordSafe passwordSafe = PasswordSafe.getInstance();
    try {
        String password = passwordSafe.getPassword(project, AttachmentAgmLinkDownloadTask.class, key);
        return new AuthData(StringUtil.notNullize(userName), password);
    }
    catch (PasswordSafeException e) {
        logger.error("Couldn't get the password for key [" + key + "]", e);
        return null;
    }
}
 
开发者ID:janotav,项目名称:ali-idea-plugin,代码行数:14,代码来源:AttachmentAgmLinkDownloadTask.java

示例14: setPassword

import com.intellij.ide.passwordSafe.PasswordSafe; //导入方法依赖的package包/类
public static void setPassword(String password) {
    CredentialAttributes attributes = new CredentialAttributes(de.domjos.ideaMantis.service.ConnectionSettings.class.getName());
    PasswordSafe safe = PasswordSafe.getInstance();
    safe.setPassword(attributes, password);
}
 
开发者ID:domjos1994,项目名称:ideaMantis,代码行数:6,代码来源:Helper.java

示例15: getPassword

import com.intellij.ide.passwordSafe.PasswordSafe; //导入方法依赖的package包/类
public static String getPassword() {
    CredentialAttributes attributes = new CredentialAttributes(de.domjos.ideaMantis.service.ConnectionSettings.class.getName());
    PasswordSafe safe = PasswordSafe.getInstance();
    return safe.getPassword(attributes);
}
 
开发者ID:domjos1994,项目名称:ideaMantis,代码行数:6,代码来源:Helper.java


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