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

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

Introduction

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

Prototype

String username

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

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  ww  w . ja v a2s  .  c  o  m*/
        Socks5PasswordAuthResponse passwordAuthResponse = new DefaultSocks5PasswordAuthResponse(
                Socks5PasswordAuthStatus.FAILURE);
        //??????channel
        ctx.writeAndFlush(passwordAuthResponse).addListener(ChannelFutureListener.CLOSE);
    }
}