SSLEngine closeOutbound - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for SSLEngine closeOutbound method.

This code example shows how to use the following methods:closeOutbound, getSession, wrap
		} 
	} 
 
	private synchronized ByteBuffer wrap( ByteBuffer b ) throws SSLException {
		outCrypt.compact();
		engineResult = sslEngine.wrap( b, outCrypt );
		outCrypt.flip();
		return outCrypt;
	} 
 
	private synchronized ByteBuffer unwrap() throws SSLException {
		int rem;
		do { 
			rem = inData.remaining();
			engineResult = sslEngine.unwrap( inCrypt, inData );
			engineStatus = engineResult.getStatus();
		} while ( engineStatus == SSLEngineResult.Status.OK && ( rem != inData.remaining() || engineResult.getHandshakeStatus() == HandshakeStatus.NEED_UNWRAP ) );
 
		inData.flip();
		return inData;

5
CodeRank
This code example shows how to use the following methods:closeOutbound, getHandshakeStatus, getSession, wrap
        if (doLog) {
            System.out.println("\n--- doClose: ");
        } 
        ByteBuffer buffer = ByteBuffer.allocate(
                // +100 because we put the data into the buffer multiple times 
                server.getSession().getPacketBufferSize()+100);
        ByteBuffer app_data_buffer = ByteBuffer.allocate(
                client.getSession().getApplicationBufferSize());
        SSLEngineResult result;
        // first: send 0 just for fun 
        if (doLog) {
            System.out.println("\nServer sends pending outboud data:");
        } 
        print(result = server.wrap(ByteBuffer.wrap(new byte[] {0}), buffer));
        assertEquals("Unexpected status of operation:",
                SSLEngineResult.Status.OK,
                result.getStatus());
        assertEquals("Unexpected status of operation:",
                SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING,
                result.getHandshakeStatus());

5
CodeRank
This code example shows how to use the following methods:closeInbound, closeOutbound
    @Override 
    public void close() throws IOException { 
        try { 
            super.close(); 
            try { 
                sslEngine.closeInbound();
                sslEngine.closeOutbound();
            } catch (SSLException e) {
                // ignore it 
            } 
            // free buffers 
            BufferPool.free(inNetBuffer);
            inNetBuffer = null;
            BufferPool.free(inReadBuffer);
            inReadBuffer = null;
            BufferPool.free(outNetBuffer);
            BufferPool.free(dummyBuffer);
            shutdownInProgress = true;
            closed = true;
        } catch (Throwable th) {
4
CodeRank
This code example shows how to use the following methods:closeOutbound, wrap
     * @todo Implement this java.io.Closeable method 
     */ 
    public void close() throws IOException { 
        if (closing) return;
        closing = true;
        sslEngine.closeOutbound();
 
        if (!flush(netOutBuffer)) {
            throw new IOException("Remaining data in the network buffer, can't send SSL close message, force a close with close(true) instead");
        } 
        //prep the buffer for the close message 
        netOutBuffer.clear();
        //perform the close, since we called sslEngine.closeOutbound 
        SSLEngineResult handshake = sslEngine.wrap(getEmptyBuf(), netOutBuffer);
        //we should be in a close state 
        if (handshake.getStatus() != SSLEngineResult.Status.CLOSED) {
            throw new IOException("Invalid close state, will not send network data.");
        } 
        //prepare the buffer for writing 
        netOutBuffer.flip();
4
CodeRank
This code example shows how to use the following methods:closeOutbound
     * 
     * @throws SSLException 
     */ 
    public void close() throws SSLException { 
        // Indicate that application is done with engine 
        tlsEngine.closeOutbound();
    } 
 
    /** 
     * Returns the current status for this TLSHandler. 
     * 
     * @return the current TLSStatus 
     */ 
    public TLSStatus getStatus() { 
        TLSStatus status = null;
        if (tlsEngineResult != null && tlsEngineResult.getStatus() == Status.BUFFER_UNDERFLOW) {
            status = TLSStatus.UNDERFLOW;
        } else { 
            if (tlsEngineResult != null && tlsEngineResult.getStatus() == Status.CLOSED) {
                status = TLSStatus.CLOSED;
3
CodeRank
closeOutbound Method Overview
Notifies this engine instance that no more outbound application data will be sent to this engine.
See Code Examples for other Java 8 SSLEngine Methods: