com.intellij.credentialStore.CredentialAttributes Java Examples
The following examples show how to use
com.intellij.credentialStore.CredentialAttributes.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ApplicationPasswordRegistry.java From p4ic4idea with Apache License 2.0 | 6 votes |
/** * Retrieve the stored password. If it was not stored, then the promise's * resolved value will be null. * * @param config source * @return promise with a null value (if no password stored) or the password. */ @NotNull public final Promise<OneTimeString> get(@NotNull final ServerConfig config) { if (LOG.isDebugEnabled()) { LOG.debug("Fetching password for config " + config.getServerName()); } final CredentialAttributes attr = getCredentialAttributes(config, true); return PasswordSafe.getInstance().getAsync(attr) .then((c) -> c == null ? null : c.getPassword()) // should use onProcessed, but that's a higher API version. .processed((p) -> { if (LOG.isDebugEnabled()) { LOG.debug("Fetched password for config " + config.getServerName()); } }) .rejected((t) -> LOG.warn("Password fetch generated an error", t)); }
Example #2
Source File: ApplicationPasswordRegistry.java From p4ic4idea with Apache License 2.0 | 5 votes |
/** * Stores the given password in the registry, associated with the config. After being * called, the password will be blanked out. */ public final void store(@NotNull ServerConfig config, @NotNull char[] password, boolean inMemoryOnly) { if (LOG.isDebugEnabled()) { LOG.debug("Storing password for config " + config.getServerName()); } final CredentialAttributes attr = getCredentialAttributes(config, inMemoryOnly); PasswordSafe.getInstance().set(attr, new Credentials(config.getUsername(), password)); Arrays.fill(password, (char) 0); }
Example #3
Source File: ApplicationPasswordRegistry.java From p4ic4idea with Apache License 2.0 | 5 votes |
/** * Remove the password associated with the configuration. * * @param config server configuration for the password. */ public final void remove(@NotNull ServerConfig config) { if (LOG.isDebugEnabled()) { LOG.debug("Removing password for config " + config.getServerName()); } CredentialAttributes attr = getCredentialAttributes(config, false); PasswordSafe.getInstance().set(attr, new Credentials(config.getUsername(), (String) null)); }
Example #4
Source File: ApplicationPasswordRegistry.java From p4ic4idea with Apache License 2.0 | 5 votes |
@NotNull protected CredentialAttributes getCredentialAttributes(@NotNull ServerConfig config, boolean inMemory) { return new CredentialAttributes( "p4ic4idea:" + config.getServerName().getFullPort(), config.getUsername(), null, inMemory); }
Example #5
Source File: MockPasswordSafe.java From p4ic4idea with Apache License 2.0 | 5 votes |
@Override public void set(@NotNull CredentialAttributes credentialAttributes, @Nullable Credentials credentials, boolean inMemoryOnly) { String pw = credentials == null ? null : credentials.getPasswordAsString(); if (pw == null) { passwords.remove(getPasswordKey(credentialAttributes)); } else { passwords.put(getPasswordKey(credentialAttributes), pw); } }
Example #6
Source File: MockPasswordSafe.java From p4ic4idea with Apache License 2.0 | 5 votes |
@Nullable @Override public Credentials get(@NotNull CredentialAttributes credentialAttributes) { String pw = passwords.get(getPasswordKey(credentialAttributes)); if (pw == null) { return null; } return new Credentials(credentialAttributes.getUserName(), pw); }
Example #7
Source File: ReviewDataProvider.java From review-board-idea-plugin with Apache License 2.0 | 4 votes |
private static void savePassword(String username, String password) { Credentials saveCredentials = new Credentials(username, password); PasswordSafe.getInstance().set(new CredentialAttributes(REVIEWBOARD_PASSWORD, username, ReviewDataProvider.class, false), saveCredentials); }
Example #8
Source File: ReviewDataProvider.java From review-board-idea-plugin with Apache License 2.0 | 4 votes |
private static String getPassword(String username) { CredentialAttributes attributes = new CredentialAttributes(REVIEWBOARD_PASSWORD, username, ReviewDataProvider.class, false); return PasswordSafe.getInstance().getPassword(attributes); }
Example #9
Source File: MockPasswordSafe.java From p4ic4idea with Apache License 2.0 | 4 votes |
@NotNull @Override public Promise<Credentials> getAsync(@NotNull CredentialAttributes credentialAttributes) { return Promise.resolve(get(credentialAttributes)); }
Example #10
Source File: MockPasswordSafe.java From p4ic4idea with Apache License 2.0 | 4 votes |
@Override public boolean isPasswordStoredOnlyInMemory(@NotNull CredentialAttributes credentialAttributes, @NotNull Credentials credentials) { return true; }
Example #11
Source File: MockPasswordSafe.java From p4ic4idea with Apache License 2.0 | 4 votes |
@Override public void set(@NotNull CredentialAttributes credentialAttributes, @Nullable Credentials credentials) { set(credentialAttributes, credentials, true); }
Example #12
Source File: MockPasswordSafe.java From p4ic4idea with Apache License 2.0 | 4 votes |
private String getPasswordKey(CredentialAttributes attr) { return attr.getServiceName() + '\u263a' + attr.getUserName(); }
Example #13
Source File: CrucibleSettings.java From Crucible4IDEA with MIT License | 4 votes |
public void savePassword(String pass) { PasswordSafe.getInstance().set(new CredentialAttributes(CRUCIBLE_SETTINGS_PASSWORD_KEY), new Credentials(USERNAME, pass)); }
Example #14
Source File: CrucibleSettings.java From Crucible4IDEA with MIT License | 4 votes |
@Nullable public String getPassword() { final Credentials credentials = PasswordSafe.getInstance().get(new CredentialAttributes(CRUCIBLE_SETTINGS_PASSWORD_KEY)); return credentials != null ? credentials.getPasswordAsString() : null; }