/** * Return a new <code>SSLReadTask</code> instance */ @Override protected DefaultReadTask newReadTask(){ StreamAlgorithm streamAlgorithm = new NoParsingAlgorithm(); streamAlgorithm.setPort(getPort()); SSLReadTask task; if (getMaxReadWorkerThreads() > 0 || asyncExecution){ task = new SSLAsyncReadTask(); } else { task = new SSLReadTask(); } task.initialize(streamAlgorithm, isUseDirectByteBuffer(), isUseByteBufferView()); task.setPipeline(getReadPipeline()); task.setSelectorThread(this); task.setRecycle(isRecycleTasks()); task.setSSLImplementation(sslImplementation); return task; }
allocateBuffers(); if (!doHandshake(SSLUtils.getReadTimeout())) { keepAlive = false; count = -1; } else { if (!handshake){ count = doRead(inputBB); if (count == -1){ keepAlive = false; keepAlive = process(); } catch (IOException ex) { keepAlive = false; keepAlive = false; } finally { manageKeepAlive(keepAlive,count,exception);
/** * Process the request using the decrypted <code>ByteBuffer</code>. The * <code>SSLProcessorTask</code> */ protected boolean process() throws IOException{ boolean keepAlive = false; SocketChannel socketChannel = (SocketChannel)key.channel(); Socket socket = socketChannel.socket(); algorithm.setSocketChannel(socketChannel); inputStream.setSelectionKey(key); if (processorTask == null){ attachProcessor(selectorThread.getProcessorTask()); } // Always true with the NoParsingAlgorithm if ( algorithm.parse(byteBuffer) ){ return executeProcessorTask(); } else { // Never happens with the default StreamAlgorithm return true; } }
SSLEngine sslEngine = null; if ( isRequestedTransportSecure ) { sslEngine = ((SSLReadTask)readTask).getSSLEngine(); if (isRequestedTransportSecure){ SSLReadTask sslReadTask = (SSLReadTask)readTask; sslReadTask.allocateBuffers(); protocolInfo.inputBB = sslReadTask.getInputBB(); protocolInfo.outputBB = sslReadTask.getOutputBB(); } else { if ( isRequestedTransportSecure ) { ((SSLReadTask)readTask).setHandshake(false);
/** * Execute a non blocking SSL handshake. */ protected boolean doHandshake(int timeout) throws IOException{ HandshakeStatus handshakeStatus = HandshakeStatus.NEED_UNWRAP; boolean OK = true; final SSLWorkerThread workerThread = (SSLWorkerThread)Thread.currentThread(); try{ if ( handshake ) { byteBuffer = SSLUtils.doHandshake (key,byteBuffer,inputBB,outputBB,sslEngine, handshakeStatus,timeout); if (doRead(inputBB) == -1){ throw new EOFException(); } } } catch (EOFException ex) { Logger logger = SSLSelectorThread.logger(); if ( logger.isLoggable(Level.FINE) ){ logger.log(Level.FINE,"doHandshake",ex); } OK = false; } finally { workerThread.setOutputBB(outputBB); } return OK; }
doHandshake(0); } catch (Throwable ex){ if ( logger.isLoggable(Level.FINE))
/** * Set appropriate attribute on the <code>ProcessorTask</code>. */ @Override public void configureProcessorTask(){ super.configureProcessorTask(); if ( !getTaskListeners().contains(processorTask) ){ processorTask.addTaskListener(this); addTaskListener((TaskListener)processorTask); } SSLAsyncOutputBuffer outputBuffer = ((SSLAsyncProcessorTask)processorTask).getSSLAsyncOutputBuffer(); if (outputBuffer == null) { processorTask.initialize(); outputBuffer = ((SSLAsyncProcessorTask)processorTask).getSSLAsyncOutputBuffer(); } outputBuffer.setSSLEngine(sslEngine); outputBuffer.setOutputBB(outputBB); } }
request.setAttribute (SSLSupport.CIPHER_SUITE_KEY, sslO); sslO = sslReadTask.doPeerCertificateChain(false); if (sslO != null) request.setAttribute (inputFilters[Constants.BUFFERED_FILTER]); try { Object sslO = sslReadTask.doPeerCertificateChain(true); if( sslO != null) { request.setAttribute