Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: sdk/lib/io/secure_socket.dart

Issue 2529393002: Make core libraries use generic method syntax. (Closed)
Patch Set: Merge to head Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of dart.io; 5 part of dart.io;
6 6
7 /** 7 /**
8 * A high-level class for communicating securely over a TCP socket, using 8 * A high-level class for communicating securely over a TCP socket, using
9 * TLS and SSL. The [SecureSocket] exposes both a [Stream] and an 9 * TLS and SSL. The [SecureSocket] exposes both a [Stream] and an
10 * [IOSink] interface, making it ideal for using together with 10 * [IOSink] interface, making it ideal for using together with
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 * 68 *
69 * See [connect] for more information on the arguments. 69 * See [connect] for more information on the arguments.
70 * 70 *
71 */ 71 */
72 static Future<SecureSocket> secure( 72 static Future<SecureSocket> secure(
73 Socket socket, 73 Socket socket,
74 {host, 74 {host,
75 SecurityContext context, 75 SecurityContext context,
76 bool onBadCertificate(X509Certificate certificate)}) { 76 bool onBadCertificate(X509Certificate certificate)}) {
77 return ((socket as dynamic/*_Socket*/)._detachRaw() as Future) 77 return ((socket as dynamic/*_Socket*/)._detachRaw() as Future)
78 .then/*<RawSecureSocket>*/((detachedRaw) { 78 .then<RawSecureSocket>((detachedRaw) {
79 return RawSecureSocket.secure( 79 return RawSecureSocket.secure(
80 detachedRaw[0] as RawSocket, 80 detachedRaw[0] as RawSocket,
81 subscription: detachedRaw[1] as StreamSubscription<RawSocketEvent>, 81 subscription: detachedRaw[1] as StreamSubscription<RawSocketEvent>,
82 host: host, 82 host: host,
83 context: context, 83 context: context,
84 onBadCertificate: onBadCertificate); 84 onBadCertificate: onBadCertificate);
85 }) 85 })
86 .then/*<SecureSocket>*/((raw) => new SecureSocket._(raw)); 86 .then<SecureSocket>((raw) => new SecureSocket._(raw));
87 } 87 }
88 88
89 /** 89 /**
90 * Takes an already connected [socket] and starts server side TLS 90 * Takes an already connected [socket] and starts server side TLS
91 * handshake to make the communication secure. When the returned 91 * handshake to make the communication secure. When the returned
92 * future completes the [SecureSocket] has completed the TLS 92 * future completes the [SecureSocket] has completed the TLS
93 * handshake. Using this function requires that the other end of the 93 * handshake. Using this function requires that the other end of the
94 * connection is going to start the TLS handshake. 94 * connection is going to start the TLS handshake.
95 * 95 *
96 * If the [socket] already has a subscription, this subscription 96 * If the [socket] already has a subscription, this subscription
(...skipping 11 matching lines...) Expand all
108 * 108 *
109 */ 109 */
110 static Future<SecureSocket> secureServer( 110 static Future<SecureSocket> secureServer(
111 Socket socket, 111 Socket socket,
112 SecurityContext context, 112 SecurityContext context,
113 {List<int> bufferedData, 113 {List<int> bufferedData,
114 bool requestClientCertificate: false, 114 bool requestClientCertificate: false,
115 bool requireClientCertificate: false, 115 bool requireClientCertificate: false,
116 List<String> supportedProtocols}) { 116 List<String> supportedProtocols}) {
117 return ((socket as dynamic/*_Socket*/)._detachRaw() as Future) 117 return ((socket as dynamic/*_Socket*/)._detachRaw() as Future)
118 .then/*<RawSecureSocket>*/((detachedRaw) { 118 .then<RawSecureSocket>((detachedRaw) {
119 return RawSecureSocket.secureServer( 119 return RawSecureSocket.secureServer(
120 detachedRaw[0] as RawSocket, 120 detachedRaw[0] as RawSocket,
121 context, 121 context,
122 subscription: detachedRaw[1] as StreamSubscription<RawSocketEvent>, 122 subscription: detachedRaw[1] as StreamSubscription<RawSocketEvent>,
123 bufferedData: bufferedData, 123 bufferedData: bufferedData,
124 requestClientCertificate: requestClientCertificate, 124 requestClientCertificate: requestClientCertificate,
125 requireClientCertificate: requireClientCertificate, 125 requireClientCertificate: requireClientCertificate,
126 supportedProtocols: supportedProtocols); 126 supportedProtocols: supportedProtocols);
127 }) 127 })
128 .then/*<SecureSocket>*/((raw) => new SecureSocket._(raw)); 128 .then<SecureSocket>((raw) => new SecureSocket._(raw));
129 } 129 }
130 130
131 /** 131 /**
132 * Get the peer certificate for a connected SecureSocket. If this 132 * Get the peer certificate for a connected SecureSocket. If this
133 * SecureSocket is the server end of a secure socket connection, 133 * SecureSocket is the server end of a secure socket connection,
134 * [peerCertificate] will return the client certificate, or null, if no 134 * [peerCertificate] will return the client certificate, or null, if no
135 * client certificate was received. If it is the client end, 135 * client certificate was received. If it is the client end,
136 * [peerCertificate] will return the server's certificate. 136 * [peerCertificate] will return the server's certificate.
137 */ 137 */
138 X509Certificate get peerCertificate; 138 X509Certificate get peerCertificate;
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 /** 1248 /**
1249 * An exception that happens in the handshake phase of establishing 1249 * An exception that happens in the handshake phase of establishing
1250 * a secure network connection, when looking up or verifying a 1250 * a secure network connection, when looking up or verifying a
1251 * certificate. 1251 * certificate.
1252 */ 1252 */
1253 class CertificateException extends TlsException { 1253 class CertificateException extends TlsException {
1254 const CertificateException([String message = "", 1254 const CertificateException([String message = "",
1255 OSError osError = null]) 1255 OSError osError = null])
1256 : super._("CertificateException", message, osError); 1256 : super._("CertificateException", message, osError);
1257 } 1257 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698