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); } }
public boolean isSavePasswordMakesSense() { final PasswordSafeImpl passwordSafe = (PasswordSafeImpl) PasswordSafe.getInstance(); return passwordSafe.getSettings().getProviderType() == PasswordSafeSettings.ProviderType.MASTER_PASSWORD; }
/** * Check if master key provider is empty * * @param ps the password safe component * @return true if the provider is empty */ private static boolean isMasterKeyEmpty(PasswordSafeImpl ps) { return ps.getMasterKeyProvider().isEmpty(); }