@Override protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception { int len = msg.readInt(); if (len == SaslUtil.SWITCH_TO_SIMPLE_AUTH) { saslRpcClient.dispose(); if (saslRpcClient.fallbackAllowed) { saslPromise.trySuccess(false); } else { saslPromise.tryFailure(new FallbackDisallowedException()); } return; } LOG.trace("Reading input token size={} for processing by initSASLContext", len); final byte[] challenge = new byte[len]; msg.readBytes(challenge); byte[] response = ugi.doAs(new PrivilegedExceptionAction<byte[]>() { @Override public byte[] run() throws Exception { return saslRpcClient.evaluateChallenge(challenge); } }); if (response != null) { writeResponse(ctx, response); } tryComplete(ctx); }
@Override protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception { // read the ConnectionHeaderResponse from server int len = msg.readInt(); byte[] buff = new byte[len]; msg.readBytes(buff); RPCProtos.ConnectionHeaderResponse connectionHeaderResponse = RPCProtos.ConnectionHeaderResponse.parseFrom(buff); // Get the CryptoCipherMeta, update the HBaseSaslRpcClient for Crypto Cipher if (connectionHeaderResponse.hasCryptoCipherMeta()) { CryptoAES cryptoAES = EncryptionUtil.createCryptoAES( connectionHeaderResponse.getCryptoCipherMeta(), conf); // replace the Sasl handler with Crypto AES handler setupCryptoAESHandler(ctx.pipeline(), cryptoAES); } saslPromise.setSuccess(true); }
private void readResponse(ChannelHandlerContext ctx, ByteBuf buf) throws IOException { int totalSize = buf.readInt(); ByteBufInputStream in = new ByteBufInputStream(buf); ResponseHeader responseHeader = ResponseHeader.parseDelimitedFrom(in);
@Override protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception { int len = msg.readInt(); if (len == SaslUtil.SWITCH_TO_SIMPLE_AUTH) { saslRpcClient.dispose(); if (saslRpcClient.fallbackAllowed) { saslPromise.trySuccess(false); } else { saslPromise.tryFailure(new FallbackDisallowedException()); } return; } LOG.trace("Reading input token size={} for processing by initSASLContext", len); final byte[] challenge = new byte[len]; msg.readBytes(challenge); byte[] response = ugi.doAs(new PrivilegedExceptionAction<byte[]>() { @Override public byte[] run() throws Exception { return saslRpcClient.evaluateChallenge(challenge); } }); if (response != null) { writeResponse(ctx, response); } tryComplete(ctx); }
/** * Reads a big-endian (31-bit) integer from the buffer. */ public static int readUnsignedInt(ByteBuf buf) { return buf.readInt() & 0x7fffffff; }
@Override public int readIntLE() { return buf.readInt(); }
@Override protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception { // read the ConnectionHeaderResponse from server int len = msg.readInt(); byte[] buff = new byte[len]; msg.readBytes(buff); RPCProtos.ConnectionHeaderResponse connectionHeaderResponse = RPCProtos.ConnectionHeaderResponse.parseFrom(buff); // Get the CryptoCipherMeta, update the HBaseSaslRpcClient for Crypto Cipher if (connectionHeaderResponse.hasCryptoCipherMeta()) { CryptoAES cryptoAES = EncryptionUtil.createCryptoAES( connectionHeaderResponse.getCryptoCipherMeta(), conf); // replace the Sasl handler with Crypto AES handler setupCryptoAESHandler(ctx.pipeline(), cryptoAES); } saslPromise.setSuccess(true); }
@Override public int readInt() { return buf.readInt(); }
private void readResponse(ChannelHandlerContext ctx, ByteBuf buf) throws IOException { int totalSize = buf.readInt(); ByteBufInputStream in = new ByteBufInputStream(buf); ResponseHeader responseHeader = ResponseHeader.parseDelimitedFrom(in);
@Override public int readInt() { checkReadableBytes(4); return buffer.readInt(); }
@Override public int readInt() { return ByteBufUtil.swapInt(buf.readInt()); }
@Override public int readInt() throws IOException { checkAvailable(4); return buffer.readInt(); }
@Override protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception { int len = msg.readInt(); if (len == SaslUtil.SWITCH_TO_SIMPLE_AUTH) { saslRpcClient.dispose(); if (saslRpcClient.fallbackAllowed) { saslPromise.trySuccess(false); } else { saslPromise.tryFailure(new FallbackDisallowedException()); } return; } if (LOG.isDebugEnabled()) { LOG.debug("Will read input token of size " + len + " for processing by initSASLContext"); } final byte[] challenge = new byte[len]; msg.readBytes(challenge); byte[] response = ugi.doAs(new PrivilegedExceptionAction<byte[]>() { @Override public byte[] run() throws Exception { return saslRpcClient.evaluateChallenge(challenge); } }); if (response != null) { writeResponse(ctx, response); } tryComplete(ctx); }
@Override protected BinaryMemcacheRequest decodeHeader(ByteBuf in) { DefaultBinaryMemcacheRequest header = new DefaultBinaryMemcacheRequest(); header.setMagic(in.readByte()); header.setOpcode(in.readByte()); header.setKeyLength(in.readShort()); header.setExtrasLength(in.readByte()); header.setDataType(in.readByte()); header.setReserved(in.readShort()); header.setTotalBodyLength(in.readInt()); header.setOpaque(in.readInt()); header.setCas(in.readLong()); return header; }
@Override protected BinaryMemcacheResponse decodeHeader(ByteBuf in) { DefaultBinaryMemcacheResponse header = new DefaultBinaryMemcacheResponse(); header.setMagic(in.readByte()); header.setOpcode(in.readByte()); header.setKeyLength(in.readShort()); header.setExtrasLength(in.readByte()); header.setDataType(in.readByte()); header.setStatus(in.readShort()); header.setTotalBodyLength(in.readInt()); header.setOpaque(in.readInt()); header.setCas(in.readLong()); return header; }
@Override protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception { // read the ConnectionHeaderResponse from server int len = msg.readInt(); byte[] buff = new byte[len]; msg.readBytes(buff); RPCProtos.ConnectionHeaderResponse connectionHeaderResponse = RPCProtos.ConnectionHeaderResponse.parseFrom(buff); // Get the CryptoCipherMeta, update the HBaseSaslRpcClient for Crypto Cipher if (connectionHeaderResponse.hasCryptoCipherMeta()) { CryptoAES cryptoAES = EncryptionUtil.createCryptoAES( connectionHeaderResponse.getCryptoCipherMeta(), conf); // replace the Sasl handler with Crypto AES handler setupCryptoAESHandler(ctx.pipeline(), cryptoAES); } saslPromise.setSuccess(true); }
final ByteBuf byteBuf = header.readSlice(length); final byte client = byteBuf.readByte(); final int verify = byteBuf.readInt();
final String dstAddr = NetUtil.intToIpAddress(in.readInt());
dstAddr = NetUtil.intToIpAddress(in.readInt()); checkpoint(State.READ_USERID);
@Override public String decodeAddress(Socks5AddressType addrType, ByteBuf in) throws Exception { if (addrType == Socks5AddressType.IPv4) { return NetUtil.intToIpAddress(in.readInt()); } if (addrType == Socks5AddressType.DOMAIN) { final int length = in.readUnsignedByte(); final String domain = in.toString(in.readerIndex(), length, CharsetUtil.US_ASCII); in.skipBytes(length); return domain; } if (addrType == Socks5AddressType.IPv6) { if (in.hasArray()) { final int readerIdx = in.readerIndex(); in.readerIndex(readerIdx + IPv6_LEN); return NetUtil.bytesToIpAddress(in.array(), in.arrayOffset() + readerIdx, IPv6_LEN); } else { byte[] tmp = new byte[IPv6_LEN]; in.readBytes(tmp); return NetUtil.bytesToIpAddress(tmp); } } else { throw new DecoderException("unsupported address type: " + (addrType.byteValue() & 0xFF)); } } };