@Test public void shouldGetX509Certificates() throws SSLPeerUnverifiedException { given(mockSession.getPeerCertificates()).willReturn(new Certificate[]{ mockCertificate, mockX509Certificate }); assertThat(sslInfo.getPeerCertificates()).containsOnly(mockX509Certificate); }
@Nullable @Override public X509Certificate[] getPeerCertificates() { Certificate[] certificates; try { certificates = session.getPeerCertificates(); } catch (Throwable ex) { return null; } List<X509Certificate> result = new ArrayList<>(certificates.length); for (Certificate certificate : certificates) { if (certificate instanceof X509Certificate) { result.add((X509Certificate) certificate); } } return (!result.isEmpty() ? result.toArray(new X509Certificate[0]) : null); }
SslInfoImpl implements SslInfo { @Nullable @Override public X509Certificate[] getPeerCertificates() { Certificate[] certificates; try { certificates = session.getPeerCertificates(); } catch (Throwable ex) { return null; } List<X509Certificate> result = new ArrayList<>(certificates.length); for (Certificate certificate : certificates) { if (certificate instanceof X509Certificate) { result.add((X509Certificate) certificate); } } return (!result.isEmpty() ? result.toArray(new X509Certificate[0]) : null); } }
SslInfoImpl implements SslInfo { @Nullable @Override public X509Certificate[] getPeerCertificates() { Certificate[] certificates; try { certificates = session.getPeerCertificates(); } catch (Throwable ex) { return null; } List<X509Certificate> result = new ArrayList<>(certificates.length); for (Certificate certificate : certificates) { if (certificate instanceof X509Certificate) { result.add((X509Certificate) certificate); } } return (!result.isEmpty() ? result.toArray(new X509Certificate[0]) : null); } SslInfoImpl(SSLSession session); }
SslInfoImpl implements SslInfo { @Nullable @Override public X509Certificate[] getPeerCertificates() { Certificate[] certificates; try { certificates = session.getPeerCertificates(); } catch (Throwable ex) { return null; } List<X509Certificate> result = new ArrayList<>(certificates.length); for (Certificate certificate : certificates) { if (certificate instanceof X509Certificate) { result.add((X509Certificate) certificate); } } return (!result.isEmpty() ? result.toArray(new X509Certificate[0]) : null); } SslInfoImpl(SSLSession session); @Nullable @Override String getSessionId(); @Nullable @Override X509Certificate[] getPeerCertificates(); }
SslInfoImpl implements SslInfo { @Nullable @Override public X509Certificate[] getPeerCertificates() { Certificate[] certificates; try { certificates = session.getPeerCertificates(); } catch (Throwable ex) { return null; } List<X509Certificate> result = new ArrayList<>(certificates.length); for (Certificate certificate : certificates) { if (certificate instanceof X509Certificate) { result.add((X509Certificate) certificate); } } return (!result.isEmpty() ? result.toArray(new X509Certificate[0]) : null); } SslInfoImpl(SSLSession session); @Nullable @Override String getSessionId(); @Nullable @Override X509Certificate[] getPeerCertificates();  }