private ByteBuffer extractByteBuffer(Buffer buffer) { if (buffer.buffer() instanceof NIOBuffer) return ((NIOBuffer)buffer.buffer()).getByteBuffer(); return ByteBuffer.wrap(buffer.array()); }
private int availableContent() { // Volatile read to ensure visibility State state = this.state; if (state != State.HEADERS_COMPLETE && state != State.CONTENT) throw new IllegalStateException(); return buffer == null ? 0 : buffer.length(); }
public boolean isInputShutdown() { synchronized (SslConnection.this) { return _endp.isInputShutdown() && !(_unwrapBuf!=null&&_unwrapBuf.hasContent()) && !(_inbound!=null&&_inbound.hasContent()); } }
private synchronized boolean unwrap(final Buffer buffer) throws IOException if (!_inbound.hasContent()) return false; synchronized(bbuf) ByteBuffer in_buffer=_inbound.getByteBuffer(); synchronized(in_buffer) int decrypted_position = bbuf.position(); in_buffer.position(_inbound.getIndex()); in_buffer.limit(_inbound.putIndex()); int encrypted_position = in_buffer.position(); _inbound.skip(encrypted_consumed); _inbound.compact(); _inbound.clear(); break; if (_logger.isDebugEnabled()) _logger.debug("{} unwrap {} {}->{}",_session,result.getStatus(),_inbound.toDetailString(),buffer.toDetailString()); break;
_unwrapBuf.compact(); toFill=_unwrapBuf; if (_unwrapBuf!=null && _unwrapBuf.hasContent()) _unwrapBuf.skip(toFill.put(_unwrapBuf)); return true; else if (_unwrapBuf!=null && _unwrapBuf.hasContent()) _unwrapBuf.skip(toFill.put(_unwrapBuf)); return true; if (_inbound.space() > 0 && (filled = _endp.fill(_inbound)) > 0) progress = true; if (_outbound.hasContent() && (flushed=_endp.flush(_outbound)) > 0) progress = true; _logger.debug("{} {} {} filled={}/{} flushed={}/{}",_session,this,_engine.getHandshakeStatus(),filled,_inbound.length(),flushed,_outbound.length()); if (toFill.space()>0 && _inbound.hasContent() && unwrap(toFill)) progress=true; if (toFlush.hasContent() && _outbound.space()>0 && wrap(toFlush)) progress=true; else if (!_inbound.hasContent()&&filled==-1)
synchronized(bbuf) _outbound.compact(); ByteBuffer out_buffer=_outbound.getByteBuffer(); synchronized(out_buffer) int decrypted_position = bbuf.position(); out_buffer.position(_outbound.putIndex()); out_buffer.limit(out_buffer.capacity()); int encrypted_position = out_buffer.position(); _outbound.setPutIndex(_outbound.putIndex() + encrypted_produced);
private synchronized boolean unwrap(final Buffer buffer) throws IOException if (!_inbound.hasContent()) return false; synchronized(bbuf) ByteBuffer in_buffer=_inbound.getByteBuffer(); synchronized(in_buffer) int decrypted_position = bbuf.position(); in_buffer.position(_inbound.getIndex()); in_buffer.limit(_inbound.putIndex()); int encrypted_position = in_buffer.position(); _inbound.skip(encrypted_consumed); _inbound.compact(); _inbound.clear(); break; if (_logger.isDebugEnabled()) _logger.debug("{} unwrap {} {}->{}",_session,result.getStatus(),_inbound.toDetailString(),buffer.toDetailString()); break;
_unwrapBuf.compact(); toFill=_unwrapBuf; if (_unwrapBuf!=null && _unwrapBuf.hasContent()) _unwrapBuf.skip(toFill.put(_unwrapBuf)); return true; else if (_unwrapBuf!=null && _unwrapBuf.hasContent()) _unwrapBuf.skip(toFill.put(_unwrapBuf)); return true; if (_inbound.space() > 0 && (filled = _endp.fill(_inbound)) > 0) progress = true; if (_outbound.hasContent() && (flushed=_endp.flush(_outbound)) > 0) progress = true; _logger.debug("{} {} {} filled={}/{} flushed={}/{}",_session,this,_engine.getHandshakeStatus(),filled,_inbound.length(),flushed,_outbound.length()); if (toFill.space()>0 && _inbound.hasContent() && unwrap(toFill)) progress=true; if (toFlush.hasContent() && _outbound.space()>0 && wrap(toFlush)) progress=true; else if (!_inbound.hasContent()&&filled==-1)
synchronized(bbuf) _outbound.compact(); ByteBuffer out_buffer=_outbound.getByteBuffer(); synchronized(out_buffer) int decrypted_position = bbuf.position(); out_buffer.position(_outbound.putIndex()); out_buffer.limit(out_buffer.capacity()); int encrypted_position = out_buffer.position(); _outbound.setPutIndex(_outbound.putIndex() + encrypted_produced);
private synchronized boolean unwrap(final Buffer buffer) throws IOException if (!_inbound.hasContent()) return false; synchronized(bbuf) ByteBuffer in_buffer=_inbound.getByteBuffer(); synchronized(in_buffer) int decrypted_position = bbuf.position(); in_buffer.position(_inbound.getIndex()); in_buffer.limit(_inbound.putIndex()); int encrypted_position = in_buffer.position(); _inbound.skip(encrypted_consumed); _inbound.compact(); _inbound.clear(); break; if (_logger.isDebugEnabled()) _logger.debug("{} unwrap {} {}->{}",_session,result.getStatus(),_inbound.toDetailString(),buffer.toDetailString()); break;
_unwrapBuf.compact(); toFill=_unwrapBuf; if (_unwrapBuf!=null && _unwrapBuf.hasContent()) _unwrapBuf.skip(toFill.put(_unwrapBuf)); return true; else if (_unwrapBuf!=null && _unwrapBuf.hasContent()) _unwrapBuf.skip(toFill.put(_unwrapBuf)); return true; if (_inbound.space() > 0 && (filled = _endp.fill(_inbound)) > 0) progress = true; if (_outbound.hasContent() && (flushed=_endp.flush(_outbound)) > 0) progress = true; _logger.debug("{} {} {} filled={}/{} flushed={}/{}",_session,this,_engine.getHandshakeStatus(),filled,_inbound.length(),flushed,_outbound.length()); if (toFill.space()>0 && _inbound.hasContent() && unwrap(toFill)) progress=true; if (toFlush.hasContent() && _outbound.space()>0 && wrap(toFlush)) progress=true; else if (!_inbound.hasContent()&&filled==-1)
synchronized(bbuf) _outbound.compact(); ByteBuffer out_buffer=_outbound.getByteBuffer(); synchronized(out_buffer) int decrypted_position = bbuf.position(); out_buffer.position(_outbound.putIndex()); out_buffer.limit(out_buffer.capacity()); int encrypted_position = out_buffer.position(); _outbound.setPutIndex(_outbound.putIndex() + encrypted_produced);
private ByteBuffer extractByteBuffer(Buffer buffer) { if (buffer.buffer() instanceof NIOBuffer) return ((NIOBuffer)buffer.buffer()).getByteBuffer(); return ByteBuffer.wrap(buffer.array()); }
public boolean isInputShutdown() { synchronized (SslConnection.this) { return _endp.isInputShutdown() && !(_unwrapBuf!=null&&_unwrapBuf.hasContent()) && !(_inbound!=null&&_inbound.hasContent()); } }
private synchronized boolean unwrap(final Buffer buffer) throws IOException if (!_inbound.hasContent()) return false; synchronized(bbuf) ByteBuffer in_buffer=_inbound.getByteBuffer(); synchronized(in_buffer) int decrypted_position = bbuf.position(); in_buffer.position(_inbound.getIndex()); in_buffer.limit(_inbound.putIndex()); int encrypted_position = in_buffer.position(); _inbound.skip(encrypted_consumed); _inbound.compact(); _inbound.clear(); break; if (_logger.isDebugEnabled()) _logger.debug("{} unwrap {} {}->{}",_session,result.getStatus(),_inbound.toDetailString(),buffer.toDetailString()); break;
_unwrapBuf.compact(); toFill=_unwrapBuf; if (_unwrapBuf!=null && _unwrapBuf.hasContent()) _unwrapBuf.skip(toFill.put(_unwrapBuf)); return true; else if (_unwrapBuf!=null && _unwrapBuf.hasContent()) _unwrapBuf.skip(toFill.put(_unwrapBuf)); return true; if (_inbound.space() > 0 && (filled = _endp.fill(_inbound)) > 0) progress = true; if (_outbound.hasContent() && (flushed=_endp.flush(_outbound)) > 0) progress = true; _logger.debug("{} {} {} filled={}/{} flushed={}/{}",_session,this,_engine.getHandshakeStatus(),filled,_inbound.length(),flushed,_outbound.length()); if (toFill.space()>0 && _inbound.hasContent() && unwrap(toFill)) progress=true; if (toFlush.hasContent() && _outbound.space()>0 && wrap(toFlush)) progress=true; else if (!_inbound.hasContent()&&filled==-1)
synchronized(bbuf) _outbound.compact(); ByteBuffer out_buffer=_outbound.getByteBuffer(); synchronized(out_buffer) int decrypted_position = bbuf.position(); out_buffer.position(_outbound.putIndex()); out_buffer.limit(out_buffer.capacity()); int encrypted_position = out_buffer.position(); _outbound.setPutIndex(_outbound.putIndex() + encrypted_produced);
private ByteBuffer extractByteBuffer(Buffer buffer) { if (buffer.buffer() instanceof NIOBuffer) return ((NIOBuffer)buffer.buffer()).getByteBuffer(); return ByteBuffer.wrap(buffer.array()); }