objc2_security_foundation/generated/
SFAuthorization.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::*;
6use objc2_foundation::*;
7#[cfg(feature = "objc2-security")]
8use objc2_security::*;
9
10use crate::*;
11
12extern_class!(
13    /// SFAuthorization APIs are used for implementing access control in applications and daemons. It has NSCoder support for proxied objects SFAuthorization is a wrapper for using the Authorization API.
14    ///
15    /// See also [Apple's documentation](https://developer.apple.com/documentation/securityfoundation/sfauthorization?language=objc)
16    #[unsafe(super(NSObject))]
17    #[derive(Debug, PartialEq, Eq, Hash)]
18    pub struct SFAuthorization;
19);
20
21extern_conformance!(
22    unsafe impl NSCoding for SFAuthorization {}
23);
24
25extern_conformance!(
26    unsafe impl NSObjectProtocol for SFAuthorization {}
27);
28
29extern_conformance!(
30    unsafe impl NSSecureCoding for SFAuthorization {}
31);
32
33impl SFAuthorization {
34    extern_methods!(
35        /// Returns an authorization object initialized with a default environment, flags and rights.
36        #[unsafe(method(authorization))]
37        #[unsafe(method_family = none)]
38        pub unsafe fn authorization() -> Option<Retained<AnyObject>>;
39
40        #[cfg(feature = "objc2-security")]
41        /// Returns the AuthorizationRef for this SFAuthorization.
42        #[unsafe(method(authorizationRef))]
43        #[unsafe(method_family = none)]
44        pub unsafe fn authorizationRef(&self) -> AuthorizationRef;
45
46        #[cfg(feature = "objc2-security")]
47        /// Returns an authorization object initialized with the specified flags, rights and environment.
48        ///
49        /// Parameter `flags`: Authorization flags.
50        ///
51        /// Parameter `rights`: (input/optional) An AuthorizationItemSet containing rights for which authorization is being requested.  If none are specified the resulting AuthorizationRef will authorize nothing at all.
52        ///
53        /// Parameter `environment`: (input/optional) An AuthorizationItemSet containing enviroment state used when making the autorization decision.  See the AuthorizationEnvironment type for details.
54        #[unsafe(method(authorizationWithFlags:rights:environment:))]
55        #[unsafe(method_family = none)]
56        pub unsafe fn authorizationWithFlags_rights_environment(
57            flags: AuthorizationFlags,
58            rights: *const AuthorizationRights,
59            environment: *const AuthorizationEnvironment,
60        ) -> Option<Retained<AnyObject>>;
61
62        #[cfg(feature = "objc2-security")]
63        /// Initializes an authorization object specified flags, rights and environment.
64        ///
65        /// Parameter `flags`: Authorization flags.
66        ///
67        /// Parameter `rights`: (input/optional) An AuthorizationItemSet containing rights for which authorization is being requested.  If none are specified the resulting AuthorizationRef will authorize nothing at all.
68        ///
69        /// Parameter `environment`: (input/optional) An AuthorizationItemSet containing enviroment state used when making the autorization decision.  See the AuthorizationEnvironment type for details.
70        #[unsafe(method(initWithFlags:rights:environment:))]
71        #[unsafe(method_family = init)]
72        pub unsafe fn initWithFlags_rights_environment(
73            this: Allocated<Self>,
74            flags: AuthorizationFlags,
75            rights: *const AuthorizationRights,
76            environment: *const AuthorizationEnvironment,
77        ) -> Option<Retained<Self>>;
78
79        /// Initializes an authorization object initialized with a default environment, flags and rights.
80        #[unsafe(method(init))]
81        #[unsafe(method_family = init)]
82        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
83
84        /// Calling this will prevent any rights that were obtained by this object to be preserved. It effectively locks down all potentially shared authorizations.
85        #[unsafe(method(invalidateCredentials))]
86        #[unsafe(method_family = none)]
87        pub unsafe fn invalidateCredentials(&self);
88
89        #[cfg(feature = "objc2-security")]
90        /// Call obtainWithRight to gain a right to have access to a privilege operation. On success, YES is returned.
91        ///
92        /// Parameter `rightName`: The name of an authorization right.
93        ///
94        /// Parameter `flags`: Authorization flags.
95        ///
96        /// Parameter `error`: Resulting error.
97        #[unsafe(method(obtainWithRight:flags:error:))]
98        #[unsafe(method_family = none)]
99        pub unsafe fn obtainWithRight_flags_error(
100            &self,
101            right_name: AuthorizationString,
102            flags: AuthorizationFlags,
103            error: Option<&mut Option<Retained<NSError>>>,
104        ) -> bool;
105
106        #[cfg(feature = "objc2-security")]
107        /// Call obtainWithRights to gain the rights to have access to privileged operations. On success, YES is returned.
108        ///
109        /// Parameter `flags`: Authorization flags.
110        ///
111        /// Parameter `rights`: (input) A rights set (see AuthorizationCreate).
112        ///
113        /// Parameter `environment`: (input/optional) An AuthorizationItemSet containing enviroment state used when making the autorization decision.  See the AuthorizationEnvironment type for details.
114        ///
115        /// Parameter `authorizedRights`: (output/optional) A pointer to a newly allocated AuthorizationInfoSet in which the authorized subset of rights are returned (authorizedRights should be deallocated by calling AuthorizationFreeInfoSet() when it is no longer needed).  If NULL the only information returned is the status.  Note that if the kAuthorizationFlagPreAuthorize flag was specified rights that could not be preauthorized are returned in authorizedRights, but their flags contains the kAuthorizationFlagCanNotPreAuthorize bit.
116        ///
117        /// Parameter `error`: Resulting error.
118        #[unsafe(method(obtainWithRights:flags:environment:authorizedRights:error:))]
119        #[unsafe(method_family = none)]
120        pub unsafe fn obtainWithRights_flags_environment_authorizedRights_error(
121            &self,
122            rights: *const AuthorizationRights,
123            flags: AuthorizationFlags,
124            environment: *const AuthorizationEnvironment,
125            authorized_rights: *mut *mut AuthorizationRights,
126            error: Option<&mut Option<Retained<NSError>>>,
127        ) -> bool;
128    );
129}
130
131/// Methods declared on superclass `NSObject`.
132impl SFAuthorization {
133    extern_methods!(
134        #[unsafe(method(new))]
135        #[unsafe(method_family = new)]
136        pub unsafe fn new() -> Retained<Self>;
137    );
138}
139
140/// SFAuthorizationDeprecated.
141impl SFAuthorization {
142    extern_methods!(
143        #[cfg(feature = "objc2-security")]
144        /// DEPRECATED: Use obtainWithRights:flags:environment:authorizedRights:error:
145        ///
146        ///
147        /// Call permitWithRights to gain the rights to have access to privileged operations and to obtain the result.
148        ///
149        /// Parameter `flags`: Authorization flags.
150        ///
151        /// Parameter `rights`: (input) A rights set (see AuthorizationCreate).
152        ///
153        /// Parameter `environment`: (input/optional) An AuthorizationItemSet containing enviroment state used when making the autorization decision.  See the AuthorizationEnvironment type for details.
154        ///
155        /// Parameter `authorizedRights`: (output/optional) A pointer to a newly allocated AuthorizationInfoSet in which the authorized subset of rights are returned (authorizedRights should be deallocated by calling AuthorizationFreeInfoSet() when it is no longer needed).  If NULL the only information returned is the status.  Note that if the kAuthorizationFlagPreAuthorize flag was specified rights that could not be preauthorized are returned in authorizedRights, but their flags contains the kAuthorizationFlagCanNotPreAuthorize bit.
156        #[deprecated]
157        #[unsafe(method(permitWithRights:flags:environment:authorizedRights:))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn permitWithRights_flags_environment_authorizedRights(
160            &self,
161            rights: *const AuthorizationRights,
162            flags: AuthorizationFlags,
163            environment: *const AuthorizationEnvironment,
164            authorized_rights: *mut AuthorizationRights,
165        ) -> OSStatus;
166
167        #[cfg(feature = "objc2-security")]
168        /// DEPRECATED: Use obtainWithRight:flags:error:
169        ///
170        ///
171        /// Call permitWithRight to gain a right to have access to a privilege operation.
172        ///
173        /// Parameter `rightName`: The name of an authorization right.
174        ///
175        /// Parameter `flags`: Authorization flags.
176        #[deprecated]
177        #[unsafe(method(permitWithRight:flags:))]
178        #[unsafe(method_family = none)]
179        pub unsafe fn permitWithRight_flags(
180            &self,
181            right_name: AuthorizationString,
182            flags: AuthorizationFlags,
183        ) -> OSStatus;
184    );
185}