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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-app-kit")]
use objc2_app_kit::*;
#[cfg(feature = "objc2-core-services")]
use objc2_core_services::*;
use objc2_foundation::*;
#[cfg(feature = "objc2-security")]
use objc2_security::*;
use crate::*;
extern_class!(
/// A `CBIdentity` object is used for accessing the attributes of an
/// identity stored in an identity authority. You can use an identity object
/// for finding identities, and storing them in an access control list
/// (ACL). If you need to edit these attributes, take advantage of the
/// `CSIdentity` class in Core Services.
///
/// You can obtain a `CBIdentity` object from one of the following class
/// factory methods: ``CBIdentity/identityWithName:authority:``,
/// ``CBIdentity/identityWithUUIDString:authority:``,
/// ``CBIdentity/identityWithPersistentReference:``, or
/// ``CBIdentity/identityWithCSIdentity:``.
///
/// A `CBIdentity` object has methods to support for interoperability with
/// the Core Services Identity API. Send ``CBIdentity/CSIdentity`` to your
/// `CBIdentity` object to return an opaque object for use in the Core
/// Services Identity API. Similarly, call
/// ``CBIdentity/identityWithCSIdentity:`` to use an Core Services Identity
/// opaque object in the Collaboration framework.
///
/// There are two subclasses of `CBIdentity`: `CBGroupIdentity` and
/// `CBUserIdentity`. If you are working specifically with a group identity,
/// use `CBGroupIdentity`. Similarly, if you are working with a user
/// identity, use `CBUserIdentity`.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/collaboration/cbidentity?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct CBIdentity;
);
extern_conformance!(
unsafe impl NSCoding for CBIdentity {}
);
extern_conformance!(
unsafe impl NSCopying for CBIdentity {}
);
unsafe impl CopyingHelper for CBIdentity {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for CBIdentity {}
);
impl CBIdentity {
extern_methods!(
#[cfg(feature = "CBIdentityAuthority")]
/// Returns the identity object with the given name from the specified identity
/// authority.
///
/// The name is compared against all valid identity names, including full names,
/// short names, email addresses, and aliases.
///
/// - Parameters:
/// - name: The name of the identity.
///
/// - authority: The identity authority to search.
///
/// - Returns: The identity object, or `nil` if no identity is found with the
/// specified name.
#[unsafe(method(identityWithName:authority:))]
#[unsafe(method_family = none)]
pub unsafe fn identityWithName_authority(
name: &NSString,
authority: &CBIdentityAuthority,
) -> Option<Retained<CBIdentity>>;
#[cfg(feature = "CBIdentityAuthority")]
#[unsafe(method(identityWithUniqueIdentifier:authority:))]
#[unsafe(method_family = none)]
pub unsafe fn identityWithUniqueIdentifier_authority(
uuid: &NSUUID,
authority: &CBIdentityAuthority,
) -> Option<Retained<CBIdentity>>;
#[cfg(feature = "CBIdentityAuthority")]
/// Returns the identity object with the given UUID from the specified identity
/// authority.
///
/// - Parameters:
/// - uuid: The UUID of the identity you are searching for.
///
/// - authority: The identity authority to search.
///
/// - Returns: The identity object, or `nil` if no identity is found with the
/// matching criteria.
#[deprecated = "Use +identityWithUniqueIdentifier:authority: instead."]
#[unsafe(method(identityWithUUIDString:authority:))]
#[unsafe(method_family = none)]
pub unsafe fn identityWithUUIDString_authority(
uuid: &NSString,
authority: &CBIdentityAuthority,
) -> Option<Retained<CBIdentity>>;
/// Returns the identity object matching the persistent reference data.
///
/// A persistent reference is an opaque data object suitable for persistent
/// storage.
///
/// - Parameters:
/// - data: The persistent data object that refers to an identity.
///
/// - Returns: The identity object matching the persistent data object, or `nil`
/// if the identity is not found.
#[unsafe(method(identityWithPersistentReference:))]
#[unsafe(method_family = none)]
pub unsafe fn identityWithPersistentReference(
data: &NSData,
) -> Option<Retained<CBIdentity>>;
#[cfg(feature = "objc2-core-services")]
/// Returns an identity object created from the specified Core Services Identity
/// opaque object.
///
/// This method is used for interoperability with the Core Services Identity
/// API.
///
/// - Parameters:
/// - csIdentity: The Core Services Identity opaque object.
///
/// - Returns: The identity object for use with the Collaboration framework.
#[unsafe(method(identityWithCSIdentity:))]
#[unsafe(method_family = none)]
pub unsafe fn identityWithCSIdentity(cs_identity: &CSIdentity) -> Retained<CBIdentity>;
#[cfg(feature = "CBIdentityAuthority")]
/// Returns the identity authority where the identity is stored.
///
/// - Returns: The identity authority where the identity is stored.
#[unsafe(method(authority))]
#[unsafe(method_family = none)]
pub unsafe fn authority(&self) -> Retained<CBIdentityAuthority>;
#[unsafe(method(uniqueIdentifier))]
#[unsafe(method_family = none)]
pub unsafe fn uniqueIdentifier(&self) -> Retained<NSUUID>;
/// Returns the UUID of the identity as a string.
///
/// The UUID string is generated so it is unique across all identity
/// authorities. When storing ACLs, one method is to store the UUID of each
/// identity. However, it is recommended that you use a persistent data object
/// instead (see ``CBIdentity/persistentReference``).
///
/// - Returns: The UUID string of the identity.
#[deprecated = "Use the uniqueIdentifier property instead."]
#[unsafe(method(UUIDString))]
#[unsafe(method_family = none)]
pub unsafe fn UUIDString(&self) -> Retained<NSString>;
/// Returns the full name of the identity.
///
/// - Returns: The full name for the identity.
#[unsafe(method(fullName))]
#[unsafe(method_family = none)]
pub unsafe fn fullName(&self) -> Retained<NSString>;
/// Returns the POSIX name of the identity.
///
/// The POSIX name is also referred to as the “short name” for an identity. It
/// can only contain the characters A-Z, a-z, 0-9, -, _, ., and
/// .
///
/// - Returns: The POSIX name of the identity.
#[unsafe(method(posixName))]
#[unsafe(method_family = none)]
pub unsafe fn posixName(&self) -> Retained<NSString>;
/// Returns an array of aliases (alternate names) for the identity.
///
/// An identity can have zero or more aliases. Like the full and short names,
/// two identities cannot share an alias.
///
/// - Returns: An array of `NSString` objects containing the alternate names for
/// the identity.
#[unsafe(method(aliases))]
#[unsafe(method_family = none)]
pub unsafe fn aliases(&self) -> Retained<NSArray<NSString>>;
/// Returns the email address of an identity.
///
/// - Returns: The email address of an identity or `nil` if none exists.
#[unsafe(method(emailAddress))]
#[unsafe(method_family = none)]
pub unsafe fn emailAddress(&self) -> Option<Retained<NSString>>;
#[cfg(feature = "objc2-app-kit")]
/// Returns the image associated with an identity.
///
/// - Returns: The image associated with an identity, or `nil` if none exists.
#[unsafe(method(image))]
#[unsafe(method_family = none)]
pub unsafe fn image(&self) -> Option<Retained<NSImage>>;
/// Returns a persistent reference to store a reference to an identity.
///
/// A persistent reference data object is an object generated from an identity.
/// Persistent data objects can be written to and read from a file, making them
/// extremely useful for storing identities in an ACL.
///
/// - Returns: A data object that uniquely references an identity.
#[unsafe(method(persistentReference))]
#[unsafe(method_family = none)]
pub unsafe fn persistentReference(&self) -> Option<Retained<NSData>>;
/// Returns a Boolean value indicating the state of the identity’s hidden property.
///
/// A hidden identity does not show up in the Identity Picker. A hidden identity refers
/// to system identities such as `root`, `www`, and `wheel`.
///
/// - Returns:
/// <doc
/// ://com.apple.documentation/documentation/objectivec/yes> if the identity is hidden;
/// <doc
/// ://com.apple.documentation/documentation/objectivec/no> if it is not.
#[unsafe(method(isHidden))]
#[unsafe(method_family = none)]
pub unsafe fn isHidden(&self) -> bool;
/// Returns a Boolean value indicating whether the identity is a member of the
/// specified group.
///
/// - Parameters:
/// - group: The group to check for membership.
///
/// - Returns:
/// <doc
/// ://com.apple.documentation/documentation/objectivec/yes> if
/// the identity is a member of the group;
/// <doc
/// ://com.apple.documentation/documentation/objectivec/no> if it is not.
#[unsafe(method(isMemberOfGroup:))]
#[unsafe(method_family = none)]
pub unsafe fn isMemberOfGroup(&self, group: &CBGroupIdentity) -> bool;
#[cfg(feature = "objc2-core-services")]
/// Returns an opaque object for use with the Core Services Identity API.
///
/// This method, along with ``CBIdentity/identityWithCSIdentity:``, is used for
/// interoperability with the Core Services Identity API.
///
/// - Returns: The opaque object for use with the Core Services Identity API.
#[unsafe(method(CSIdentity))]
#[unsafe(method_family = none)]
pub unsafe fn CSIdentity(&self) -> Retained<CSIdentity>;
);
}
/// Methods declared on superclass `NSObject`.
impl CBIdentity {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
extern_class!(
/// An object of the `CBUserIdentity` class represents a user identity and is
/// used for accessing the attributes of a user identity from an identity
/// authority. The principal attributes of `CBUserIdentity` are a POSIX user
/// identifier (UID), password, and certificate.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/collaboration/cbuseridentity?language=objc)
#[unsafe(super(CBIdentity, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct CBUserIdentity;
);
extern_conformance!(
unsafe impl NSCoding for CBUserIdentity {}
);
extern_conformance!(
unsafe impl NSCopying for CBUserIdentity {}
);
unsafe impl CopyingHelper for CBUserIdentity {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for CBUserIdentity {}
);
impl CBUserIdentity {
extern_methods!(
#[cfg(all(feature = "CBIdentityAuthority", feature = "libc"))]
/// Returns the user identity with the given POSIX UID in the specified identity
/// authority.
///
/// - Parameters:
/// - uid: The UID of the identity you are searching for.
///
/// - authority: The identity authority to search.
///
/// - Returns: The user identity with the given UID in the specified identity
/// authority, or `nil` if no identity exists with the specified UID.
#[unsafe(method(userIdentityWithPosixUID:authority:))]
#[unsafe(method_family = none)]
pub unsafe fn userIdentityWithPosixUID_authority(
uid: libc::uid_t,
authority: &CBIdentityAuthority,
) -> Option<Retained<CBUserIdentity>>;
#[cfg(feature = "libc")]
/// Returns the POSIX UID of the identity.
///
/// The POSIX UID is a integer that can identify a user within an identity
/// authority. UIDs are not guaranteed to be unique within an identity
/// authority.
///
/// - Returns: The POSIX UID of the identity.
#[unsafe(method(posixUID))]
#[unsafe(method_family = none)]
pub unsafe fn posixUID(&self) -> libc::uid_t;
#[cfg(feature = "objc2-security")]
/// Returns the public authentication certificate associated with a user
/// identity.
///
/// The Collaboration framework supports certificate-based authentication in
/// addition to passwords. If a certificate is stored for a user identity, it
/// will be the default method of authentication.
///
/// When a .Mac account is associated with a user identity, the authentication
/// certificate is automatically downloaded from the .Mac servers.
///
/// - Returns: The public authentication certificate, or `nil` if none exists.
#[unsafe(method(certificate))]
#[unsafe(method_family = none)]
pub unsafe fn certificate(&self) -> Option<Retained<SecCertificate>>;
/// Returns a Boolean value indicating whether the identity is allowed to authenticate.
///
/// If the identity does not have authentication credentials (a password or certificate),
/// it is not able to log in. However, an identity with authentication credentials does
/// not ensure that it is enabled. Any identity can be disabled.
///
/// - Returns: `TRUE` if the identity can authenticate; otherwise, `FALSE`.
#[unsafe(method(isEnabled))]
#[unsafe(method_family = none)]
pub unsafe fn isEnabled(&self) -> bool;
/// Returns a Boolean value indicating whether the given password is correct for
/// the identity.
///
/// - Parameters:
/// - password: The password to test for the identity.
///
/// - Returns: `TRUE` if the password is correct; otherwise, `FALSE`.
#[unsafe(method(authenticateWithPassword:))]
#[unsafe(method_family = none)]
pub unsafe fn authenticateWithPassword(&self, password: &NSString) -> bool;
);
}
/// Methods declared on superclass `NSObject`.
impl CBUserIdentity {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
extern_class!(
/// An object of the `CBGroupIdentity` class represents a group identity and is
/// used for viewing the attributes of group identities from an identity
/// authority. The principal attributes of a `CBGroupIdentity` object are a
/// POSIX group identifier (GID) and a list of members.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/collaboration/cbgroupidentity?language=objc)
#[unsafe(super(CBIdentity, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct CBGroupIdentity;
);
extern_conformance!(
unsafe impl NSCoding for CBGroupIdentity {}
);
extern_conformance!(
unsafe impl NSCopying for CBGroupIdentity {}
);
unsafe impl CopyingHelper for CBGroupIdentity {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for CBGroupIdentity {}
);
impl CBGroupIdentity {
extern_methods!(
#[cfg(all(feature = "CBIdentityAuthority", feature = "libc"))]
/// Returns the group identity with the given POSIX GID in the specified
/// identity authority.
///
/// - Parameters:
/// - gid: The GID of the group identity you are searching for.
/// - authority: An identity authority in which to search for the group identity.
/// - Returns: The group identity object with the given GID in the specified
/// identity authority, or `nil` if no identity exists with the specified GID.
///
/// ## See Also
///
/// - [Identity Services Programming Guide](https://developer.apple.com/library/archive/documentation/Networking/Conceptual/IdentityServices_ProgGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40004490)
#[unsafe(method(groupIdentityWithPosixGID:authority:))]
#[unsafe(method_family = none)]
pub unsafe fn groupIdentityWithPosixGID_authority(
gid: libc::gid_t,
authority: &CBIdentityAuthority,
) -> Option<Retained<CBGroupIdentity>>;
#[cfg(feature = "libc")]
/// Returns the POSIX GID of the identity.
///
/// The POSIX GID is an integer that can identify a group within an identity
/// authority. GIDs are not guaranteed to be unique within an identity
/// authority.
///
/// - Returns: The POSIX GID of the group identity.
#[unsafe(method(posixGID))]
#[unsafe(method_family = none)]
pub unsafe fn posixGID(&self) -> libc::gid_t;
/// Returns the members of the group.
///
/// This method only returns direct members of a group, it does not return
/// members of members. Both user and group identities can be members of a
/// group, but a group cannot be a member of itself. You also cannot have
/// “circular” membership, i.e. a group be a member of another group that is a
/// member of the first group.
///
/// - Returns: An array of `CBIdentity` objects each representing a member of
/// the group identity.
#[deprecated = "Use the memberIdentities property instead."]
#[unsafe(method(members))]
#[unsafe(method_family = none)]
pub unsafe fn members(&self) -> Option<Retained<NSArray>>;
#[unsafe(method(memberIdentities))]
#[unsafe(method_family = none)]
pub unsafe fn memberIdentities(&self) -> Retained<NSArray<CBIdentity>>;
);
}
/// Methods declared on superclass `NSObject`.
impl CBGroupIdentity {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}