當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。