Example usage for javax.net.ssl SSLSession getPacketBufferSize

List of usage examples for javax.net.ssl SSLSession getPacketBufferSize

Introduction

In this page you can find the example usage for javax.net.ssl SSLSession getPacketBufferSize.

Prototype

public int getPacketBufferSize();

Source Link

Document

Gets the current size of the largest SSL/TLS/DTLS packet that is expected when using this session.

Usage

From source file:org.apache.hc.client5.http.impl.auth.CredSspScheme.java

private String wrapHandshake() throws AuthenticationException {
    final ByteBuffer src = allocateOutBuffer();
    src.flip();/*  ww  w . j a  va 2  s  . c  om*/
    final SSLEngine sslEngine = getSSLEngine();
    final SSLSession sslSession = sslEngine.getSession();
    // Needs to be twice the size as there may be two wraps during handshake.
    // Primitive and inefficient solution, but it works.
    final ByteBuffer dst = ByteBuffer.allocate(sslSession.getPacketBufferSize() * 2);
    while (sslEngine.getHandshakeStatus() == HandshakeStatus.NEED_WRAP) {
        wrap(src, dst);
    }
    dst.flip();
    return encodeBase64(dst);
}

From source file:org.apache.hc.client5.http.impl.auth.CredSspScheme.java

private String wrap(final ByteBuffer src) throws AuthenticationException {
    final SSLEngine sslEngine = getSSLEngine();
    final SSLSession sslSession = sslEngine.getSession();
    final ByteBuffer dst = ByteBuffer.allocate(sslSession.getPacketBufferSize());
    wrap(src, dst);//from  www .  j  av a2  s  . co m
    dst.flip();
    return encodeBase64(dst);
}