private SSLSocketFactory tryToGetSSLSocketFactory() { try { return sslContextParameters.createSSLContext(camelContext) .getSocketFactory(); } catch (GeneralSecurityException | IOException e) { throw new RuntimeException("Setting SSL failed", e); } } }
private SSLContext createSSLContext() { try { return sslContextParameters.createSSLContext(); } catch (Exception e) { throw new RuntimeCamelException("Error initializing SSLContext.", e); } }
/** * Creates a new instance using a factory created by the provided client configuration * parameters. * * @param params the configuration parameters to use when creating the socket factory * @param camelContext the Camel context */ public SSLContextParametersSecureProtocolSocketFactory(SSLContextParameters params, CamelContext camelContext) { try { this.context = params.createSSLContext(camelContext); this.factory = this.context.getSocketFactory(); } catch (Exception e) { throw new RuntimeCamelException("Error creating the SSLContext.", e); } }
private ServerConnector getSslSocketConnector(Server server, SSLContextParameters sslContextParameters) throws Exception { ServerConnector sslSocketConnector = null; if (sslContextParameters != null) { SslContextFactory sslContextFactory = new WebSocketComponentSslContextFactory(); sslContextFactory.setSslContext(sslContextParameters.createSSLContext(getCamelContext())); sslSocketConnector = new ServerConnector(server, sslContextFactory); } else { SslContextFactory sslContextFactory = new SslContextFactory(); sslContextFactory.setKeyStorePassword(sslKeyPassword); sslContextFactory.setKeyManagerPassword(sslPassword); if (sslKeystore != null) { sslContextFactory.setKeyStorePath(sslKeystore); } sslSocketConnector = new ServerConnector(server, sslContextFactory); } return sslSocketConnector; }
public WsSecurityInformation getSecurityInformation() { SSLContextParameters sslContextParameters = getSslContextParameters(); if (sslContextParameters == null && secure) { Map<String, SSLContextParameters> sslContextParameterMap = getCamelContext().getRegistry().findByTypeWithName(SSLContextParameters.class); if (sslContextParameterMap.size() == 1) { Map.Entry<String, SSLContextParameters> entry = sslContextParameterMap.entrySet().iterator().next(); sslContextParameters = entry.getValue(); } else if (sslContextParameterMap.size() > 1) { throw new AmbiguousBeanException(SSLContextParameters.class); } } try { SSLContext sslContext = sslContextParameters != null ? sslContextParameters.createSSLContext(getCamelContext()) : null; return new WsSecurityInformation(secure, sslContext, hostnameVerifier, username, password); } catch (Exception e) { throw new RuntimeCamelException(e); } }
public Consul createConsulClient(CamelContext camelContext) throws Exception { Consul.Builder builder = Consul.builder(); builder.withPing(pingInstance); if (ObjectHelper.isNotEmpty(url)) { builder.withUrl(url); } if (ObjectHelper.isNotEmpty(camelContext) && ObjectHelper.isNotEmpty(sslContextParameters)) { builder.withSslContext(sslContextParameters.createSSLContext(camelContext)); } if (ObjectHelper.isNotEmpty(aclToken)) { builder.withAclToken(aclToken); } if (requiresBasicAuthentication()) { builder.withBasicAuth(userName, password); } if (ObjectHelper.isNotEmpty(connectTimeoutMillis)) { builder.withConnectTimeoutMillis(connectTimeoutMillis); } if (ObjectHelper.isNotEmpty(readTimeoutMillis)) { builder.withReadTimeoutMillis(readTimeoutMillis); } if (ObjectHelper.isNotEmpty(writeTimeoutMillis)) { builder.withWriteTimeoutMillis(writeTimeoutMillis); } return builder.build(); }
public EtcdClient createClient() throws Exception { return new EtcdClient( new EtcdSecurityContext( sslContextParameters != null ? sslContextParameters.createSSLContext(context) : null, userName, password), EtcdHelper.resolveURIs(context, getUris()) ); }
@Override public WebServiceConnection createConnection(URI uri) throws IOException { WebServiceConnection wsc = delegate.createConnection(uri); if (wsc instanceof HttpUrlConnection) { HttpURLConnection connection = ((HttpUrlConnection) wsc).getConnection(); if (configuration.getTimeout() > -1) { connection.setReadTimeout(configuration.getTimeout()); } if (configuration.getSslContextParameters() != null && connection instanceof HttpsURLConnection) { try { synchronized (this) { if (sslContext == null) { sslContext = configuration.getSslContextParameters().createSSLContext(camelContext); } } } catch (GeneralSecurityException e) { throw new RuntimeCamelException("Error creating SSLContext based on SSLContextParameters.", e); } ((HttpsURLConnection) connection).setSSLSocketFactory(sslContext.getSocketFactory()); } } else { throw new RuntimeCamelException("Unsupported delegate. Delegate must return a org.springframework.ws.transport.http.HttpUrlConnection. Found " + wsc.getClass()); } return wsc; }
private static LinkedInOAuthRequestFilter createRequestFilter(LinkedInConfiguration configuration) { // validate configuration configuration.validate(); final String[] enabledProtocols; try { // use default SSP to create supported non-SSL protocols list final SSLContext sslContext = new SSLContextParameters().createSSLContext(); enabledProtocols = sslContext.createSSLEngine().getEnabledProtocols(); } catch (GeneralSecurityException e) { throw ObjectHelper.wrapRuntimeCamelException(e); } catch (IOException e) { throw ObjectHelper.wrapRuntimeCamelException(e); } return new LinkedInOAuthRequestFilter(getOAuthParams(configuration), configuration.getHttpParams(), configuration.isLazyAuth(), enabledProtocols); }
private LinkedInOAuthRequestFilter createRequestFilter(LinkedInConfiguration configuration) { // validate configuration configuration.validate(); final String[] enabledProtocols; try { // use default SSP to create supported non-SSL protocols list final SSLContext sslContext = new SSLContextParameters().createSSLContext(getCamelContext()); enabledProtocols = sslContext.createSSLEngine().getEnabledProtocols(); } catch (GeneralSecurityException e) { throw ObjectHelper.wrapRuntimeCamelException(e); } catch (IOException e) { throw ObjectHelper.wrapRuntimeCamelException(e); } return new LinkedInOAuthRequestFilter(getOAuthParams(configuration), configuration.getHttpParams(), configuration.isLazyAuth(), enabledProtocols); }
answer = configuration.getSslContextParameters().createSSLContext(); } else { if (configuration.getKeyStoreFile() == null && configuration.getKeyStoreResource() == null) {
answer = configuration.getSslContextParameters().createSSLContext(camelContext); } else { if (configuration.getKeyStoreFile() == null && configuration.getKeyStoreResource() == null) {
answer = configuration.getSslContextParameters().createSSLContext(camelContext); } else { if (configuration.getKeyStoreFile() == null && configuration.getKeyStoreResource() == null) {
answer = configuration.getSslContextParameters().createSSLContext(camelContext); } else { if (configuration.getKeyStoreFile() == null && configuration.getKeyStoreResource() == null) {
answer = configuration.getSslContextParameters().createSSLContext(producer.getContext()); } else { if (configuration.getKeyStoreFile() == null && configuration.getKeyStoreResource() == null) {
answer = configuration.getSslContextParameters().createSSLContext(producer.getContext()); } else { if (configuration.getKeyStoreFile() == null && configuration.getKeyStoreResource() == null) {
answer = configuration.getSslContextParameters().createSSLContext(producer.getContext()); } else { if (configuration.getKeyStoreFile() == null && configuration.getKeyStoreResource() == null) {
clientBuilder.setSSLContext(sslContextParameters.createSSLContext()); } catch (GeneralSecurityException e) { throw ObjectHelper.wrapRuntimeCamelException(e);
asyncClientBuilder.setSSLContext(sslContextParameters.createSSLContext(getCamelContext())); } catch (GeneralSecurityException e) { throw ObjectHelper.wrapRuntimeCamelException(e);
private void configureApnsCertificate(ApnsServiceBuilder builder) throws IOException, GeneralSecurityException { if (getSslContextParameters() != null) { builder.withSSLContext(getSslContextParameters().createSSLContext(getCamelContext())); return; } ObjectHelper.notNull(getCamelContext(), "camelContext"); StringHelper.notEmpty(getCertificatePath(), "certificatePath"); StringHelper.notEmpty(getCertificatePassword(), "certificatePassword"); InputStream certificateInputStream = null; try { certificateInputStream = ResourceHelper.resolveMandatoryResourceAsInputStream(camelContext, getCertificatePath()); builder.withCert(certificateInputStream, getCertificatePassword()); } finally { ResourceUtils.close(certificateInputStream); } }