58 final InputRecord inputRecord; |
57 final InputRecord inputRecord; |
59 final OutputRecord outputRecord; |
58 final OutputRecord outputRecord; |
60 |
59 |
61 // connection status |
60 // connection status |
62 boolean isUnsureMode; |
61 boolean isUnsureMode; |
63 boolean isNegotiated; |
62 boolean isNegotiated = false; |
64 boolean isBroken; |
63 boolean isBroken = false; |
65 boolean isInputCloseNotified; |
64 boolean isInputCloseNotified = false; |
66 boolean isOutputCloseNotified; |
65 boolean isOutputCloseNotified = false; |
67 Exception closeReason; |
66 Exception closeReason = null; |
68 |
67 |
69 // negotiated security parameters |
68 // negotiated security parameters |
70 SSLSessionImpl conSession; |
69 SSLSessionImpl conSession; |
71 ProtocolVersion protocolVersion; |
70 ProtocolVersion protocolVersion; |
72 String applicationProtocol; |
71 String applicationProtocol= null; |
73 |
72 |
74 // handshake context |
73 // handshake context |
75 HandshakeContext handshakeContext; |
74 HandshakeContext handshakeContext = null; |
76 |
75 |
77 // connection reserved status for handshake. |
76 // connection reserved status for handshake. |
78 boolean secureRenegotiation; |
77 boolean secureRenegotiation = false; |
79 byte[] clientVerifyData; |
78 byte[] clientVerifyData; |
80 byte[] serverVerifyData; |
79 byte[] serverVerifyData; |
81 |
80 |
82 // connection sensitive configuration |
81 // connection sensitive configuration |
83 List<NamedGroup> serverRequestedNamedGroups; |
82 List<NamedGroup> serverRequestedNamedGroups; |
84 |
83 |
85 SecretKey baseWriteSecret, baseReadSecret; |
|
86 CipherSuite cipherSuite; |
84 CipherSuite cipherSuite; |
|
85 private static final byte[] emptyByteArray = new byte[0]; |
87 |
86 |
88 // Please never use the transport parameter other than storing a |
87 // Please never use the transport parameter other than storing a |
89 // reference to this object. |
88 // reference to this object. |
|
89 // Called by SSLEngineImpl |
90 TransportContext(SSLContextImpl sslContext, SSLTransport transport, |
90 TransportContext(SSLContextImpl sslContext, SSLTransport transport, |
91 InputRecord inputRecord, OutputRecord outputRecord) { |
91 InputRecord inputRecord, OutputRecord outputRecord) { |
|
92 this(sslContext, transport, new SSLConfiguration(sslContext, true), |
|
93 inputRecord, outputRecord, true); |
|
94 } |
|
95 |
|
96 // Please never use the transport parameter other than storing a |
|
97 // reference to this object. |
|
98 // Called by SSLSocketImpl |
|
99 TransportContext(SSLContextImpl sslContext, SSLTransport transport, |
|
100 InputRecord inputRecord, OutputRecord outputRecord, |
|
101 boolean isClientMode) { |
|
102 this(sslContext, transport, |
|
103 new SSLConfiguration(sslContext, isClientMode), |
|
104 inputRecord, outputRecord,false); |
|
105 } |
|
106 |
|
107 // Please never use the transport parameter other than storing a |
|
108 // reference to this object. |
|
109 // Called by SSLSocketImpl with an existing SSLConfig |
|
110 TransportContext(SSLContextImpl sslContext, SSLTransport transport, |
|
111 SSLConfiguration sslConfig, |
|
112 InputRecord inputRecord, OutputRecord outputRecord) { |
|
113 this(sslContext, transport, (SSLConfiguration)sslConfig.clone(), |
|
114 inputRecord, outputRecord, false); |
|
115 } |
|
116 |
|
117 private TransportContext(SSLContextImpl sslContext, SSLTransport transport, |
|
118 SSLConfiguration sslConfig, InputRecord inputRecord, |
|
119 OutputRecord outputRecord, boolean isUnsureMode) { |
92 this.transport = transport; |
120 this.transport = transport; |
93 this.sslContext = sslContext; |
121 this.sslContext = sslContext; |
94 this.inputRecord = inputRecord; |
122 this.inputRecord = inputRecord; |
95 this.outputRecord = outputRecord; |
123 this.outputRecord = outputRecord; |
96 this.sslConfig = new SSLConfiguration(sslContext, true); |
124 this.sslConfig = sslConfig; |
97 this.sslConfig.maximumPacketSize = outputRecord.getMaxPacketSize(); |
|
98 this.isUnsureMode = true; |
|
99 |
|
100 initialize(); |
|
101 |
|
102 this.acc = AccessController.getContext(); |
|
103 this.consumers = new HashMap<>(); |
|
104 } |
|
105 |
|
106 // Please never use the transport parameter other than storing a |
|
107 // reference to this object. |
|
108 TransportContext(SSLContextImpl sslContext, SSLTransport transport, |
|
109 InputRecord inputRecord, OutputRecord outputRecord, |
|
110 boolean isClientMode) { |
|
111 this.transport = transport; |
|
112 this.sslContext = sslContext; |
|
113 this.inputRecord = inputRecord; |
|
114 this.outputRecord = outputRecord; |
|
115 this.sslConfig = new SSLConfiguration(sslContext, isClientMode); |
|
116 this.sslConfig.maximumPacketSize = outputRecord.getMaxPacketSize(); |
|
117 this.isUnsureMode = false; |
|
118 |
|
119 initialize(); |
|
120 |
|
121 this.acc = AccessController.getContext(); |
|
122 this.consumers = new HashMap<>(); |
|
123 } |
|
124 |
|
125 // Please never use the transport parameter other than storing a |
|
126 // reference to this object. |
|
127 TransportContext(SSLContextImpl sslContext, SSLTransport transport, |
|
128 SSLConfiguration sslConfig, |
|
129 InputRecord inputRecord, OutputRecord outputRecord) { |
|
130 this.transport = transport; |
|
131 this.sslContext = sslContext; |
|
132 this.inputRecord = inputRecord; |
|
133 this.outputRecord = outputRecord; |
|
134 this.sslConfig = (SSLConfiguration)sslConfig.clone(); |
|
135 if (this.sslConfig.maximumPacketSize == 0) { |
125 if (this.sslConfig.maximumPacketSize == 0) { |
136 this.sslConfig.maximumPacketSize = outputRecord.getMaxPacketSize(); |
126 this.sslConfig.maximumPacketSize = outputRecord.getMaxPacketSize(); |
137 } |
127 } |
138 this.isUnsureMode = false; |
128 this.isUnsureMode = isUnsureMode; |
139 |
129 |
140 initialize(); |
|
141 |
|
142 this.acc = AccessController.getContext(); |
|
143 this.consumers = new HashMap<>(); |
|
144 } |
|
145 |
|
146 // Initialize the non-final class variables. |
|
147 private void initialize() { |
|
148 // initial security parameters |
130 // initial security parameters |
149 this.conSession = SSLSessionImpl.nullSession; |
131 this.conSession = SSLSessionImpl.nullSession; |
150 this.protocolVersion = this.sslConfig.maximumProtocolVersion; |
132 this.protocolVersion = this.sslConfig.maximumProtocolVersion; |
151 this.applicationProtocol = null; |
133 this.clientVerifyData = emptyByteArray; |
152 |
134 this.serverVerifyData = emptyByteArray; |
153 // initial handshake context |
135 |
154 this.handshakeContext = null; |
136 this.acc = AccessController.getContext(); |
155 |
137 this.consumers = new HashMap<>(); |
156 // initial security parameters for secure renegotiation |
|
157 this.secureRenegotiation = false; |
|
158 this.clientVerifyData = new byte[0]; |
|
159 this.serverVerifyData = new byte[0]; |
|
160 |
|
161 this.isNegotiated = false; |
|
162 this.isBroken = false; |
|
163 this.isInputCloseNotified = false; |
|
164 this.isOutputCloseNotified = false; |
|
165 this.closeReason = null; |
|
166 } |
138 } |
167 |
139 |
168 // Dispatch plaintext to a specific consumer. |
140 // Dispatch plaintext to a specific consumer. |
169 void dispatch(Plaintext plaintext) throws IOException { |
141 void dispatch(Plaintext plaintext) throws IOException { |
170 if (plaintext == null) { |
142 if (plaintext == null) { |