protected void clientClose(final SelectionKey key) { log.traceNio(key,"clientClose()", "ENTER"); try { key.channel().close(); } catch (Exception ignore) { } NetCtx att = (NetCtx) key.attachment(); if (att != null) { synchronized (att) { if (att.getTlsContext() != null) att.getTlsContext().setSslState(CLOSING); } } }
@Override public boolean submit(final SelectionKey key, boolean copyOnSchedule, ByteBuffer... buffers) { NetCtx atta = (NetCtx) key.attachment(); TlsContext tctx = atta.getTlsContext(); ByteBuffer[] bufs = buffers;
private LinkedList<ByteBuffer> sslEncode(SelectionKey key, ByteBuffer...ibufs) { NetCtx atta = (NetCtx)key.attachment(); TlsContext tctx = atta.getTlsContext(); LinkedList<ByteBuffer> obufs = new LinkedList<ByteBuffer>();
log.traceNio(key, "run", "SELECTOR/isReadable()"); NetCtx a = (NetCtx)key.attachment(); TlsContext tctx = a.getTlsContext(); if (tctx == null) { doRead(key); log.traceNio(key, "run", "SELECTOR/isWritable()"); NetCtx a = (NetCtx)key.attachment(); TlsContext tctx = a.getTlsContext(); if (tctx == null) { doWrite(key);
public void traceNio(SelectionKey key, String tag, String action) { if (isTraceEnabled()) { NetCtx atta = (NetCtx)key.attachment(); if (atta != null) { TlsContext tctx = atta.getTlsContext(); if (tctx != null) { trace(keyToString(key) + " " + tag + " " + action + ", state=" + tctx.getSslState() + ", netBuf=" + tctx.getSslNetBuf() + ", appBuf=" + tctx.getSslAppBuf()); } else { trace(keyToString(key) + " " + tag + " " + action + ", (no attachment)"); } } else { trace(keyToString(key) + " " + tag + " " + action + ", (no attachment)"); } } } }
TlsContext tctx = atta.getTlsContext();
private void sslHandshake(final SelectionKey key) { NetCtx atta = atta(key); SocketChannel ch = (SocketChannel) key.channel(); TlsContext tctx = atta.getTlsContext(); SSLEngine engine = tctx.getSslEngine(); SSLEngineResult.HandshakeStatus handshakeStatus;
@Override public RingHandler request(SelectionKey key, String httpVersion, HttpMethod method, String uri, String query) { NetCtx ctx = NetCtx.fromKey(key); request = PersistentArrayMap.EMPTY.asTransient() .assoc(SERVER_PORT, ctx.getServerPort()) .assoc(SERVER_NAME, ctx.getServerName()) .assoc(REMOTE_ADDR, ctx.getRemoteAddr()) .assoc(PROTOCOL, httpVersion) .assoc(URI, uri) .assoc(QUERY_STRING, query) .assoc(REQUEST_METHOD, getMethod(method)) .assoc(SCHEME, ctx.getTlsContext() != null ? HTTPS : HTTP); headers = PersistentArrayMap.EMPTY.asTransient(); // TODO SSL_CLIENT_CERT return this; }