use of org.kse.crypto.secretkey.SecretKeyType in project keystore-explorer by kaikramer.
the class DProperties method createSecretKeyNodes.
private void createSecretKeyNodes(DefaultMutableTreeNode parentNode, SecretKey secretKey) {
DefaultMutableTreeNode secretKeyNode = new DefaultMutableTreeNode(res.getString("DProperties.properties.SecretKey"));
parentNode.add(secretKeyNode);
KeyInfo keyInfo = SecretKeyUtil.getKeyInfo(secretKey);
String keyAlg = keyInfo.getAlgorithm();
// Try and get friendly algorithm name for secret key
SecretKeyType secretKeyType = SecretKeyType.resolveJce(keyAlg);
if (secretKeyType != null) {
keyAlg = secretKeyType.friendly();
}
secretKeyNode.add(new DefaultMutableTreeNode(MessageFormat.format(res.getString("DProperties.properties.Algorithm"), keyAlg)));
Integer keySize = keyInfo.getSize();
if (keySize != null) {
secretKeyNode.add(new DefaultMutableTreeNode(MessageFormat.format(res.getString("DProperties.properties.KeySize"), "" + keyInfo.getSize())));
} else {
secretKeyNode.add(new DefaultMutableTreeNode(MessageFormat.format(res.getString("DProperties.properties.KeySize"), "?")));
}
String keyFormat = secretKey.getFormat();
secretKeyNode.add(new DefaultMutableTreeNode(MessageFormat.format(res.getString("DProperties.properties.Format"), keyFormat)));
String keyEncoded = "0x" + new BigInteger(1, secretKey.getEncoded()).toString(16).toUpperCase();
secretKeyNode.add(new DefaultMutableTreeNode(MessageFormat.format(res.getString("DProperties.properties.Encoded"), keyEncoded)));
}
Aggregations