Home / Class/ ExampleOcspClientHandler Class — netty Architecture

ExampleOcspClientHandler Class — netty Architecture

Architecture documentation for the ExampleOcspClientHandler class in OcspClientExample.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  f002386d_c8a1_f43e_732b_a343ebbe5d63["ExampleOcspClientHandler"]
  78bd9b38_0697_2858_7e74_e153357ddaa0["OcspClientExample.java"]
  f002386d_c8a1_f43e_732b_a343ebbe5d63 -->|defined in| 78bd9b38_0697_2858_7e74_e153357ddaa0
  c83912b3_2a3c_4f9b_d837_ac84708794d8["ExampleOcspClientHandler()"]
  f002386d_c8a1_f43e_732b_a343ebbe5d63 -->|method| c83912b3_2a3c_4f9b_d837_ac84708794d8
  2a4433c3_a383_f7f0_c1d2_eb1493fef9e5["verify()"]
  f002386d_c8a1_f43e_732b_a343ebbe5d63 -->|method| 2a4433c3_a383_f7f0_c1d2_eb1493fef9e5

Relationship Graph

Source Code

example/src/main/java/io/netty/example/ocsp/OcspClientExample.java lines 207–248

    private static class ExampleOcspClientHandler extends OcspClientHandler {

        ExampleOcspClientHandler(ReferenceCountedOpenSslEngine engine) {
            super(engine);
        }

        @Override
        protected boolean verify(ChannelHandlerContext ctx, ReferenceCountedOpenSslEngine engine) throws Exception {
            byte[] staple = engine.getOcspResponse();
            if (staple == null) {
                throw new IllegalStateException("Server didn't provide an OCSP staple!");
            }

            OCSPResp response = new OCSPResp(staple);
            if (response.getStatus() != OCSPResponseStatus.SUCCESSFUL) {
                return false;
            }

            SSLSession session = engine.getSession();
            X509Certificate[] chain = session.getPeerCertificateChain();
            BigInteger certSerial = chain[0].getSerialNumber();

            BasicOCSPResp basicResponse = (BasicOCSPResp) response.getResponseObject();
            SingleResp first = basicResponse.getResponses()[0];

            // ATTENTION: CertificateStatus.GOOD is actually a null value! Do not use
            // equals() or you'll NPE!
            CertificateStatus status = first.getCertStatus();
            BigInteger ocspSerial = first.getCertID().getSerialNumber();
            String message = new StringBuilder()
                .append("OCSP status of ").append(ctx.channel().remoteAddress())
                .append("\n  Status: ").append(status == CertificateStatus.GOOD ? "Good" : status)
                .append("\n  This Update: ").append(first.getThisUpdate())
                .append("\n  Next Update: ").append(first.getNextUpdate())
                .append("\n  Cert Serial: ").append(certSerial)
                .append("\n  OCSP Serial: ").append(ocspSerial)
                .toString();
            System.out.println(message);

            return status == CertificateStatus.GOOD && certSerial.equals(ocspSerial);
        }
    }

Frequently Asked Questions

What is the ExampleOcspClientHandler class?
ExampleOcspClientHandler is a class in the netty codebase, defined in example/src/main/java/io/netty/example/ocsp/OcspClientExample.java.
Where is ExampleOcspClientHandler defined?
ExampleOcspClientHandler is defined in example/src/main/java/io/netty/example/ocsp/OcspClientExample.java at line 207.

Analyze Your Own Codebase

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

Try Supermodel Free