OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 patch class TlsSocket { |
| 6 /* patch */ static void setCertificateDatabase(String pkcertDirectory) |
| 7 native "TlsSocket_SetCertificateDatabase"; |
| 8 } |
| 9 |
| 10 |
| 11 patch class _TlsFilter { |
| 12 /* patch */ factory _TlsFilter() => new _TlsFilterImpl(); |
| 13 } |
| 14 |
| 15 |
| 16 /** |
| 17 * _TlsFilterImpl wraps a filter that encrypts and decrypts data travelling |
| 18 * over a TLS encrypted socket. The filter also handles the handshaking |
| 19 * and certificate verification. |
| 20 * |
| 21 * 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 * native code can access the same data. |
| 24 */ |
| 25 class _TlsFilterImpl extends NativeFieldWrapperClass1 implements _TlsFilter { |
| 26 _TlsFilterImpl() { |
| 27 buffers = new List<_TlsExternalBuffer>(_TlsSocket.NUM_BUFFERS); |
| 28 for (int i = 0; i < _TlsSocket.NUM_BUFFERS; ++i) { |
| 29 buffers[i] = new _TlsExternalBuffer(); |
| 30 } |
| 31 } |
| 32 |
| 33 void connect(String hostName, int port) native "TlsSocket_Connect"; |
| 34 |
| 35 void destroy() { |
| 36 buffers = null; |
| 37 _destroy(); |
| 38 } |
| 39 |
| 40 void _destroy() native "TlsSocket_Destroy"; |
| 41 |
| 42 void handshake() native "TlsSocket_Handshake"; |
| 43 |
| 44 void init() native "TlsSocket_Init"; |
| 45 |
| 46 int processBuffer(int bufferIndex) native "TlsSocket_ProcessBuffer"; |
| 47 |
| 48 void registerHandshakeCompleteCallback(Function handshakeCompleteHandler) |
| 49 native "TlsSocket_RegisterHandshakeCompleteCallback"; |
| 50 |
| 51 List<_TlsExternalBuffer> buffers; |
| 52 } |
OLD | NEW |