@Test public void shouldSetJksTrustOptions() { given(mockSsl.getTrustStoreType()).willReturn("JKS"); given(mockSsl.getTrustStore()).willReturn("/trust/store/path"); given(mockSsl.getTrustStorePassword()).willReturn("pass"); customizer.apply(mockHttpServerOptions); ArgumentCaptor<JksOptions> captor = ArgumentCaptor.forClass(JksOptions.class); verify(mockHttpServerOptions).setTrustOptions(captor.capture()); JksOptions jksOptions = captor.getValue(); assertThat(jksOptions.getPath()).isEqualTo("/trust/store/path"); assertThat(jksOptions.getPassword()).isEqualTo("pass"); }
@Override public HttpServerOptions apply(HttpServerOptions options) { Ssl ssl = factory.getSsl(); if (ssl == null) { return options; } options.setSsl(ssl.isEnabled()); options.setKeyCertOptions(keyCertOptionsAdapter(ssl)); options.setTrustOptions(trustOptionsAdapter(ssl)); propertyMapper.from(ssl.getClientAuth()) .whenNonNull() .as(this::clientAuthAdapter) .to(options::setClientAuth); propertyMapper.from(ssl.getEnabledProtocols()) .whenNonNull() .as(Arrays::asList) .as(LinkedHashSet::new) .to(options::setEnabledSecureTransportProtocols); propertyMapper.from(ssl.getCiphers()) .whenNonNull() .as(Arrays::stream) .to(stream -> stream.forEach(options::addEnabledCipherSuite)); return options; }
SslCustomizer implements HttpServerOptionsCustomizer { @Override public HttpServerOptions apply(HttpServerOptions options) { Ssl ssl = factory.getSsl(); if (ssl == null) { return options; } options.setSsl(ssl.isEnabled()); options.setKeyCertOptions(keyCertOptionsAdapter(ssl)); options.setTrustOptions(trustOptionsAdapter(ssl)); propertyMapper.from(ssl.getClientAuth()) .whenNonNull() .as(this::clientAuthAdapter) .to(options::setClientAuth); propertyMapper.from(ssl.getEnabledProtocols()) .whenNonNull() .as(Arrays::asList) .as(LinkedHashSet::new) .to(options::setEnabledSecureTransportProtocols); propertyMapper.from(ssl.getCiphers()) .whenNonNull() .as(Arrays::stream) .to(stream -> stream.forEach(options::addEnabledCipherSuite)); return options; } }
SslCustomizer implements HttpServerOptionsCustomizer { @Override public HttpServerOptions apply(HttpServerOptions options) { Ssl ssl = factory.getSsl(); if (ssl == null) { return options; } options.setSsl(ssl.isEnabled()); options.setKeyCertOptions(keyCertOptionsAdapter(ssl)); options.setTrustOptions(trustOptionsAdapter(ssl)); propertyMapper.from(ssl.getClientAuth()) .whenNonNull() .as(this::clientAuthAdapter) .to(options::setClientAuth); propertyMapper.from(ssl.getEnabledProtocols()) .whenNonNull() .as(Arrays::asList) .as(LinkedHashSet::new) .to(options::setEnabledSecureTransportProtocols); propertyMapper.from(ssl.getCiphers()) .whenNonNull() .as(Arrays::stream) .to(stream -> stream.forEach(options::addEnabledCipherSuite)); return options; } SslCustomizer(AbstractConfigurableWebServerFactory factory); }
SslCustomizer implements HttpServerOptionsCustomizer { @Override public HttpServerOptions apply(HttpServerOptions options) { Ssl ssl = factory.getSsl(); if (ssl == null) { return options; } options.setSsl(ssl.isEnabled()); options.setKeyCertOptions(keyCertOptionsAdapter(ssl)); options.setTrustOptions(trustOptionsAdapter(ssl)); propertyMapper.from(ssl.getClientAuth()) .whenNonNull() .as(this::clientAuthAdapter) .to(options::setClientAuth); propertyMapper.from(ssl.getEnabledProtocols()) .whenNonNull() .as(Arrays::asList) .as(LinkedHashSet::new) .to(options::setEnabledSecureTransportProtocols); propertyMapper.from(ssl.getCiphers()) .whenNonNull() .as(Arrays::stream) .to(stream -> stream.forEach(options::addEnabledCipherSuite)); return options; } SslCustomizer(AbstractConfigurableWebServerFactory factory); @Override HttpServerOptions apply(HttpServerOptions options); }
SslCustomizer implements HttpServerOptionsCustomizer { @Override public HttpServerOptions apply(HttpServerOptions options) { Ssl ssl = factory.getSsl(); if (ssl == null) { return options; } options.setSsl(ssl.isEnabled()); options.setKeyCertOptions(keyCertOptionsAdapter(ssl)); options.setTrustOptions(trustOptionsAdapter(ssl)); propertyMapper.from(ssl.getClientAuth()) .whenNonNull() .as(this::clientAuthAdapter) .to(options::setClientAuth); propertyMapper.from(ssl.getEnabledProtocols()) .whenNonNull() .as(Arrays::asList) .as(LinkedHashSet::new) .to(options::setEnabledSecureTransportProtocols); propertyMapper.from(ssl.getCiphers()) .whenNonNull() .as(Arrays::stream) .to(stream -> stream.forEach(options::addEnabledCipherSuite)); return options; } SslCustomizer(AbstractConfigurableWebServerFactory factory); @Override HttpServerOptions apply(HttpServerOptions options);  }