public void received()

in client/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLReceiver.java [94:205]


    public void received(ByteBuffer buf)
    {
        ByteBuffer netData = addPreviouslyUnreadData(buf);

        HandshakeStatus handshakeStatus;
        Status status;

        while (netData.hasRemaining())
        {
            try
            {
                SSLEngineResult result = engine.unwrap(netData, appData);
                synchronized (_sslStatus.getSslLock())
                {
                    _sslStatus.getSslLock().notifyAll();
                }

                int read = result.bytesProduced();
                status = result.getStatus();
                handshakeStatus = result.getHandshakeStatus();

                if (read > 0)
                {
                    int limit = appData.limit();
                    appData.limit(appData.position());
                    appData.position(appData.position() - read);

                    ByteBuffer data = appData.slice();

                    appData.limit(limit);
                    appData.position(appData.position() + read);

                    delegate.received(data);
                }


                switch(status)
                {
                    case CLOSED:
                        synchronized(_sslStatus.getSslLock())
                        {
                            _sslStatus.getSslLock().notifyAll();
                        }
                        return;

                    case BUFFER_OVERFLOW:
                        appData = ByteBuffer.allocate(sslBufSize);
                        continue;

                    case BUFFER_UNDERFLOW:
                        localBuffer.clear();
                        localBuffer.put(netData);
                        localBuffer.flip();
                        dataCached = true;
                        break;

                    case OK:
                        break; // do nothing

                    default:
                        throw new IllegalStateException("SSLReceiver: Invalid State " + status);
                }

                switch (handshakeStatus)
                {
                    case NEED_UNWRAP:
                        if (netData.hasRemaining())
                        {
                            continue;
                        }
                        break;
                    case NEED_WRAP:
                        break;
                    case NEED_TASK:
                        doTasks();
                        break;
                    case FINISHED:
                        if (_hostname != null)
                        {
                            SSLUtil.verifyHostname(engine, _hostname);
                        }
                        break;
                    case NOT_HANDSHAKING:
                        break;
                    default:
                        throw new IllegalStateException("SSLReceiver: Invalid State " + status);
                }
                if (handshakeStatus != HandshakeStatus.NEED_UNWRAP)
                {
                    synchronized(_sslStatus.getSslLock())
                    {
                        _sslStatus.getSslLock().notifyAll();
                    }
                }

            }
            catch(SSLException e)
            {
                if (LOGGER.isDebugEnabled())
                {
                    LOGGER.debug("Error caught in SSLReceiver", e);
                }
                _sslStatus.setSslErrorFlag();
                synchronized(_sslStatus.getSslLock())
                {
                    _sslStatus.getSslLock().notifyAll();
                }                
                exception(new TransportException("Error in SSLReceiver: " + e.getMessage(),e));
            }

        }
    }