Example usage for javax.net.ssl SSLEngine getSession

List of usage examples for javax.net.ssl SSLEngine getSession

Introduction

In this page you can find the example usage for javax.net.ssl SSLEngine getSession.

Prototype

public abstract SSLSession getSession();

Source Link

Document

Returns the SSLSession in use in this SSLEngine .

Usage

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

private ByteBuffer allocateOutBuffer() {
    final SSLEngine sslEngine = getSSLEngine();
    final SSLSession sslSession = sslEngine.getSession();
    return ByteBuffer.allocate(sslSession.getApplicationBufferSize());
}

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

private String wrapHandshake() throws AuthenticationException {
    final ByteBuffer src = allocateOutBuffer();
    src.flip();/*from  w  ww. j a v  a2 s  . c  o m*/
    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  w  w  w  .  j  a va2 s  . co m
    dst.flip();
    return encodeBase64(dst);
}

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

private void unwrapHandshake(final String inputString) throws MalformedChallengeException {
    final SSLEngine sslEngine = getSSLEngine();
    final SSLSession sslSession = sslEngine.getSession();
    final ByteBuffer src = decodeBase64(inputString);
    final ByteBuffer dst = ByteBuffer.allocate(sslSession.getApplicationBufferSize());
    while (sslEngine.getHandshakeStatus() == HandshakeStatus.NEED_UNWRAP) {
        unwrap(src, dst);//from  w w w  .j a v  a  2  s  . co m
    }
}

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

private ByteBuffer unwrap(final String inputString) throws MalformedChallengeException {
    final SSLEngine sslEngine = getSSLEngine();
    final SSLSession sslSession = sslEngine.getSession();
    final ByteBuffer src = decodeBase64(inputString);
    final ByteBuffer dst = ByteBuffer.allocate(sslSession.getApplicationBufferSize());
    unwrap(src, dst);/*from w  w  w . j a  v a  2s  .  c o  m*/
    dst.flip();
    return dst;
}