Search in sources :

Example 1 with PasswordSafe

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);
}
Also used : CommitStepException(com.intellij.ide.wizard.CommitStepException) Project(com.intellij.openapi.project.Project) KeyStore(java.security.KeyStore) File(java.io.File) PasswordSafe(com.intellij.ide.passwordSafe.PasswordSafe)

Aggregations

PasswordSafe (com.intellij.ide.passwordSafe.PasswordSafe)1 CommitStepException (com.intellij.ide.wizard.CommitStepException)1 Project (com.intellij.openapi.project.Project)1 File (java.io.File)1 KeyStore (java.security.KeyStore)1