use of org.kse.crypto.Password in project keystore-explorer by kaikramer.
the class DGetPassword method okPressed.
private void okPressed() {
password = new Password(jpfPassword.getPassword());
closeDialog();
}
use of org.kse.crypto.Password in project keystore-explorer by kaikramer.
the class DProperties method createPrivateKeyNodes.
private void createPrivateKeyNodes(DefaultMutableTreeNode parentNode, String alias) throws CryptoException {
try {
KeyStore keyStore = currentState.getKeyStore();
Password password = getEntryPassword(alias);
if (password == null) {
DefaultMutableTreeNode privateKeyNode = new DefaultMutableTreeNode(res.getString("DProperties.properties.PrivateKey"));
parentNode.add(privateKeyNode);
DefaultMutableTreeNode lockedNode = new DefaultMutableTreeNode(res.getString("DProperties.properties.Locked"));
privateKeyNode.add(lockedNode);
return;
}
PrivateKey privateKey = (PrivateKey) keyStore.getKey(alias, password.toCharArray());
createPrivateKeyNodes(parentNode, privateKey);
} catch (NoSuchAlgorithmException ex) {
throw new CryptoException(res.getString("DProperties.NoGetProperties.exception.message"), ex);
} catch (KeyStoreException ex) {
throw new CryptoException(res.getString("DProperties.NoGetProperties.exception.message"), ex);
} catch (UnrecoverableKeyException ex) {
throw new CryptoException(res.getString("DProperties.NoGetProperties.exception.message"), ex);
}
}
use of org.kse.crypto.Password in project keystore-explorer by kaikramer.
the class DProperties method createKeyNodes.
private void createKeyNodes(DefaultMutableTreeNode parentNode, String alias) throws CryptoException {
try {
KeyStore keyStore = currentState.getKeyStore();
DefaultMutableTreeNode keyNode = new DefaultMutableTreeNode(alias);
parentNode.add(keyNode);
createLastModifiedNode(keyNode, alias);
Password password = getEntryPassword(alias);
if (password == null) {
DefaultMutableTreeNode lockedNode = new DefaultMutableTreeNode(res.getString("DProperties.properties.Locked"));
keyNode.add(lockedNode);
return;
}
Key key = keyStore.getKey(alias, password.toCharArray());
if (key instanceof PublicKey) {
createPublicKeyNodes(keyNode, (PublicKey) key);
} else if (key instanceof PrivateKey) {
createPrivateKeyNodes(keyNode, (PrivateKey) key);
} else if (key instanceof SecretKey) {
createSecretKeyNodes(keyNode, (SecretKey) key);
}
} catch (NoSuchAlgorithmException ex) {
throw new CryptoException(res.getString("DProperties.NoGetProperties.exception.message"), ex);
} catch (KeyStoreException ex) {
throw new CryptoException(res.getString("DProperties.NoGetProperties.exception.message"), ex);
} catch (UnrecoverableKeyException ex) {
throw new CryptoException(res.getString("DProperties.NoGetProperties.exception.message"), ex);
}
}
use of org.kse.crypto.Password in project keystore-explorer by kaikramer.
the class PasswordCallbackHandler method handlePasswordCallback.
private void handlePasswordCallback(PasswordCallback passCb) throws UnsupportedCallbackException {
DGetPassword dGetPassword = new DGetPassword(frame, res.getString("PasswordCallbackHandler.Title"));
dGetPassword.setLocationRelativeTo(frame);
dGetPassword.setVisible(true);
Password password = dGetPassword.getPassword();
if (password == null) {
throw new CancellationException("Password Callback canceled by user");
}
passCb.setPassword(password.toCharArray());
}
use of org.kse.crypto.Password in project keystore-explorer by kaikramer.
the class DExportPrivateKeyPvk method exportPressed.
private void exportPressed() {
if (jrbExchange.isSelected()) {
keyType = MsPvkUtil.PVK_KEY_EXCHANGE;
} else {
keyType = MsPvkUtil.PVK_KEY_SIGNATURE;
}
encrypt = jcbEncrypt.isSelected();
if (encrypt) {
strongEncryption = jrbStrong.isSelected();
Password firstPassword;
if (jpfPassword instanceof JPasswordQualityField) {
char[] firstPasswordChars = ((JPasswordQualityField) jpfPassword).getPassword();
if (firstPasswordChars == null) {
JOptionPane.showMessageDialog(this, res.getString("DExportPrivateKeyPvk.MinimumPasswordQualityNotMet.message"), res.getString("DExportPrivateKeyPvk.Simple.Title"), JOptionPane.WARNING_MESSAGE);
return;
}
firstPassword = new Password(firstPasswordChars);
} else {
firstPassword = new Password(((JPasswordField) jpfPassword).getPassword());
}
Password confirmPassword = new Password(jpfConfirmPassword.getPassword());
if (firstPassword.equals(confirmPassword)) {
exportPassword = firstPassword;
} else {
JOptionPane.showMessageDialog(this, res.getString("DExportPrivateKeyPvk.PasswordsNoMatch.message"), res.getString("DExportPrivateKeyPvk.Simple.Title"), JOptionPane.WARNING_MESSAGE);
return;
}
}
String exportFileChars = jtfExportFile.getText().trim();
if (exportFileChars.length() == 0) {
JOptionPane.showMessageDialog(this, res.getString("DExportPrivateKeyPvk.ExportFileRequired.message"), res.getString("DExportPrivateKeyPvk.Simple.Title"), JOptionPane.WARNING_MESSAGE);
return;
}
File exportFile = new File(exportFileChars);
if (exportFile.isFile()) {
String message = MessageFormat.format(res.getString("DExportPrivateKeyPvk.OverWriteExportFile.message"), exportFile);
int selected = JOptionPane.showConfirmDialog(this, message, res.getString("DExportPrivateKeyPvk.Simple.Title"), JOptionPane.YES_NO_OPTION);
if (selected != JOptionPane.YES_OPTION) {
return;
}
}
this.exportFile = exportFile;
exportSelected = true;
closeDialog();
}
Aggregations