本文整理汇总了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;
}
示例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;
}
示例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());
}
}
示例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)) ;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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());
}
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例15: status
@Override HandshakeStatus status()
{
if (state.isReadState())
return HandshakeStatus.NEED_UNWRAP;
if (state.isWriteState())
return HandshakeStatus.NEED_WRAP;
return HandshakeStatus.FINISHED;
}