use of com.cloudhopper.smpp.ssl.SslConfiguration in project load-balancer by RestComm.
the class ConfigInit method getSmppSessionConfiguration.
static SmppSessionConfiguration getSmppSessionConfiguration(int i, boolean isSslClient) {
SmppSessionConfiguration config = new SmppSessionConfiguration();
config.setWindowSize(1);
config.setName("Client " + i);
config.setType(SmppBindType.TRANSCEIVER);
config.setHost("127.0.0.1");
config.setConnectTimeout(10000);
config.setSystemId("RestComm");
config.setPassword("password");
config.getLoggingOptions().setLogBytes(true);
// to enable monitoring (request expiration)
config.setRequestExpiryTimeout(30000);
config.setWindowMonitorInterval(15000);
config.setCountersEnabled(true);
if (isSslClient) {
config.setPort(2876);
SslConfiguration sslConfig = new SslConfiguration();
sslConfig.setTrustAll(true);
sslConfig.setValidateCerts(true);
sslConfig.setValidatePeerCerts(true);
config.setSslConfiguration(sslConfig);
config.setUseSsl(true);
} else {
config.setPort(2776);
}
return config;
}
use of com.cloudhopper.smpp.ssl.SslConfiguration in project load-balancer by RestComm.
the class ConfigInit method getSmppServerConfiguration.
static SmppServerConfiguration getSmppServerConfiguration(int i, boolean isSslServer) {
SmppServerConfiguration config = new SmppServerConfiguration();
config.setName("SMPP Server " + i);
config.setHost("127.0.0.1");
config.setMaxConnectionSize(10);
config.setNonBlockingSocketsEnabled(true);
config.setDefaultRequestExpiryTimeout(30000);
config.setDefaultWindowMonitorInterval(15000);
config.setDefaultWindowSize(5);
config.setDefaultWindowWaitTimeout(config.getDefaultRequestExpiryTimeout());
config.setDefaultSessionCountersEnabled(true);
config.setJmxEnabled(true);
config.setPort(10021 + i);
config.setHost("127.0.0.1");
if (isSslServer) {
SslConfiguration sslConfig = new SslConfiguration();
sslConfig.setKeyStorePath(ConfigInit.class.getClassLoader().getResource("keystore").getFile());
sslConfig.setKeyStorePassword("123456");
sslConfig.setTrustStorePath(ConfigInit.class.getClassLoader().getResource("keystore").getFile());
sslConfig.setTrustStorePassword("123456");
config.setUseSsl(true);
config.setSslConfiguration(sslConfig);
}
return config;
}
use of com.cloudhopper.smpp.ssl.SslConfiguration in project load-balancer by RestComm.
the class SmppBalancerRunner method start.
public void start() {
SmppServerConfiguration regularConfiguration = new SmppServerConfiguration();
regularConfiguration.setName("SMPP Load Balancer");
String smppHost = balancerRunner.balancerContext.lbConfig.getSmppConfiguration().getSmppExternalHost();
if (smppHost == null || smppHost.equals("")) {
smppHost = balancerRunner.balancerContext.lbConfig.getSmppConfiguration().getSmppHost();
}
regularConfiguration.setHost(smppHost);
regularConfiguration.setPort(balancerRunner.balancerContext.lbConfig.getSmppConfiguration().getSmppPort());
regularConfiguration.setMaxConnectionSize(balancerRunner.balancerContext.lbConfig.getSmppConfiguration().getMaxConnectionSize());
regularConfiguration.setNonBlockingSocketsEnabled(balancerRunner.balancerContext.lbConfig.getSmppConfiguration().isNonBlockingSocketsEnabled());
regularConfiguration.setDefaultSessionCountersEnabled(balancerRunner.balancerContext.lbConfig.getSmppConfiguration().isDefaultSessionCountersEnabled());
regularConfiguration.setUseSsl(false);
SmppServerConfiguration securedConfiguration = null;
Integer smppSslPort = balancerRunner.balancerContext.lbConfig.getSmppConfiguration().getSmppSslPort();
if (smppSslPort != null) {
securedConfiguration = new SmppServerConfiguration();
String smppSslHost = balancerRunner.balancerContext.lbConfig.getSmppConfiguration().getSmppExternalHost();
if (smppSslHost == null || smppSslHost.equals("")) {
smppSslHost = balancerRunner.balancerContext.lbConfig.getSmppConfiguration().getSmppHost();
}
securedConfiguration.setHost(smppSslHost);
securedConfiguration.setPort(smppSslPort);
securedConfiguration.setMaxConnectionSize(balancerRunner.balancerContext.lbConfig.getSmppConfiguration().getMaxConnectionSize());
securedConfiguration.setNonBlockingSocketsEnabled(balancerRunner.balancerContext.lbConfig.getSmppConfiguration().isNonBlockingSocketsEnabled());
securedConfiguration.setDefaultSessionCountersEnabled(balancerRunner.balancerContext.lbConfig.getSmppConfiguration().isDefaultSessionCountersEnabled());
securedConfiguration.setUseSsl(true);
SslConfiguration sslConfig = new SslConfiguration();
sslConfig.setKeyStorePath(balancerRunner.balancerContext.lbConfig.getSslConfiguration().getKeyStore());
sslConfig.setKeyStorePassword(balancerRunner.balancerContext.lbConfig.getSslConfiguration().getKeyStorePassword());
sslConfig.setTrustStorePath(balancerRunner.balancerContext.lbConfig.getSslConfiguration().getTrustStore());
sslConfig.setTrustStorePassword(balancerRunner.balancerContext.lbConfig.getSslConfiguration().getTrustStorePassword());
String sProtocols = balancerRunner.balancerContext.lbConfig.getSslConfiguration().getTlsClientProtocols();
String sCipherSuites = balancerRunner.balancerContext.lbConfig.getSslConfiguration().getEnabledCipherSuites();
if (sProtocols != null) {
String[] protocols = sProtocols.split(",");
sslConfig.setIncludeProtocols(protocols);
}
if (sCipherSuites != null) {
String[] cipherSuites = sCipherSuites.split(",");
sslConfig.setIncludeCipherSuites(cipherSuites);
}
securedConfiguration.setSslConfiguration(sslConfig);
}
// TODO manage MUX or LB
if (balancerRunner.balancerContext.lbConfig.getSmppConfiguration().isMuxMode()) {
logger.info("MUX mode enabled for SMPP");
dispatcher = new MBalancerDispatcher(balancerRunner, monitorExecutor);
mSmppLbServer = new MServer(regularConfiguration, securedConfiguration, executor, balancerRunner, (MBalancerDispatcher) dispatcher, monitorExecutor);
mSmppLbServer.start();
} else {
logger.info("Load balance mode enabled for SMPP");
dispatcher = new BalancerDispatcher(balancerRunner, monitorExecutor);
smppLbServer = new BalancerServer(regularConfiguration, securedConfiguration, executor, balancerRunner, (BalancerDispatcher) dispatcher, monitorExecutor);
smppLbServer.start();
}
}
use of com.cloudhopper.smpp.ssl.SslConfiguration in project load-balancer by RestComm.
the class ClientConnectionImpl method connect.
@Override
public Boolean connect() {
ChannelFuture channelFuture = null;
try {
if (logger.isDebugEnabled())
logger.debug("LB trying to connect to server " + config.getHost() + " " + config.getPort());
channelFuture = clientBootstrap.connect(new InetSocketAddress(config.getHost(), config.getPort()), new InetSocketAddress(localSmppAddress, 0)).sync();
channel = channelFuture.getChannel();
if (config.isUseSsl()) {
SslConfiguration sslConfig = config.getSslConfiguration();
if (sslConfig == null)
throw new IllegalStateException("sslConfiguration must be set");
try {
SslContextFactory factory = new SslContextFactory(sslConfig);
SSLEngine sslEngine = factory.newSslEngine();
sslEngine.setUseClientMode(true);
channel.getPipeline().addFirst(SmppChannelConstants.PIPELINE_SESSION_SSL_NAME, new SslHandler(sslEngine));
} catch (Exception e) {
logger.error("Unable to create SSL session: " + e.getMessage(), e);
}
}
} catch (Exception ex) {
return false;
}
if (clientState != ClientState.REBINDING)
clientState = ClientState.OPEN;
return true;
}
use of com.cloudhopper.smpp.ssl.SslConfiguration in project load-balancer by RestComm.
the class TestHttpServerPipelineFactory method getPipeline.
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline pipeline = pipeline();
if (!terminateTLSTraffic) {
SslConfiguration sslConfig = new SslConfiguration();
sslConfig.setKeyStorePath(TestHttpServerPipelineFactory.class.getClassLoader().getResource("keystore").getFile());
sslConfig.setKeyStorePassword("123456");
sslConfig.setTrustStorePath(TestHttpServerPipelineFactory.class.getClassLoader().getResource("keystore").getFile());
sslConfig.setTrustStorePassword("123456");
SslContextFactory factory = new SslContextFactory(sslConfig);
SSLEngine sslEngine = factory.newSslEngine();
sslEngine.setUseClientMode(false);
pipeline.addLast("ssl", new SslHandler(sslEngine));
}
pipeline.addLast("decoder", new HttpRequestDecoder());
// http://code.google.com/p/commscale/issues/detail?id=5 support for HttpChunks
// https://telestax.atlassian.net/browse/LB-8 if commented accessing the RestComm Management console fails, so making the maxContentLength Configurable
pipeline.addLast("aggregator", new HttpChunkAggregator(maxContentLength));
pipeline.addLast("encoder", new HttpResponseEncoder());
// Remove the following line if you don't want automatic content compression.
// pipeline.addLast("deflater", new HttpContentCompressor());
pipeline.addLast("handler", new HttpServerRequestHandler(requestCount, requests, chunkResponse, badSever));
return pipeline;
}
Aggregations