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


Java PasswordSafe类代码示例

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


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

示例1: PasswordSafeOptionsPanel

import com.intellij.ide.passwordSafe.PasswordSafe; //导入依赖的package包/类
/**
 * The constructor
 *
 * @param passwordSafe the password safe service instance
 */
public PasswordSafeOptionsPanel(PasswordSafe passwordSafe) {
  myPasswordSafe = (PasswordSafeImpl)passwordSafe;
  myMasterPasswordStateLabel.setForeground(JBColor.BLUE);
  updateMasterPasswordState();
  myManagePasswordButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      if (myPasswordSafe.getMasterKeyProvider().isEmpty()) {
        MasterPasswordDialog.resetMasterPasswordDialog(null, myPasswordSafe.getMasterKeyProvider(), PasswordSafeOptionsPanel.class).show();
      }
      else {
        MasterPasswordDialog.changeMasterPasswordDialog(null, myPasswordSafe.getMasterKeyProvider(), PasswordSafeOptionsPanel.class).show();
      }
      updateMasterPasswordState();
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:PasswordSafeOptionsPanel.java

示例2: getPassword

import com.intellij.ide.passwordSafe.PasswordSafe; //导入依赖的package包/类
@NotNull
public String getPassword() {
  final String login = getLogin();
  if (StringUtil.isEmptyOrSpaces(login)) return "";

  String password;
  try {
    password = PasswordSafe.getInstance().getPassword(null, StudySettings.class, STEPIC_SETTINGS_PASSWORD_KEY);
  }
  catch (PasswordSafeException e) {
    LOG.info("Couldn't get password for key [" + STEPIC_SETTINGS_PASSWORD_KEY + "]", e);
    password = "";
  }

  return StringUtil.notNullize(password);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:StudySettings.java

示例3: 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

示例4: 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

示例5: 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

示例6: doOKAction

import com.intellij.ide.passwordSafe.PasswordSafe; //导入依赖的package包/类
@Override
protected void doOKAction() {
  final String email = getEmail();
  if (myConfiguration != null) {
    myConfiguration.setEmail(email);
  }
  else {
    PropertiesComponent.getInstance(myProject).setValue(EMAIL_KEY, email);
  }
  if (myRememberPasswordCheckBox.isSelected()) {
    try {
      PasswordSafe.getInstance().storePassword(myProject, AppEngineAccountDialog.class, getPasswordKey(email), getPassword());
    }
    catch (PasswordSafeException e) {
      Messages.showErrorDialog(myProject, "Cannot store password: " + e.getMessage(), CommonBundle.getErrorTitle());
      return;
    }
  }
  super.doOKAction();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:AppEngineAccountDialog.java

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: getInstance

import com.intellij.ide.passwordSafe.PasswordSafe; //导入依赖的package包/类
@Nullable
public InstanceCredentials getInstance(String name) {
    if (!instanceNames.contains(name)) {
        return null;
    }
    if (instanceMap.get(name) != null) {
        return instanceMap.get(name);
    }
    String clearString;
    try {
        clearString = PasswordSafe.getInstance().getPassword(ProjectManager.getInstance().getDefaultProject(), InstancesPersistentStateComponent.class, SALES_FORCE_INSTANCE + name);
    } catch (Exception e) {
        logger.warn("Unable to get credentials from password safe", e);
        return null;
    }
    InstanceCredentials instance = InstanceCredentials.fromString(clearString);
    instanceMap.put(name, instance);
    return instance;
}
 
开发者ID:polyglot-mark,项目名称:salesforce-plugin,代码行数:20,代码来源:InstancesPersistentStateComponent.java

示例12: saveProjectPassword

import com.intellij.ide.passwordSafe.PasswordSafe; //导入依赖的package包/类
public void saveProjectPassword(NSClient client) {
    if (client != null) {
        CredentialAttributes attributes = new CredentialAttributes(client.getNSAccount().getAccountName() + ":" + client.getNSAccount().getAccountId(), client.getNSAccount().getAccountEmail(), this.getClass(), false);
        Credentials saveCredentials = new Credentials(attributes.getUserName(), client.getNSAccount().getAccountPassword());
        PasswordSafe.getInstance().set(attributes, saveCredentials);
    }
}
 
开发者ID:Topher84,项目名称:NetSuite-Tools-For-WebStorm,代码行数:8,代码来源:ProjectSettingsController.java

示例13: apply

import com.intellij.ide.passwordSafe.PasswordSafe; //导入依赖的package包/类
@Override
public boolean apply() {
  if (myFirstTime ||
      Messages.showYesNoDialog((Project)null, "All stored passwords will be removed! Are you sure you want to proceed?",
                               "Confirm Master Password Reset", Messages.getWarningIcon()) == Messages.YES) {
    mySafe.resetMasterPassword(new String(myNewPasswordField.getPassword()), myEncryptCheckBox.isSelected());
    ((PasswordSafeImpl)PasswordSafe.getInstance()).getMemoryProvider().clear();
    return true;
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:ResetPasswordComponent.java

示例14: 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

示例15: setPassword

import com.intellij.ide.passwordSafe.PasswordSafe; //导入依赖的package包/类
public void setPassword(@NotNull String password) {
  try {
    PasswordSafe.getInstance().storePassword(null, StudySettings.class, STEPIC_SETTINGS_PASSWORD_KEY, password);
  }
  catch (PasswordSafeException e) {
    LOG.info("Couldn't set password for key [" + STEPIC_SETTINGS_PASSWORD_KEY + "]", e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:StudySettings.java


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