use of org.kse.gui.dialogs.sign.DSignMidlet in project keystore-explorer by kaikramer.
the class SignMidletAction method doAction.
/**
* Do action.
*/
@Override
protected void doAction() {
try {
KeyStoreHistory history = kseFrame.getActiveKeyStoreHistory();
KeyStoreState currentState = history.getCurrentState();
String alias = kseFrame.getSelectedEntryAlias();
Password password = getEntryPassword(alias, currentState);
if (password == null) {
return;
}
KeyStore keyStore = currentState.getKeyStore();
PrivateKey privateKey = (PrivateKey) keyStore.getKey(alias, password.toCharArray());
X509Certificate[] certs = X509CertUtil.orderX509CertChain(X509CertUtil.convertCertificates(keyStore.getCertificateChain(alias)));
if (!privateKey.getAlgorithm().equals(KeyPairType.RSA.jce())) {
JOptionPane.showMessageDialog(frame, res.getString("SignMidletAction.ReqRsaKeyPairMidletSigning.message"), res.getString("SignMidletAction.SignMidlet.Title"), JOptionPane.WARNING_MESSAGE);
return;
}
DSignMidlet dSignMidlet = new DSignMidlet(frame);
dSignMidlet.setLocationRelativeTo(frame);
dSignMidlet.setVisible(true);
File inputJadFile = dSignMidlet.getInputJad();
File outputJadFile = dSignMidlet.getOutputJad();
File jarFile = dSignMidlet.getJar();
if (inputJadFile == null) {
return;
}
if (inputJadFile.equals(outputJadFile)) {
MidletSigner.sign(inputJadFile, jarFile, (RSAPrivateKey) privateKey, certs, 1);
} else {
MidletSigner.sign(inputJadFile, outputJadFile, jarFile, (RSAPrivateKey) privateKey, certs, 1);
}
JOptionPane.showMessageDialog(frame, res.getString("SignMidletAction.SignMidletSuccessful.message"), res.getString("SignMidletAction.SignMidlet.Title"), JOptionPane.INFORMATION_MESSAGE);
} catch (Exception ex) {
DError.displayError(frame, ex);
}
}
Aggregations