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