Search in sources :

Example 1 with Credentials

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);
}
Also used : CredentialAttributes(com.intellij.credentialStore.CredentialAttributes) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Credentials(com.intellij.credentialStore.Credentials) HashSet(java.util.HashSet)

Example 2 with 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);
}
Also used : OneTimeString(com.intellij.credentialStore.OneTimeString) Credentials(com.intellij.credentialStore.Credentials) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with Credentials

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);
}
Also used : Credentials(com.intellij.credentialStore.Credentials)

Example 4 with Credentials

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);
    }
}
Also used : Credentials(com.intellij.credentialStore.Credentials)

Example 5 with Credentials

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;
}
Also used : CredentialAttributes(com.intellij.credentialStore.CredentialAttributes) Set(java.util.Set) HashSet(java.util.HashSet) JsonSyntaxException(com.google.gson.JsonSyntaxException) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Credentials(com.intellij.credentialStore.Credentials) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

Credentials (com.intellij.credentialStore.Credentials)7 CredentialAttributes (com.intellij.credentialStore.CredentialAttributes)4 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 LinkedHashMap (java.util.LinkedHashMap)2 Set (java.util.Set)2 NotNull (org.jetbrains.annotations.NotNull)2 JsonSyntaxException (com.google.gson.JsonSyntaxException)1 OneTimeString (com.intellij.credentialStore.OneTimeString)1 Map (java.util.Map)1 Nullable (org.jetbrains.annotations.Nullable)1 TokenInfo (org.stepik.api.objects.auth.TokenInfo)1 StepikProjectManager (org.stepik.core.StepikProjectManager)1