本文整理汇总了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();
}
});
}
示例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);
}
示例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);
}
}
示例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);
}
}
}
示例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);
}
}
示例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();
}
示例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);
}
}
}
示例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;
}
}
示例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;
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
}