objc2_foundation/generated/NSURLAuthenticationChallenge.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9extern_protocol!(
10 /// This protocol represents the sender of an
11 /// authentication challenge. It has methods to provide a credential,
12 /// to continue without any credential, getting whatever failure
13 /// result would happen in that case, cancel a challenge, perform the default
14 /// action as defined by the system, or reject the currently supplied protection-space
15 /// in the challenge.
16 ///
17 /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlauthenticationchallengesender?language=objc)
18 pub unsafe trait NSURLAuthenticationChallengeSender: NSObjectProtocol {
19 #[cfg(feature = "NSURLCredential")]
20 #[unsafe(method(useCredential:forAuthenticationChallenge:))]
21 #[unsafe(method_family = none)]
22 unsafe fn useCredential_forAuthenticationChallenge(
23 &self,
24 credential: &NSURLCredential,
25 challenge: &NSURLAuthenticationChallenge,
26 );
27
28 #[unsafe(method(continueWithoutCredentialForAuthenticationChallenge:))]
29 #[unsafe(method_family = none)]
30 unsafe fn continueWithoutCredentialForAuthenticationChallenge(
31 &self,
32 challenge: &NSURLAuthenticationChallenge,
33 );
34
35 #[unsafe(method(cancelAuthenticationChallenge:))]
36 #[unsafe(method_family = none)]
37 unsafe fn cancelAuthenticationChallenge(&self, challenge: &NSURLAuthenticationChallenge);
38
39 #[optional]
40 #[unsafe(method(performDefaultHandlingForAuthenticationChallenge:))]
41 #[unsafe(method_family = none)]
42 unsafe fn performDefaultHandlingForAuthenticationChallenge(
43 &self,
44 challenge: &NSURLAuthenticationChallenge,
45 );
46
47 #[optional]
48 #[unsafe(method(rejectProtectionSpaceAndContinueWithChallenge:))]
49 #[unsafe(method_family = none)]
50 unsafe fn rejectProtectionSpaceAndContinueWithChallenge(
51 &self,
52 challenge: &NSURLAuthenticationChallenge,
53 );
54 }
55);
56
57extern_class!(
58 /// This class represents an authentication challenge. It
59 /// provides all the information about the challenge, and has a method
60 /// to indicate when it's done.
61 ///
62 /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlauthenticationchallenge?language=objc)
63 #[unsafe(super(NSObject))]
64 #[derive(Debug, PartialEq, Eq, Hash)]
65 pub struct NSURLAuthenticationChallenge;
66);
67
68unsafe impl Send for NSURLAuthenticationChallenge {}
69
70unsafe impl Sync for NSURLAuthenticationChallenge {}
71
72#[cfg(feature = "NSObject")]
73extern_conformance!(
74 unsafe impl NSCoding for NSURLAuthenticationChallenge {}
75);
76
77extern_conformance!(
78 unsafe impl NSObjectProtocol for NSURLAuthenticationChallenge {}
79);
80
81#[cfg(feature = "NSObject")]
82extern_conformance!(
83 unsafe impl NSSecureCoding for NSURLAuthenticationChallenge {}
84);
85
86impl NSURLAuthenticationChallenge {
87 extern_methods!(
88 #[cfg(all(
89 feature = "NSError",
90 feature = "NSURLCredential",
91 feature = "NSURLProtectionSpace",
92 feature = "NSURLResponse"
93 ))]
94 /// Initialize an authentication challenge
95 ///
96 /// Parameter `space`: The NSURLProtectionSpace to use
97 ///
98 /// Parameter `credential`: The proposed NSURLCredential for this challenge, or nil
99 ///
100 /// Parameter `previousFailureCount`: A count of previous failures attempting access.
101 ///
102 /// Parameter `response`: The NSURLResponse for the authentication failure, if applicable, else nil
103 ///
104 /// Parameter `error`: The NSError for the authentication failure, if applicable, else nil
105 ///
106 /// Returns: An authentication challenge initialized with the specified parameters
107 #[unsafe(method(initWithProtectionSpace:proposedCredential:previousFailureCount:failureResponse:error:sender:))]
108 #[unsafe(method_family = init)]
109 pub unsafe fn initWithProtectionSpace_proposedCredential_previousFailureCount_failureResponse_error_sender(
110 this: Allocated<Self>,
111 space: &NSURLProtectionSpace,
112 credential: Option<&NSURLCredential>,
113 previous_failure_count: NSInteger,
114 response: Option<&NSURLResponse>,
115 error: Option<&NSError>,
116 sender: &ProtocolObject<dyn NSURLAuthenticationChallengeSender>,
117 ) -> Retained<Self>;
118
119 /// Initialize an authentication challenge copying all parameters from another one.
120 ///
121 /// Returns: A new challenge initialized with the parameters from the passed in challenge
122 ///
123 /// This initializer may be useful to subclassers that want to proxy
124 /// one type of authentication challenge to look like another type.
125 #[unsafe(method(initWithAuthenticationChallenge:sender:))]
126 #[unsafe(method_family = init)]
127 pub unsafe fn initWithAuthenticationChallenge_sender(
128 this: Allocated<Self>,
129 challenge: &NSURLAuthenticationChallenge,
130 sender: &ProtocolObject<dyn NSURLAuthenticationChallengeSender>,
131 ) -> Retained<Self>;
132
133 #[cfg(feature = "NSURLProtectionSpace")]
134 /// Get a description of the protection space that requires authentication
135 ///
136 /// Returns: The protection space that needs authentication
137 #[unsafe(method(protectionSpace))]
138 #[unsafe(method_family = none)]
139 pub unsafe fn protectionSpace(&self) -> Retained<NSURLProtectionSpace>;
140
141 #[cfg(feature = "NSURLCredential")]
142 /// Get the proposed credential for this challenge
143 ///
144 /// Returns: The proposed credential
145 ///
146 /// proposedCredential may be nil, if there is no default
147 /// credential to use for this challenge (either stored or in the
148 /// URL). If the credential is not nil and returns YES for
149 /// hasPassword, this means the NSURLConnection thinks the credential
150 /// is ready to use as-is. If it returns NO for hasPassword, then the
151 /// credential is not ready to use as-is, but provides a default
152 /// username the client could use when prompting.
153 #[unsafe(method(proposedCredential))]
154 #[unsafe(method_family = none)]
155 pub unsafe fn proposedCredential(&self) -> Option<Retained<NSURLCredential>>;
156
157 /// Get count of previous failed authentication attempts
158 ///
159 /// Returns: The count of previous failures
160 #[unsafe(method(previousFailureCount))]
161 #[unsafe(method_family = none)]
162 pub unsafe fn previousFailureCount(&self) -> NSInteger;
163
164 #[cfg(feature = "NSURLResponse")]
165 /// Get the response representing authentication failure.
166 ///
167 /// Returns: The failure response or nil
168 ///
169 /// If there was a previous authentication failure, and
170 /// this protocol uses responses to indicate authentication failure,
171 /// then this method will return the response. Otherwise it will
172 /// return nil.
173 #[unsafe(method(failureResponse))]
174 #[unsafe(method_family = none)]
175 pub unsafe fn failureResponse(&self) -> Option<Retained<NSURLResponse>>;
176
177 #[cfg(feature = "NSError")]
178 /// Get the error representing authentication failure.
179 ///
180 /// If there was a previous authentication failure, and
181 /// this protocol uses errors to indicate authentication failure,
182 /// then this method will return the error. Otherwise it will
183 /// return nil.
184 #[unsafe(method(error))]
185 #[unsafe(method_family = none)]
186 pub unsafe fn error(&self) -> Option<Retained<NSError>>;
187
188 /// Get the sender of this challenge
189 ///
190 /// Returns: The sender of the challenge
191 ///
192 /// The sender is the object you should reply to when done processing the challenge.
193 #[unsafe(method(sender))]
194 #[unsafe(method_family = none)]
195 pub unsafe fn sender(
196 &self,
197 ) -> Option<Retained<ProtocolObject<dyn NSURLAuthenticationChallengeSender>>>;
198 );
199}
200
201/// Methods declared on superclass `NSObject`.
202impl NSURLAuthenticationChallenge {
203 extern_methods!(
204 #[unsafe(method(init))]
205 #[unsafe(method_family = init)]
206 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
207
208 #[unsafe(method(new))]
209 #[unsafe(method_family = new)]
210 pub unsafe fn new() -> Retained<Self>;
211 );
212}