当前位置: 首页>>代码示例>>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;未经允许,请勿转载。