FileDocCategorySizeDatePackage
SSLOutputWriter.javaAPI DocGlassfish v2 API3927Fri May 04 22:37:10 BST 2007com.sun.enterprise.web.connector.grizzly.ssl

SSLOutputWriter

public final class SSLOutputWriter extends Object
SSL over NIO utility to encrypt ByteBuffer and flush them. All the SSLEngine operations are delegated to class SSLUtils
author
Jeanfrancois Arcand

Fields Summary
Constructors Summary
Methods Summary
public static voidflushChannel(java.nio.channels.SocketChannel socketChannel, java.nio.ByteBuffer bb)
Encrypt the response and flush it using OutputWriter

      
        SSLWorkerThread workerThread = (SSLWorkerThread)Thread.currentThread();
        SSLEngine sslEngine = workerThread.getSSLEngine();
        ByteBuffer outputBB = workerThread.getOutputBB();
        flushChannel(socketChannel,bb,outputBB,sslEngine);
    
public static voidflushChannel(java.nio.channels.SocketChannel socketChannel, java.nio.ByteBuffer bb, java.nio.ByteBuffer outputBB, javax.net.ssl.SSLEngine sslEngine)
Encrypt the response and flush it using OutputWriter

   
        
        while (bb.hasRemaining()) {
            SSLEngineResult result = SSLUtils.wrap(bb,outputBB,sslEngine);
            switch (result.getStatus()) {
                case OK:
                    if (result.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
                        SSLUtils.executeDelegatedTask(sslEngine);
                    }
                    break;

                default:
                    throw new IOException("SSLOutputWriter: " + result.getStatus());
            }

            if (outputBB.hasRemaining()) {
                OutputWriter.flushChannel(socketChannel,outputBB);
            }
        }
        outputBB.clear();