当前位置: 首页>>代码示例>>Java>>正文


Java Status.BUFFER_UNDERFLOW属性代码示例

本文整理汇总了Java中javax.net.ssl.SSLEngineResult.Status.BUFFER_UNDERFLOW属性的典型用法代码示例。如果您正苦于以下问题:Java Status.BUFFER_UNDERFLOW属性的具体用法?Java Status.BUFFER_UNDERFLOW怎么用?Java Status.BUFFER_UNDERFLOW使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javax.net.ssl.SSLEngineResult.Status的用法示例。


在下文中一共展示了Status.BUFFER_UNDERFLOW属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkResult

private void checkResult(SSLEngineResult result, boolean wrap)
        throws SSLException {

    handshakeStatus = result.getHandshakeStatus();
    resultStatus = result.getStatus();

    if (resultStatus != Status.OK &&
            (wrap || resultStatus != Status.BUFFER_UNDERFLOW)) {
        throw new SSLException("TODO");
    }
    if (wrap && result.bytesConsumed() != 0) {
        throw new SSLException("TODO");
    }
    if (!wrap && result.bytesProduced() != 0) {
        throw new SSLException("TODO");
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:17,代码来源:AsyncChannelWrapperSecure.java

示例2: SSLSocketChannel2

public SSLSocketChannel2( SocketChannel channel , SSLEngine sslEngine , ExecutorService exec , SelectionKey key ) throws IOException {
	if( channel == null || sslEngine == null || exec == null )
		throw new IllegalArgumentException( "parameter must not be null" );

	this.socketChannel = channel;
	this.sslEngine = sslEngine;
	this.exec = exec;

	readEngineResult = writeEngineResult = new SSLEngineResult( Status.BUFFER_UNDERFLOW, sslEngine.getHandshakeStatus(), 0, 0 ); // init to prevent NPEs

	tasks = new ArrayList<Future<?>>( 3 );
	if( key != null ) {
		key.interestOps( key.interestOps() | SelectionKey.OP_WRITE );
		this.selectionKey = key;
	}
	createBuffers( sslEngine.getSession() );
	// kick off handshake
	socketChannel.write( wrap( emptybuffer ) );// initializes res
	processHandshake();
}
 
开发者ID:LDLN,项目名称:Responder-Android,代码行数:20,代码来源:SSLSocketChannel2.java

示例3: SSLSocketChannel2

public SSLSocketChannel2(SocketChannel channel, SSLEngine sslEngine, ExecutorService exec, SelectionKey key) throws IOException {
    if (channel == null || sslEngine == null || exec == null) {
        throw new IllegalArgumentException("parameter must not be null");
    }

    this.socketChannel = channel;
    this.sslEngine = sslEngine;
    this.exec = exec;

    readEngineResult = writeEngineResult = new SSLEngineResult(Status.BUFFER_UNDERFLOW, sslEngine.getHandshakeStatus(), 0, 0); // init to prevent NPEs

    tasks = new ArrayList<Future<?>>(3);
    if (key != null) {
        key.interestOps(key.interestOps() | SelectionKey.OP_WRITE);
        this.selectionKey = key;
    }
    createBuffers(sslEngine.getSession());
    // kick off handshake
    socketChannel.write(wrap(emptybuffer));// initializes res
    processHandshake();
}
 
开发者ID:GloriousEggroll,项目名称:quorrabot,代码行数:21,代码来源:SSLSocketChannel2.java

示例4: SSLSocketChannel2

public SSLSocketChannel2( SocketChannel channel , SSLEngine sslEngine , ExecutorService exec , SelectionKey key ) throws IOException {
	if( channel == null || sslEngine == null || exec == null )
		throw new IllegalArgumentException( "parameter must not be null" );

	this.socketChannel = channel;
	this.sslEngine = sslEngine;
	this.exec = exec;

	readEngineResult = writeEngineResult = new SSLEngineResult( Status.BUFFER_UNDERFLOW, sslEngine.getHandshakeStatus(), 0, 0 ); // init to prevent NPEs

	tasks = new ArrayList<Future<?>>( 3 );
	if( key != null ) {
		key.interestOps( key.interestOps() | SelectionKey.OP_WRITE );
		this.selectionKey = key;
	}
	createBuffers( sslEngine.getSession() );
	// kick off request
	socketChannel.write( wrap( emptybuffer ) );// initializes res
	processHandshake();
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:20,代码来源:SSLSocketChannel2.java

示例5: SSLSocketChannel

public SSLSocketChannel(SocketChannel channel, SSLEngine sslEngine, ExecutorService exec, SelectionKey key) throws IOException {
	if(channel == null || sslEngine == null || exec == null)
		throw new IllegalArgumentException("parameter must not be null");

	this.socketChannel = channel;
	this.sslEngine = sslEngine;
	this.exec = exec;

	readEngineResult = writeEngineResult = new SSLEngineResult(Status.BUFFER_UNDERFLOW, sslEngine.getHandshakeStatus(), 0, 0); // init to prevent NPEs

	tasks = new ArrayList<Future<?>>(3);
	if(key != null) {
		key.interestOps(key.interestOps() | SelectionKey.OP_WRITE);
		this.selectionKey = key;
	}
	createBuffers(sslEngine.getSession());
	socketChannel.write(wrap(emptybuffer));
	processHandshake();
}
 
开发者ID:frc2503,项目名称:r2016,代码行数:19,代码来源:SSLSocketChannel.java

示例6: SSLSocketChannel2

public SSLSocketChannel2(SocketChannel channel, SSLEngine sslEngine, ExecutorService exec, SelectionKey key) throws IOException {
    if (channel == null || sslEngine == null || exec == null)
        throw new IllegalArgumentException("parameter must not be null");

    this.socketChannel = channel;
    this.sslEngine = sslEngine;
    this.exec = exec;

    readEngineResult = writeEngineResult = new SSLEngineResult(Status.BUFFER_UNDERFLOW, sslEngine.getHandshakeStatus(), 0, 0); // init to prevent NPEs

    tasks = new ArrayList<Future<?>>(3);
    if (key != null) {
        key.interestOps(key.interestOps() | SelectionKey.OP_WRITE);
        this.selectionKey = key;
    }
    createBuffers(sslEngine.getSession());
    // kick off handshake
    socketChannel.write(wrap(emptybuffer));// initializes res
    processHandshake();
}
 
开发者ID:sensorsdata,项目名称:sa-sdk-android,代码行数:20,代码来源:SSLSocketChannel2.java

示例7: doCallbackIncreaseBufferProcess

protected SSLEngineResult doCallbackIncreaseBufferProcess(HandshakeCallback callback,
        HandshakeBuffer hb) throws SSLException, WebSocketException {
    SSLEngineResult res = null;
    do {
        res = callback.execute(hb);
        if (log.isLoggable(Level.FINER)) {
            log.finer("res: \n" + res);
            log.finer("buffer: " + hb);
        }
        if (res.getStatus() == Status.BUFFER_OVERFLOW) {
            increaseBuffer(hb, hb.localBuffer);
        } else if (res.getStatus() == Status.BUFFER_UNDERFLOW) {
            increaseBuffer(hb, hb.netBuffer);
        }

        if (res.getStatus() != Status.BUFFER_OVERFLOW) {
            break;
        }
    } while (true);
    return res;
}
 
开发者ID:kuiwang,项目名称:my-dev,代码行数:21,代码来源:SSLHandshake.java

示例8: getStatus

/**
 * Returns the current status for this TLSHandler.
 *
 * @return the current TLSStatus
 */
public TLSStatus getStatus() {
    if (tlsEngineResult != null && tlsEngineResult.getStatus() == Status.BUFFER_UNDERFLOW) {
        return TLSStatus.UNDERFLOW;
    } else {
        if (tlsEngineResult != null && tlsEngineResult.getStatus() == Status.CLOSED) {
            return TLSStatus.CLOSED;
        } else {
            switch (tlsEngine.getHandshakeStatus()) {
            case NEED_WRAP:
                return TLSStatus.NEED_WRITE;
            case NEED_UNWRAP:
                return TLSStatus.NEED_READ;
            default:
                return TLSStatus.OK;
            }
        }
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:23,代码来源:TLSWrapper.java

示例9: SSLSocketChannel2

public SSLSocketChannel2( SocketChannel channel , SSLEngine sslEngine , ExecutorService exec , SelectionKey key ) throws IOException {
    if( channel == null || sslEngine == null || exec == null )
        throw new IllegalArgumentException( "parameter must not be null" );

    this.socketChannel = channel;
    this.sslEngine = sslEngine;
    this.exec = exec;

    readEngineResult = writeEngineResult = new SSLEngineResult( Status.BUFFER_UNDERFLOW, sslEngine.getHandshakeStatus(), 0, 0 ); // init to prevent NPEs

    tasks = new ArrayList<Future<?>>( 3 );
    if( key != null ) {
        key.interestOps( key.interestOps() | SelectionKey.OP_WRITE );
        this.selectionKey = key;
    }
    createBuffers( sslEngine.getSession() );
    // kick off handshake
    socketChannel.write( wrap( emptybuffer ) );// initializes res
    processHandshake();
}
 
开发者ID:snowhow,项目名称:cordova-plugin-gpstrack,代码行数:20,代码来源:SSLSocketChannel2.java

示例10: getStatus

/**
 * Returns the current status for this TLSHandler.
 *
 * @return the current TLSStatus
 */
public TLSStatus getStatus() {
    TLSStatus status = null;
    if (tlsEngineResult != null && tlsEngineResult.getStatus() == Status.BUFFER_UNDERFLOW) {
        status = TLSStatus.UNDERFLOW;
    } else {
        if (tlsEngineResult != null && tlsEngineResult.getStatus() == Status.CLOSED) {
            status = TLSStatus.CLOSED;
        } else {
            switch (tlsEngine.getHandshakeStatus()) {
            case NEED_WRAP:
                status = TLSStatus.NEED_WRITE;
                break;
            case NEED_UNWRAP:
                status = TLSStatus.NEED_READ;
                break;
            default:
                status = TLSStatus.OK;
                break;
            }
        }
    }
    return status;
}
 
开发者ID:surevine,项目名称:openfire-bespoke,代码行数:28,代码来源:TLSWrapper.java

示例11: 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

示例12: read

public int read(ByteBuffer dst) throws IOException {
    if (!dst.hasRemaining()) {
        return 0;
    }
    if (!isHandShakeComplete()) {
        if (isBlocking()) {
            while (!isHandShakeComplete()) {
                processHandshake();
            }
        } else {
            processHandshake();
            if (!isHandShakeComplete()) {
                return 0;
            }
        }
    }
    int purged = readRemaining(dst);
    if (purged != 0) {
        return purged;
    }
    if ($assertionsDisabled || this.inData.position() == 0) {
        this.inData.clear();
        if (this.inCrypt.hasRemaining()) {
            this.inCrypt.compact();
        } else {
            this.inCrypt.clear();
        }
        if (((isBlocking() && this.inCrypt.position() == 0) || this.engineStatus == Status.BUFFER_UNDERFLOW) && this.socketChannel.read(this.inCrypt) == -1) {
            return -1;
        }
        this.inCrypt.flip();
        unwrap();
        int transfered = transfereTo(this.inData, dst);
        return (transfered == 0 && isBlocking()) ? read(dst) : transfered;
    } else {
        throw new AssertionError();
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:38,代码来源:SSLSocketChannel2.java

示例13: write

/**
* Writes a sequence of bytes to this channel from the given buffer.
*
* @param src The buffer from which bytes are to be retrieved
* @return The number of bytes read, possibly zero, or -1 if the channel has reached end-of-stream
* @throws IOException If some other I/O error occurs
*/
@Override
public int write(ByteBuffer src) throws IOException {
    int written = 0;
    if (closing) throw new IllegalStateException("Channel is in closing state");
    if (!handshakeComplete) return written;

    if (!flush(netWriteBuffer))
        return written;

    netWriteBuffer.clear();
    SSLEngineResult wrapResult = sslEngine.wrap(src, netWriteBuffer);
    netWriteBuffer.flip();

    //handle ssl renegotiation
    if (wrapResult.getHandshakeStatus() != HandshakeStatus.NOT_HANDSHAKING && wrapResult.getStatus() == Status.OK) {
        renegotiate();
        return written;
    }

    if (wrapResult.getStatus() == Status.OK) {
        written = wrapResult.bytesConsumed();
        flush(netWriteBuffer);
    } else if (wrapResult.getStatus() == Status.BUFFER_OVERFLOW) {
        int currentNetWriteBufferSize = netWriteBufferSize();
        netWriteBuffer.compact();
        netWriteBuffer = Utils.ensureCapacity(netWriteBuffer, currentNetWriteBufferSize);
        netWriteBuffer.flip();
        if (netWriteBuffer.limit() >= currentNetWriteBufferSize)
            throw new IllegalStateException("SSL BUFFER_OVERFLOW when available data size (" + netWriteBuffer.limit() + ") >= network buffer size (" + currentNetWriteBufferSize + ")");
    } else if (wrapResult.getStatus() == Status.BUFFER_UNDERFLOW) {
        throw new IllegalStateException("SSL BUFFER_UNDERFLOW during write");
    } else if (wrapResult.getStatus() == Status.CLOSED) {
        throw new EOFException();
    }
    return written;
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:43,代码来源:SslTransportLayer.java

示例14: checkResult

private void checkResult(SSLEngineResult result, boolean wrap) throws SSLException {

			handshakeStatus = result.getHandshakeStatus();
			resultStatus = result.getStatus();

			if (resultStatus != Status.OK && (wrap || resultStatus != Status.BUFFER_UNDERFLOW)) {
				throw new SSLException("TODO");
			}
			if (wrap && result.bytesConsumed() != 0) {
				throw new SSLException("TODO");
			}
			if (!wrap && result.bytesProduced() != 0) {
				throw new SSLException("TODO");
			}
		}
 
开发者ID:how2j,项目名称:lazycat,代码行数:15,代码来源:AsyncChannelWrapperSecure.java

示例15: decrypt

public ReuseableMergedByteBuffers decrypt(final MergedByteBuffers bb) throws EncryptionException {
  final ReuseableMergedByteBuffers mbb = new ReuseableMergedByteBuffers(false);
  if(!this.startedHandshake.get()) {
    mbb.add(bb);
    return mbb;
  }
  encryptedReadBuffers.add(bb);
  final ByteBuffer encBB = encryptedReadBuffers.pullBuffer(encryptedReadBuffers.remaining());
  while(encBB.remaining() > 0) {
    int lastSize = encBB.remaining();
    final ByteBuffer dbb = getDecryptedByteBuffer();
    final ByteBuffer newBB = dbb.duplicate();
    SSLEngineResult res;
    try {
      res = ssle.unwrap(encBB, dbb);
      //We have to check both each time till complete
      if(! handshakeFuture.isDone()) {
        processHandshake(res.getHandshakeStatus());
        processHandshake(ssle.getHandshakeStatus());
      }
    } catch (SSLException e) {
      throw new EncryptionException(e);
    }
    newBB.limit(dbb.position());
    if(newBB.hasRemaining()) {
      mbb.add(newBB);
    } else if (res.getStatus() == Status.BUFFER_UNDERFLOW || (lastSize > 0 && lastSize == encBB.remaining())) {
      if(encBB.hasRemaining()) {
        encryptedReadBuffers.add(encBB);
      }
      break;
    }
  }
  return mbb;

}
 
开发者ID:threadly,项目名称:litesockets,代码行数:36,代码来源:SSLProcessor.java


注:本文中的javax.net.ssl.SSLEngineResult.Status.BUFFER_UNDERFLOW属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。