Example usage for javax.net.ssl SSLEngine getHandshakeStatus

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

Introduction

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

Prototype

public abstract SSLEngineResult.HandshakeStatus getHandshakeStatus();

Source Link

Document

Returns the current handshake status for this SSLEngine .

Usage

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 w w  .  j a v a2  s. com*/
    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 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  ww . j av a2 s. c o m
    }
}

From source file:org.globus.gsi.gssapi.GlobusGSSContextImpl.java

private void runDelegatedTasks(SSLEngine engine) throws Exception {

    Runnable runnable;/*from  w  w  w.j a  v a 2  s.co m*/
    while ((runnable = engine.getDelegatedTask()) != null) {
        logger.debug("\trunning delegated task...");
        runnable.run();
    }
    SSLEngineResult.HandshakeStatus hsStatus = engine.getHandshakeStatus();
    if (hsStatus == SSLEngineResult.HandshakeStatus.NEED_TASK) {
        throw new Exception("handshake shouldn't need additional tasks");
    }
    logger.debug("\tnew HandshakeStatus: " + hsStatus);
}