From 0ecfd783645a581d9859dab90e9ddf14b4b55232 Mon Sep 17 00:00:00 2001 From: tkellner Date: Wed, 30 May 2012 15:47:13 +0000 Subject: Correct cast of certificate array git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@1087 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../src/main/java/at/gv/egiz/bku/spring/PKITrustManager.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'bkucommon/src/main/java/at/gv') diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/spring/PKITrustManager.java b/bkucommon/src/main/java/at/gv/egiz/bku/spring/PKITrustManager.java index a2a83ca1..076fdf11 100644 --- a/bkucommon/src/main/java/at/gv/egiz/bku/spring/PKITrustManager.java +++ b/bkucommon/src/main/java/at/gv/egiz/bku/spring/PKITrustManager.java @@ -37,6 +37,7 @@ import iaik.pki.store.truststore.TrustStoreFactory; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import java.util.Date; +import java.util.Set; import javax.net.ssl.X509TrustManager; @@ -148,13 +149,16 @@ public class PKITrustManager implements X509TrustManager { try { TrustStore trustStore = TrustStoreFactory.getInstance(pkiProfile.getTrustStoreProfile(), tid); - return (X509Certificate[]) trustStore.getTrustedCertificates(tid).toArray(); - + @SuppressWarnings("unchecked") + Set certs = trustStore.getTrustedCertificates(tid); + return certs.toArray(new X509Certificate[certs.size()]); } catch (TrustStoreException e) { log.warn("Failed to get list of accepted issuers.", e); return new X509Certificate[] {}; + } catch (ClassCastException e) { + log.error("Failed to cast list of accepted issuers.", e); + return new X509Certificate[] {}; } - } private static iaik.x509.X509Certificate[] convertCerts( -- cgit v1.2.3