Java 类org.springframework.boot.context.embedded.Ssl.ClientAuth 实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:AbstractEmbeddedServletContainerFactoryTests.java   
@Test
public void pkcs12KeyStoreAndTrustStore() throws Exception {
    AbstractEmbeddedServletContainerFactory factory = getFactory();
    addTestTxtFile(factory);
    factory.setSsl(getSsl(ClientAuth.NEED, null, "classpath:test.p12",
            "classpath:test.p12", null, null));
    this.container = factory.getEmbeddedServletContainer();
    this.container.start();
    KeyStore keyStore = KeyStore.getInstance("pkcs12");
    keyStore.load(new FileInputStream(new File("src/test/resources/test.p12")),
            "secret".toCharArray());
    SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
            new SSLContextBuilder()
                    .loadTrustMaterial(null, new TrustSelfSignedStrategy())
                    .loadKeyMaterial(keyStore, "secret".toCharArray()).build());
    HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory)
            .build();
    HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(
            httpClient);
    assertThat(getResponse(getLocalUrl("https", "/test.txt"), requestFactory))
            .isEqualTo("test");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:AbstractEmbeddedServletContainerFactoryTests.java   
@Test
public void sslNeedsClientAuthenticationSucceedsWithClientCertificate()
        throws Exception {
    AbstractEmbeddedServletContainerFactory factory = getFactory();
    addTestTxtFile(factory);
    factory.setSsl(getSsl(ClientAuth.NEED, "password", "classpath:test.jks",
            "classpath:test.jks", null, null));
    this.container = factory.getEmbeddedServletContainer();
    this.container.start();
    KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
    keyStore.load(new FileInputStream(new File("src/test/resources/test.jks")),
            "secret".toCharArray());
    SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
            new SSLContextBuilder()
                    .loadTrustMaterial(null, new TrustSelfSignedStrategy())
                    .loadKeyMaterial(keyStore, "password".toCharArray()).build());
    HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory)
            .build();
    HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(
            httpClient);
    assertThat(getResponse(getLocalUrl("https", "/test.txt"), requestFactory))
            .isEqualTo("test");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:AbstractEmbeddedServletContainerFactoryTests.java   
@Test(expected = IOException.class)
public void sslNeedsClientAuthenticationFailsWithoutClientCertificate()
        throws Exception {
    AbstractEmbeddedServletContainerFactory factory = getFactory();
    addTestTxtFile(factory);
    factory.setSsl(getSsl(ClientAuth.NEED, "password", "classpath:test.jks"));
    this.container = factory.getEmbeddedServletContainer();
    this.container.start();
    SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
            new SSLContextBuilder()
                    .loadTrustMaterial(null, new TrustSelfSignedStrategy()).build());
    HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory)
            .build();
    HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(
            httpClient);
    getResponse(getLocalUrl("https", "/test.txt"), requestFactory);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:AbstractEmbeddedServletContainerFactoryTests.java   
@Test
public void sslWantsClientAuthenticationSucceedsWithClientCertificate()
        throws Exception {
    AbstractEmbeddedServletContainerFactory factory = getFactory();
    addTestTxtFile(factory);
    factory.setSsl(getSsl(ClientAuth.WANT, "password", "classpath:test.jks"));
    this.container = factory.getEmbeddedServletContainer();
    this.container.start();
    KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
    keyStore.load(new FileInputStream(new File("src/test/resources/test.jks")),
            "secret".toCharArray());
    SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
            new SSLContextBuilder()
                    .loadTrustMaterial(null, new TrustSelfSignedStrategy())
                    .loadKeyMaterial(keyStore, "password".toCharArray()).build());
    HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory)
            .build();
    HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(
            httpClient);
    assertThat(getResponse(getLocalUrl("https", "/test.txt"), requestFactory))
            .isEqualTo("test");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:AbstractEmbeddedServletContainerFactoryTests.java   
@Test
public void sslWantsClientAuthenticationSucceedsWithoutClientCertificate()
        throws Exception {
    AbstractEmbeddedServletContainerFactory factory = getFactory();
    addTestTxtFile(factory);
    factory.setSsl(getSsl(ClientAuth.WANT, "password", "classpath:test.jks"));
    this.container = factory.getEmbeddedServletContainer();
    this.container.start();
    SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
            new SSLContextBuilder()
                    .loadTrustMaterial(null, new TrustSelfSignedStrategy()).build());
    HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory)
            .build();
    HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(
            httpClient);
    assertThat(getResponse(getLocalUrl("https", "/test.txt"), requestFactory))
            .isEqualTo("test");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:AbstractEmbeddedServletContainerFactoryTests.java   
private Ssl getSsl(ClientAuth clientAuth, String keyPassword, String keyStore,
        String trustStore, String[] supportedProtocols, String[] ciphers) {
    Ssl ssl = new Ssl();
    ssl.setClientAuth(clientAuth);
    if (keyPassword != null) {
        ssl.setKeyPassword(keyPassword);
    }
    if (keyStore != null) {
        ssl.setKeyStore(keyStore);
        ssl.setKeyStorePassword("secret");
        ssl.setKeyStoreType(getStoreType(keyStore));
    }
    if (trustStore != null) {
        ssl.setTrustStore(trustStore);
        ssl.setTrustStorePassword("secret");
        ssl.setTrustStoreType(getStoreType(trustStore));
    }
    if (ciphers != null) {
        ssl.setCiphers(ciphers);
    }
    if (supportedProtocols != null) {
        ssl.setEnabledProtocols(supportedProtocols);
    }
    return ssl;
}
项目:spring-boot-concourse    文件:AbstractEmbeddedServletContainerFactoryTests.java   
@Test
public void pkcs12KeyStoreAndTrustStore() throws Exception {
    AbstractEmbeddedServletContainerFactory factory = getFactory();
    addTestTxtFile(factory);
    factory.setSsl(getSsl(ClientAuth.NEED, null, "classpath:test.p12",
            "classpath:test.p12", null, null));
    this.container = factory.getEmbeddedServletContainer();
    this.container.start();
    KeyStore keyStore = KeyStore.getInstance("pkcs12");
    keyStore.load(new FileInputStream(new File("src/test/resources/test.p12")),
            "secret".toCharArray());
    SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
            new SSLContextBuilder()
                    .loadTrustMaterial(null, new TrustSelfSignedStrategy())
                    .loadKeyMaterial(keyStore, "secret".toCharArray()).build());
    HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory)
            .build();
    HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(
            httpClient);
    assertThat(getResponse(getLocalUrl("https", "/test.txt"), requestFactory))
            .isEqualTo("test");
}
项目:spring-boot-concourse    文件:AbstractEmbeddedServletContainerFactoryTests.java   
@Test
public void sslNeedsClientAuthenticationSucceedsWithClientCertificate()
        throws Exception {
    AbstractEmbeddedServletContainerFactory factory = getFactory();
    addTestTxtFile(factory);
    factory.setSsl(getSsl(ClientAuth.NEED, "password", "classpath:test.jks",
            "classpath:test.jks", null, null));
    this.container = factory.getEmbeddedServletContainer();
    this.container.start();
    KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
    keyStore.load(new FileInputStream(new File("src/test/resources/test.jks")),
            "secret".toCharArray());
    SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
            new SSLContextBuilder()
                    .loadTrustMaterial(null, new TrustSelfSignedStrategy())
                    .loadKeyMaterial(keyStore, "password".toCharArray()).build());
    HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory)
            .build();
    HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(
            httpClient);
    assertThat(getResponse(getLocalUrl("https", "/test.txt"), requestFactory))
            .isEqualTo("test");
}
项目:spring-boot-concourse    文件:AbstractEmbeddedServletContainerFactoryTests.java   
@Test(expected = IOException.class)
public void sslNeedsClientAuthenticationFailsWithoutClientCertificate()
        throws Exception {
    AbstractEmbeddedServletContainerFactory factory = getFactory();
    addTestTxtFile(factory);
    factory.setSsl(getSsl(ClientAuth.NEED, "password", "classpath:test.jks"));
    this.container = factory.getEmbeddedServletContainer();
    this.container.start();
    SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
            new SSLContextBuilder()
                    .loadTrustMaterial(null, new TrustSelfSignedStrategy()).build());
    HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory)
            .build();
    HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(
            httpClient);
    getResponse(getLocalUrl("https", "/test.txt"), requestFactory);
}
项目:spring-boot-concourse    文件:AbstractEmbeddedServletContainerFactoryTests.java   
@Test
public void sslWantsClientAuthenticationSucceedsWithClientCertificate()
        throws Exception {
    AbstractEmbeddedServletContainerFactory factory = getFactory();
    addTestTxtFile(factory);
    factory.setSsl(getSsl(ClientAuth.WANT, "password", "classpath:test.jks"));
    this.container = factory.getEmbeddedServletContainer();
    this.container.start();
    KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
    keyStore.load(new FileInputStream(new File("src/test/resources/test.jks")),
            "secret".toCharArray());
    SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
            new SSLContextBuilder()
                    .loadTrustMaterial(null, new TrustSelfSignedStrategy())
                    .loadKeyMaterial(keyStore, "password".toCharArray()).build());
    HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory)
            .build();
    HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(
            httpClient);
    assertThat(getResponse(getLocalUrl("https", "/test.txt"), requestFactory))
            .isEqualTo("test");
}
项目:spring-boot-concourse    文件:AbstractEmbeddedServletContainerFactoryTests.java   
@Test
public void sslWantsClientAuthenticationSucceedsWithoutClientCertificate()
        throws Exception {
    AbstractEmbeddedServletContainerFactory factory = getFactory();
    addTestTxtFile(factory);
    factory.setSsl(getSsl(ClientAuth.WANT, "password", "classpath:test.jks"));
    this.container = factory.getEmbeddedServletContainer();
    this.container.start();
    SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
            new SSLContextBuilder()
                    .loadTrustMaterial(null, new TrustSelfSignedStrategy()).build());
    HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory)
            .build();
    HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(
            httpClient);
    assertThat(getResponse(getLocalUrl("https", "/test.txt"), requestFactory))
            .isEqualTo("test");
}
项目:spring-boot-concourse    文件:AbstractEmbeddedServletContainerFactoryTests.java   
private Ssl getSsl(ClientAuth clientAuth, String keyPassword, String keyStore,
        String trustStore, String[] supportedProtocols, String[] ciphers) {
    Ssl ssl = new Ssl();
    ssl.setClientAuth(clientAuth);
    if (keyPassword != null) {
        ssl.setKeyPassword(keyPassword);
    }
    if (keyStore != null) {
        ssl.setKeyStore(keyStore);
        ssl.setKeyStorePassword("secret");
        ssl.setKeyStoreType(getStoreType(keyStore));
    }
    if (trustStore != null) {
        ssl.setTrustStore(trustStore);
        ssl.setTrustStorePassword("secret");
        ssl.setTrustStoreType(getStoreType(trustStore));
    }
    if (ciphers != null) {
        ssl.setCiphers(ciphers);
    }
    if (supportedProtocols != null) {
        ssl.setEnabledProtocols(supportedProtocols);
    }
    return ssl;
}
项目:contestparser    文件:AbstractEmbeddedServletContainerFactoryTests.java   
@Test
public void pkcs12KeyStoreAndTrustStore() throws Exception {
    AbstractEmbeddedServletContainerFactory factory = getFactory();
    addTestTxtFile(factory);
    factory.setSsl(getSsl(ClientAuth.NEED, null, "classpath:test.p12",
            "classpath:test.p12"));
    this.container = factory.getEmbeddedServletContainer();
    this.container.start();
    KeyStore keyStore = KeyStore.getInstance("pkcs12");
    keyStore.load(new FileInputStream(new File("src/test/resources/test.p12")),
            "secret".toCharArray());
    SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
            new SSLContextBuilder()
                    .loadTrustMaterial(null, new TrustSelfSignedStrategy())
                    .loadKeyMaterial(keyStore, "secret".toCharArray()).build());
    HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory)
            .build();
    HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(
            httpClient);
    assertThat(getResponse(getLocalUrl("https", "/test.txt"), requestFactory),
            equalTo("test"));
}
项目:contestparser    文件:AbstractEmbeddedServletContainerFactoryTests.java   
@Test
public void sslNeedsClientAuthenticationSucceedsWithClientCertificate()
        throws Exception {
    AbstractEmbeddedServletContainerFactory factory = getFactory();
    addTestTxtFile(factory);
    factory.setSsl(getSsl(ClientAuth.NEED, "password", "classpath:test.jks",
            "classpath:test.jks"));
    this.container = factory.getEmbeddedServletContainer();
    this.container.start();
    KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
    keyStore.load(new FileInputStream(new File("src/test/resources/test.jks")),
            "secret".toCharArray());
    SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
            new SSLContextBuilder()
                    .loadTrustMaterial(null, new TrustSelfSignedStrategy())
                    .loadKeyMaterial(keyStore, "password".toCharArray()).build());
    HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory)
            .build();
    HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(
            httpClient);
    assertThat(getResponse(getLocalUrl("https", "/test.txt"), requestFactory),
            equalTo("test"));
}
项目:contestparser    文件:AbstractEmbeddedServletContainerFactoryTests.java   
@Test(expected = IOException.class)
public void sslNeedsClientAuthenticationFailsWithoutClientCertificate()
        throws Exception {
    AbstractEmbeddedServletContainerFactory factory = getFactory();
    addTestTxtFile(factory);
    factory.setSsl(getSsl(ClientAuth.NEED, "password", "classpath:test.jks"));
    this.container = factory.getEmbeddedServletContainer();
    this.container.start();
    SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
            new SSLContextBuilder()
                    .loadTrustMaterial(null, new TrustSelfSignedStrategy()).build());
    HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory)
            .build();
    HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(
            httpClient);
    getResponse(getLocalUrl("https", "/test.txt"), requestFactory);
}
项目:contestparser    文件:AbstractEmbeddedServletContainerFactoryTests.java   
@Test
public void sslWantsClientAuthenticationSucceedsWithClientCertificate()
        throws Exception {
    AbstractEmbeddedServletContainerFactory factory = getFactory();
    addTestTxtFile(factory);
    factory.setSsl(getSsl(ClientAuth.WANT, "password", "classpath:test.jks"));
    this.container = factory.getEmbeddedServletContainer();
    this.container.start();
    KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
    keyStore.load(new FileInputStream(new File("src/test/resources/test.jks")),
            "secret".toCharArray());
    SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
            new SSLContextBuilder()
                    .loadTrustMaterial(null, new TrustSelfSignedStrategy())
                    .loadKeyMaterial(keyStore, "password".toCharArray()).build());
    HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory)
            .build();
    HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(
            httpClient);
    assertThat(getResponse(getLocalUrl("https", "/test.txt"), requestFactory),
            equalTo("test"));
}
项目:contestparser    文件:AbstractEmbeddedServletContainerFactoryTests.java   
@Test
public void sslWantsClientAuthenticationSucceedsWithoutClientCertificate()
        throws Exception {
    AbstractEmbeddedServletContainerFactory factory = getFactory();
    addTestTxtFile(factory);
    factory.setSsl(getSsl(ClientAuth.WANT, "password", "classpath:test.jks"));
    this.container = factory.getEmbeddedServletContainer();
    this.container.start();
    SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
            new SSLContextBuilder()
                    .loadTrustMaterial(null, new TrustSelfSignedStrategy()).build());
    HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory)
            .build();
    HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(
            httpClient);
    assertThat(getResponse(getLocalUrl("https", "/test.txt"), requestFactory),
            equalTo("test"));
}
项目:contestparser    文件:AbstractEmbeddedServletContainerFactoryTests.java   
private Ssl getSsl(ClientAuth clientAuth, String keyPassword, String keyStore,
        String trustStore) {
    Ssl ssl = new Ssl();
    ssl.setClientAuth(clientAuth);
    if (keyPassword != null) {
        ssl.setKeyPassword(keyPassword);
    }
    if (keyStore != null) {
        ssl.setKeyStore(keyStore);
        ssl.setKeyStorePassword("secret");
        ssl.setKeyStoreType(getStoreType(keyStore));
    }
    if (trustStore != null) {
        ssl.setTrustStore(trustStore);
        ssl.setTrustStorePassword("secret");
        ssl.setTrustStoreType(getStoreType(trustStore));
    }
    return ssl;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:TomcatEmbeddedServletContainerFactory.java   
private void configureSslClientAuth(AbstractHttp11JsseProtocol<?> protocol, Ssl ssl) {
    if (ssl.getClientAuth() == ClientAuth.NEED) {
        protocol.setClientAuth(Boolean.TRUE.toString());
    }
    else if (ssl.getClientAuth() == ClientAuth.WANT) {
        protocol.setClientAuth("want");
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:UndertowEmbeddedServletContainerFactory.java   
private SslClientAuthMode getSslClientAuthMode(Ssl ssl) {
    if (ssl.getClientAuth() == ClientAuth.NEED) {
        return SslClientAuthMode.REQUIRED;
    }
    if (ssl.getClientAuth() == ClientAuth.WANT) {
        return SslClientAuthMode.REQUESTED;
    }
    return SslClientAuthMode.NOT_REQUESTED;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:JettyEmbeddedServletContainerFactory.java   
private void configureSslClientAuth(SslContextFactory factory, Ssl ssl) {
    if (ssl.getClientAuth() == ClientAuth.NEED) {
        factory.setNeedClientAuth(true);
        factory.setWantClientAuth(true);
    }
    else if (ssl.getClientAuth() == ClientAuth.WANT) {
        factory.setWantClientAuth(true);
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:AbstractEmbeddedServletContainerFactoryTests.java   
@Test
public void sslWithCustomSslStoreProvider() throws Exception {
    AbstractEmbeddedServletContainerFactory factory = getFactory();
    addTestTxtFile(factory);
    Ssl ssl = new Ssl();
    ssl.setClientAuth(ClientAuth.NEED);
    ssl.setKeyPassword("password");
    factory.setSsl(ssl);
    SslStoreProvider sslStoreProvider = mock(SslStoreProvider.class);
    given(sslStoreProvider.getKeyStore()).willReturn(loadStore());
    given(sslStoreProvider.getTrustStore()).willReturn(loadStore());
    factory.setSslStoreProvider(sslStoreProvider);
    this.container = factory.getEmbeddedServletContainer();
    this.container.start();
    KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
    keyStore.load(new FileInputStream(new File("src/test/resources/test.jks")),
            "secret".toCharArray());
    SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
            new SSLContextBuilder()
                    .loadTrustMaterial(null, new TrustSelfSignedStrategy())
                    .loadKeyMaterial(keyStore, "password".toCharArray()).build());
    HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory)
            .build();
    HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(
            httpClient);
    assertThat(getResponse(getLocalUrl("https", "/test.txt"), requestFactory))
            .isEqualTo("test");
    verify(sslStoreProvider).getKeyStore();
    verify(sslStoreProvider).getTrustStore();
}
项目:spring-boot-concourse    文件:TomcatEmbeddedServletContainerFactory.java   
private void configureSslClientAuth(AbstractHttp11JsseProtocol<?> protocol, Ssl ssl) {
    if (ssl.getClientAuth() == ClientAuth.NEED) {
        protocol.setClientAuth(Boolean.TRUE.toString());
    }
    else if (ssl.getClientAuth() == ClientAuth.WANT) {
        protocol.setClientAuth("want");
    }
}
项目:spring-boot-concourse    文件:UndertowEmbeddedServletContainerFactory.java   
private SslClientAuthMode getSslClientAuthMode(Ssl ssl) {
    if (ssl.getClientAuth() == ClientAuth.NEED) {
        return SslClientAuthMode.REQUIRED;
    }
    if (ssl.getClientAuth() == ClientAuth.WANT) {
        return SslClientAuthMode.REQUESTED;
    }
    return SslClientAuthMode.NOT_REQUESTED;
}
项目:spring-boot-concourse    文件:JettyEmbeddedServletContainerFactory.java   
private void configureSslClientAuth(SslContextFactory factory, Ssl ssl) {
    if (ssl.getClientAuth() == ClientAuth.NEED) {
        factory.setNeedClientAuth(true);
        factory.setWantClientAuth(true);
    }
    else if (ssl.getClientAuth() == ClientAuth.WANT) {
        factory.setWantClientAuth(true);
    }
}
项目:spring-boot-concourse    文件:AbstractEmbeddedServletContainerFactoryTests.java   
@Test
public void sslWithCustomSslStoreProvider() throws Exception {
    AbstractEmbeddedServletContainerFactory factory = getFactory();
    addTestTxtFile(factory);
    Ssl ssl = new Ssl();
    ssl.setClientAuth(ClientAuth.NEED);
    ssl.setKeyPassword("password");
    factory.setSsl(ssl);
    SslStoreProvider sslStoreProvider = mock(SslStoreProvider.class);
    given(sslStoreProvider.getKeyStore()).willReturn(loadStore());
    given(sslStoreProvider.getTrustStore()).willReturn(loadStore());
    factory.setSslStoreProvider(sslStoreProvider);
    this.container = factory.getEmbeddedServletContainer();
    this.container.start();
    KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
    keyStore.load(new FileInputStream(new File("src/test/resources/test.jks")),
            "secret".toCharArray());
    SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
            new SSLContextBuilder()
                    .loadTrustMaterial(null, new TrustSelfSignedStrategy())
                    .loadKeyMaterial(keyStore, "password".toCharArray()).build());
    HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory)
            .build();
    HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(
            httpClient);
    assertThat(getResponse(getLocalUrl("https", "/test.txt"), requestFactory))
            .isEqualTo("test");
    verify(sslStoreProvider).getKeyStore();
    verify(sslStoreProvider).getTrustStore();
}
项目:contestparser    文件:TomcatEmbeddedServletContainerFactory.java   
private void configureSslClientAuth(AbstractHttp11JsseProtocol<?> protocol, Ssl ssl) {
    if (ssl.getClientAuth() == ClientAuth.NEED) {
        protocol.setClientAuth(Boolean.TRUE.toString());
    }
    else if (ssl.getClientAuth() == ClientAuth.WANT) {
        protocol.setClientAuth("want");
    }
}
项目:contestparser    文件:UndertowEmbeddedServletContainerFactory.java   
private SslClientAuthMode getSslClientAuthMode(Ssl ssl) {
    if (ssl.getClientAuth() == ClientAuth.NEED) {
        return SslClientAuthMode.REQUIRED;
    }
    if (ssl.getClientAuth() == ClientAuth.WANT) {
        return SslClientAuthMode.REQUESTED;
    }
    return SslClientAuthMode.NOT_REQUESTED;
}
项目:contestparser    文件:JettyEmbeddedServletContainerFactory.java   
private void configureSslClientAuth(SslContextFactory factory, Ssl ssl) {
    if (ssl.getClientAuth() == ClientAuth.NEED) {
        factory.setNeedClientAuth(true);
        factory.setWantClientAuth(true);
    }
    else if (ssl.getClientAuth() == ClientAuth.WANT) {
        factory.setWantClientAuth(true);
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:AbstractEmbeddedServletContainerFactoryTests.java   
protected Ssl getSsl(ClientAuth clientAuth, String keyPassword, String keyStore) {
    return getSsl(clientAuth, keyPassword, keyStore, null, null, null);
}
项目:spring-boot-concourse    文件:AbstractEmbeddedServletContainerFactoryTests.java   
private Ssl getSsl(ClientAuth clientAuth, String keyPassword, String keyStore) {
    return getSsl(clientAuth, keyPassword, keyStore, null, null, null);
}
项目:contestparser    文件:AbstractEmbeddedServletContainerFactoryTests.java   
private Ssl getSsl(ClientAuth clientAuth, String keyPassword, String keyStore) {
    return getSsl(clientAuth, keyPassword, keyStore, null);
}