Home / Class/ SocksAuthRequest Class — netty Architecture

SocksAuthRequest Class — netty Architecture

Architecture documentation for the SocksAuthRequest class in SocksAuthRequest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  11085beb_9f00_41e4_2195_72be7e6fd523["SocksAuthRequest"]
  2fe2b88b_1bd5_8929_ce98_a86bf44dca05["SocksAuthRequest.java"]
  11085beb_9f00_41e4_2195_72be7e6fd523 -->|defined in| 2fe2b88b_1bd5_8929_ce98_a86bf44dca05
  f3a049dc_a615_92ec_3f62_73f738f5fadf["SocksAuthRequest()"]
  11085beb_9f00_41e4_2195_72be7e6fd523 -->|method| f3a049dc_a615_92ec_3f62_73f738f5fadf
  86b986ac_be5d_9555_c618_d2eb25a7df42["String()"]
  11085beb_9f00_41e4_2195_72be7e6fd523 -->|method| 86b986ac_be5d_9555_c618_d2eb25a7df42
  dde6fb6e_85fd_895c_0387_eabaa609b80b["encodeAsByteBuf()"]
  11085beb_9f00_41e4_2195_72be7e6fd523 -->|method| dde6fb6e_85fd_895c_0387_eabaa609b80b

Relationship Graph

Source Code

codec-socks/src/main/java/io/netty/handler/codec/socks/SocksAuthRequest.java lines 30–80

public final class SocksAuthRequest extends SocksRequest {
    private static final SocksSubnegotiationVersion SUBNEGOTIATION_VERSION = SocksSubnegotiationVersion.AUTH_PASSWORD;
    private final String username;
    private final String password;

    public SocksAuthRequest(String username, String password) {
        super(SocksRequestType.AUTH);
        ObjectUtil.checkNotNull(username, "username");
        ObjectUtil.checkNotNull(password, "password");
        final CharsetEncoder asciiEncoder = CharsetUtil.encoder(CharsetUtil.US_ASCII);
        if (!asciiEncoder.canEncode(username) || !asciiEncoder.canEncode(password)) {
            throw new IllegalArgumentException(
                    "username: " + username + " or password: **** values should be in pure ascii");
        }
        if (username.length() > 255) {
            throw new IllegalArgumentException("username: " + username + " exceeds 255 char limit");
        }
        if (password.length() > 255) {
            throw new IllegalArgumentException("password: **** exceeds 255 char limit");
        }
        this.username = username;
        this.password = password;
    }

    /**
     * Returns username that needs to be authenticated
     *
     * @return username that needs to be authenticated
     */
    public String username() {
        return username;
    }

    /**
     * Returns password that needs to be validated
     *
     * @return password that needs to be validated
     */
    public String password() {
        return password;
    }

    @Override
    public void encodeAsByteBuf(ByteBuf byteBuf) {
        byteBuf.writeByte(SUBNEGOTIATION_VERSION.byteValue());
        byteBuf.writeByte(username.length());
        byteBuf.writeCharSequence(username, CharsetUtil.US_ASCII);
        byteBuf.writeByte(password.length());
        byteBuf.writeCharSequence(password, CharsetUtil.US_ASCII);
    }
}

Frequently Asked Questions

What is the SocksAuthRequest class?
SocksAuthRequest is a class in the netty codebase, defined in codec-socks/src/main/java/io/netty/handler/codec/socks/SocksAuthRequest.java.
Where is SocksAuthRequest defined?
SocksAuthRequest is defined in codec-socks/src/main/java/io/netty/handler/codec/socks/SocksAuthRequest.java at line 30.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free