| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 patch class TlsSocket { | 5 patch class TlsSocket { |
| 6 /* patch */ static void setCertificateDatabase(String pkcertDirectory) | 6 /* patch */ static void setCertificateDatabase(String certificateDatabase, |
| 7 [String password]) |
| 7 native "TlsSocket_SetCertificateDatabase"; | 8 native "TlsSocket_SetCertificateDatabase"; |
| 8 } | 9 } |
| 9 | 10 |
| 10 | 11 |
| 11 patch class _TlsFilter { | 12 patch class _TlsFilter { |
| 12 /* patch */ factory _TlsFilter() => new _TlsFilterImpl(); | 13 /* patch */ factory _TlsFilter() => new _TlsFilterImpl(); |
| 13 } | 14 } |
| 14 | 15 |
| 15 | 16 |
| 16 /** | 17 /** |
| 17 * _TlsFilterImpl wraps a filter that encrypts and decrypts data travelling | 18 * _TlsFilterImpl wraps a filter that encrypts and decrypts data travelling |
| 18 * over a TLS encrypted socket. The filter also handles the handshaking | 19 * over a TLS encrypted socket. The filter also handles the handshaking |
| 19 * and certificate verification. | 20 * and certificate verification. |
| 20 * | 21 * |
| 21 * The filter exposes its input and output buffers as Dart objects that | 22 * The filter exposes its input and output buffers as Dart objects that |
| 22 * are backed by an external C array of bytes, so that both Dart code and | 23 * are backed by an external C array of bytes, so that both Dart code and |
| 23 * native code can access the same data. | 24 * native code can access the same data. |
| 24 */ | 25 */ |
| 25 class _TlsFilterImpl extends NativeFieldWrapperClass1 implements _TlsFilter { | 26 class _TlsFilterImpl extends NativeFieldWrapperClass1 implements _TlsFilter { |
| 26 _TlsFilterImpl() { | 27 _TlsFilterImpl() { |
| 27 buffers = new List<_TlsExternalBuffer>(_TlsSocket.NUM_BUFFERS); | 28 buffers = new List<_TlsExternalBuffer>(_TlsSocket.NUM_BUFFERS); |
| 28 for (int i = 0; i < _TlsSocket.NUM_BUFFERS; ++i) { | 29 for (int i = 0; i < _TlsSocket.NUM_BUFFERS; ++i) { |
| 29 buffers[i] = new _TlsExternalBuffer(); | 30 buffers[i] = new _TlsExternalBuffer(); |
| 30 } | 31 } |
| 31 } | 32 } |
| 32 | 33 |
| 33 void connect(String hostName, int port) native "TlsSocket_Connect"; | 34 void connect(String hostName, |
| 35 int port, |
| 36 bool is_server, |
| 37 String certificate_name) native "TlsSocket_Connect"; |
| 34 | 38 |
| 35 void destroy() { | 39 void destroy() { |
| 36 buffers = null; | 40 buffers = null; |
| 37 _destroy(); | 41 _destroy(); |
| 38 } | 42 } |
| 39 | 43 |
| 40 void _destroy() native "TlsSocket_Destroy"; | 44 void _destroy() native "TlsSocket_Destroy"; |
| 41 | 45 |
| 42 void handshake() native "TlsSocket_Handshake"; | 46 void handshake() native "TlsSocket_Handshake"; |
| 43 | 47 |
| 44 void init() native "TlsSocket_Init"; | 48 void init() native "TlsSocket_Init"; |
| 45 | 49 |
| 46 int processBuffer(int bufferIndex) native "TlsSocket_ProcessBuffer"; | 50 int processBuffer(int bufferIndex) native "TlsSocket_ProcessBuffer"; |
| 47 | 51 |
| 48 void registerHandshakeCompleteCallback(Function handshakeCompleteHandler) | 52 void registerHandshakeCompleteCallback(Function handshakeCompleteHandler) |
| 49 native "TlsSocket_RegisterHandshakeCompleteCallback"; | 53 native "TlsSocket_RegisterHandshakeCompleteCallback"; |
| 50 | 54 |
| 51 List<_TlsExternalBuffer> buffers; | 55 List<_TlsExternalBuffer> buffers; |
| 52 } | 56 } |
| OLD | NEW |