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