# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: C:\Projects\Grizzly\trunk\modules\portunif\src # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: main/java/com/sun/grizzly/portunif/TLSPUPreProcessor.java --- main/java/com/sun/grizzly/portunif/TLSPUPreProcessor.java Base (BASE) +++ main/java/com/sun/grizzly/portunif/TLSPUPreProcessor.java Locally Modified (Based On LOCAL) @@ -26,8 +26,9 @@ import com.sun.grizzly.Context; import com.sun.grizzly.Controller; import com.sun.grizzly.SSLConfig; -import com.sun.grizzly.filter.SSLReadFilter; +import com.sun.grizzly.util.SSLSelectionKeyAttachment; import com.sun.grizzly.util.SSLUtils; +import com.sun.grizzly.util.SelectionKeyAttachment; import java.io.EOFException; import java.io.IOException; import java.nio.ByteBuffer; @@ -50,12 +51,7 @@ private static final String TMP_DECODED_BUFFER ="TMP_DECODED_BUFFER"; - /** - * Decrypted ByteBuffer default size. - */ - private final static int appBBSize = 5 * 4096; - /** * The SSLContext associated with the SSL implementation * we are running on. @@ -108,14 +104,14 @@ SSLEngine sslEngine = null; - Object attachment = key.attachment(); - if (attachment == null || !(attachment instanceof SSLEngine)) { + Object attachment = SelectionKeyAttachment.getAttachment(key); + if (attachment == null || !(attachment instanceof SSLSelectionKeyAttachment)) { sslEngine = sslContext.createSSLEngine(); sslEngine.setUseClientMode(false); sslEngine.setNeedClientAuth(needClientAuth); sslEngine.setWantClientAuth(wantClientAuth); } else { - sslEngine = (SSLEngine) attachment; + sslEngine = ((SSLSelectionKeyAttachment) attachment).getSslEngine(); } ByteBuffer inputBB = protocolRequest.getSecuredInputByteBuffer(); @@ -146,8 +142,7 @@ inputBB.put((ByteBuffer) byteBuffer.flip()); byteBuffer.clear(); - boolean OK = Boolean.TRUE.equals( - sslEngine.getSession().getValue(SSLReadFilter.HANDSHAKE)); + boolean OK = sslEngine.getSession().isValid(); if (!OK) { // Handshake wasn't completed on prev step HandshakeStatus handshakeStatus = HandshakeStatus.NEED_UNWRAP; @@ -156,8 +151,7 @@ byteBuffer = SSLUtils.doHandshake(channel, byteBuffer, inputBB, outputBB, sslEngine, handshakeStatus, SSLUtils.getReadTimeout(), inputBB.position() > 0); - sslEngine.getSession().putValue(SSLReadFilter.HANDSHAKE, true); - key.attach(sslEngine); + SSLSelectionKeyAttachment.attach(key, sslEngine); protocolRequest.setSSLEngine(sslEngine); // set "no available data" for secured output buffer outputBB.limit(outputBB.position()); @@ -196,8 +190,6 @@ if (byteRead > -1) { byteBuffer = SSLUtils.unwrapAll(byteBuffer, inputBB, sslEngine); protocolRequest.setByteBuffer(byteBuffer); - sslEngine.getSession().putValue(SSLReadFilter.DATA_DECODED, - Boolean.TRUE); } else { throw new EOFException(); } Index: test/java/com/sun/grizzly/portunif/SimpleProtocolHandler.java --- test/java/com/sun/grizzly/portunif/SimpleProtocolHandler.java Base (BASE) +++ test/java/com/sun/grizzly/portunif/SimpleProtocolHandler.java Locally Modified (Based On LOCAL) @@ -25,13 +25,14 @@ import com.sun.grizzly.Context; import com.sun.grizzly.Controller; +import com.sun.grizzly.util.SSLSelectionKeyAttachment; import com.sun.grizzly.util.OutputWriter; import com.sun.grizzly.util.SSLOutputWriter; +import com.sun.grizzly.util.SelectionKeyAttachment; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.SelectionKey; import java.util.logging.Level; -import javax.net.ssl.SSLEngine; /** * @author Alexey Stashok @@ -78,9 +79,9 @@ buffer.position(pos); } - Object attachment = protocolRequest.getSelectionKey().attachment(); - if (attachment instanceof SSLEngine) { - protocolRequest.setSSLEngine((SSLEngine) attachment); + Object attachment = SelectionKeyAttachment.getAttachment(protocolRequest.getSelectionKey()); + if (attachment instanceof SSLSelectionKeyAttachment) { + protocolRequest.setSSLEngine(((SSLSelectionKeyAttachment) attachment).getSslEngine()); allocateBuffers(protocolRequest); } else { protocolRequest.setSSLEngine(null);