1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package io.netty.handler.codec.haproxy;
18
19 import io.netty.buffer.ByteBuf;
20 import io.netty.buffer.Unpooled;
21 import io.netty.util.internal.StringUtil;
22
23 import java.util.Collections;
24 import java.util.List;
25
26
27
28
29
30 public final class HAProxySSLTLV extends HAProxyTLV {
31
32 private final int verify;
33 private final List<HAProxyTLV> tlvs;
34 private final byte clientBitField;
35
36
37
38
39
40
41
42
43
44 public HAProxySSLTLV(final int verify, final byte clientBitField, final List<HAProxyTLV> tlvs) {
45 this(verify, clientBitField, tlvs, Unpooled.EMPTY_BUFFER);
46 }
47
48
49
50
51
52
53
54
55
56
57 HAProxySSLTLV(final int verify, final byte clientBitField, final List<HAProxyTLV> tlvs, final ByteBuf rawContent) {
58 super(Type.PP2_TYPE_SSL, (byte) 0x20, rawContent);
59
60 this.verify = verify;
61 this.tlvs = Collections.unmodifiableList(tlvs);
62 this.clientBitField = clientBitField;
63 }
64
65
66
67
68 public boolean isPP2ClientCertConn() {
69 return (clientBitField & 0x2) != 0;
70 }
71
72
73
74
75 public boolean isPP2ClientSSL() {
76 return (clientBitField & 0x1) != 0;
77 }
78
79
80
81
82 public boolean isPP2ClientCertSess() {
83 return (clientBitField & 0x4) != 0;
84 }
85
86
87
88
89 public byte client() {
90 return clientBitField;
91 }
92
93
94
95
96 public int verify() {
97 return verify;
98 }
99
100
101
102
103 public List<HAProxyTLV> encapsulatedTLVs() {
104 return tlvs;
105 }
106
107 @Override
108 int contentNumBytes() {
109 int tlvNumBytes = 0;
110 for (int i = 0; i < tlvs.size(); i++) {
111 tlvNumBytes += tlvs.get(i).totalNumBytes();
112 }
113 return 5 + tlvNumBytes;
114 }
115
116 @Override
117 public String toString() {
118 return StringUtil.simpleClassName(this) +
119 "(type: " + type() +
120 ", typeByteValue: " + typeByteValue() +
121 ", client: " + client() +
122 ", verify: " + verify() +
123 ", numEncapsulatedTlvs: " + tlvs.size() + ')';
124 }
125 }