Example usage for io.netty.handler.codec.socksx.v5 DefaultSocks5PasswordAuthRequest password

List of usage examples for io.netty.handler.codec.socksx.v5 DefaultSocks5PasswordAuthRequest password

Introduction

In this page you can find the example usage for io.netty.handler.codec.socksx.v5 DefaultSocks5PasswordAuthRequest password.

Prototype

String password

To view the source code for io.netty.handler.codec.socksx.v5 DefaultSocks5PasswordAuthRequest password.

Click Source Link

Usage

From source file:com.slyak.services.proxy.handler.Socks5PasswordAuthRequestHandler.java

License:Apache License

@Override
protected void channelRead0(ChannelHandlerContext ctx, DefaultSocks5PasswordAuthRequest msg) throws Exception {
    if (authProvider.authenticate(msg.username(), msg.password())) {
        Socks5PasswordAuthResponse passwordAuthResponse = new DefaultSocks5PasswordAuthResponse(
                Socks5PasswordAuthStatus.SUCCESS);
        ctx.writeAndFlush(passwordAuthResponse);
    } else {/*from w ww .  j av a 2 s. co m*/
        Socks5PasswordAuthResponse passwordAuthResponse = new DefaultSocks5PasswordAuthResponse(
                Socks5PasswordAuthStatus.FAILURE);
        //??????channel
        ctx.writeAndFlush(passwordAuthResponse).addListener(ChannelFutureListener.CLOSE);
    }
}