use of org.jboss.netty.handler.ssl.SslHandler in project camel by apache.
the class HttpServerSharedPipelineFactory method getPipeline.
@Override
public ChannelPipeline getPipeline() throws Exception {
// Create a default pipeline implementation.
ChannelPipeline pipeline = Channels.pipeline();
SslHandler sslHandler = configureServerSSLOnDemand();
if (sslHandler != null) {
LOG.debug("Server SSL handler configured and added as an interceptor against the ChannelPipeline: {}", sslHandler);
pipeline.addLast("ssl", sslHandler);
}
pipeline.addLast("decoder", new HttpRequestDecoder(4096, configuration.getMaxHeaderSize(), 8192));
if (configuration.isChunked()) {
pipeline.addLast("aggregator", new HttpChunkAggregator(configuration.getChunkedMaxContentLength()));
}
pipeline.addLast("encoder", new HttpResponseEncoder());
if (configuration.isCompression()) {
pipeline.addLast("deflater", new HttpContentCompressor());
}
pipeline.addLast("handler", channelFactory.getChannelHandler());
return pipeline;
}
use of org.jboss.netty.handler.ssl.SslHandler in project camel by apache.
the class NettyConfiguration method parseURI.
public void parseURI(URI uri, Map<String, Object> parameters, NettyComponent component, String... supportedProtocols) throws Exception {
protocol = uri.getScheme();
boolean found = false;
for (String supportedProtocol : supportedProtocols) {
if (protocol != null && protocol.equalsIgnoreCase(supportedProtocol)) {
found = true;
break;
}
}
if (!found) {
throw new IllegalArgumentException("Unrecognized Netty protocol: " + protocol + " for uri: " + uri);
}
setHost(uri.getHost());
if (uri.getPort() != -1) {
setPort(uri.getPort());
}
ssl = component.getAndRemoveOrResolveReferenceParameter(parameters, "ssl", boolean.class, false);
sslHandler = component.getAndRemoveOrResolveReferenceParameter(parameters, "sslHandler", SslHandler.class, sslHandler);
passphrase = component.getAndRemoveOrResolveReferenceParameter(parameters, "passphrase", String.class, passphrase);
keyStoreFormat = component.getAndRemoveOrResolveReferenceParameter(parameters, "keyStoreFormat", String.class, keyStoreFormat == null ? "JKS" : keyStoreFormat);
securityProvider = component.getAndRemoveOrResolveReferenceParameter(parameters, "securityProvider", String.class, securityProvider == null ? "SunX509" : securityProvider);
keyStoreFile = component.getAndRemoveOrResolveReferenceParameter(parameters, "keyStoreFile", File.class, keyStoreFile);
trustStoreFile = component.getAndRemoveOrResolveReferenceParameter(parameters, "trustStoreFile", File.class, trustStoreFile);
keyStoreResource = component.getAndRemoveOrResolveReferenceParameter(parameters, "keyStoreResource", String.class, keyStoreResource);
trustStoreResource = component.getAndRemoveOrResolveReferenceParameter(parameters, "trustStoreResource", String.class, trustStoreResource);
clientPipelineFactory = component.getAndRemoveOrResolveReferenceParameter(parameters, "clientPipelineFactory", ClientPipelineFactory.class, clientPipelineFactory);
serverPipelineFactory = component.getAndRemoveOrResolveReferenceParameter(parameters, "serverPipelineFactory", ServerPipelineFactory.class, serverPipelineFactory);
// set custom encoders and decoders first
List<ChannelHandler> referencedEncoders = component.resolveAndRemoveReferenceListParameter(parameters, "encoders", ChannelHandler.class, null);
addToHandlersList(encoders, referencedEncoders, ChannelHandler.class);
List<ChannelHandler> referencedDecoders = component.resolveAndRemoveReferenceListParameter(parameters, "decoders", ChannelHandler.class, null);
addToHandlersList(decoders, referencedDecoders, ChannelHandler.class);
// then set parameters with the help of the camel context type converters
EndpointHelper.setReferenceProperties(component.getCamelContext(), this, parameters);
EndpointHelper.setProperties(component.getCamelContext(), this, parameters);
// additional netty options, we don't want to store an empty map, so set it as null if empty
options = IntrospectionSupport.extractProperties(parameters, "option.");
if (options != null && options.isEmpty()) {
options = null;
}
// add default encoders and decoders
if (encoders.isEmpty() && decoders.isEmpty()) {
if (isAllowDefaultCodec()) {
// are we textline or object?
if (isTextline()) {
Charset charset = getEncoding() != null ? Charset.forName(getEncoding()) : CharsetUtil.UTF_8;
encoders.add(ChannelHandlerFactories.newStringEncoder(charset));
ChannelBuffer[] delimiters = delimiter == TextLineDelimiter.LINE ? Delimiters.lineDelimiter() : Delimiters.nulDelimiter();
decoders.add(ChannelHandlerFactories.newDelimiterBasedFrameDecoder(decoderMaxLineLength, delimiters));
decoders.add(ChannelHandlerFactories.newStringDecoder(charset));
if (LOG.isDebugEnabled()) {
LOG.debug("Using textline encoders and decoders with charset: {}, delimiter: {} and decoderMaxLineLength: {}", new Object[] { charset, delimiter, decoderMaxLineLength });
}
} else {
// object serializable is then used
encoders.add(ChannelHandlerFactories.newObjectEncoder());
decoders.add(ChannelHandlerFactories.newObjectDecoder());
LOG.debug("Using object encoders and decoders");
}
} else {
LOG.debug("No encoders and decoders will be used");
}
} else {
LOG.debug("Using configured encoders and/or decoders");
}
}
use of org.jboss.netty.handler.ssl.SslHandler in project camel by apache.
the class NettyEndpoint method getSSLSession.
protected SSLSession getSSLSession(ChannelHandlerContext ctx) {
final SslHandler sslHandler = ctx.getPipeline().get(SslHandler.class);
SSLSession sslSession = null;
if (sslHandler != null) {
sslSession = sslHandler.getEngine().getSession();
}
return sslSession;
}
use of org.jboss.netty.handler.ssl.SslHandler in project camel by apache.
the class DefaultClientPipelineFactory method getPipeline.
public ChannelPipeline getPipeline() throws Exception {
// create a new pipeline
ChannelPipeline channelPipeline = Channels.pipeline();
SslHandler sslHandler = configureClientSSLOnDemand();
if (sslHandler != null) {
// must close on SSL exception
sslHandler.setCloseOnSSLException(true);
LOG.debug("Client SSL handler configured and added to the ChannelPipeline: {}", sslHandler);
addToPipeline("ssl", channelPipeline, sslHandler);
}
List<ChannelHandler> decoders = producer.getConfiguration().getDecoders();
for (int x = 0; x < decoders.size(); x++) {
ChannelHandler decoder = decoders.get(x);
if (decoder instanceof ChannelHandlerFactory) {
// use the factory to create a new instance of the channel as it may not be shareable
decoder = ((ChannelHandlerFactory) decoder).newChannelHandler();
}
addToPipeline("decoder-" + x, channelPipeline, decoder);
}
List<ChannelHandler> encoders = producer.getConfiguration().getEncoders();
for (int x = 0; x < encoders.size(); x++) {
ChannelHandler encoder = encoders.get(x);
if (encoder instanceof ChannelHandlerFactory) {
// use the factory to create a new instance of the channel as it may not be shareable
encoder = ((ChannelHandlerFactory) encoder).newChannelHandler();
}
addToPipeline("encoder-" + x, channelPipeline, encoder);
}
// do we use request timeout?
if (producer.getConfiguration().getRequestTimeout() > 0) {
if (LOG.isTraceEnabled()) {
LOG.trace("Using request timeout {} millis", producer.getConfiguration().getRequestTimeout());
}
ChannelHandler timeout = new ReadTimeoutHandler(producer.getEndpoint().getTimer(), producer.getConfiguration().getRequestTimeout(), TimeUnit.MILLISECONDS);
addToPipeline("timeout", channelPipeline, timeout);
}
// our handler must be added last
addToPipeline("handler", channelPipeline, new ClientChannelHandler(producer));
LOG.trace("Created ChannelPipeline: {}", channelPipeline);
return channelPipeline;
}
use of org.jboss.netty.handler.ssl.SslHandler in project cdap by caskdata.
the class SSLHandlerFactory method create.
public SslHandler create() {
SSLEngine engine = serverContext.createSSLEngine();
engine.setUseClientMode(false);
SslHandler handler = new SslHandler(engine);
handler.setEnableRenegotiation(false);
return handler;
}
Aggregations