From f97dccddf5f213474a8c551e7f5f471dc10f10aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Kil=C3=A5s?= Date: Sun, 3 Aug 2014 13:40:55 +0200 Subject: [PATCH] Changed from List to array type for X509CertificatePanel constructor --- .../desktoputil/VerifyCertificateDialogImpl.java | 3 ++- .../plugin/desktoputil/ViewCertificateFrame.java | 13 +++++++++++-- .../plugin/desktoputil/X509CertificatePanel.java | 16 +++++++++------- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/net/java/sip/communicator/plugin/desktoputil/VerifyCertificateDialogImpl.java b/src/net/java/sip/communicator/plugin/desktoputil/VerifyCertificateDialogImpl.java index 6fba19222..71b6c68ad 100644 --- a/src/net/java/sip/communicator/plugin/desktoputil/VerifyCertificateDialogImpl.java +++ b/src/net/java/sip/communicator/plugin/desktoputil/VerifyCertificateDialogImpl.java @@ -242,7 +242,8 @@ private void actionShowCertificate() Component certInfoPane = null; if (!certs.isEmpty()) { - certInfoPane = new X509CertificatePanel(certs); + certInfoPane = new X509CertificatePanel( + certs.toArray(new X509Certificate[0])); } else { diff --git a/src/net/java/sip/communicator/plugin/desktoputil/ViewCertificateFrame.java b/src/net/java/sip/communicator/plugin/desktoputil/ViewCertificateFrame.java index a4067025d..3c2d9d55e 100644 --- a/src/net/java/sip/communicator/plugin/desktoputil/ViewCertificateFrame.java +++ b/src/net/java/sip/communicator/plugin/desktoputil/ViewCertificateFrame.java @@ -8,7 +8,7 @@ import java.awt.*; import java.security.cert.*; -import java.util.Arrays; +import java.util.*; import javax.swing.*; import org.jitsi.service.resources.*; @@ -126,7 +126,16 @@ private void init() Component certInfoPane; if (certs[0] instanceof X509Certificate) { - certInfoPane = new X509CertificatePanel(Arrays.asList((X509Certificate[])certs)); + ArrayList x509s = new ArrayList(); + for (Certificate c : certs) + { + if (c instanceof X509Certificate) + { + x509s.add(c); + } + } + certInfoPane = new X509CertificatePanel( + (X509Certificate[]) x509s.toArray(new X509Certificate[0])); } else { diff --git a/src/net/java/sip/communicator/plugin/desktoputil/X509CertificatePanel.java b/src/net/java/sip/communicator/plugin/desktoputil/X509CertificatePanel.java index 6d5bacf8f..498a4ad9b 100644 --- a/src/net/java/sip/communicator/plugin/desktoputil/X509CertificatePanel.java +++ b/src/net/java/sip/communicator/plugin/desktoputil/X509CertificatePanel.java @@ -46,7 +46,10 @@ public class X509CertificatePanel */ public X509CertificatePanel(X509Certificate certificate) { - this(Arrays.asList(certificate)); + this(new X509Certificate[] + { + certificate + }); } /** @@ -54,7 +57,7 @@ public X509CertificatePanel(X509Certificate certificate) * * @param certificates X509Certificate objects */ - public X509CertificatePanel(java.util.List certificates) + public X509CertificatePanel(X509Certificate[] certificates) { setLayout(new BorderLayout(5, 5)); @@ -66,10 +69,9 @@ public X509CertificatePanel(java.util.List certificates) DefaultMutableTreeNode top = new DefaultMutableTreeNode(); DefaultMutableTreeNode previous = top; - ListIterator it = certificates.listIterator( - certificates.size()); - while (it.hasPrevious()) { - X509Certificate cert = it.previous(); + for (int i = certificates.length - 1; i >= 0; i--) + { + X509Certificate cert = certificates[i]; DefaultMutableTreeNode next = new DefaultMutableTreeNode(cert); previous.add(next); previous = next; @@ -132,7 +134,7 @@ public void valueChanged(TreeSelectionEvent e) { infoTextPane.setOpaque(false); infoTextPane.setEditable(false); infoTextPane.setContentType("text/html"); - infoTextPane.setText(toString(certificates.get(0))); + infoTextPane.setText(toString(certificates[0])); final JScrollPane certScroll = new JScrollPane(infoTextPane); certScroll.setPreferredSize(new Dimension(300, 500));