use of org.kse.gui.error.Problem in project keystore-explorer by kaikramer.
the class DImportKeyPairPvk method createLoadPvkProblem.
private Problem createLoadPvkProblem(Exception exception, File pvkFile) {
String problemStr = null;
ArrayList<String> causeList = new ArrayList<String>();
if (jcbEncrypted.isSelected()) {
problemStr = MessageFormat.format(res.getString("DImportKeyPairPvk.NoLoadEncryptedPvk.Problem"), pvkFile.getName());
causeList.add(res.getString("DImportKeyPairPvk.PasswordIncorrectPvk.Cause"));
} else {
problemStr = MessageFormat.format(res.getString("DImportKeyPairPvk.NoLoadUnencryptedPvk.Problem"), pvkFile.getName());
}
causeList.add(res.getString("DImportKeyPairPvk.NotPvk.Cause"));
causeList.add(res.getString("DImportKeyPairPvk.CorruptedPvk.Cause"));
String[] causes = causeList.toArray(new String[causeList.size()]);
Problem problem = new Problem(problemStr, causes, exception);
return problem;
}
use of org.kse.gui.error.Problem in project keystore-explorer by kaikramer.
the class DImportKeyPairPvk method createLoadCertsProblem.
private Problem createLoadCertsProblem(Exception exception, File certsFile) {
String problemStr = MessageFormat.format(res.getString("DImportKeyPairPvk.NoLoadCerts.Problem"), certsFile.getName());
String[] causes = new String[] { res.getString("DImportKeyPairPvk.NotCerts.Cause"), res.getString("DImportKeyPairPvk.CorruptedCerts.Cause") };
Problem problem = new Problem(problemStr, causes, exception);
return problem;
}
use of org.kse.gui.error.Problem in project keystore-explorer by kaikramer.
the class DSignMidlet method okPressed.
private void okPressed() {
String inputJad = jtfInputJad.getText().trim();
if (inputJad.length() == 0) {
JOptionPane.showMessageDialog(this, res.getString("DSignMidlet.InputJadRequired.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
return;
}
File inputJadFile = new File(inputJad);
if (!inputJadFile.isFile()) {
JOptionPane.showMessageDialog(this, MessageFormat.format(res.getString("DSignMidlet.InputJadNotFile.message"), inputJadFile), getTitle(), JOptionPane.WARNING_MESSAGE);
return;
}
try {
MidletSigner.readJadFile(inputJadFile);
} catch (IOException ex) {
String problemStr = MessageFormat.format(res.getString("DSignMidlet.NoOpenJad.Problem"), inputJadFile.getName());
String[] causes = new String[] { res.getString("DSignMidlet.NotJad.Cause"), res.getString("DSignMidlet.CorruptedJad.Cause") };
Problem problem = new Problem(problemStr, causes, ex);
DProblem dProblem = new DProblem(this, res.getString("DSignMidlet.ProblemOpeningJad.Title"), problem);
dProblem.setLocationRelativeTo(this);
dProblem.setVisible(true);
return;
}
boolean signDirectly = jcbSignDirectly.isSelected();
File outputJadFile;
if (signDirectly) {
outputJadFile = inputJadFile;
} else {
String outputJad = jtfOutputJad.getText().trim();
if (outputJad.length() == 0) {
JOptionPane.showMessageDialog(this, res.getString("DSignMidlet.OutputJadRequired.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
return;
}
outputJadFile = new File(outputJad);
}
String jar = jtfJar.getText().trim();
if (jar.length() == 0) {
JOptionPane.showMessageDialog(this, res.getString("DSignMidlet.JarRequired.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
return;
}
File jarFile = new File(jar);
if (!jarFile.isFile()) {
JOptionPane.showMessageDialog(this, MessageFormat.format(res.getString("DSignMidlet.JarNotFile.message"), jarFile), getTitle(), JOptionPane.WARNING_MESSAGE);
return;
}
JarFile jarFileTest = null;
try {
jarFileTest = new JarFile(jarFile);
} catch (IOException ex) {
String problemStr = MessageFormat.format(res.getString("DSignMidlet.NoOpenJar.Problem"), jarFile.getName());
String[] causes = new String[] { res.getString("DSignMidlet.NotJar.Cause"), res.getString("DSignMidlet.CorruptedJar.Cause") };
Problem problem = new Problem(problemStr, causes, ex);
DProblem dProblem = new DProblem(this, res.getString("DSignMidlet.ProblemOpeningJar.Title"), problem);
dProblem.setLocationRelativeTo(this);
dProblem.setVisible(true);
return;
} finally {
IOUtils.closeQuietly(jarFileTest);
}
if (!signDirectly) {
if (outputJadFile.isFile()) {
String message = MessageFormat.format(res.getString("DSignMidlet.OverWriteOutputJadFile.message"), outputJadFile);
int selected = JOptionPane.showConfirmDialog(this, message, getTitle(), JOptionPane.YES_NO_OPTION);
if (selected != JOptionPane.YES_OPTION) {
return;
}
}
}
this.inputJadFile = inputJadFile;
this.outputJadFile = outputJadFile;
this.jarFile = jarFile;
closeDialog();
}
use of org.kse.gui.error.Problem in project keystore-explorer by kaikramer.
the class OpenAction method showErrorMessage.
private int showErrorMessage(File keyStoreFile, KeyStoreLoadException klex) {
String problemStr = MessageFormat.format(res.getString("OpenAction.NoOpenKeyStore.Problem"), klex.getKeyStoreType().friendly(), keyStoreFile.getName());
String[] causes = new String[] { res.getString("OpenAction.PasswordIncorrectKeyStore.Cause"), res.getString("OpenAction.CorruptedKeyStore.Cause") };
Problem problem = new Problem(problemStr, causes, klex);
DProblem dProblem = new DProblem(frame, res.getString("OpenAction.ProblemOpeningKeyStore.Title"), problem);
dProblem.setLocationRelativeTo(frame);
dProblem.setVisible(true);
int choice = JOptionPane.showConfirmDialog(frame, res.getString("OpenAction.TryAgain.message"), res.getString("OpenAction.TryAgain.Title"), JOptionPane.YES_NO_OPTION);
return choice;
}
use of org.kse.gui.error.Problem in project keystore-explorer by kaikramer.
the class KeyStoreExplorerAction method unlockEntry.
/**
* Unlock a key or key pair entry. Updates the KeyStore history with the
* password.
*
* @param alias
* Entry's alias
* @param state
* KeyStore state
* @return Key pair password if successful, null otherwise
*/
protected Password unlockEntry(String alias, KeyStoreState state) {
try {
KeyStore keyStore = state.getKeyStore();
DGetPassword dGetPassword = new DGetPassword(frame, MessageFormat.format(res.getString("KeyStoreExplorerAction.UnlockEntry.Title"), alias));
dGetPassword.setLocationRelativeTo(frame);
dGetPassword.setVisible(true);
Password password = dGetPassword.getPassword();
if (password == null) {
return null;
}
// Test password is correct
keyStore.getKey(alias, password.toCharArray());
state.setEntryPassword(alias, password);
kseFrame.updateControls(true);
return password;
} catch (GeneralSecurityException ex) {
String problemStr = MessageFormat.format(res.getString("KeyStoreExplorerAction.NoUnlockEntry.Problem"), alias);
String[] causes = new String[] { res.getString("KeyStoreExplorerAction.PasswordIncorrectEntry.Cause") };
Problem problem = new Problem(problemStr, causes, ex);
DProblem dProblem = new DProblem(frame, res.getString("KeyStoreExplorerAction.ProblemUnlockingEntry.Title"), problem);
dProblem.setLocationRelativeTo(frame);
dProblem.setVisible(true);
return null;
}
}
Aggregations