use of org.kse.gui.dialogs.importexport.DExportPrivateKeyType in project keystore-explorer by kaikramer.
the class ExportKeyPairPrivateKeyAction 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());
DExportPrivateKeyType dExportPrivateKeyType = new DExportPrivateKeyType(frame);
dExportPrivateKeyType.setLocationRelativeTo(frame);
dExportPrivateKeyType.setVisible(true);
if (!dExportPrivateKeyType.exportTypeSelected()) {
return;
}
if (dExportPrivateKeyType.exportPkcs8()) {
exportAsPkcs8(privateKey, alias);
} else if (dExportPrivateKeyType.exportPvk()) {
exportAsPvk(privateKey, alias);
} else {
exportAsOpenSsl(privateKey, alias);
}
} catch (Exception ex) {
DError.displayError(frame, ex);
}
}
Aggregations