jdk/src/share/classes/sun/net/httpserver/SSLStreams.java
changeset 10596 39b3a979e600
parent 7668 d4a77089c587
equal deleted inserted replaced
10595:c5be3e19fbab 10596:39b3a979e600
     1 /*
     1 /*
     2  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    27 
    27 
    28 import java.net.*;
    28 import java.net.*;
    29 import java.nio.*;
    29 import java.nio.*;
    30 import java.io.*;
    30 import java.io.*;
    31 import java.nio.channels.*;
    31 import java.nio.channels.*;
    32 import java.util.*;
       
    33 import java.util.concurrent.*;
       
    34 import java.util.concurrent.locks.*;
    32 import java.util.concurrent.locks.*;
    35 import javax.net.ssl.*;
    33 import javax.net.ssl.*;
    36 import javax.net.ssl.SSLEngineResult.*;
    34 import javax.net.ssl.SSLEngineResult.*;
    37 import com.sun.net.httpserver.*;
    35 import com.sun.net.httpserver.*;
    38 import com.sun.net.httpserver.spi.*;
       
    39 
    36 
    40 /**
    37 /**
    41  * given a non-blocking SocketChannel, it produces
    38  * given a non-blocking SocketChannel, it produces
    42  * (blocking) streams which encrypt/decrypt the SSL content
    39  * (blocking) streams which encrypt/decrypt the SSL content
    43  * and handle the SSL handshaking automatically.
    40  * and handle the SSL handshaking automatically.
   446     /* do the (complete) handshake after acquiring the handshake lock.
   443     /* do the (complete) handshake after acquiring the handshake lock.
   447      * If two threads call this at the same time, then we depend
   444      * If two threads call this at the same time, then we depend
   448      * on the wrapper methods being idempotent. eg. if wrapAndSend()
   445      * on the wrapper methods being idempotent. eg. if wrapAndSend()
   449      * is called with no data to send then there must be no problem
   446      * is called with no data to send then there must be no problem
   450      */
   447      */
       
   448     @SuppressWarnings("fallthrough")
   451     void doHandshake (HandshakeStatus hs_status) throws IOException {
   449     void doHandshake (HandshakeStatus hs_status) throws IOException {
   452         try {
   450         try {
   453             handshaking.lock();
   451             handshaking.lock();
   454             ByteBuffer tmp = allocate(BufType.APPLICATION);
   452             ByteBuffer tmp = allocate(BufType.APPLICATION);
   455             while (hs_status != HandshakeStatus.FINISHED &&
   453             while (hs_status != HandshakeStatus.FINISHED &&