use of com.intellij.ide.passwordSafe.PasswordSafe in project android by JetBrains.
the class KeystoreStep method commitForNext.
@Override
protected void commitForNext() throws CommitStepException {
final String keyStoreLocation = myKeyStorePathField.getText().trim();
if (keyStoreLocation.length() == 0) {
throw new CommitStepException(AndroidBundle.message("android.export.package.specify.keystore.location.error"));
}
final char[] keyStorePassword = myKeyStorePasswordField.getPassword();
if (keyStorePassword.length == 0) {
throw new CommitStepException(AndroidBundle.message("android.export.package.specify.key.store.password.error"));
}
final String keyAlias = myKeyAliasField.getText().trim();
if (keyAlias.length() == 0) {
throw new CommitStepException(AndroidBundle.message("android.export.package.specify.key.alias.error"));
}
final char[] keyPassword = myKeyPasswordField.getPassword();
if (keyPassword.length == 0) {
throw new CommitStepException(AndroidBundle.message("android.export.package.specify.key.password.error"));
}
if (myUseGradleForSigning) {
myWizard.setGradleSigningInfo(new GradleSigningInfo(keyStoreLocation, keyStorePassword, keyAlias, keyPassword));
} else {
final KeyStore keyStore = loadKeyStore(new File(keyStoreLocation));
if (keyStore == null) {
throw new CommitStepException(AndroidBundle.message("android.export.package.keystore.error.title"));
}
loadKeyAndSaveToWizard(keyStore, keyAlias, keyPassword);
}
final Project project = myWizard.getProject();
final GenerateSignedApkSettings settings = GenerateSignedApkSettings.getInstance(project);
settings.KEY_STORE_PATH = keyStoreLocation;
settings.KEY_ALIAS = keyAlias;
final boolean rememberPasswords = myRememberPasswordCheckBox.isSelected();
settings.REMEMBER_PASSWORDS = rememberPasswords;
final PasswordSafe passwordSafe = PasswordSafe.getInstance();
final String keyStorePasswordKey = makePasswordKey(KEY_STORE_PASSWORD_KEY, keyStoreLocation, null);
final String keyPasswordKey = makePasswordKey(KEY_PASSWORD_KEY, keyStoreLocation, keyAlias);
passwordSafe.setPassword(KeystoreStep.class, keyStorePasswordKey, rememberPasswords ? new String(keyStorePassword) : null);
passwordSafe.setPassword(KeystoreStep.class, keyPasswordKey, rememberPasswords ? new String(keyPassword) : null);
}
Aggregations