Java Code Examples for org.tio.core.intf.Packet#isSslEncrypted()

The following examples show how to use org.tio.core.intf.Packet#isSslEncrypted() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SendRunnable.java    From t-io with Apache License 2.0 6 votes vote down vote up
public boolean sendPacket(Packet packet) {
	ByteBuffer byteBuffer = getByteBuffer(packet);
	if (isSsl) {
		if (!packet.isSslEncrypted()) {
			SslVo sslVo = new SslVo(byteBuffer, packet);
			try {
				channelContext.sslFacadeContext.getSslFacade().encrypt(sslVo);
				byteBuffer = sslVo.getByteBuffer();
			} catch (SSLException e) {
				log.error(channelContext.toString() + ", 进行SSL加密时发生了异常", e);
				Tio.close(channelContext, "进行SSL加密时发生了异常", CloseCode.SSL_ENCRYPTION_ERROR);
				return false;
			}
		}
	}

	sendByteBuffer(byteBuffer, packet);
	return true;
}
 
Example 2
Source File: SslUtils.java    From t-io with Apache License 2.0 5 votes vote down vote up
/**
 * 是否需要对这个packet进行SSL加密 
 * @param packet
 * @param tioConfig
 * @return
 */
public static boolean needSslEncrypt(Packet packet, TioConfig tioConfig) {
	if (!packet.isSslEncrypted() && tioConfig.sslConfig != null) {
		return true;
	}
	return false;
}