|
|
|
@ -9,6 +9,7 @@
|
|
|
|
import java.awt.*;
|
|
|
|
import java.awt.*;
|
|
|
|
import java.security.*;
|
|
|
|
import java.security.*;
|
|
|
|
import java.security.cert.*;
|
|
|
|
import java.security.cert.*;
|
|
|
|
|
|
|
|
import java.security.cert.Certificate;
|
|
|
|
import java.security.interfaces.*;
|
|
|
|
import java.security.interfaces.*;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
|
|
@ -44,9 +45,9 @@ public class X509CertificatePanel
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param certificate <tt>X509Certificate</tt> object
|
|
|
|
* @param certificate <tt>X509Certificate</tt> object
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public X509CertificatePanel(X509Certificate certificate)
|
|
|
|
public X509CertificatePanel(Certificate certificate)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this(new X509Certificate[]
|
|
|
|
this(new Certificate[]
|
|
|
|
{
|
|
|
|
{
|
|
|
|
certificate
|
|
|
|
certificate
|
|
|
|
});
|
|
|
|
});
|
|
|
|
@ -57,7 +58,7 @@ public X509CertificatePanel(X509Certificate certificate)
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param certificates <tt>X509Certificate</tt> objects
|
|
|
|
* @param certificates <tt>X509Certificate</tt> objects
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public X509CertificatePanel(X509Certificate[] certificates)
|
|
|
|
public X509CertificatePanel(Certificate[] certificates)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
setLayout(new BorderLayout(5, 5));
|
|
|
|
setLayout(new BorderLayout(5, 5));
|
|
|
|
|
|
|
|
|
|
|
|
@ -71,7 +72,7 @@ public X509CertificatePanel(X509Certificate[] certificates)
|
|
|
|
DefaultMutableTreeNode previous = top;
|
|
|
|
DefaultMutableTreeNode previous = top;
|
|
|
|
for (int i = certificates.length - 1; i >= 0; i--)
|
|
|
|
for (int i = certificates.length - 1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
X509Certificate cert = certificates[i];
|
|
|
|
Certificate cert = certificates[i];
|
|
|
|
DefaultMutableTreeNode next = new DefaultMutableTreeNode(cert);
|
|
|
|
DefaultMutableTreeNode next = new DefaultMutableTreeNode(cert);
|
|
|
|
previous.add(next);
|
|
|
|
previous.add(next);
|
|
|
|
previous = next;
|
|
|
|
previous = next;
|
|
|
|
@ -100,6 +101,17 @@ public Component getTreeCellRendererComponent(JTree tree,
|
|
|
|
component.setText(
|
|
|
|
component.setText(
|
|
|
|
getSimplifiedName((X509Certificate) o));
|
|
|
|
getSimplifiedName((X509Certificate) o));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// We don't know how to represent this certificate type,
|
|
|
|
|
|
|
|
// let's use the first 20 characters
|
|
|
|
|
|
|
|
String text = o.toString();
|
|
|
|
|
|
|
|
if (text.length() > 20)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
text = text.substring(0, 20);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
component.setText(text);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return component;
|
|
|
|
return component;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -146,13 +158,42 @@ public void valueChanged(TreeSelectionEvent e)
|
|
|
|
add(certScroll, BorderLayout.CENTER);
|
|
|
|
add(certScroll, BorderLayout.CENTER);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private String toString(X509Certificate certificate)
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Creates a String representation of the given object.
|
|
|
|
|
|
|
|
* @param certificate to print
|
|
|
|
|
|
|
|
* @return the String representation
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private String toString(Object certificate)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
final StringBuilder sb = new StringBuilder();
|
|
|
|
final StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
|
|
sb.append("<html><body>\n");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (certificate instanceof X509Certificate)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
renderX509(sb, (X509Certificate) certificate);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
sb.append("<pre>\n");
|
|
|
|
|
|
|
|
sb.append(certificate.toString());
|
|
|
|
|
|
|
|
sb.append("</pre>\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sb.append("</body></html>");
|
|
|
|
|
|
|
|
return sb.toString();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Appends an HTML representation of the given X509Certificate.
|
|
|
|
|
|
|
|
* @param sb StringBuilder to append to
|
|
|
|
|
|
|
|
* @param certificate to print
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private void renderX509(StringBuilder sb, X509Certificate certificate)
|
|
|
|
|
|
|
|
{
|
|
|
|
X500Principal issuer = certificate.getIssuerX500Principal();
|
|
|
|
X500Principal issuer = certificate.getIssuerX500Principal();
|
|
|
|
X500Principal subject = certificate.getSubjectX500Principal();
|
|
|
|
X500Principal subject = certificate.getSubjectX500Principal();
|
|
|
|
|
|
|
|
|
|
|
|
sb.append("<html><body><table cellspacing='1' cellpadding='1'>\n");
|
|
|
|
sb.append("<table cellspacing='1' cellpadding='1'>\n");
|
|
|
|
|
|
|
|
|
|
|
|
// subject
|
|
|
|
// subject
|
|
|
|
addTitle(sb, R.getI18NString("service.gui.CERT_INFO_ISSUED_TO"));
|
|
|
|
addTitle(sb, R.getI18NString("service.gui.CERT_INFO_ISSUED_TO"));
|
|
|
|
@ -300,9 +341,7 @@ else if(certificate.getPublicKey().getAlgorithm().equals("DSA"))
|
|
|
|
getHex(certificate.getSignature())
|
|
|
|
getHex(certificate.getSignature())
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
sb.append("</table></body></html>");
|
|
|
|
sb.append("</table>\n");
|
|
|
|
|
|
|
|
|
|
|
|
return sb.toString();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
@ -448,11 +487,7 @@ private void valueChangedPerformed(TreeSelectionEvent e)
|
|
|
|
if (o instanceof DefaultMutableTreeNode)
|
|
|
|
if (o instanceof DefaultMutableTreeNode)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DefaultMutableTreeNode node = (DefaultMutableTreeNode) o;
|
|
|
|
DefaultMutableTreeNode node = (DefaultMutableTreeNode) o;
|
|
|
|
if (node.getUserObject() instanceof X509Certificate)
|
|
|
|
infoTextPane.setText(toString(node.getUserObject()));
|
|
|
|
{
|
|
|
|
|
|
|
|
infoTextPane.setText(
|
|
|
|
|
|
|
|
toString((X509Certificate) node.getUserObject()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|