objc2_collaboration/generated/
CBIdentity.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#[cfg(feature = "objc2-app-kit")]
6use objc2_app_kit::*;
7#[cfg(feature = "objc2-core-services")]
8use objc2_core_services::*;
9use objc2_foundation::*;
10#[cfg(feature = "objc2-security")]
11use objc2_security::*;
12
13use crate::*;
14
15extern_class!(
16    /// A `CBIdentity` object is used for accessing the attributes of an
17    /// identity stored in an identity authority. You can use an identity object
18    /// for finding identities, and storing them in an access control list
19    /// (ACL). If you need to edit these attributes, take advantage of the
20    /// `CSIdentity` class in Core Services.
21    ///
22    /// You can obtain a `CBIdentity` object from one of the following class
23    /// factory methods: ``CBIdentity/identityWithName:authority:``,
24    /// ``CBIdentity/identityWithUUIDString:authority:``,
25    /// ``CBIdentity/identityWithPersistentReference:``, or
26    /// ``CBIdentity/identityWithCSIdentity:``.
27    ///
28    /// A `CBIdentity` object has methods to support for interoperability with
29    /// the Core Services Identity API. Send ``CBIdentity/CSIdentity`` to your
30    /// `CBIdentity` object to return an opaque object for use in the Core
31    /// Services Identity API. Similarly, call
32    /// ``CBIdentity/identityWithCSIdentity:`` to use an Core Services Identity
33    /// opaque object in the Collaboration framework.
34    ///
35    /// There are two subclasses of `CBIdentity`: `CBGroupIdentity` and
36    /// `CBUserIdentity`. If you are working specifically with a group identity,
37    /// use `CBGroupIdentity`. Similarly, if you are working with a user
38    /// identity, use `CBUserIdentity`.
39    ///
40    /// See also [Apple's documentation](https://developer.apple.com/documentation/collaboration/cbidentity?language=objc)
41    #[unsafe(super(NSObject))]
42    #[derive(Debug, PartialEq, Eq, Hash)]
43    pub struct CBIdentity;
44);
45
46extern_conformance!(
47    unsafe impl NSCoding for CBIdentity {}
48);
49
50extern_conformance!(
51    unsafe impl NSCopying for CBIdentity {}
52);
53
54unsafe impl CopyingHelper for CBIdentity {
55    type Result = Self;
56}
57
58extern_conformance!(
59    unsafe impl NSObjectProtocol for CBIdentity {}
60);
61
62impl CBIdentity {
63    extern_methods!(
64        #[cfg(feature = "CBIdentityAuthority")]
65        /// Returns the identity object with the given name from the specified identity
66        /// authority.
67        ///
68        /// The name is compared against all valid identity names, including full names,
69        /// short names, email addresses, and aliases.
70        ///
71        /// - Parameters:
72        /// - name: The name of the identity.
73        ///
74        /// - authority: The identity authority to search.
75        ///
76        /// - Returns: The identity object, or `nil` if no identity is found with the
77        /// specified name.
78        #[unsafe(method(identityWithName:authority:))]
79        #[unsafe(method_family = none)]
80        pub unsafe fn identityWithName_authority(
81            name: &NSString,
82            authority: &CBIdentityAuthority,
83        ) -> Option<Retained<CBIdentity>>;
84
85        #[cfg(feature = "CBIdentityAuthority")]
86        #[unsafe(method(identityWithUniqueIdentifier:authority:))]
87        #[unsafe(method_family = none)]
88        pub unsafe fn identityWithUniqueIdentifier_authority(
89            uuid: &NSUUID,
90            authority: &CBIdentityAuthority,
91        ) -> Option<Retained<CBIdentity>>;
92
93        #[cfg(feature = "CBIdentityAuthority")]
94        /// Returns the identity object with the given UUID from the specified identity
95        /// authority.
96        ///
97        /// - Parameters:
98        /// - uuid: The UUID of the identity you are searching for.
99        ///
100        /// - authority: The identity authority to search.
101        ///
102        /// - Returns: The identity object, or `nil` if no identity is found with the
103        /// matching criteria.
104        #[deprecated = "Use +identityWithUniqueIdentifier:authority: instead."]
105        #[unsafe(method(identityWithUUIDString:authority:))]
106        #[unsafe(method_family = none)]
107        pub unsafe fn identityWithUUIDString_authority(
108            uuid: &NSString,
109            authority: &CBIdentityAuthority,
110        ) -> Option<Retained<CBIdentity>>;
111
112        /// Returns the identity object matching the persistent reference data.
113        ///
114        /// A persistent reference is an opaque data object suitable for persistent
115        /// storage.
116        ///
117        /// - Parameters:
118        /// - data: The persistent data object that refers to an identity.
119        ///
120        /// - Returns: The identity object matching the persistent data object, or `nil`
121        /// if the identity is not found.
122        #[unsafe(method(identityWithPersistentReference:))]
123        #[unsafe(method_family = none)]
124        pub unsafe fn identityWithPersistentReference(
125            data: &NSData,
126        ) -> Option<Retained<CBIdentity>>;
127
128        #[cfg(feature = "objc2-core-services")]
129        /// Returns an identity object created from the specified Core Services Identity
130        /// opaque object.
131        ///
132        /// This method is used for interoperability with the Core Services Identity
133        /// API.
134        ///
135        /// - Parameters:
136        /// - csIdentity: The Core Services Identity opaque object.
137        ///
138        /// - Returns: The identity object for use with the Collaboration framework.
139        #[unsafe(method(identityWithCSIdentity:))]
140        #[unsafe(method_family = none)]
141        pub unsafe fn identityWithCSIdentity(cs_identity: &CSIdentity) -> Retained<CBIdentity>;
142
143        #[cfg(feature = "CBIdentityAuthority")]
144        /// Returns the identity authority where the identity is stored.
145        ///
146        /// - Returns: The identity authority where the identity is stored.
147        #[unsafe(method(authority))]
148        #[unsafe(method_family = none)]
149        pub unsafe fn authority(&self) -> Retained<CBIdentityAuthority>;
150
151        #[unsafe(method(uniqueIdentifier))]
152        #[unsafe(method_family = none)]
153        pub unsafe fn uniqueIdentifier(&self) -> Retained<NSUUID>;
154
155        /// Returns the UUID of the identity as a string.
156        ///
157        /// The UUID string is generated so it is unique across all identity
158        /// authorities. When storing ACLs, one method is to store the UUID of each
159        /// identity. However, it is recommended that you use a persistent data object
160        /// instead (see ``CBIdentity/persistentReference``).
161        ///
162        /// - Returns: The UUID string of the identity.
163        #[deprecated = "Use the uniqueIdentifier property instead."]
164        #[unsafe(method(UUIDString))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn UUIDString(&self) -> Retained<NSString>;
167
168        /// Returns the full name of the identity.
169        ///
170        /// - Returns: The full name for the identity.
171        #[unsafe(method(fullName))]
172        #[unsafe(method_family = none)]
173        pub unsafe fn fullName(&self) -> Retained<NSString>;
174
175        /// Returns the POSIX name of the identity.
176        ///
177        /// The POSIX name is also referred to as the “short name” for an identity. It
178        /// can only contain the characters A-Z, a-z, 0-9, -, _, ., and
179        /// .
180        ///
181        /// - Returns: The POSIX name of the identity.
182        #[unsafe(method(posixName))]
183        #[unsafe(method_family = none)]
184        pub unsafe fn posixName(&self) -> Retained<NSString>;
185
186        /// Returns an array of aliases (alternate names) for the identity.
187        ///
188        /// An identity can have zero or more aliases. Like the full and short names,
189        /// two identities cannot share an alias.
190        ///
191        /// - Returns: An array of `NSString` objects containing the alternate names for
192        /// the identity.
193        #[unsafe(method(aliases))]
194        #[unsafe(method_family = none)]
195        pub unsafe fn aliases(&self) -> Retained<NSArray<NSString>>;
196
197        /// Returns the email address of an identity.
198        ///
199        /// - Returns: The email address of an identity or `nil` if none exists.
200        #[unsafe(method(emailAddress))]
201        #[unsafe(method_family = none)]
202        pub unsafe fn emailAddress(&self) -> Option<Retained<NSString>>;
203
204        #[cfg(feature = "objc2-app-kit")]
205        /// Returns the image associated with an identity.
206        ///
207        /// - Returns: The image associated with an identity, or `nil` if none exists.
208        #[unsafe(method(image))]
209        #[unsafe(method_family = none)]
210        pub unsafe fn image(&self) -> Option<Retained<NSImage>>;
211
212        /// Returns a persistent reference to store a reference to an identity.
213        ///
214        /// A persistent reference data object is an object generated from an identity.
215        /// Persistent data objects can be written to and read from a file, making them
216        /// extremely useful for storing identities in an ACL.
217        ///
218        /// - Returns: A data object that uniquely references an identity.
219        #[unsafe(method(persistentReference))]
220        #[unsafe(method_family = none)]
221        pub unsafe fn persistentReference(&self) -> Option<Retained<NSData>>;
222
223        /// Returns a Boolean value indicating the state of the identity’s hidden property.
224        ///
225        /// A hidden identity does not show up in the Identity Picker. A hidden identity refers
226        /// to system identities such as `root`, `www`, and `wheel`.
227        ///
228        /// - Returns:
229        /// <doc
230        /// ://com.apple.documentation/documentation/objectivec/yes> if the identity is hidden;
231        /// <doc
232        /// ://com.apple.documentation/documentation/objectivec/no> if it is not.
233        #[unsafe(method(isHidden))]
234        #[unsafe(method_family = none)]
235        pub unsafe fn isHidden(&self) -> bool;
236
237        /// Returns a Boolean value indicating whether the identity is a member of the
238        /// specified group.
239        ///
240        /// - Parameters:
241        /// - group: The group to check for membership.
242        ///
243        /// - Returns:
244        /// <doc
245        /// ://com.apple.documentation/documentation/objectivec/yes> if
246        /// the identity is a member of the group;
247        /// <doc
248        /// ://com.apple.documentation/documentation/objectivec/no> if it is not.
249        #[unsafe(method(isMemberOfGroup:))]
250        #[unsafe(method_family = none)]
251        pub unsafe fn isMemberOfGroup(&self, group: &CBGroupIdentity) -> bool;
252
253        #[cfg(feature = "objc2-core-services")]
254        /// Returns an opaque object for use with the Core Services Identity API.
255        ///
256        /// This method, along with ``CBIdentity/identityWithCSIdentity:``, is used for
257        /// interoperability with the Core Services Identity API.
258        ///
259        /// - Returns: The opaque object for use with the Core Services Identity API.
260        #[unsafe(method(CSIdentity))]
261        #[unsafe(method_family = none)]
262        pub unsafe fn CSIdentity(&self) -> Retained<CSIdentity>;
263    );
264}
265
266/// Methods declared on superclass `NSObject`.
267impl CBIdentity {
268    extern_methods!(
269        #[unsafe(method(init))]
270        #[unsafe(method_family = init)]
271        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
272
273        #[unsafe(method(new))]
274        #[unsafe(method_family = new)]
275        pub unsafe fn new() -> Retained<Self>;
276    );
277}
278
279extern_class!(
280    /// An object of the `CBUserIdentity` class represents a user identity and is
281    /// used for accessing the attributes of a user identity from an identity
282    /// authority. The principal attributes of `CBUserIdentity` are a POSIX user
283    /// identifier (UID), password, and certificate.
284    ///
285    /// See also [Apple's documentation](https://developer.apple.com/documentation/collaboration/cbuseridentity?language=objc)
286    #[unsafe(super(CBIdentity, NSObject))]
287    #[derive(Debug, PartialEq, Eq, Hash)]
288    pub struct CBUserIdentity;
289);
290
291extern_conformance!(
292    unsafe impl NSCoding for CBUserIdentity {}
293);
294
295extern_conformance!(
296    unsafe impl NSCopying for CBUserIdentity {}
297);
298
299unsafe impl CopyingHelper for CBUserIdentity {
300    type Result = Self;
301}
302
303extern_conformance!(
304    unsafe impl NSObjectProtocol for CBUserIdentity {}
305);
306
307impl CBUserIdentity {
308    extern_methods!(
309        #[cfg(all(feature = "CBIdentityAuthority", feature = "libc"))]
310        /// Returns the user identity with the given POSIX UID in the specified identity
311        /// authority.
312        ///
313        /// - Parameters:
314        /// - uid: The UID of the identity you are searching for.
315        ///
316        /// - authority: The identity authority to search.
317        ///
318        /// - Returns: The user identity with the given UID in the specified identity
319        /// authority, or `nil` if no identity exists with the specified UID.
320        #[unsafe(method(userIdentityWithPosixUID:authority:))]
321        #[unsafe(method_family = none)]
322        pub unsafe fn userIdentityWithPosixUID_authority(
323            uid: libc::uid_t,
324            authority: &CBIdentityAuthority,
325        ) -> Option<Retained<CBUserIdentity>>;
326
327        #[cfg(feature = "libc")]
328        /// Returns the POSIX UID of the identity.
329        ///
330        /// The POSIX UID is a integer that can identify a user within an identity
331        /// authority. UIDs are not guaranteed to be unique within an identity
332        /// authority.
333        ///
334        /// - Returns: The POSIX UID of the identity.
335        #[unsafe(method(posixUID))]
336        #[unsafe(method_family = none)]
337        pub unsafe fn posixUID(&self) -> libc::uid_t;
338
339        #[cfg(feature = "objc2-security")]
340        /// Returns the public authentication certificate associated with a user
341        /// identity.
342        ///
343        /// The Collaboration framework supports certificate-based authentication in
344        /// addition to passwords. If a certificate is stored for a user identity, it
345        /// will be the default method of authentication.
346        ///
347        /// When a .Mac account is associated with a user identity, the authentication
348        /// certificate is automatically downloaded from the .Mac servers.
349        ///
350        /// - Returns: The public authentication certificate, or `nil` if none exists.
351        #[unsafe(method(certificate))]
352        #[unsafe(method_family = none)]
353        pub unsafe fn certificate(&self) -> Option<Retained<SecCertificate>>;
354
355        /// Returns a Boolean value indicating whether the identity is allowed to authenticate.
356        ///
357        /// If the identity does not have authentication credentials (a password or certificate),
358        /// it is not able to log in. However, an identity with authentication credentials does
359        /// not ensure that it is enabled. Any identity can be disabled.
360        ///
361        /// - Returns: `TRUE` if the identity can authenticate; otherwise, `FALSE`.
362        #[unsafe(method(isEnabled))]
363        #[unsafe(method_family = none)]
364        pub unsafe fn isEnabled(&self) -> bool;
365
366        /// Returns a Boolean value indicating whether the given password is correct for
367        /// the identity.
368        ///
369        /// - Parameters:
370        /// - password: The password to test for the identity.
371        ///
372        /// - Returns: `TRUE` if the password is correct; otherwise, `FALSE`.
373        #[unsafe(method(authenticateWithPassword:))]
374        #[unsafe(method_family = none)]
375        pub unsafe fn authenticateWithPassword(&self, password: &NSString) -> bool;
376    );
377}
378
379/// Methods declared on superclass `NSObject`.
380impl CBUserIdentity {
381    extern_methods!(
382        #[unsafe(method(init))]
383        #[unsafe(method_family = init)]
384        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
385
386        #[unsafe(method(new))]
387        #[unsafe(method_family = new)]
388        pub unsafe fn new() -> Retained<Self>;
389    );
390}
391
392extern_class!(
393    /// An object of the `CBGroupIdentity` class represents a group identity and is
394    /// used for viewing the attributes of group identities from an identity
395    /// authority. The principal attributes of a `CBGroupIdentity` object are a
396    /// POSIX group identifier (GID) and a list of members.
397    ///
398    /// See also [Apple's documentation](https://developer.apple.com/documentation/collaboration/cbgroupidentity?language=objc)
399    #[unsafe(super(CBIdentity, NSObject))]
400    #[derive(Debug, PartialEq, Eq, Hash)]
401    pub struct CBGroupIdentity;
402);
403
404extern_conformance!(
405    unsafe impl NSCoding for CBGroupIdentity {}
406);
407
408extern_conformance!(
409    unsafe impl NSCopying for CBGroupIdentity {}
410);
411
412unsafe impl CopyingHelper for CBGroupIdentity {
413    type Result = Self;
414}
415
416extern_conformance!(
417    unsafe impl NSObjectProtocol for CBGroupIdentity {}
418);
419
420impl CBGroupIdentity {
421    extern_methods!(
422        #[cfg(all(feature = "CBIdentityAuthority", feature = "libc"))]
423        /// Returns the group identity with the given POSIX GID in the specified
424        /// identity authority.
425        ///
426        /// - Parameters:
427        /// - gid: The GID of the group identity you are searching for.
428        /// - authority: An identity authority in which to search for the group identity.
429        /// - Returns: The group identity object with the given GID in the specified
430        /// identity authority, or `nil` if no identity exists with the specified GID.
431        ///
432        /// ## See Also
433        ///
434        /// - [Identity Services Programming Guide](https://developer.apple.com/library/archive/documentation/Networking/Conceptual/IdentityServices_ProgGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40004490)
435        #[unsafe(method(groupIdentityWithPosixGID:authority:))]
436        #[unsafe(method_family = none)]
437        pub unsafe fn groupIdentityWithPosixGID_authority(
438            gid: libc::gid_t,
439            authority: &CBIdentityAuthority,
440        ) -> Option<Retained<CBGroupIdentity>>;
441
442        #[cfg(feature = "libc")]
443        /// Returns the POSIX GID of the identity.
444        ///
445        /// The POSIX GID is an integer that can identify a group within an identity
446        /// authority. GIDs are not guaranteed to be unique within an identity
447        /// authority.
448        ///
449        /// - Returns: The POSIX GID of the group identity.
450        #[unsafe(method(posixGID))]
451        #[unsafe(method_family = none)]
452        pub unsafe fn posixGID(&self) -> libc::gid_t;
453
454        /// Returns the members of the group.
455        ///
456        /// This method only returns direct members of a group, it does not return
457        /// members of members. Both user and group identities can be members of a
458        /// group, but a group cannot be a member of itself. You also cannot have
459        /// “circular” membership, i.e. a group be a member of another group that is a
460        /// member of the first group.
461        ///
462        /// - Returns: An array of `CBIdentity` objects each representing a member of
463        /// the group identity.
464        #[deprecated = "Use the memberIdentities property instead."]
465        #[unsafe(method(members))]
466        #[unsafe(method_family = none)]
467        pub unsafe fn members(&self) -> Option<Retained<NSArray>>;
468
469        #[unsafe(method(memberIdentities))]
470        #[unsafe(method_family = none)]
471        pub unsafe fn memberIdentities(&self) -> Retained<NSArray<CBIdentity>>;
472    );
473}
474
475/// Methods declared on superclass `NSObject`.
476impl CBGroupIdentity {
477    extern_methods!(
478        #[unsafe(method(init))]
479        #[unsafe(method_family = init)]
480        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
481
482        #[unsafe(method(new))]
483        #[unsafe(method_family = new)]
484        pub unsafe fn new() -> Retained<Self>;
485    );
486}