org.apache.camel.support.jsse.KeyManagersParameters Java Examples
The following examples show how to use
org.apache.camel.support.jsse.KeyManagersParameters.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Application.java From wildfly-camel-examples with Apache License 2.0 | 6 votes |
private SSLContextParameters createProducerSSLContextParameters() { final KeyStoreParameters ksp = new KeyStoreParameters(); ksp.setResource(CLIENT_CERT_KEYSTORE_PATH); ksp.setPassword(CLIENT_CERT_KEYSTORE_PASSWORD); final KeyManagersParameters kmp = new KeyManagersParameters(); kmp.setKeyStore(ksp); kmp.setKeyPassword(CLIENT_CERT_KEYSTORE_PASSWORD); final SSLContextClientParameters sslContextClientParameters = new SSLContextClientParameters(); final SSLContextParameters sslContextParameters = new SSLContextParameters(); sslContextParameters.setClientParameters(sslContextClientParameters); sslContextParameters.setKeyManagers(kmp); sslContextParameters.setCertAlias("client"); sslContextParameters.setSecureSocketProtocol("TLSv1.2"); // so that the client trusts the self-signed server certificate final KeyStoreParameters trustStoreParams = new KeyStoreParameters(); trustStoreParams.setResource(CLIENT_CERT_TRUSTSTORE_PATH); trustStoreParams.setPassword(CLIENT_CERT_KEYSTORE_PASSWORD); final TrustManagersParameters tmp = new TrustManagersParameters(); tmp.setKeyStore(trustStoreParams); sslContextParameters.setTrustManagers(tmp); return sslContextParameters; }
Example #2
Source File: AhcWSSIntegrationTest.java From wildfly-camel with Apache License 2.0 | 6 votes |
private static SSLContextParameters defineSSLContextClientParameters() { KeyStoreParameters ksp = new KeyStoreParameters(); ksp.setResource("/" + KEYSTORE); ksp.setPassword(KEYSTORE_PASSWORD); KeyManagersParameters kmp = new KeyManagersParameters(); kmp.setKeyPassword(KEYSTORE_PASSWORD); kmp.setKeyStore(ksp); TrustManagersParameters tmp = new TrustManagersParameters(); tmp.setKeyStore(ksp); SSLContextParameters scp = new SSLContextParameters(); scp.setKeyManagers(kmp); scp.setTrustManagers(tmp); return scp; }
Example #3
Source File: SecureNettyIntegrationTest.java From wildfly-camel with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { KeyStoreParameters ksp = new KeyStoreParameters(); ksp.setResource("/" + KEYSTORE); ksp.setPassword(KEYSTORE_PASSWORD); KeyManagersParameters kmp = new KeyManagersParameters(); kmp.setKeyPassword(KEYSTORE_PASSWORD); kmp.setKeyStore(ksp); TrustManagersParameters tmp = new TrustManagersParameters(); tmp.setKeyStore(ksp); SSLContextParameters scp = new SSLContextParameters(); scp.setKeyManagers(kmp); scp.setTrustManagers(tmp); InitialContext context = new InitialContext(); context.bind("sslContextParameters", scp); }
Example #4
Source File: CXFWSSecureConsumerIntegrationTest.java From wildfly-camel with Apache License 2.0 | 6 votes |
private SSLContextParameters createSSLContextParameters() { KeyStoreParameters ksp = new KeyStoreParameters(); ksp.setResource(System.getProperty("jboss.server.config.dir") + "/application.keystore"); ksp.setPassword("password"); KeyManagersParameters kmp = new KeyManagersParameters(); kmp.setKeyStore(ksp); kmp.setKeyPassword("password"); SSLContextClientParameters sslContextClientParameters = new SSLContextClientParameters(); SSLContextParameters sslContextParameters = new SSLContextParameters(); sslContextParameters.setClientParameters(sslContextClientParameters); sslContextParameters.setKeyManagers(kmp); TrustManagersParameters tmp = new TrustManagersParameters(); tmp.setKeyStore(ksp); sslContextParameters.setTrustManagers(tmp); return sslContextParameters; }
Example #5
Source File: EMailUtil.java From syndesis with Apache License 2.0 | 5 votes |
public static SSLContextParameters createSSLContextParameters(Map<String, Object> options) { String protocol = ConnectorOptions.extractOption(options, PROTOCOL); if (! isSecure(protocol)) { return null; } KeyStoreParameters keystoreParams = new KeyStoreParameters() { @Override public KeyStore createKeyStore() throws GeneralSecurityException, IOException { try { return EMailUtil.createKeyStore(options); } catch (Exception e) { throw new GeneralSecurityException(e); } } }; KeyManagersParameters keyManagersParams = new KeyManagersParameters(); keyManagersParams.setKeyStore(keystoreParams); TrustManagersParameters trustManagersParams = new TrustManagersParameters(); trustManagersParams.setKeyStore(keystoreParams); SSLContextParameters sslContextParameters = new SSLContextParameters(); sslContextParameters.setKeyManagers(keyManagersParams); sslContextParameters.setTrustManagers(trustManagersParams); return sslContextParameters; }
Example #6
Source File: KafkaConnectionCustomizer.java From syndesis with Apache License 2.0 | 5 votes |
private static SSLContextParameters createSSLContextParameters(String certificate) { KeyStoreHelper brokerKeyStoreHelper = new KeyStoreHelper(certificate, "brokerCertificate").store(); KeyStoreParameters keyStore = createKeyStore(brokerKeyStoreHelper); KeyStoreParameters brokerStore = createKeyStore(brokerKeyStoreHelper); KeyManagersParameters kmp = createKeyManagerParameters(keyStore); TrustManagersParameters tmp = createTrustManagerParameters(brokerStore); SSLContextParameters scp = new SSLContextParameters(); scp.setKeyManagers(kmp); scp.setTrustManagers(tmp); return scp; }
Example #7
Source File: CamelSSLConfigurationProperties.java From camel-spring-boot with Apache License 2.0 | 4 votes |
public KeyManagersParameters getKeyManagers() { return config.getKeyManagers(); }
Example #8
Source File: CamelSSLConfigurationProperties.java From camel-spring-boot with Apache License 2.0 | 4 votes |
public void setKeyManagers(KeyManagersParameters keyManagers) { config.setKeyManagers(keyManagers); }
Example #9
Source File: PlatformHttpServiceCustomizerTest.java From camel-k-runtime with Apache License 2.0 | 4 votes |
@Test public void testPlatformHttpComponentSSL() throws Exception { KeyStoreParameters keystoreParameters = new KeyStoreParameters(); keystoreParameters.setResource("jsse/service.jks"); keystoreParameters.setPassword("security"); SSLContextParameters serviceSSLContextParameters = new SSLContextParameters(); KeyManagersParameters serviceSSLKeyManagers = new KeyManagersParameters(); serviceSSLKeyManagers.setKeyPassword("security"); serviceSSLKeyManagers.setKeyStore(keystoreParameters); serviceSSLContextParameters.setKeyManagers(serviceSSLKeyManagers); KeyStoreParameters truststoreParameters = new KeyStoreParameters(); truststoreParameters.setResource("jsse/truststore.jks"); truststoreParameters.setPassword("storepass"); TrustManagersParameters clientAuthServiceSSLTrustManagers = new TrustManagersParameters(); clientAuthServiceSSLTrustManagers.setKeyStore(truststoreParameters); serviceSSLContextParameters.setTrustManagers(clientAuthServiceSSLTrustManagers); SSLContextServerParameters clientAuthSSLContextServerParameters = new SSLContextServerParameters(); clientAuthSSLContextServerParameters.setClientAuthentication("REQUIRE"); serviceSSLContextParameters.setServerParameters(clientAuthSSLContextServerParameters); SSLContextParameters clientSSLContextParameters = new SSLContextParameters(); TrustManagersParameters clientSSLTrustManagers = new TrustManagersParameters(); clientSSLTrustManagers.setKeyStore(truststoreParameters); clientSSLContextParameters.setTrustManagers(clientSSLTrustManagers); KeyManagersParameters clientAuthClientSSLKeyManagers = new KeyManagersParameters(); clientAuthClientSSLKeyManagers.setKeyPassword("security"); clientAuthClientSSLKeyManagers.setKeyStore(keystoreParameters); clientSSLContextParameters.setKeyManagers(clientAuthClientSSLKeyManagers); CamelContext context = new DefaultCamelContext(); context.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { fromF("platform-http:/") .transform().body(String.class, b -> b.toUpperCase()); } }); PlatformHttpServiceContextCustomizer httpService = new PlatformHttpServiceContextCustomizer(); httpService.setBindPort(AvailablePortFinder.getNextAvailable()); httpService.setSslContextParameters(serviceSSLContextParameters); httpService.apply(context); try { context.getRegistry().bind("clientSSLContextParameters", clientSSLContextParameters); context.start(); String result = context.createFluentProducerTemplate() .toF("https://localhost:%d?sslContextParameters=#clientSSLContextParameters", httpService.getBindPort()) .withBody("test") .request(String.class); assertThat(result).isEqualTo("TEST"); } finally { context.stop(); } }
Example #10
Source File: PlatformHttpServiceCustomizerTest.java From camel-k-runtime with Apache License 2.0 | 4 votes |
@Test public void testPlatformHttpComponentGlobalSSL() throws Exception { KeyStoreParameters keystoreParameters = new KeyStoreParameters(); keystoreParameters.setResource("jsse/service.jks"); keystoreParameters.setPassword("security"); SSLContextParameters serviceSSLContextParameters = new SSLContextParameters(); KeyManagersParameters serviceSSLKeyManagers = new KeyManagersParameters(); serviceSSLKeyManagers.setKeyPassword("security"); serviceSSLKeyManagers.setKeyStore(keystoreParameters); serviceSSLContextParameters.setKeyManagers(serviceSSLKeyManagers); KeyStoreParameters truststoreParameters = new KeyStoreParameters(); truststoreParameters.setResource("jsse/truststore.jks"); truststoreParameters.setPassword("storepass"); TrustManagersParameters clientAuthServiceSSLTrustManagers = new TrustManagersParameters(); clientAuthServiceSSLTrustManagers.setKeyStore(truststoreParameters); serviceSSLContextParameters.setTrustManagers(clientAuthServiceSSLTrustManagers); SSLContextServerParameters clientAuthSSLContextServerParameters = new SSLContextServerParameters(); clientAuthSSLContextServerParameters.setClientAuthentication("REQUIRE"); serviceSSLContextParameters.setServerParameters(clientAuthSSLContextServerParameters); SSLContextParameters clientSSLContextParameters = new SSLContextParameters(); TrustManagersParameters clientSSLTrustManagers = new TrustManagersParameters(); clientSSLTrustManagers.setKeyStore(truststoreParameters); clientSSLContextParameters.setTrustManagers(clientSSLTrustManagers); KeyManagersParameters clientAuthClientSSLKeyManagers = new KeyManagersParameters(); clientAuthClientSSLKeyManagers.setKeyPassword("security"); clientAuthClientSSLKeyManagers.setKeyStore(keystoreParameters); clientSSLContextParameters.setKeyManagers(clientAuthClientSSLKeyManagers); CamelContext context = new DefaultCamelContext(); context.setSSLContextParameters(serviceSSLContextParameters); context.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { fromF("platform-http:/") .transform().body(String.class, b -> b.toUpperCase()); } }); PlatformHttpServiceContextCustomizer httpService = new PlatformHttpServiceContextCustomizer(); httpService.setBindPort(AvailablePortFinder.getNextAvailable()); httpService.setUseGlobalSslContextParameters(true); httpService.apply(context); try { context.getRegistry().bind("clientSSLContextParameters", clientSSLContextParameters); context.start(); String result = context.createFluentProducerTemplate() .toF("https://localhost:%d?sslContextParameters=#clientSSLContextParameters", httpService.getBindPort()) .withBody("test") .request(String.class); assertThat(result).isEqualTo("TEST"); } finally { context.stop(); } }
Example #11
Source File: KafkaConnectionCustomizer.java From syndesis with Apache License 2.0 | 4 votes |
private static KeyManagersParameters createKeyManagerParameters(KeyStoreParameters keyStore) { KeyManagersParameters keyManagersParams = new KeyManagersParameters(); keyManagersParams.setKeyStore(keyStore); keyManagersParams.setKeyPassword(keyStore.getPassword()); return keyManagersParams; }