@@ -96,20 +96,22 @@ public let NSURLAuthenticationMethodNegotiate: String = "NSURLAuthenticationMeth
96
96
@const NSURLAuthenticationMethodClientCertificate
97
97
@abstract SSL Client certificate. Applies to any protocol.
98
98
*/
99
+ @available ( * , deprecated, message: " swift-corelibs-foundation does not currently support certificate authentication. " )
99
100
public let NSURLAuthenticationMethodClientCertificate : String = " NSURLAuthenticationMethodClientCertificate "
100
101
101
102
/*!
102
103
@const NSURLAuthenticationMethodServerTrust
103
104
@abstract SecTrustRef validation required. Applies to any protocol.
104
105
*/
106
+ @available ( * , deprecated, message: " swift-corelibs-foundation does not support methods of authentication that rely on the Darwin Security framework. " )
105
107
public let NSURLAuthenticationMethodServerTrust : String = " NSURLAuthenticationMethodServerTrust "
106
108
107
109
108
110
/*!
109
111
@class URLProtectionSpace
110
112
@discussion This class represents a protection space requiring authentication.
111
113
*/
112
- open class URLProtectionSpace : NSObject , NSSecureCoding , NSCopying {
114
+ open class URLProtectionSpace : NSObject , NSCopying {
113
115
114
116
private let _host : String
115
117
private let _isProxy : Bool
@@ -123,17 +125,10 @@ open class URLProtectionSpace : NSObject, NSSecureCoding, NSCopying {
123
125
return copy ( with: nil )
124
126
}
125
127
126
- open func copy( with zone: NSZone ? = nil ) -> Any { NSUnimplemented ( ) }
127
- public static var supportsSecureCoding : Bool { return true }
128
-
129
- open func encode( with aCoder: NSCoder ) {
130
- NSUnimplemented ( )
131
- }
132
- public required init ? ( coder aDecoder: NSCoder ) {
133
- NSUnimplemented ( )
128
+ open func copy( with zone: NSZone ? = nil ) -> Any {
129
+ return self // These instances are immutable.
134
130
}
135
131
136
-
137
132
/*!
138
133
@method initWithHost:port:protocol:realm:authenticationMethod:
139
134
@abstract Initialize a protection space representing an origin server, or a realm on one
@@ -199,7 +194,34 @@ open class URLProtectionSpace : NSObject, NSSecureCoding, NSCopying {
199
194
@abstract Determine if the password for this protection space can be sent securely
200
195
@result YES if a secure authentication method or protocol will be used, NO otherwise
201
196
*/
202
- open var receivesCredentialSecurely : Bool { NSUnimplemented ( ) }
197
+ open var receivesCredentialSecurely : Bool {
198
+ switch self . protocol {
199
+ // The documentation is ambiguous whether a protection space needs to use the NSURLProtectionSpace… constants, or URL schemes.
200
+ // Allow both.
201
+ case NSURLProtectionSpaceHTTPS: fallthrough
202
+ case " https " : fallthrough
203
+ case " ftps " :
204
+ return true
205
+
206
+ default :
207
+ switch authenticationMethod {
208
+ case NSURLAuthenticationMethodDefault: fallthrough
209
+ case NSURLAuthenticationMethodHTTPBasic: fallthrough
210
+ case NSURLAuthenticationMethodHTTPDigest: fallthrough
211
+ case NSURLAuthenticationMethodHTMLForm:
212
+ return false
213
+
214
+ case NSURLAuthenticationMethodNTLM: fallthrough
215
+ case NSURLAuthenticationMethodNegotiate: fallthrough
216
+ case NSURLAuthenticationMethodClientCertificate: fallthrough
217
+ case NSURLAuthenticationMethodServerTrust:
218
+ return true
219
+
220
+ default :
221
+ return false
222
+ }
223
+ }
224
+ }
203
225
204
226
/*!
205
227
@method host
@@ -333,18 +355,14 @@ extension URLProtectionSpace {
333
355
@abstract Returns an array of acceptable certificate issuing authorities for client certification authentication. Issuers are identified by their distinguished name and returned as a DER encoded data.
334
356
@result An array of NSData objects. (Nil if the authenticationMethod is not NSURLAuthenticationMethodClientCertificate)
335
357
*/
336
- public var distinguishedNames : [ Data ] ? { NSUnimplemented ( ) }
337
- }
338
-
339
- // TODO: Currently no implementation of Security.framework
340
- /*
341
- extension URLProtectionSpace {
358
+ @available ( * , deprecated, message: " swift-corelibs-foundation does not currently support certificate authentication. " )
359
+ public var distinguishedNames : [ Data ] ? { return nil }
342
360
343
361
/*!
344
362
@method serverTrust
345
363
@abstract Returns a SecTrustRef which represents the state of the servers SSL transaction state
346
364
@result A SecTrustRef from Security.framework. (Nil if the authenticationMethod is not NSURLAuthenticationMethodServerTrust)
347
365
*/
348
- public var serverTrust: SecTrust? { NSUnimplemented() }
366
+ @available ( * , unavailable, message: " swift-corelibs-foundation does not support methods of authentication that rely on the Darwin Security framework. " )
367
+ public var serverTrust : Any ? { NSUnsupported ( ) }
349
368
}
350
- */
0 commit comments