@Test void buildTrustedCertFromUrl() throws Exception { SSLSocketFactory sf = mock(SSLSocketFactory.class); SSLSocket socket = mock(SSLSocket.class); SSLSession sslSession = mock(SSLSession.class); when(sf.createSocket(anyString(), anyInt())).thenReturn(socket); when(socket.getSession()).thenReturn(sslSession); when(sslSession.getPeerCertificates()).thenReturn(new X509Certificate[]{testCert}); final TrustedCertEntityBuilder builder = new TrustedCertEntityBuilder(new IdGenerator(), sf, certFact); final Bundle bundle = new Bundle(); final TrustedCert trustedCert = new TrustedCert(ImmutableMap.of(VERIFY_HOSTNAME, true), null); bundle.putAllTrustedCerts(ImmutableMap.of(URL_NAME, trustedCert)); final List<Entity> trustedCerts = builder.build(bundle, EntityBuilder.BundleType.ENVIRONMENT, DocumentTools.INSTANCE.getDocumentBuilder().newDocument()); assertEquals(1, trustedCerts.size()); final Element trustedCertEntityXml = verifyTrustedCertElement(trustedCerts, true); verifyProperties(trustedCertEntityXml); verifyCertDetails(trustedCertEntityXml); }
@Override public List<Entity> build(Bundle bundle, BundleType bundleType, Document document) { if (bundle instanceof AnnotatedBundle) { Map<String, TrustedCert> trustedCertMap = Optional.ofNullable(bundle.getTrustedCerts()).orElse(Collections.emptyMap()); return buildEntities(trustedCertMap, ((AnnotatedBundle)bundle).getFullBundle(), bundleType, document); } else { return buildEntities(bundle.getTrustedCerts(), bundle, bundleType, document); } }
TrustedCertEntityBuilder implements EntityBuilder { @Override public List<Entity> build(Bundle bundle, BundleType bundleType, Document document) { if (bundle instanceof AnnotatedBundle) { Map<String, TrustedCert> trustedCertMap = Optional.ofNullable(bundle.getTrustedCerts()).orElse(Collections.emptyMap()); return buildEntities(trustedCertMap, ((AnnotatedBundle)bundle).getFullBundle(), bundleType, document); } else { return buildEntities(bundle.getTrustedCerts(), bundle, bundleType, document); } } }
TrustedCertEntityBuilder implements EntityBuilder { @Override public List<Entity> build(Bundle bundle, BundleType bundleType, Document document) { if (bundle instanceof AnnotatedBundle) { Map<String, TrustedCert> trustedCertMap = Optional.ofNullable(bundle.getTrustedCerts()).orElse(Collections.emptyMap()); return buildEntities(trustedCertMap, ((AnnotatedBundle)bundle).getFullBundle(), bundleType, document); } else { return buildEntities(bundle.getTrustedCerts(), bundle, bundleType, document); } } @Inject  TrustedCertEntityBuilder(IdGenerator idGenerator, SSLSocketFactory acceptAllSocketFactory, CertificateFactory certFactory); }
TrustedCertEntityBuilder implements EntityBuilder { @Override public List<Entity> build(Bundle bundle, BundleType bundleType, Document document) { if (bundle instanceof AnnotatedBundle) { Map<String, TrustedCert> trustedCertMap = Optional.ofNullable(bundle.getTrustedCerts()).orElse(Collections.emptyMap()); return buildEntities(trustedCertMap, ((AnnotatedBundle)bundle).getFullBundle(), bundleType, document); } else { return buildEntities(bundle.getTrustedCerts(), bundle, bundleType, document); } } @Inject  TrustedCertEntityBuilder(IdGenerator idGenerator, SSLSocketFactory acceptAllSocketFactory, CertificateFactory certFactory); @Override List<Entity> build(Bundle bundle, BundleType bundleType, Document document); @Override @NotNull Integer getOrder(); }
TrustedCertEntityBuilder implements EntityBuilder { @Override public List<Entity> build(Bundle bundle, BundleType bundleType, Document document) { if (bundle instanceof AnnotatedBundle) { Map<String, TrustedCert> trustedCertMap = Optional.ofNullable(bundle.getTrustedCerts()).orElse(Collections.emptyMap()); return buildEntities(trustedCertMap, ((AnnotatedBundle)bundle).getFullBundle(), bundleType, document); } else { return buildEntities(bundle.getTrustedCerts(), bundle, bundleType, document); } } @Inject  TrustedCertEntityBuilder(IdGenerator idGenerator, SSLSocketFactory acceptAllSocketFactory, CertificateFactory certFactory); @Override List<Entity> build(Bundle bundle, BundleType bundleType, Document document); @Override @NotNull Integer getOrder();  }