objc2_foundation/generated/
NSURLProtectionSpace.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5
6use crate::*;
7
8extern "C" {
9    /// The protocol for HTTP
10    ///
11    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlprotectionspacehttp?language=objc)
12    #[cfg(feature = "NSString")]
13    pub static NSURLProtectionSpaceHTTP: &'static NSString;
14}
15
16extern "C" {
17    /// The protocol for HTTPS
18    ///
19    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlprotectionspacehttps?language=objc)
20    #[cfg(feature = "NSString")]
21    pub static NSURLProtectionSpaceHTTPS: &'static NSString;
22}
23
24extern "C" {
25    /// The protocol for FTP
26    ///
27    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlprotectionspaceftp?language=objc)
28    #[cfg(feature = "NSString")]
29    #[deprecated = "FTP is deprecated and only supported in the classic loading mode"]
30    pub static NSURLProtectionSpaceFTP: &'static NSString;
31}
32
33extern "C" {
34    /// The proxy type for http proxies
35    ///
36    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlprotectionspacehttpproxy?language=objc)
37    #[cfg(feature = "NSString")]
38    pub static NSURLProtectionSpaceHTTPProxy: &'static NSString;
39}
40
41extern "C" {
42    /// The proxy type for https proxies
43    ///
44    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlprotectionspacehttpsproxy?language=objc)
45    #[cfg(feature = "NSString")]
46    pub static NSURLProtectionSpaceHTTPSProxy: &'static NSString;
47}
48
49extern "C" {
50    /// The proxy type for ftp proxies
51    ///
52    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlprotectionspaceftpproxy?language=objc)
53    #[cfg(feature = "NSString")]
54    #[deprecated = "FTP is deprecated and only supported in the classic loading mode"]
55    pub static NSURLProtectionSpaceFTPProxy: &'static NSString;
56}
57
58extern "C" {
59    /// The proxy type for SOCKS proxies
60    ///
61    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlprotectionspacesocksproxy?language=objc)
62    #[cfg(feature = "NSString")]
63    pub static NSURLProtectionSpaceSOCKSProxy: &'static NSString;
64}
65
66extern "C" {
67    /// The default authentication method for a protocol
68    ///
69    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlauthenticationmethoddefault?language=objc)
70    #[cfg(feature = "NSString")]
71    pub static NSURLAuthenticationMethodDefault: &'static NSString;
72}
73
74extern "C" {
75    /// HTTP basic authentication. Equivalent to
76    /// NSURLAuthenticationMethodDefault for http.
77    ///
78    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlauthenticationmethodhttpbasic?language=objc)
79    #[cfg(feature = "NSString")]
80    pub static NSURLAuthenticationMethodHTTPBasic: &'static NSString;
81}
82
83extern "C" {
84    /// HTTP digest authentication.
85    ///
86    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlauthenticationmethodhttpdigest?language=objc)
87    #[cfg(feature = "NSString")]
88    pub static NSURLAuthenticationMethodHTTPDigest: &'static NSString;
89}
90
91extern "C" {
92    /// HTML form authentication. Applies to any protocol.
93    ///
94    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlauthenticationmethodhtmlform?language=objc)
95    #[cfg(feature = "NSString")]
96    pub static NSURLAuthenticationMethodHTMLForm: &'static NSString;
97}
98
99extern "C" {
100    /// NTLM authentication.
101    ///
102    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlauthenticationmethodntlm?language=objc)
103    #[cfg(feature = "NSString")]
104    pub static NSURLAuthenticationMethodNTLM: &'static NSString;
105}
106
107extern "C" {
108    /// Negotiate authentication.
109    ///
110    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlauthenticationmethodnegotiate?language=objc)
111    #[cfg(feature = "NSString")]
112    pub static NSURLAuthenticationMethodNegotiate: &'static NSString;
113}
114
115extern "C" {
116    /// SSL Client certificate.  Applies to any protocol.
117    ///
118    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlauthenticationmethodclientcertificate?language=objc)
119    #[cfg(feature = "NSString")]
120    pub static NSURLAuthenticationMethodClientCertificate: &'static NSString;
121}
122
123extern "C" {
124    /// SecTrustRef validation required.  Applies to any protocol.
125    ///
126    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlauthenticationmethodservertrust?language=objc)
127    #[cfg(feature = "NSString")]
128    pub static NSURLAuthenticationMethodServerTrust: &'static NSString;
129}
130
131extern_class!(
132    /// This class represents a protection space requiring authentication.
133    ///
134    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlprotectionspace?language=objc)
135    #[unsafe(super(NSObject))]
136    #[derive(Debug, PartialEq, Eq, Hash)]
137    pub struct NSURLProtectionSpace;
138);
139
140unsafe impl Send for NSURLProtectionSpace {}
141
142unsafe impl Sync for NSURLProtectionSpace {}
143
144#[cfg(feature = "NSObject")]
145extern_conformance!(
146    unsafe impl NSCoding for NSURLProtectionSpace {}
147);
148
149#[cfg(feature = "NSObject")]
150extern_conformance!(
151    unsafe impl NSCopying for NSURLProtectionSpace {}
152);
153
154#[cfg(feature = "NSObject")]
155unsafe impl CopyingHelper for NSURLProtectionSpace {
156    type Result = Self;
157}
158
159extern_conformance!(
160    unsafe impl NSObjectProtocol for NSURLProtectionSpace {}
161);
162
163#[cfg(feature = "NSObject")]
164extern_conformance!(
165    unsafe impl NSSecureCoding for NSURLProtectionSpace {}
166);
167
168impl NSURLProtectionSpace {
169    extern_methods!(
170        #[cfg(feature = "NSString")]
171        /// Initialize a protection space representing an origin server, or a realm on one
172        ///
173        /// Parameter `host`: The hostname of the server
174        ///
175        /// Parameter `port`: The port for the server
176        ///
177        /// Parameter `protocol`: The protocol for this server - e.g. "http", "ftp", "https"
178        ///
179        /// Parameter `realm`: A string indicating a protocol-specific subdivision
180        /// of a single host. For http and https, this maps to the realm
181        /// string in http authentication challenges. For many other protocols
182        /// it is unused.
183        ///
184        /// Parameter `authenticationMethod`: The authentication method to use to access this protection space -
185        /// valid values include nil (default method),
186        /// "
187        /// digest" and @"form".
188        ///
189        /// Returns: The initialized object.
190        #[unsafe(method(initWithHost:port:protocol:realm:authenticationMethod:))]
191        #[unsafe(method_family = init)]
192        pub fn initWithHost_port_protocol_realm_authenticationMethod(
193            this: Allocated<Self>,
194            host: &NSString,
195            port: NSInteger,
196            protocol: Option<&NSString>,
197            realm: Option<&NSString>,
198            authentication_method: Option<&NSString>,
199        ) -> Retained<Self>;
200
201        #[cfg(feature = "NSString")]
202        /// Initialize a protection space representing a proxy server, or a realm on one
203        ///
204        /// Parameter `host`: The hostname of the proxy server
205        ///
206        /// Parameter `port`: The port for the proxy server
207        ///
208        /// Parameter `type`: The type of proxy - e.g. "http", "ftp", "SOCKS"
209        ///
210        /// Parameter `realm`: A string indicating a protocol-specific subdivision
211        /// of a single host. For http and https, this maps to the realm
212        /// string in http authentication challenges. For many other protocols
213        /// it is unused.
214        ///
215        /// Parameter `authenticationMethod`: The authentication method to use to access this protection space -
216        /// valid values include nil (default method) and
217        /// "
218        /// digest"
219        ///
220        /// Returns: The initialized object.
221        #[unsafe(method(initWithProxyHost:port:type:realm:authenticationMethod:))]
222        #[unsafe(method_family = init)]
223        pub fn initWithProxyHost_port_type_realm_authenticationMethod(
224            this: Allocated<Self>,
225            host: &NSString,
226            port: NSInteger,
227            r#type: Option<&NSString>,
228            realm: Option<&NSString>,
229            authentication_method: Option<&NSString>,
230        ) -> Retained<Self>;
231
232        #[cfg(feature = "NSString")]
233        /// Get the authentication realm for which the protection space that
234        /// needs authentication
235        ///
236        /// This is generally only available for http
237        /// authentication, and may be nil otherwise.
238        ///
239        /// Returns: The realm string
240        #[unsafe(method(realm))]
241        #[unsafe(method_family = none)]
242        pub fn realm(&self) -> Option<Retained<NSString>>;
243
244        /// Determine if the password for this protection space can be sent securely
245        ///
246        /// Returns: YES if a secure authentication method or protocol will be used, NO otherwise
247        #[unsafe(method(receivesCredentialSecurely))]
248        #[unsafe(method_family = none)]
249        pub fn receivesCredentialSecurely(&self) -> bool;
250
251        /// Determine if this authenticating protection space is a proxy server
252        ///
253        /// Returns: YES if a proxy, NO otherwise
254        #[unsafe(method(isProxy))]
255        #[unsafe(method_family = none)]
256        pub fn isProxy(&self) -> bool;
257
258        #[cfg(feature = "NSString")]
259        /// Get the proxy host if this is a proxy authentication, or the host from the URL.
260        ///
261        /// Returns: The host for this protection space.
262        #[unsafe(method(host))]
263        #[unsafe(method_family = none)]
264        pub fn host(&self) -> Retained<NSString>;
265
266        /// Get the proxy port if this is a proxy authentication, or the port from the URL.
267        ///
268        /// Returns: The port for this protection space, or 0 if not set.
269        #[unsafe(method(port))]
270        #[unsafe(method_family = none)]
271        pub fn port(&self) -> NSInteger;
272
273        #[cfg(feature = "NSString")]
274        /// Get the type of this protection space, if a proxy
275        ///
276        /// Returns: The type string, or nil if not a proxy.
277        #[unsafe(method(proxyType))]
278        #[unsafe(method_family = none)]
279        pub fn proxyType(&self) -> Option<Retained<NSString>>;
280
281        #[cfg(feature = "NSString")]
282        /// Get the protocol of this protection space, if not a proxy
283        ///
284        /// Returns: The type string, or nil if a proxy.
285        #[unsafe(method(protocol))]
286        #[unsafe(method_family = none)]
287        pub fn protocol(&self) -> Option<Retained<NSString>>;
288
289        #[cfg(feature = "NSString")]
290        /// Get the authentication method to be used for this protection space
291        ///
292        /// Returns: The authentication method
293        #[unsafe(method(authenticationMethod))]
294        #[unsafe(method_family = none)]
295        pub fn authenticationMethod(&self) -> Retained<NSString>;
296    );
297}
298
299/// Methods declared on superclass `NSObject`.
300impl NSURLProtectionSpace {
301    extern_methods!(
302        #[unsafe(method(init))]
303        #[unsafe(method_family = init)]
304        pub fn init(this: Allocated<Self>) -> Retained<Self>;
305
306        #[unsafe(method(new))]
307        #[unsafe(method_family = new)]
308        pub fn new() -> Retained<Self>;
309    );
310}
311
312impl DefaultRetained for NSURLProtectionSpace {
313    #[inline]
314    fn default_retained() -> Retained<Self> {
315        Self::new()
316    }
317}
318
319/// NSClientCertificateSpace.
320///
321/// This category supplies additional information for use when a client certificate is required by the server in order to complete authentication.
322impl NSURLProtectionSpace {
323    extern_methods!(
324        #[cfg(all(feature = "NSArray", feature = "NSData"))]
325        /// 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.
326        ///
327        /// Returns: An array of NSData objects.  (Nil if the authenticationMethod is not NSURLAuthenticationMethodClientCertificate)
328        #[unsafe(method(distinguishedNames))]
329        #[unsafe(method_family = none)]
330        pub fn distinguishedNames(&self) -> Option<Retained<NSArray<NSData>>>;
331    );
332}
333
334/// NSServerTrustValidationSpace.
335///
336/// This category supplies additional information for use by the client to evaluate whether to trust a given server during a security handshake.
337impl NSURLProtectionSpace {
338    extern_methods!();
339}