Index: runtime/bin/secure_socket_patch.dart |
diff --git a/runtime/bin/secure_socket_patch.dart b/runtime/bin/secure_socket_patch.dart |
index ad29bd5f0fa79f22bce2e66af01c2498df054197..735ba3b29fdf88aa58303bc8a56b8d3fbc2fff45 100644 |
--- a/runtime/bin/secure_socket_patch.dart |
+++ b/runtime/bin/secure_socket_patch.dart |
@@ -2,18 +2,23 @@ |
// for details. All rights reserved. Use of this source code is governed by a |
// BSD-style license that can be found in the LICENSE file. |
-@patch class SecureSocket { |
- @patch factory SecureSocket._(RawSecureSocket rawSocket) => |
+@patch |
+class SecureSocket { |
+ @patch |
+ factory SecureSocket._(RawSecureSocket rawSocket) => |
new _SecureSocket(rawSocket); |
} |
- |
-@patch class _SecureFilter { |
- @patch factory _SecureFilter() => new _SecureFilterImpl(); |
+@patch |
+class _SecureFilter { |
+ @patch |
+ factory _SecureFilter() => new _SecureFilterImpl(); |
} |
-@patch class X509Certificate { |
- @patch factory X509Certificate._() => new _X509CertificateImpl(); |
+@patch |
+class X509Certificate { |
+ @patch |
+ factory X509Certificate._() => new _X509CertificateImpl(); |
} |
class _SecureSocket extends _Socket implements SecureSocket { |
@@ -26,30 +31,31 @@ class _SecureSocket extends _Socket implements SecureSocket { |
_raw.onBadCertificate = callback; |
} |
- void renegotiate({bool useSessionCache: true, |
- bool requestClientCertificate: false, |
- bool requireClientCertificate: false}) { |
- _raw.renegotiate(useSessionCache: useSessionCache, |
- requestClientCertificate: requestClientCertificate, |
- requireClientCertificate: requireClientCertificate); |
+ void renegotiate( |
+ {bool useSessionCache: true, |
+ bool requestClientCertificate: false, |
+ bool requireClientCertificate: false}) { |
+ _raw.renegotiate( |
+ useSessionCache: useSessionCache, |
+ requestClientCertificate: requestClientCertificate, |
+ requireClientCertificate: requireClientCertificate); |
} |
X509Certificate get peerCertificate { |
if (_raw == null) { |
- throw new StateError("peerCertificate called on destroyed SecureSocket"); |
+ throw new StateError("peerCertificate called on destroyed SecureSocket"); |
} |
return _raw.peerCertificate; |
} |
String get selectedProtocol { |
if (_raw == null) { |
- throw new StateError("selectedProtocol called on destroyed SecureSocket"); |
+ throw new StateError("selectedProtocol called on destroyed SecureSocket"); |
} |
return _raw.selectedProtocol; |
} |
} |
- |
/** |
* _SecureFilterImpl wraps a filter that encrypts and decrypts data travelling |
* over an encrypted socket. The filter also handles the handshaking |
@@ -59,8 +65,7 @@ class _SecureSocket extends _Socket implements SecureSocket { |
* are backed by an external C array of bytes, so that both Dart code and |
* native code can access the same data. |
*/ |
-class _SecureFilterImpl |
- extends NativeFieldWrapperClass1 |
+class _SecureFilterImpl extends NativeFieldWrapperClass1 |
implements _SecureFilter { |
// Performance is improved if a full buffer of plaintext fits |
// in the encrypted buffer, when encrypted. |
@@ -70,18 +75,18 @@ class _SecureFilterImpl |
_SecureFilterImpl() { |
buffers = new List<_ExternalBuffer>(_RawSecureSocket.NUM_BUFFERS); |
for (int i = 0; i < _RawSecureSocket.NUM_BUFFERS; ++i) { |
- buffers[i] = new _ExternalBuffer(_RawSecureSocket._isBufferEncrypted(i) ? |
- ENCRYPTED_SIZE : |
- SIZE); |
+ buffers[i] = new _ExternalBuffer( |
+ _RawSecureSocket._isBufferEncrypted(i) ? ENCRYPTED_SIZE : SIZE); |
} |
} |
- void connect(String hostName, |
- SecurityContext context, |
- bool is_server, |
- bool requestClientCertificate, |
- bool requireClientCertificate, |
- Uint8List protocols) native "SecureSocket_Connect"; |
+ void connect( |
+ String hostName, |
+ SecurityContext context, |
+ bool is_server, |
+ bool requestClientCertificate, |
+ bool requireClientCertificate, |
+ Uint8List protocols) native "SecureSocket_Connect"; |
void destroy() { |
buffers = null; |
@@ -94,10 +99,8 @@ class _SecureFilterImpl |
String selectedProtocol() native "SecureSocket_GetSelectedProtocol"; |
- void renegotiate(bool useSessionCache, |
- bool requestClientCertificate, |
- bool requireClientCertificate) |
- native "SecureSocket_Renegotiate"; |
+ void renegotiate(bool useSessionCache, bool requestClientCertificate, |
+ bool requireClientCertificate) native "SecureSocket_Renegotiate"; |
void init() native "SecureSocket_Init"; |
@@ -115,22 +118,25 @@ class _SecureFilterImpl |
List<_ExternalBuffer> buffers; |
} |
-@patch class SecurityContext { |
- @patch factory SecurityContext() { |
+@patch |
+class SecurityContext { |
+ @patch |
+ factory SecurityContext() { |
return new _SecurityContext(); |
} |
- @patch static SecurityContext get defaultContext { |
+ @patch |
+ static SecurityContext get defaultContext { |
return _SecurityContext.defaultContext; |
} |
- @patch static bool get alpnSupported { |
+ @patch |
+ static bool get alpnSupported { |
return _SecurityContext.alpnSupported; |
} |
} |
-class _SecurityContext |
- extends NativeFieldWrapperClass1 |
+class _SecurityContext extends NativeFieldWrapperClass1 |
implements SecurityContext { |
_SecurityContext() { |
_createNativeContext(); |
@@ -138,13 +144,14 @@ class _SecurityContext |
void _createNativeContext() native "SecurityContext_Allocate"; |
- static final SecurityContext defaultContext = |
- new _SecurityContext().._trustBuiltinRoots(); |
+ static final SecurityContext defaultContext = new _SecurityContext() |
+ .._trustBuiltinRoots(); |
void usePrivateKey(String file, {String password}) { |
List<int> bytes = (new File(file)).readAsBytesSync(); |
usePrivateKeyBytes(bytes, password: password); |
} |
+ |
void usePrivateKeyBytes(List<int> keyBytes, {String password}) |
native "SecurityContext_UsePrivateKeyBytes"; |
@@ -152,6 +159,7 @@ class _SecurityContext |
List<int> bytes = (new File(file)).readAsBytesSync(); |
setTrustedCertificatesBytes(bytes, password: password); |
} |
+ |
void setTrustedCertificatesBytes(List<int> certBytes, {String password}) |
native "SecurityContext_SetTrustedCertificatesBytes"; |
@@ -159,6 +167,7 @@ class _SecurityContext |
List<int> bytes = (new File(file)).readAsBytesSync(); |
useCertificateChainBytes(bytes, password: password); |
} |
+ |
void useCertificateChainBytes(List<int> chainBytes, {String password}) |
native "SecurityContext_UseCertificateChainBytes"; |
@@ -166,6 +175,7 @@ class _SecurityContext |
List<int> bytes = (new File(file)).readAsBytesSync(); |
setClientAuthoritiesBytes(bytes, password: password); |
} |
+ |
void setClientAuthoritiesBytes(List<int> authCertBytes, {String password}) |
native "SecurityContext_SetClientAuthoritiesBytes"; |
@@ -176,10 +186,10 @@ class _SecurityContext |
SecurityContext._protocolsToLengthEncoding(protocols); |
_setAlpnProtocols(encodedProtocols, isServer); |
} |
+ |
void _setAlpnProtocols(Uint8List protocols, bool isServer) |
native "SecurityContext_SetAlpnProtocols"; |
- void _trustBuiltinRoots() |
- native "SecurityContext_TrustBuiltinRoots"; |
+ void _trustBuiltinRoots() native "SecurityContext_TrustBuiltinRoots"; |
} |
/** |
@@ -196,12 +206,13 @@ class _X509CertificateImpl extends NativeFieldWrapperClass1 |
String get issuer native "X509_Issuer"; |
DateTime get startValidity { |
return new DateTime.fromMillisecondsSinceEpoch(_startValidity(), |
- isUtc: true); |
+ isUtc: true); |
} |
+ |
DateTime get endValidity { |
- return new DateTime.fromMillisecondsSinceEpoch(_endValidity(), |
- isUtc: true); |
+ return new DateTime.fromMillisecondsSinceEpoch(_endValidity(), isUtc: true); |
} |
+ |
int _startValidity() native "X509_StartValidity"; |
int _endValidity() native "X509_EndValidity"; |
} |