synchronized void initializeAsynchronousTransfer(final FilterChainContext context, final HttpRequestPacket requestPacket) throws IOException { if (asyncTransferInitiated) { throw new IllegalStateException("Async transfer has already been initiated."); } if (feeder == null) { throw new IllegalStateException("No feeder available to perform the transfer."); } assert (context != null); assert (requestPacket != null); this.requestPacket = requestPacket; this.contentBuilder = HttpContent.builder(requestPacket); final Connection c = context.getConnection(); origMaxPendingBytes = c.getMaxAsyncWriteQueueSize(); if (configuredMaxPendingBytes != DEFAULT) { c.setMaxAsyncWriteQueueSize(configuredMaxPendingBytes); } this.context = context; asyncTransferInitiated = true; if (requestPacket.isSecure() && (getSSLEngine(context.getConnection()) == null)) { flushOnSSLHandshakeComplete(); } else { feederFlush(context.getConnection()); } }
/** * flag, which indicates whether this <tt>HttpCodecFilter</tt> is dealing with * the secured HTTP packets. For this filter flag means nothing, it's just * a value, which is getting set to a {@link HttpRequestPacket} or * {@link HttpResponsePacket}. * * @param connection {@link Connection} * @return <tt>true</tt>, if the {@link Connection} is secured, or <tt>false</tt> * otherwise */ protected static boolean isSecure(final Connection connection) { return SSLUtils.getSSLEngine(connection) != null; }
/** * flag, which indicates whether this <tt>HttpCodecFilter</tt> is dealing with * the secured HTTP packets. For this filter flag means nothing, it's just * a value, which is getting set to a {@link HttpRequestPacket} or * {@link HttpResponsePacket}. * * @param connection {@link Connection} * @return <tt>true</tt>, if the {@link Connection} is secured, or <tt>false</tt> * otherwise */ protected static boolean isSecure(final Connection connection) { return SSLUtils.getSSLEngine(connection) != null; }
/** * flag, which indicates whether this <tt>HttpCodecFilter</tt> is dealing with * the secured HTTP packets. For this filter flag means nothing, it's just * a value, which is getting set to a {@link HttpRequestPacket} or * {@link HttpResponsePacket}. * * @param connection {@link Connection} * @return <tt>true</tt>, if the {@link Connection} is secured, or <tt>false</tt> * otherwise */ protected static boolean isSecure(final Connection connection) { return SSLUtils.getSSLEngine(connection) != null; }
@Override public SSLSession getSSLSession() { final SSLEngine sslEngine = SSLUtils.getSSLEngine(connection); return sslEngine != null ? sslEngine.getSession() : null; }
public SSLSupportImpl(Connection connection) { engine = SSLUtils.getSSLEngine(connection); if (engine == null) { throw new IllegalStateException("SSLEngine is null"); } session = engine.getSession(); }
public SSLSupportImpl(Connection connection) { engine = SSLUtils.getSSLEngine(connection); if (engine == null) { throw new IllegalStateException("SSLEngine is null"); } session = engine.getSession(); }
public SSLSupportImpl(Connection connection) { engine = SSLUtils.getSSLEngine(connection); if (engine == null) { throw new IllegalStateException("SSLEngine is null"); } session = engine.getSession(); }
public SSLSupportImpl(Connection connection) { engine = SSLUtils.getSSLEngine(connection); if (engine == null) { throw new IllegalStateException("SSLEngine is null"); } session = engine.getSession(); }
public SSLSupportImpl(Connection connection) { engine = SSLUtils.getSSLEngine(connection); if (engine == null) { throw new IllegalStateException("SSLEngine is null"); } session = engine.getSession(); }
public SSLSupportImpl(Connection connection) { engine = SSLUtils.getSSLEngine(connection); if (engine == null) { throw new IllegalStateException("SSLEngine is null"); } session = engine.getSession(); }
public SSLSupportImpl(Connection connection) { engine = SSLUtils.getSSLEngine(connection); if (engine == null) { throw new IllegalStateException("SSLEngine is null"); } session = engine.getSession(); }
public SSLSupportImpl(Connection connection) { engine = SSLUtils.getSSLEngine(connection); if (engine == null) { throw new IllegalStateException("SSLEngine is null"); } session = engine.getSession(); }
public SSLSupportImpl(Connection connection) { engine = SSLUtils.getSSLEngine(connection); if (engine == null) { throw new IllegalStateException("SSLEngine is null"); } session = engine.getSession(); }
@Override protected TransformationResult<Buffer, Buffer> transformImpl( final AttributeStorage state, final Buffer originalMessage) throws TransformationException { final SSLEngine sslEngine = SSLUtils.getSSLEngine((Connection) state); if (sslEngine == null) { return HANDSHAKE_NOT_EXECUTED_RESULT; } //noinspection SynchronizationOnLocalVariableOrMethodParameter synchronized(state) { // synchronize parallel writers here return wrapAll(sslEngine, originalMessage); } }
@Override protected TransformationResult<Buffer, Buffer> transformImpl( final AttributeStorage state, final Buffer originalMessage) throws TransformationException { final SSLEngine sslEngine = SSLUtils.getSSLEngine((Connection) state); if (sslEngine == null) { return HANDSHAKE_NOT_EXECUTED_RESULT; } //noinspection SynchronizationOnLocalVariableOrMethodParameter synchronized(state) { // synchronize parallel writers here return wrapAll(sslEngine, originalMessage); } }
@Override protected TransformationResult<Buffer, Buffer> transformImpl( final AttributeStorage state, final Buffer originalMessage) throws TransformationException { final SSLEngine sslEngine = SSLUtils.getSSLEngine((Connection) state); if (sslEngine == null) { return HANDSHAKE_NOT_EXECUTED_RESULT; } //noinspection SynchronizationOnLocalVariableOrMethodParameter synchronized(state) { // synchronize parallel writers here return wrapAll(sslEngine, originalMessage); } }
@Override protected TransformationResult<Buffer, Buffer> transformImpl( final AttributeStorage state, final Buffer originalMessage) throws TransformationException { final SSLEngine sslEngine = SSLUtils.getSSLEngine((Connection) state); if (sslEngine == null) { return HANDSHAKE_NOT_EXECUTED_RESULT; } //noinspection SynchronizationOnLocalVariableOrMethodParameter synchronized(state) { // synchronize parallel writers here return wrapAll(sslEngine, originalMessage); } }
@Override public NextAction handleEvent(final FilterChainContext ctx, final FilterChainEvent event) throws IOException { if (event.type() == SSLSwitchingEvent.class) { final SSLSwitchingEvent se = (SSLSwitchingEvent) event; final boolean isSecure = se.isSecure(); CONNECTION_IS_SECURE.set(se.getConnection(), isSecure); // if enabling security - create SSLEngine here, because default // Grizzly SSLFilter will use host/port info from the Connection, rather // than request URL. Specifically this doesn't work with CONNECT tunnels. if (isSecure && SSLUtils.getSSLEngine(ctx.getConnection()) == null) { // if SSLEngine is not yet set for the connection - initialize it final SSLEngine sslEngine = getClientSSLEngineConfigurator() .createSSLEngine(se.getHost(), se.getPort() == -1 ? 443 : se.getPort() ); sslEngine.beginHandshake(); SSLUtils.setSSLEngine(ctx.getConnection(), sslEngine); } return ctx.getStopAction(); } return ctx.getInvokeAction(); }
private X509Certificate getServerCertificate(final Request request) { // return the active server certificate, which is used for this connection. final SSLEngine sslEngine = SSLUtils.getSSLEngine( request.getContext().getConnection()); return (X509Certificate) sslEngine.getSession().getLocalCertificates()[0]; } }