use of com.intellij.credentialStore.Credentials in project intellij-plugins by StepicOrg.
the class CookieStore method save.
void save() {
CredentialAttributes attributes;
String serviceName = getClass().getName();
attributes = new CredentialAttributes(serviceName, "cookies", getClass(), false);
Map<String, Set<Cookie>> cookies = new HashMap<>();
buckets.forEach((key, value) -> cookies.put(key, new HashSet<>(value.values())));
String serialized = gson.toJson(cookies, bucketsType);
Credentials credentials = new Credentials(attributes.getUserName(), serialized);
PasswordSafe.getInstance().set(attributes, credentials);
}
use of com.intellij.credentialStore.Credentials in project intellij-community by JetBrains.
the class BasePasswordSafeProvider method get.
@Nullable
public Credentials get(@NotNull CredentialAttributes attributes) {
byte[] masterKey = key();
byte[] encryptedPassword = getEncryptedPassword(EncryptionUtil.encryptKey(masterKey, EncryptionUtil.rawKey(attributes)));
OneTimeString password = encryptedPassword == null ? null : EncryptionUtil.decryptText(masterKey, encryptedPassword);
return password == null ? null : new Credentials(attributes.getUserName(), password);
}
use of com.intellij.credentialStore.Credentials in project intellij-community by JetBrains.
the class IdeErrorsDialog method updateCredentialsPane.
private void updateCredentialsPane(AbstractMessage message) {
if (message != null) {
ErrorReportSubmitter submitter = getSubmitter(message.getThrowable());
if (submitter instanceof ITNReporter) {
myCredentialsPanel.setVisible(true);
Credentials credentials = ErrorReportConfigurable.getCredentials();
if (CredentialAttributesKt.isFulfilled(credentials)) {
assert credentials != null;
myCredentialsLabel.setHtmlText(DiagnosticBundle.message("diagnostic.error.report.submit.report.as", credentials.getUserName()));
} else {
myCredentialsLabel.setHtmlText(DiagnosticBundle.message("diagnostic.error.report.submit.error.anonymously"));
}
return;
}
}
myCredentialsPanel.setVisible(false);
}
use of com.intellij.credentialStore.Credentials in project intellij-community by JetBrains.
the class GitHttpGuiAuthenticator method saveAuthData.
@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) {
Credentials credentials = new Credentials(myPasswordKey, myPassword);
PasswordSafe.getInstance().set(CredentialAttributes(PASS_REQUESTER, credentials.getUserName()), credentials, !mySaveOnDisk);
}
}
use of com.intellij.credentialStore.Credentials in project intellij-plugins by StepicOrg.
the class CookieStore method loadCookies.
@NotNull
private Map<String, Map<Cookie, Cookie>> loadCookies() {
CredentialAttributes attributes;
String serviceName = this.getClass().getName();
attributes = new CredentialAttributes(serviceName, "cookies", getClass(), false);
Credentials credentials = PasswordSafe.getInstance().get(attributes);
String json = credentials != null ? credentials.getPasswordAsString() : null;
Map<String, Set<Cookie>> cookies = new HashMap<>();
if (json != null) {
try {
cookies = gson.fromJson(json, bucketsType);
} catch (JsonSyntaxException e) {
logger.warn(e);
}
}
Map<String, Map<Cookie, Cookie>> buckets = new HashMap<>();
cookies.forEach((key, value) -> {
Map<Cookie, Cookie> bucket = new HashMap<>();
value.forEach(cookie -> bucket.put(cookie, cookie));
buckets.put(key, bucket);
});
return buckets;
}
Aggregations