Home / Function/ authenticate() — netty Function Reference

authenticate() — netty Function Reference

Architecture documentation for the authenticate() function in HttpProxyServer.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  53be49a0_9a3d_011c_81ec_41cafe0e8353["authenticate()"]
  7398b183_c32e_55ec_e1e5_f9d148e814ea["HttpProxyServer"]
  53be49a0_9a3d_011c_81ec_41cafe0e8353 -->|defined in| 7398b183_c32e_55ec_e1e5_f9d148e814ea
  91005a3a_7b43_4ee7_4384_456793529f8a["handleProxyProtocol()"]
  91005a3a_7b43_4ee7_4384_456793529f8a -->|calls| 53be49a0_9a3d_011c_81ec_41cafe0e8353
  0b96569d_afe9_bbb8_48b0_efef32f1bdac["handleProxyProtocol()"]
  0b96569d_afe9_bbb8_48b0_efef32f1bdac -->|calls| 53be49a0_9a3d_011c_81ec_41cafe0e8353
  style 53be49a0_9a3d_011c_81ec_41cafe0e8353 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

handler-proxy/src/test/java/io/netty/handler/proxy/HttpProxyServer.java lines 75–105

    private boolean authenticate(ChannelHandlerContext ctx, FullHttpRequest req) {
        assertEquals(HttpMethod.CONNECT, req.method());

        if (testMode != TestMode.INTERMEDIARY) {
            ctx.pipeline().addBefore(ctx.name(), "lineDecoder", new LineBasedFrameDecoder(64, false, true));
        }

        ctx.pipeline().remove(HttpObjectAggregator.class);
        ctx.pipeline().get(HttpServerCodec.class).removeInboundHandler();

        boolean authzSuccess = false;
        if (username != null) {
            CharSequence authz = req.headers().get(HttpHeaderNames.PROXY_AUTHORIZATION);
            if (authz != null) {
                String[] authzParts = authz.toString().split(" ", 2);
                ByteBuf authzBuf64 = Unpooled.copiedBuffer(authzParts[1], CharsetUtil.US_ASCII);
                ByteBuf authzBuf = Base64.decode(authzBuf64);

                String expectedAuthz = username + ':' + password;
                authzSuccess = "Basic".equals(authzParts[0]) &&
                               expectedAuthz.equals(authzBuf.toString(CharsetUtil.US_ASCII));

                authzBuf64.release();
                authzBuf.release();
            }
        } else {
            authzSuccess = true;
        }

        return authzSuccess;
    }

Domain

Subdomains

Frequently Asked Questions

What does authenticate() do?
authenticate() is a function in the netty codebase, defined in handler-proxy/src/test/java/io/netty/handler/proxy/HttpProxyServer.java.
Where is authenticate() defined?
authenticate() is defined in handler-proxy/src/test/java/io/netty/handler/proxy/HttpProxyServer.java at line 75.
What calls authenticate()?
authenticate() is called by 2 function(s): handleProxyProtocol, handleProxyProtocol.

Analyze Your Own Codebase

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

Try Supermodel Free