use of org.kse.gui.dialogs.DViewPrivateKey in project keystore-explorer by kaikramer.
the class ExamineFileAction method openPrivateKey.
private void openPrivateKey(File file, CryptoFileType fileType) throws IOException, CryptoException {
PrivateKey privKey = null;
Password password = null;
switch(fileType) {
case ENC_PKCS8_PVK:
password = getPassword(file);
if (password == null || password.isNulled()) {
return;
}
privKey = Pkcs8Util.loadEncrypted(new FileInputStream(file), password);
break;
case UNENC_PKCS8_PVK:
privKey = Pkcs8Util.load(new FileInputStream(file));
break;
case ENC_OPENSSL_PVK:
password = getPassword(file);
if (password == null || password.isNulled()) {
return;
}
privKey = OpenSslPvkUtil.loadEncrypted(new FileInputStream(file), password);
break;
case UNENC_OPENSSL_PVK:
privKey = OpenSslPvkUtil.load(new FileInputStream(file));
break;
case ENC_MS_PVK:
password = getPassword(file);
if (password == null || password.isNulled()) {
return;
}
privKey = MsPvkUtil.loadEncrypted(new FileInputStream(file), password);
break;
case UNENC_MS_PVK:
privKey = MsPvkUtil.load(new FileInputStream(file));
break;
default:
break;
}
DViewPrivateKey dViewPrivateKey = new DViewPrivateKey(frame, MessageFormat.format(res.getString("ExamineFileAction.PrivateKeyDetailsFile.Title"), file.getName()), privKey, null);
dViewPrivateKey.setLocationRelativeTo(frame);
dViewPrivateKey.setVisible(true);
}
use of org.kse.gui.dialogs.DViewPrivateKey in project keystore-explorer by kaikramer.
the class KeyDetailsAction method showKeySelectedEntry.
/**
* Show the key details of the selected KeyStore entry.
*/
public void showKeySelectedEntry() {
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();
Key key = keyStore.getKey(alias, password.toCharArray());
if (key instanceof SecretKey) {
SecretKey secretKey = (SecretKey) key;
DViewSecretKey dViewSecretKey = new DViewSecretKey(frame, MessageFormat.format(res.getString("KeyDetailsAction.SecretKeyDetailsEntry.Title"), alias), secretKey);
dViewSecretKey.setLocationRelativeTo(frame);
dViewSecretKey.setVisible(true);
} else if (key instanceof PrivateKey) {
PrivateKey privateKey = (PrivateKey) key;
DViewPrivateKey dViewPrivateKey = new DViewPrivateKey(frame, MessageFormat.format(res.getString("KeyDetailsAction.PrivateKeyDetailsEntry.Title"), alias), privateKey, history.getExplicitProvider());
dViewPrivateKey.setLocationRelativeTo(frame);
dViewPrivateKey.setVisible(true);
} else if (key instanceof PublicKey) {
PublicKey publicKey = (PublicKey) key;
DViewPublicKey dViewPublicKey = new DViewPublicKey(frame, MessageFormat.format(res.getString("KeyDetailsAction.PublicKeyDetailsEntry.Title"), alias), publicKey);
dViewPublicKey.setLocationRelativeTo(frame);
dViewPublicKey.setVisible(true);
}
} catch (Exception ex) {
DError.displayError(frame, ex);
}
}
use of org.kse.gui.dialogs.DViewPrivateKey in project keystore-explorer by kaikramer.
the class KeyPairPrivateKeyDetailsAction 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 privKey = (PrivateKey) keyStore.getKey(alias, password.toCharArray());
DViewPrivateKey dViewPrivateKey = new DViewPrivateKey(frame, MessageFormat.format(res.getString("KeyPairPrivateKeyDetailsAction.PrivKeyDetailsEntry.Title"), alias), privKey, history.getExplicitProvider());
dViewPrivateKey.setLocationRelativeTo(frame);
dViewPrivateKey.setVisible(true);
} catch (Exception ex) {
DError.displayError(frame, ex);
}
}
use of org.kse.gui.dialogs.DViewPrivateKey in project keystore-explorer by kaikramer.
the class DImportKeyPairOpenSsl method privateKeyDetailsPressed.
private void privateKeyDetailsPressed() {
try {
String path = new File(jtfPrivateKeyPath.getText()).getName();
PrivateKey privateKey = loadPrivateKey();
if (privateKey != null) {
DViewPrivateKey dViewPrivateKey = new DViewPrivateKey(this, MessageFormat.format(res.getString("DImportKeyPairOpenSsl.ViewPrivateKeyDetails.Title"), path), privateKey, new BouncyCastleProvider());
dViewPrivateKey.setLocationRelativeTo(this);
dViewPrivateKey.setVisible(true);
}
} catch (CryptoException ex) {
DError.displayError(this, ex);
}
}
use of org.kse.gui.dialogs.DViewPrivateKey in project keystore-explorer by kaikramer.
the class DImportKeyPairPkcs8 method privateKeyDetailsPressed.
private void privateKeyDetailsPressed() {
try {
String path = new File(jtfPrivateKeyPath.getText()).getName();
PrivateKey privateKey = loadPrivateKey();
if (privateKey != null) {
DViewPrivateKey dViewPrivateKey = new DViewPrivateKey(this, MessageFormat.format(res.getString("DImportKeyPairPkcs8.ViewPrivateKeyDetails.Title"), path), privateKey, new BouncyCastleProvider());
dViewPrivateKey.setLocationRelativeTo(this);
dViewPrivateKey.setVisible(true);
}
} catch (CryptoException ex) {
DError.displayError(this, ex);
}
}
Aggregations