private void startSecureEventTransmission(String hostName, int port, DataBridgeReceiverService dataBridgeReceiverService) throws DataBridgeException { try { ServerConfiguration serverConfig = ServerConfiguration.getInstance(); String keyStore = serverConfig.getFirstProperty("Security.KeyStore.Location"); if (keyStore == null) { keyStore = System.getProperty("Security.KeyStore.Location"); if (keyStore == null) { throw new DataBridgeException("Cannot start agent server, not valid Security.KeyStore.Location is null"); } } String keyStorePassword = serverConfig.getFirstProperty("Security.KeyStore.Password"); if (keyStorePassword == null) { keyStorePassword = System.getProperty("Security.KeyStore.Password"); if (keyStorePassword == null) { throw new DataBridgeException("Cannot start agent server, not valid Security.KeyStore.Password is null "); } } startSecureEventTransmission(hostName, port, keyStore, keyStorePassword, dataBridgeReceiverService); } catch (TransportException e) { throw new DataBridgeException("Cannot start agent server on port " + port, e); } catch (UnknownHostException e) { //ignore since localhost } }
private void startSecureEventTransmission(String hostName, int port, String sslProtocols, String ciphers, DataBridgeReceiverService dataBridgeReceiverService) throws DataBridgeException { try { String keyStore = dataBridgeReceiverService.getInitialConfig().getKeyStoreLocation(); if (keyStore == null) { keyStore = System.getProperty("Security.KeyStore.Location"); if (keyStore == null) { throw new DataBridgeException("Cannot start thrift agent server, not valid " + "Security.KeyStore.Location is null"); } } String keyStorePassword = dataBridgeReceiverService.getInitialConfig().getKeyStorePassword(); if (keyStorePassword == null) { keyStorePassword = System.getProperty("Security.KeyStore.Password"); if (keyStorePassword == null) { throw new DataBridgeException("Cannot start thrift agent server, not valid" + " Security.KeyStore.Password is null "); } } startSecureEventTransmission(hostName, port, sslProtocols, ciphers, keyStore, keyStorePassword, dataBridgeReceiverService); } catch (TransportException e) { throw new DataBridgeException("Cannot start agent server on port " + port, e); } catch (UnknownHostException e) { //ignore since localhost } }
throw new DataBridgeException("Cannot start thrift agent server, not valid " + "Security.KeyStore.Location is null"); keyStorePassword = System.getProperty("Security.KeyStore.Password"); if (keyStorePassword == null) { throw new DataBridgeException("Cannot start thrift agent server, not valid" + " Security.KeyStore.Password is null "); throw new DataBridgeException("Cannot start agent server on port " + port, e); } catch (UnknownHostException e) {
keyStore = System.getProperty("Security.KeyStore.Location"); if (keyStore == null) { throw new DataBridgeException("Cannot start binary agent server, " + "not valid Security.KeyStore.Location is null"); keyStorePassword = System.getProperty("Security.KeyStore.Password"); if (keyStorePassword == null) { throw new DataBridgeException("Cannot start binary agent server, not valid Security.KeyStore. " + "Password is null "); ks.load(inputStream, keyStorePassword.toCharArray()); } catch (CertificateException e) { throw new DataBridgeException("Cannot start binary agent server, Certification error occurred", e); } catch (NoSuchAlgorithmException e) { throw new DataBridgeException( "Cannot start binary agent server, Error occurred when loading keystore", e); } catch (KeyStoreException e) { throw new DataBridgeException("Cannot start binary agent server, " + "Error occurred when creating keystore", e); } finally { log.info("Started Binary SSL Transport on port : " + binaryDataReceiverConfiguration.getSSLPort()); } catch (KeyManagementException e) { throw new DataBridgeException("Cannot start binary agent server, " + "Error occurred when initiating SSL context", e); } catch (NoSuchAlgorithmException | KeyStoreException | UnrecoverableKeyException e) { throw new DataBridgeException("Cannot start binary agent server, " + "Error occurred when initiating KeyManagerFactory using keystore", e);
protected void startEventTransmission(String hostName, int port, DataBridgeReceiverService dataBridgeReceiverService) throws DataBridgeException { try { TServerSocket serverTransport = new TServerSocket( new InetSocketAddress(hostName, port)); ThriftEventTransmissionService.Processor<ThriftEventTransmissionServiceImpl> processor = new ThriftEventTransmissionService.Processor<ThriftEventTransmissionServiceImpl>( new ThriftEventTransmissionServiceImpl(dataBridgeReceiverService)); dataReceiverServer = new TThreadPoolServer( new TThreadPoolServer.Args(serverTransport).processor(processor)); Thread thread = new Thread(new ServerThread(dataReceiverServer)); log.info("Thrift port : " + port); thread.start(); } catch (TTransportException e) { throw new DataBridgeException("Cannot start Thrift server on port " + port + " on host " + hostName, e); } }
protected void startEventTransmission(String hostName, int port, DataBridgeReceiverService dataBridgeReceiverService) throws DataBridgeException { try { TServerSocket serverTransport = new TServerSocket( new InetSocketAddress(hostName, port)); ThriftEventTransmissionService.Processor<ThriftEventTransmissionServiceImpl> processor = new ThriftEventTransmissionService.Processor<ThriftEventTransmissionServiceImpl>( new ThriftEventTransmissionServiceImpl(dataBridgeReceiverService)); dataReceiverServer = new TThreadPoolServer( new TThreadPoolServer.Args(serverTransport).processor(processor)); Thread thread = new Thread(new ServerThread(dataReceiverServer)); log.info("Thrift port : " + port); thread.start(); } catch (TTransportException e) { throw new DataBridgeException("Cannot start Thrift server on port " + port + " on host " + hostName, e); } }
protected void startEventTransmission(String hostName, int port, DataBridgeReceiverService dataBridgeReceiverService) throws DataBridgeException { try { TServerSocket serverTransport = new TServerSocket( new InetSocketAddress(hostName, port)); ThriftEventTransmissionService.Processor<ThriftEventTransmissionServiceImpl> processor = new ThriftEventTransmissionService.Processor<ThriftEventTransmissionServiceImpl>( new ThriftEventTransmissionServiceImpl(dataBridgeReceiverService)); TThreadPoolServer.Args args = new TThreadPoolServer.Args(serverTransport).processor(processor) .maxWorkerThreads(thriftDataReceiverConfiguration.getTcpMaxWorkerThreads()); if (thriftDataReceiverConfiguration.getTcpMinWorkerThreads() != ThriftDataReceiverConstants.UNDEFINED) { args.minWorkerThreads = thriftDataReceiverConfiguration.getTcpMinWorkerThreads(); } if (thriftDataReceiverConfiguration.getTcpRequestTimeout() != ThriftDataReceiverConstants.UNDEFINED) { args.requestTimeout = thriftDataReceiverConfiguration.getTcpRequestTimeout(); } if (thriftDataReceiverConfiguration.getTcpStopTimeoutVal() != ThriftDataReceiverConstants.UNDEFINED) { args.stopTimeoutVal = thriftDataReceiverConfiguration.getTcpStopTimeoutVal(); } dataReceiverServer = new TThreadPoolServer(args); Thread thread = new Thread(new ServerThread(dataReceiverServer)); log.info("Thrift port : " + port); thread.start(); } catch (TTransportException e) { throw new DataBridgeException("Cannot start Thrift server on port " + port + " on host " + hostName, e); } }