1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use crate::*;
extern_class!(
/// NSURLCredentialStorage implements a singleton object (shared instance) which manages the shared credentials cache. Note: Whereas in Mac OS X any application can access any credential with a persistence of NSURLCredentialPersistencePermanent provided the user gives permission, in iPhone OS an application can access only its own credentials.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlcredentialstorage?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct NSURLCredentialStorage;
);
unsafe impl Send for NSURLCredentialStorage {}
unsafe impl Sync for NSURLCredentialStorage {}
extern_conformance!(
unsafe impl NSObjectProtocol for NSURLCredentialStorage {}
);
impl NSURLCredentialStorage {
extern_methods!(
/// Get the shared singleton authentication storage
///
/// Returns: the shared authentication storage
#[unsafe(method(sharedCredentialStorage))]
#[unsafe(method_family = none)]
pub fn sharedCredentialStorage() -> Retained<NSURLCredentialStorage>;
#[cfg(all(
feature = "NSDictionary",
feature = "NSString",
feature = "NSURLCredential",
feature = "NSURLProtectionSpace"
))]
/// Get a dictionary mapping usernames to credentials for the specified protection space.
///
/// Parameter `space`: An NSURLProtectionSpace indicating the protection space for which to get credentials
///
/// Returns: A dictionary where the keys are usernames and the values are the corresponding NSURLCredentials.
#[unsafe(method(credentialsForProtectionSpace:))]
#[unsafe(method_family = none)]
pub fn credentialsForProtectionSpace(
&self,
space: &NSURLProtectionSpace,
) -> Option<Retained<NSDictionary<NSString, NSURLCredential>>>;
#[cfg(all(
feature = "NSDictionary",
feature = "NSString",
feature = "NSURLCredential",
feature = "NSURLProtectionSpace"
))]
/// Get a dictionary mapping NSURLProtectionSpaces to dictionaries which map usernames to NSURLCredentials
///
/// Returns: an NSDictionary where the keys are NSURLProtectionSpaces
/// and the values are dictionaries, in which the keys are usernames
/// and the values are NSURLCredentials
#[unsafe(method(allCredentials))]
#[unsafe(method_family = none)]
pub fn allCredentials(
&self,
) -> Retained<NSDictionary<NSURLProtectionSpace, NSDictionary<NSString, NSURLCredential>>>;
#[cfg(all(feature = "NSURLCredential", feature = "NSURLProtectionSpace"))]
/// Add a new credential to the set for the specified protection space or replace an existing one.
///
/// Parameter `credential`: The credential to set.
///
/// Parameter `space`: The protection space for which to add it.
///
/// Multiple credentials may be set for a given protection space, but each must have
/// a distinct user. If a credential with the same user is already set for the protection space,
/// the new one will replace it.
#[unsafe(method(setCredential:forProtectionSpace:))]
#[unsafe(method_family = none)]
pub fn setCredential_forProtectionSpace(
&self,
credential: &NSURLCredential,
space: &NSURLProtectionSpace,
);
#[cfg(all(feature = "NSURLCredential", feature = "NSURLProtectionSpace"))]
/// Remove the credential from the set for the specified protection space.
///
/// Parameter `credential`: The credential to remove.
///
/// Parameter `space`: The protection space for which a credential should be removed
///
/// The credential is removed from both persistent and temporary storage. A credential that
/// has a persistence policy of NSURLCredentialPersistenceSynchronizable will fail.
/// See removeCredential:forProtectionSpace:options.
#[unsafe(method(removeCredential:forProtectionSpace:))]
#[unsafe(method_family = none)]
pub fn removeCredential_forProtectionSpace(
&self,
credential: &NSURLCredential,
space: &NSURLProtectionSpace,
);
#[cfg(all(
feature = "NSDictionary",
feature = "NSString",
feature = "NSURLCredential",
feature = "NSURLProtectionSpace"
))]
/// Remove the credential from the set for the specified protection space based on options.
///
/// Parameter `credential`: The credential to remove.
///
/// Parameter `space`: The protection space for which a credential should be removed
///
/// Parameter `options`: A dictionary containing options to consider when removing the credential. This should
/// be used when trying to delete a credential that has the NSURLCredentialPersistenceSynchronizable policy.
/// Please note that when NSURLCredential objects that have a NSURLCredentialPersistenceSynchronizable policy
/// are removed, the credential will be removed on all devices that contain this credential.
///
/// The credential is removed from both persistent and temporary storage.
///
/// # Safety
///
/// `options` generic should be of the correct type.
#[unsafe(method(removeCredential:forProtectionSpace:options:))]
#[unsafe(method_family = none)]
pub unsafe fn removeCredential_forProtectionSpace_options(
&self,
credential: &NSURLCredential,
space: &NSURLProtectionSpace,
options: Option<&NSDictionary<NSString, AnyObject>>,
);
#[cfg(all(feature = "NSURLCredential", feature = "NSURLProtectionSpace"))]
/// Get the default credential for the specified protection space.
///
/// Parameter `space`: The protection space for which to get the default credential.
#[unsafe(method(defaultCredentialForProtectionSpace:))]
#[unsafe(method_family = none)]
pub fn defaultCredentialForProtectionSpace(
&self,
space: &NSURLProtectionSpace,
) -> Option<Retained<NSURLCredential>>;
#[cfg(all(feature = "NSURLCredential", feature = "NSURLProtectionSpace"))]
/// Set the default credential for the specified protection space.
///
/// Parameter `credential`: The credential to set as default.
///
/// Parameter `space`: The protection space for which the credential should be set as default.
///
/// If the credential is not yet in the set for the protection space, it will be added to it.
#[unsafe(method(setDefaultCredential:forProtectionSpace:))]
#[unsafe(method_family = none)]
pub fn setDefaultCredential_forProtectionSpace(
&self,
credential: &NSURLCredential,
space: &NSURLProtectionSpace,
);
);
}
/// Methods declared on superclass `NSObject`.
impl NSURLCredentialStorage {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub fn new() -> Retained<Self>;
);
}
impl DefaultRetained for NSURLCredentialStorage {
#[inline]
fn default_retained() -> Retained<Self> {
Self::new()
}
}
/// NSURLSessionTaskAdditions.
impl NSURLCredentialStorage {
extern_methods!(
#[cfg(all(
feature = "NSDictionary",
feature = "NSString",
feature = "NSURLCredential",
feature = "NSURLProtectionSpace",
feature = "NSURLSession",
feature = "block2"
))]
/// # Safety
///
/// `completion_handler` block must be sendable.
#[unsafe(method(getCredentialsForProtectionSpace:task:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn getCredentialsForProtectionSpace_task_completionHandler(
&self,
protection_space: &NSURLProtectionSpace,
task: &NSURLSessionTask,
completion_handler: &block2::DynBlock<
dyn Fn(*mut NSDictionary<NSString, NSURLCredential>),
>,
);
#[cfg(all(
feature = "NSURLCredential",
feature = "NSURLProtectionSpace",
feature = "NSURLSession"
))]
#[unsafe(method(setCredential:forProtectionSpace:task:))]
#[unsafe(method_family = none)]
pub fn setCredential_forProtectionSpace_task(
&self,
credential: &NSURLCredential,
protection_space: &NSURLProtectionSpace,
task: &NSURLSessionTask,
);
#[cfg(all(
feature = "NSDictionary",
feature = "NSString",
feature = "NSURLCredential",
feature = "NSURLProtectionSpace",
feature = "NSURLSession"
))]
/// # Safety
///
/// `options` generic should be of the correct type.
#[unsafe(method(removeCredential:forProtectionSpace:options:task:))]
#[unsafe(method_family = none)]
pub unsafe fn removeCredential_forProtectionSpace_options_task(
&self,
credential: &NSURLCredential,
protection_space: &NSURLProtectionSpace,
options: Option<&NSDictionary<NSString, AnyObject>>,
task: &NSURLSessionTask,
);
#[cfg(all(
feature = "NSURLCredential",
feature = "NSURLProtectionSpace",
feature = "NSURLSession",
feature = "block2"
))]
/// # Safety
///
/// `completion_handler` block must be sendable.
#[unsafe(method(getDefaultCredentialForProtectionSpace:task:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn getDefaultCredentialForProtectionSpace_task_completionHandler(
&self,
space: &NSURLProtectionSpace,
task: &NSURLSessionTask,
completion_handler: &block2::DynBlock<dyn Fn(*mut NSURLCredential)>,
);
#[cfg(all(
feature = "NSURLCredential",
feature = "NSURLProtectionSpace",
feature = "NSURLSession"
))]
#[unsafe(method(setDefaultCredential:forProtectionSpace:task:))]
#[unsafe(method_family = none)]
pub fn setDefaultCredential_forProtectionSpace_task(
&self,
credential: &NSURLCredential,
protection_space: &NSURLProtectionSpace,
task: &NSURLSessionTask,
);
);
}
extern "C" {
/// This notification is sent on the main thread whenever
/// the set of stored credentials changes.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlcredentialstoragechangednotification?language=objc)
#[cfg(all(feature = "NSNotification", feature = "NSString"))]
#[deprecated = "Notification is never posted"]
pub static NSURLCredentialStorageChangedNotification: &'static NSNotificationName;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlcredentialstorageremovesynchronizablecredentials?language=objc)
#[cfg(feature = "NSString")]
pub static NSURLCredentialStorageRemoveSynchronizableCredentials: &'static NSString;
}