use of org.kse.gui.dialogs.importexport.DExportPrivateKeyPvk in project keystore-explorer by kaikramer.
the class ExportKeyPairPrivateKeyAction method exportAsPvk.
private void exportAsPvk(PrivateKey privateKey, String alias) throws CryptoException, IOException {
File exportFile = null;
try {
DExportPrivateKeyPvk dExportPrivateKeyPvk = new DExportPrivateKeyPvk(frame, alias, privateKey, applicationSettings.getPasswordQualityConfig());
dExportPrivateKeyPvk.setLocationRelativeTo(frame);
dExportPrivateKeyPvk.setVisible(true);
if (!dExportPrivateKeyPvk.exportSelected()) {
return;
}
exportFile = dExportPrivateKeyPvk.getExportFile();
int keyType = dExportPrivateKeyPvk.getKeyType();
boolean encrypt = dExportPrivateKeyPvk.encrypt();
boolean strongEncryption = false;
Password exportPassword = null;
if (encrypt) {
strongEncryption = dExportPrivateKeyPvk.useStrongEncryption();
exportPassword = dExportPrivateKeyPvk.getExportPassword();
}
byte[] encoded = getPvkEncodedPrivateKey(privateKey, keyType, exportPassword, strongEncryption);
exportEncodedPrivateKey(encoded, exportFile);
JOptionPane.showMessageDialog(frame, res.getString("ExportKeyPairPrivateKeyAction.ExportPrivateKeyPvkSuccessful.message"), res.getString("ExportKeyPairPrivateKeyAction.ExportPrivateKeyPvk.Title"), JOptionPane.INFORMATION_MESSAGE);
} catch (FileNotFoundException ex) {
String message = MessageFormat.format(res.getString("ExportKeyPairPrivateKeyAction.NoWriteFile.message"), exportFile);
JOptionPane.showMessageDialog(frame, message, res.getString("ExportKeyPairPrivateKeyAction.ExportPrivateKeyPvk.Title"), JOptionPane.WARNING_MESSAGE);
}
}
Aggregations