use of org.kse.crypto.CryptoException in project keystore-explorer by kaikramer.
the class DProperties method createKeysNodes.
private void createKeysNodes(DefaultMutableTreeNode parentNode) throws CryptoException {
try {
KeyStore keyStore = currentState.getKeyStore();
TreeSet<String> aliases = getAliasesInAlphaOrder();
DefaultMutableTreeNode keysNode = new DefaultMutableTreeNode(res.getString("DProperties.properties.Keys"));
parentNode.add(keysNode);
boolean keysPresent = false;
for (String alias : aliases) {
if (KeyStoreUtil.isKeyEntry(alias, keyStore)) {
createKeyNodes(keysNode, alias);
keysPresent = true;
}
}
if (!keysPresent) {
DefaultMutableTreeNode emptyKeyNode = new DefaultMutableTreeNode(res.getString("DProperties.properties.None"));
keysNode.add(emptyKeyNode);
}
} catch (KeyStoreException ex) {
throw new CryptoException(res.getString("DProperties.NoGetProperties.exception.message"), ex);
}
}
use of org.kse.crypto.CryptoException 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.CryptoException in project keystore-explorer by kaikramer.
the class DProperties method createKeyPairsNodes.
private void createKeyPairsNodes(DefaultMutableTreeNode parentNode) throws CryptoException {
try {
KeyStore keyStore = currentState.getKeyStore();
TreeSet<String> aliases = getAliasesInAlphaOrder();
DefaultMutableTreeNode keyPairsNode = new DefaultMutableTreeNode(res.getString("DProperties.properties.KeyPairs"));
parentNode.add(keyPairsNode);
boolean keyPairsPresent = false;
for (String alias : aliases) {
if (KeyStoreUtil.isKeyPairEntry(alias, keyStore)) {
createKeyPairNodes(keyPairsNode, alias);
keyPairsPresent = true;
}
}
if (!keyPairsPresent) {
DefaultMutableTreeNode emptyKeyPairNode = new DefaultMutableTreeNode(res.getString("DProperties.properties.None"));
keyPairsNode.add(emptyKeyPairNode);
}
} catch (KeyStoreException ex) {
throw new CryptoException(res.getString("DProperties.NoGetProperties.exception.message"), ex);
}
}
use of org.kse.crypto.CryptoException in project keystore-explorer by kaikramer.
the class DProperties method createLastModifiedNode.
private void createLastModifiedNode(DefaultMutableTreeNode parentNode, String alias) throws CryptoException {
try {
KeyStore keyStore = currentState.getKeyStore();
if (KeyStoreType.resolveJce(keyStore.getType()) != KeyStoreType.PKCS12) {
String lastModified = MessageFormat.format(res.getString("DProperties.properties.LastModified"), StringUtils.formatDate(keyStore.getCreationDate(alias)));
parentNode.add(new DefaultMutableTreeNode(lastModified));
}
} catch (ProviderException e) {
// some keystore types do not provide creation dates for their entries => simply create no node
} catch (KeyStoreException e) {
throw new CryptoException(res.getString("DProperties.NoGetProperties.exception.message"), e);
}
}
use of org.kse.crypto.CryptoException 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);
}
}
Aggregations