Package javax.net.ssl

Examples of javax.net.ssl.SSLEngine.wrap()


     */
    public void testCloseOutbound() throws Exception {
        SSLEngine engine = getEngine();
        assertFalse(engine.isOutboundDone());
        engine.closeOutbound();
        SSLEngineResult result = engine.wrap(ByteBuffer.allocate(0),
                ByteBuffer.allocate(20000));
        assertEquals("Incorrect status", result.getStatus(),
                SSLEngineResult.Status.CLOSED);
        assertEquals("Incorrect status", result.getHandshakeStatus(),
                SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING);
View Full Code Here


     */
    public void testCloseInbound() throws Exception {
        SSLEngine engine = getEngine();
        assertFalse(engine.isInboundDone());
        engine.closeInbound();
        SSLEngineResult result = engine.wrap(ByteBuffer.allocate(0),
                ByteBuffer.allocate(20000));
        assertEquals("Incorrect status", result.getStatus(),
                SSLEngineResult.Status.CLOSED);
        assertEquals("Incorrect status", result.getHandshakeStatus(),
                SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING);
View Full Code Here

            if (doLog) {
                System.out.println("Wrapping of the alert message");
            }
            SSLEngineResult result = null;
            print(result = server.wrap(ByteBuffer.allocate(0), buffer));
            assertEquals("Unexpected status of operation:",
                    SSLEngineResult.Status.CLOSED,
                    result.getStatus());
            assertEquals("Unexpected status of operation:",
                    SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING,
View Full Code Here

                0, result.bytesProduced());

            if (doLog) {
                System.out.println("\nServer wraps the fatal alert");
            }
            print(result = server.wrap(ByteBuffer.allocate(0), buffer));
            assertEquals("Unexpected status of operation:",
                    SSLEngineResult.Status.CLOSED,
                    result.getStatus());
            assertEquals("Unexpected status of operation:",
                    SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING,
View Full Code Here

                    // handshake data was fully read by another peer,
                    // so we need clear the buffer before reusing it
                    buffer.clear();
                }
                // wrap the next handshake message
                print(result = current_engine.wrap(app_data, buffer));
                // if there are no any messages to send, switch the engine
                if (current_engine.getHandshakeStatus()
                        != SSLEngineResult.HandshakeStatus.NEED_WRAP) {
                    // switch the current engine
                    step ^= 1;
View Full Code Here

                if (!buffers[step].hasRemaining()) {
                    if (doLog) {
                        System.out.println(
                                "\nTry to WRAP the application data");
                    }
                    print(result = current_engine.wrap(
                                ByteBuffer.wrap(new byte[] {0}), app_data));
                    // The output in app_data will be produced only if it
                    // is rehandshaking stage
                    // (i.e. initial handshake has been done)
                    if (result.bytesProduced() > 0) {
View Full Code Here

        try {
            engine.setUseClientMode(false);
            fail("Expected IllegalArgumentException was not thrown");
        } catch (IllegalArgumentException e) { }

        engine.wrap(ByteBuffer.allocate(0), ByteBuffer.allocate(
                engine.getSession().getPacketBufferSize()));
        try {
            engine.setUseClientMode(false);
            fail("Expected IllegalArgumentException was not thrown");
        } catch (IllegalArgumentException e) { }
View Full Code Here

        int port = 8080;
        ByteBuffer bbN = null;
        ByteBuffer bb = ByteBuffer.allocate(10);
        SSLEngine e = new mySSLEngine(host, port);

        e.wrap(bbN, bb);
        e.wrap(bb, bbN);

        ByteBuffer roBb = bb.asReadOnlyBuffer();
        assertTrue("Not read only byte buffer", roBb.isReadOnly());
        e.wrap(bb, roBb);
View Full Code Here

        ByteBuffer bbN = null;
        ByteBuffer bb = ByteBuffer.allocate(10);
        SSLEngine e = new mySSLEngine(host, port);

        e.wrap(bbN, bb);
        e.wrap(bb, bbN);

        ByteBuffer roBb = bb.asReadOnlyBuffer();
        assertTrue("Not read only byte buffer", roBb.isReadOnly());
        e.wrap(bb, roBb);
View Full Code Here

        e.wrap(bbN, bb);
        e.wrap(bb, bbN);

        ByteBuffer roBb = bb.asReadOnlyBuffer();
        assertTrue("Not read only byte buffer", roBb.isReadOnly());
        e.wrap(bb, roBb);

    }

    /**
     * Test for <code>wrap(ByteBuffer[] srcs, ByteBuffer dst)</code> method
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.