use of com.intellij.ide.wizard.CommitStepException in project intellij-community by JetBrains.
the class AbstractProjectWizard method doFinishAction.
@VisibleForTesting
public boolean doFinishAction() {
if (myDelegate != null) {
myDelegate.doFinishAction();
return true;
}
int idx = getCurrentStep();
try {
do {
final ModuleWizardStep step = mySteps.get(idx);
if (step != getCurrentStepObject()) {
step.updateStep();
}
if (!commitStepData(step)) {
return false;
}
step.onStepLeaving();
try {
step._commit(true);
} catch (CommitStepException e) {
handleCommitException(e);
return false;
}
if (!isLastStep(idx)) {
idx = getNextStep(idx);
} else {
for (ModuleWizardStep wizardStep : mySteps) {
try {
wizardStep.onWizardFinished();
} catch (CommitStepException e) {
handleCommitException(e);
return false;
}
}
break;
}
} while (true);
} finally {
myCurrentStep = idx;
updateStep();
}
return true;
}
use of com.intellij.ide.wizard.CommitStepException in project android by JetBrains.
the class GradleSignStep method commitForNext.
@Override
protected void commitForNext() throws CommitStepException {
if (myAndroidModel == null) {
throw new CommitStepException(AndroidBundle.message("android.apk.sign.gradle.no.model"));
}
final String apkFolder = myApkPathField.getText().trim();
if (apkFolder.isEmpty()) {
throw new CommitStepException(AndroidBundle.message("android.apk.sign.gradle.missing.destination"));
}
File f = new File(apkFolder);
if (!f.isDirectory() || !f.canWrite()) {
throw new CommitStepException(AndroidBundle.message("android.apk.sign.gradle.invalid.destination"));
}
int[] selectedFlavorIndices = myFlavorsList.getSelectedIndices();
if (!myFlavorsListModel.isEmpty() && selectedFlavorIndices.length == 0) {
throw new CommitStepException(AndroidBundle.message("android.apk.sign.gradle.missing.flavors"));
}
Object[] selectedFlavors = myFlavorsList.getSelectedValues();
List<String> flavors = new ArrayList<String>(selectedFlavors.length);
for (int i = 0; i < selectedFlavors.length; i++) {
flavors.add((String) selectedFlavors[i]);
}
boolean isV1 = myV1JarSignatureCheckBox.isSelected();
boolean isV2 = myV2FullAPKSignatureCheckBox.isSelected();
if (myV1JarSignatureCheckBox.isEnabled() && !isV1 && !isV2) {
throw new CommitStepException(AndroidBundle.message("android.apk.sign.gradle.missing.signature-version"));
}
myWizard.setApkPath(apkFolder);
myWizard.setGradleOptions((String) myBuildTypeCombo.getSelectedItem(), flavors);
myWizard.setV1Signature(isV1);
myWizard.setV2Signature(isV2);
PropertiesComponent properties = PropertiesComponent.getInstance(myWizard.getProject());
properties.setValue(PROPERTY_APK_PATH, apkFolder);
properties.setValues(PROPERTY_FLAVORS, ArrayUtil.toStringArray(flavors));
properties.setValue(PROPERTY_BUILD_TYPE, (String) myBuildTypeCombo.getSelectedItem());
properties.setValue(PROPERTY_V1_SIGN, myV1JarSignatureCheckBox.isSelected());
properties.setValue(PROPERTY_V2_SIGN, myV2FullAPKSignatureCheckBox.isSelected());
}
use of com.intellij.ide.wizard.CommitStepException 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);
}
use of com.intellij.ide.wizard.CommitStepException in project android by JetBrains.
the class KeystoreStep method loadKeyStore.
private KeyStore loadKeyStore(File keystoreFile) throws CommitStepException {
final char[] password = myKeyStorePasswordField.getPassword();
FileInputStream fis = null;
AndroidUtils.checkPassword(password);
if (!keystoreFile.isFile()) {
throw new CommitStepException(AndroidBundle.message("android.cannot.find.file.error", keystoreFile.getPath()));
}
final KeyStore keyStore;
try {
keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
//noinspection IOResourceOpenedButNotSafelyClosed
fis = new FileInputStream(keystoreFile);
keyStore.load(fis, password);
} catch (Exception e) {
throw new CommitStepException(e.getMessage());
} finally {
if (fis != null) {
try {
fis.close();
} catch (IOException ignored) {
}
}
Arrays.fill(password, '\0');
}
return keyStore;
}
use of com.intellij.ide.wizard.CommitStepException in project android by JetBrains.
the class KeystoreStep method loadKeyAndSaveToWizard.
private void loadKeyAndSaveToWizard(KeyStore keyStore, String alias, char[] keyPassword) throws CommitStepException {
KeyStore.PrivateKeyEntry entry;
try {
assert keyStore != null;
entry = (KeyStore.PrivateKeyEntry) keyStore.getEntry(alias, new KeyStore.PasswordProtection(keyPassword));
} catch (Exception e) {
throw new CommitStepException("Error: " + e.getMessage());
}
if (entry == null) {
throw new CommitStepException(AndroidBundle.message("android.extract.package.cannot.find.key.error", alias));
}
PrivateKey privateKey = entry.getPrivateKey();
Certificate certificate = entry.getCertificate();
if (privateKey == null || certificate == null) {
throw new CommitStepException(AndroidBundle.message("android.extract.package.cannot.find.key.error", alias));
}
myWizard.setPrivateKey(privateKey);
myWizard.setCertificate((X509Certificate) certificate);
}
Aggregations