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 SecureSocket { |
| 6 /* patch */ static void setCertificateDatabase(String certificateDatabase, |
| 7 [String password]) |
| 8 native "SecureSocket_SetCertificateDatabase"; |
| 9 } |
| 10 |
| 11 |
| 12 patch class _SecureFilter { |
| 13 /* patch */ factory _SecureFilter() => new _SecureFilterImpl(); |
| 14 } |
| 15 |
| 16 |
| 17 /** |
| 18 * _SecureFilterImpl wraps a filter that encrypts and decrypts data travelling |
| 19 * over an encrypted socket. The filter also handles the handshaking |
| 20 * and certificate verification. |
| 21 * |
| 22 * The filter exposes its input and output buffers as Dart objects that |
| 23 * are backed by an external C array of bytes, so that both Dart code and |
| 24 * native code can access the same data. |
| 25 */ |
| 26 class _SecureFilterImpl |
| 27 extends NativeFieldWrapperClass1 |
| 28 implements _SecureFilter { |
| 29 _SecureFilterImpl() { |
| 30 buffers = new List<_ExternalBuffer>(_SecureSocket.NUM_BUFFERS); |
| 31 for (int i = 0; i < _SecureSocket.NUM_BUFFERS; ++i) { |
| 32 buffers[i] = new _ExternalBuffer(); |
| 33 } |
| 34 } |
| 35 |
| 36 void connect(String hostName, |
| 37 int port, |
| 38 bool is_server, |
| 39 String certificate_name) native "SecureSocket_Connect"; |
| 40 |
| 41 void destroy() { |
| 42 buffers = null; |
| 43 _destroy(); |
| 44 } |
| 45 |
| 46 void _destroy() native "SecureSocket_Destroy"; |
| 47 |
| 48 void handshake() native "SecureSocket_Handshake"; |
| 49 |
| 50 void init() native "SecureSocket_Init"; |
| 51 |
| 52 int processBuffer(int bufferIndex) native "SecureSocket_ProcessBuffer"; |
| 53 |
| 54 void registerHandshakeCompleteCallback(Function handshakeCompleteHandler) |
| 55 native "SecureSocket_RegisterHandshakeCompleteCallback"; |
| 56 |
| 57 List<_ExternalBuffer> buffers; |
| 58 } |
OLD | NEW |