當前位置: 首頁>>代碼示例>>Java>>正文


Java HandshakeStatus.NEED_UNWRAP屬性代碼示例

本文整理匯總了Java中javax.net.ssl.SSLEngineResult.HandshakeStatus.NEED_UNWRAP屬性的典型用法代碼示例。如果您正苦於以下問題:Java HandshakeStatus.NEED_UNWRAP屬性的具體用法?Java HandshakeStatus.NEED_UNWRAP怎麽用?Java HandshakeStatus.NEED_UNWRAP使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在javax.net.ssl.SSLEngineResult.HandshakeStatus的用法示例。


在下文中一共展示了HandshakeStatus.NEED_UNWRAP屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handshakeUnwrap

/**
* Perform handshake unwrap
* @param doRead boolean
* @return SSLEngineResult
* @throws IOException
*/
private SSLEngineResult handshakeUnwrap(boolean doRead) throws IOException {
    log.trace("SSLHandshake handshakeUnwrap {}", channelId);
    SSLEngineResult result;
    if (doRead)  {
        int read = socketChannel.read(netReadBuffer);
        if (read == -1) throw new EOFException("EOF during handshake.");
    }
    boolean cont;
    do {
        //prepare the buffer with the incoming data
        netReadBuffer.flip();
        result = sslEngine.unwrap(netReadBuffer, appReadBuffer);
        netReadBuffer.compact();
        handshakeStatus = result.getHandshakeStatus();
        if (result.getStatus() == SSLEngineResult.Status.OK &&
            result.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
            handshakeStatus = runDelegatedTasks();
        }
        cont = result.getStatus() == SSLEngineResult.Status.OK &&
            handshakeStatus == HandshakeStatus.NEED_UNWRAP;
        log.trace("SSLHandshake handshakeUnwrap: handshakeStatus {} status {}", handshakeStatus, result.getStatus());
    } while (netReadBuffer.position() != 0 && cont);

    return result;
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:31,代碼來源:SslTransportLayer.java

示例2: unwrap

/**
 * performs the unwrap operation by unwrapping from {@link #inCrypt} to {@link #inData}
 **/
private synchronized ByteBuffer unwrap() throws SSLException {
	int rem;
	//There are some ssl test suites, which get around the selector.select() call, which cause an infinite unwrap and 100% cpu usage (see #459 and #458)
	if(readEngineResult.getStatus() == Status.CLOSED && sslEngine.getHandshakeStatus() == HandshakeStatus.NOT_HANDSHAKING){
		try {
			close();
		} catch (IOException e) {
			//Not really interesting
		}
	}
	do {
		rem = inData.remaining();
		readEngineResult = sslEngine.unwrap( inCrypt, inData );
	} while ( readEngineResult.getStatus() == Status.OK && ( rem != inData.remaining() || sslEngine.getHandshakeStatus() == HandshakeStatus.NEED_UNWRAP ) );
	inData.flip();
	return inData;
}
 
開發者ID:MundoSK,項目名稱:MundoSK,代碼行數:20,代碼來源:SSLSocketChannel2.java

示例3: unwrap

public ByteBuf unwrap(SocketChannel channel, ByteBuf src) throws IOException {
    SSLEngine sslEngine = channel.getSSLEngine();
    ByteBuf dst = getTempDst(sslEngine);
    for (;;) {
        dst.clear();
        SSLEngineResult result = sslEngine.unwrap(src.nioBuffer(), dst.nioBuffer());
        HandshakeStatus handshakeStatus = result.getHandshakeStatus();
        synchByteBuf(result, src, dst);
        if (handshakeStatus != HandshakeStatus.NOT_HANDSHAKING) {
            if (handshakeStatus == HandshakeStatus.NEED_WRAP) {
                channel.doFlush(forgeFuture.duplicate());
                return null;
            } else if (handshakeStatus == HandshakeStatus.NEED_TASK) {
                runDelegatedTasks(sslEngine);
                continue;
            } else if (handshakeStatus == HandshakeStatus.FINISHED) {
                channel.finishHandshake(null);
                return null;
            } else if (handshakeStatus == HandshakeStatus.NEED_UNWRAP) {
                return null;
            }
        }
        return gc(channel, dst.flip());
    }
}
 
開發者ID:generallycloud,項目名稱:baseio,代碼行數:25,代碼來源:SslHandler.java

示例4: SSLReadWriteSelectorHandler

public SSLReadWriteSelectorHandler(SocketChannel sc, SelectionKey selectionKey,
                                   SSLContext sslContext) throws IOException {
    super(sc);

    sslEngine = sslContext.createSSLEngine();
    sslEngine.setUseClientMode(false);
    initialHSStatus = HandshakeStatus.NEED_UNWRAP;
    initialHSComplete = false;

    int netBBSize = sslEngine.getSession().getPacketBufferSize();
    inNetBB = ByteBuffer.allocate(netBBSize);
    outNetBB = ByteBuffer.allocate(netBBSize);
    outNetBB.position(0);
    outNetBB.limit(0);

    int appBBSize = sslEngine.getSession().getApplicationBufferSize();
    requestBB = ByteBuffer.allocate(appBBSize);

    while (!doHandshake(selectionKey)) ;
}
 
開發者ID:94fzb,項目名稱:simplewebserver,代碼行數:20,代碼來源:SSLReadWriteSelectorHandler.java

示例5: unwrap

/**
 * performs the unwrap operation by unwrapping from {@link #inCrypt} to {@link #inData}
 **/
private synchronized ByteBuffer unwrap() throws SSLException {
	int rem;
	//There are some ssl test suites, which get around the selector.select() call, which cause an infinite unwrap and 100% cpu usage (see #459 and #458)
	if(readEngineResult.getStatus() == SSLEngineResult.Status.CLOSED && sslEngine.getHandshakeStatus() == HandshakeStatus.NOT_HANDSHAKING){
		try {
			close();
		} catch (IOException e) {
			//Not really interesting
		}
	}
	do {
		rem = inData.remaining();
		readEngineResult = sslEngine.unwrap( inCrypt, inData );
	} while ( readEngineResult.getStatus() == SSLEngineResult.Status.OK && ( rem != inData.remaining() || sslEngine.getHandshakeStatus() == HandshakeStatus.NEED_UNWRAP ) );
	inData.flip();
	return inData;
}
 
開發者ID:cping,項目名稱:RipplePower,代碼行數:20,代碼來源:SSLSocketChannel2.java

示例6: handshakeUnwrap

/**
 * Perform handshake unwrap
 * @param doread boolean
 * @return SSLEngineResult
 * @throws IOException
 */
protected SSLEngineResult handshakeUnwrap(boolean doread) throws IOException {

    if (netInBuffer.position() == netInBuffer.limit()) {
        //clear the buffer if we have emptied it out on data
        netInBuffer.clear();
    }
    if ( doread )  {
        //if we have data to read, read it
        int read = sc.read(netInBuffer);
        if (read == -1) throw new IOException("EOF encountered during handshake.");
    }
    SSLEngineResult result;
    boolean cont = false;
    //loop while we can perform pure SSLEngine data
    do {
        //prepare the buffer with the incoming data
        netInBuffer.flip();
        //call unwrap
        result = sslEngine.unwrap(netInBuffer, bufHandler.getReadBuffer());
        //compact the buffer, this is an optional method, wonder what would happen if we didn't
        netInBuffer.compact();
        //read in the status
        handshakeStatus = result.getHandshakeStatus();
        if ( result.getStatus() == SSLEngineResult.Status.OK &&
             result.getHandshakeStatus() == HandshakeStatus.NEED_TASK ) {
            //execute tasks if we need to
            handshakeStatus = tasks();
        }
        //perform another unwrap?
        cont = result.getStatus() == SSLEngineResult.Status.OK &&
               handshakeStatus == HandshakeStatus.NEED_UNWRAP;
    }while ( cont );
    return result;
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:40,代碼來源:SecureNioChannel.java

示例7: unwrap

/**
 * performs the unwrap operation by unwrapping from {@link #inCrypt} to {@link #inData}
 **/
private synchronized ByteBuffer unwrap() throws SSLException {
	int rem;
	do {
		rem = inData.remaining();
		readEngineResult = sslEngine.unwrap( inCrypt, inData );
	} while ( readEngineResult.getStatus() == SSLEngineResult.Status.OK && ( rem != inData.remaining() || sslEngine.getHandshakeStatus() == HandshakeStatus.NEED_UNWRAP ) );
	inData.flip();
	return inData;
}
 
開發者ID:LDLN,項目名稱:Responder-Android,代碼行數:12,代碼來源:SSLSocketChannel2.java

示例8: unwrap

/**
   * performs the unwrap operation by unwrapping from {@link #inCrypt} to
   * {@link #inData}
*
   */
  private synchronized ByteBuffer unwrap() throws SSLException {
      int rem;
      do {
          rem = inData.remaining();
          readEngineResult = sslEngine.unwrap(inCrypt, inData);
      } while (readEngineResult.getStatus() == SSLEngineResult.Status.OK && (rem != inData.remaining() || sslEngine.getHandshakeStatus() == HandshakeStatus.NEED_UNWRAP));
      inData.flip();
      return inData;
  }
 
開發者ID:GloriousEggroll,項目名稱:quorrabot,代碼行數:14,代碼來源:SSLSocketChannel2.java

示例9: processHandshake

private synchronized void processHandshake() throws IOException {
    if (this.engineResult.getHandshakeStatus() != HandshakeStatus.NOT_HANDSHAKING) {
        if (!this.tasks.isEmpty()) {
            Iterator<Future<?>> it = this.tasks.iterator();
            while (it.hasNext()) {
                Future<?> f = (Future) it.next();
                if (f.isDone()) {
                    it.remove();
                } else if (isBlocking()) {
                    consumeFutureUninterruptible(f);
                }
            }
        }
        if (this.engineResult.getHandshakeStatus() == HandshakeStatus.NEED_UNWRAP) {
            if (!isBlocking() || this.engineStatus == Status.BUFFER_UNDERFLOW) {
                this.inCrypt.compact();
                if (this.socketChannel.read(this.inCrypt) == -1) {
                    throw new IOException("connection closed unexpectedly by peer");
                }
                this.inCrypt.flip();
            }
            this.inData.compact();
            unwrap();
            if (this.engineResult.getHandshakeStatus() == HandshakeStatus.FINISHED) {
                createBuffers(this.sslEngine.getSession());
            }
        }
        consumeDelegatedTasks();
        if (!$assertionsDisabled && this.engineResult.getHandshakeStatus() == HandshakeStatus.NOT_HANDSHAKING) {
            throw new AssertionError();
        } else if (this.tasks.isEmpty() || this.engineResult.getHandshakeStatus() == HandshakeStatus.NEED_WRAP) {
            this.socketChannel.write(wrap(emptybuffer));
            if (this.engineResult.getHandshakeStatus() == HandshakeStatus.FINISHED) {
                createBuffers(this.sslEngine.getSession());
            }
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:38,代碼來源:SSLSocketChannel2.java

示例10: unwrap

private synchronized ByteBuffer unwrap() throws SSLException {
    while (true) {
        int rem = this.inData.remaining();
        this.engineResult = this.sslEngine.unwrap(this.inCrypt, this.inData);
        this.engineStatus = this.engineResult.getStatus();
        if (this.engineStatus != Status.OK || (rem == this.inData.remaining() && this.engineResult.getHandshakeStatus() != HandshakeStatus.NEED_UNWRAP)) {
            this.inData.flip();
        }
    }
    this.inData.flip();
    return this.inData;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:12,代碼來源:SSLSocketChannel2.java

示例11: handshakeUnwrap

/**
 * Perform handshake unwrap
 * 
 * @param doread
 *            boolean
 * @return SSLEngineResult
 * @throws IOException
 */
protected SSLEngineResult handshakeUnwrap(boolean doread) throws IOException {

	if (netInBuffer.position() == netInBuffer.limit()) {
		// clear the buffer if we have emptied it out on data
		netInBuffer.clear();
	}
	if (doread) {
		// if we have data to read, read it
		int read = sc.read(netInBuffer);
		if (read == -1)
			throw new IOException("EOF encountered during handshake.");
	}
	SSLEngineResult result;
	boolean cont = false;
	// loop while we can perform pure SSLEngine data
	do {
		// prepare the buffer with the incoming data
		netInBuffer.flip();
		// call unwrap
		result = sslEngine.unwrap(netInBuffer, bufHandler.getReadBuffer());
		// compact the buffer, this is an optional method, wonder what would
		// happen if we didn't
		netInBuffer.compact();
		// read in the status
		handshakeStatus = result.getHandshakeStatus();
		if (result.getStatus() == SSLEngineResult.Status.OK
				&& result.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
			// execute tasks if we need to
			handshakeStatus = tasks();
		}
		// perform another unwrap?
		cont = result.getStatus() == SSLEngineResult.Status.OK && handshakeStatus == HandshakeStatus.NEED_UNWRAP;
	} while (cont);
	return result;
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:43,代碼來源:SecureNioChannel.java

示例12: handshakeUnwrap

/**
* Perform handshake unwrap
* @param doRead boolean
* @return SSLEngineResult
* @throws IOException
*/
private SSLEngineResult handshakeUnwrap(boolean doRead) throws IOException {
    log.trace("SSLHandshake handshakeUnwrap {}", channelId);
    SSLEngineResult result;
    boolean cont = false;
    int read = 0;
    if (doRead)  {
        read = socketChannel.read(netReadBuffer);
        if (read == -1) throw new EOFException("EOF during handshake.");
    }
    do {
        //prepare the buffer with the incoming data
        netReadBuffer.flip();
        result = sslEngine.unwrap(netReadBuffer, appReadBuffer);
        netReadBuffer.compact();
        handshakeStatus = result.getHandshakeStatus();
        if (result.getStatus() == SSLEngineResult.Status.OK &&
            result.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
            handshakeStatus = runDelegatedTasks();
        }
        cont = result.getStatus() == SSLEngineResult.Status.OK &&
            handshakeStatus == HandshakeStatus.NEED_UNWRAP;
        log.trace("SSLHandshake handshakeUnwrap: handshakeStatus {} status {}", handshakeStatus, result.getStatus());
    } while (netReadBuffer.position() != 0 && cont);

    return result;
}
 
開發者ID:txazo,項目名稱:kafka,代碼行數:32,代碼來源:SslTransportLayer.java

示例13: unwrap

private synchronized ByteBuffer unwrap() throws SSLException {
	int rem;
	do {
		rem = inData.remaining();
		readEngineResult = sslEngine.unwrap(inCrypt, inData);
	} while (readEngineResult.getStatus() == SSLEngineResult.Status.OK && (rem != inData.remaining() || sslEngine.getHandshakeStatus() == HandshakeStatus.NEED_UNWRAP));
	inData.flip();
	return inData;
}
 
開發者ID:frc2503,項目名稱:r2016,代碼行數:9,代碼來源:SSLSocketChannel.java

示例14: status

@Override HandshakeStatus status()
{
  if (!tasks.isEmpty())
    return HandshakeStatus.NEED_TASK;
  if (state.isReadState())
    return HandshakeStatus.NEED_UNWRAP;
  if (state.isWriteState())
    return HandshakeStatus.NEED_WRAP;

  return HandshakeStatus.FINISHED;
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:11,代碼來源:ServerHandshake.java

示例15: status

@Override HandshakeStatus status()
{
  if (state.isReadState())
    return HandshakeStatus.NEED_UNWRAP;
  if (state.isWriteState())
    return HandshakeStatus.NEED_WRAP;
  return HandshakeStatus.FINISHED;
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:8,代碼來源:ClientHandshake.java


注:本文中的javax.net.ssl.SSLEngineResult.HandshakeStatus.NEED_UNWRAP屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。