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 ///
55 /// # Safety
56 ///
57 /// - `rights` must be a valid pointer.
58 /// - `environment` must be a valid pointer.
59 #[unsafe(method(authorizationWithFlags:rights:environment:))]
60 #[unsafe(method_family = none)]
61 pub unsafe fn authorizationWithFlags_rights_environment(
62 flags: AuthorizationFlags,
63 rights: *const AuthorizationRights,
64 environment: *const AuthorizationEnvironment,
65 ) -> Option<Retained<AnyObject>>;
66
67 #[cfg(feature = "objc2-security")]
68 /// Initializes an authorization object specified flags, rights and environment.
69 ///
70 /// Parameter `flags`: Authorization flags.
71 ///
72 /// 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.
73 ///
74 /// Parameter `environment`: (input/optional) An AuthorizationItemSet containing enviroment state used when making the autorization decision. See the AuthorizationEnvironment type for details.
75 ///
76 /// # Safety
77 ///
78 /// - `rights` must be a valid pointer.
79 /// - `environment` must be a valid pointer.
80 #[unsafe(method(initWithFlags:rights:environment:))]
81 #[unsafe(method_family = init)]
82 pub unsafe fn initWithFlags_rights_environment(
83 this: Allocated<Self>,
84 flags: AuthorizationFlags,
85 rights: *const AuthorizationRights,
86 environment: *const AuthorizationEnvironment,
87 ) -> Option<Retained<Self>>;
88
89 /// Initializes an authorization object initialized with a default environment, flags and rights.
90 #[unsafe(method(init))]
91 #[unsafe(method_family = init)]
92 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
93
94 /// Calling this will prevent any rights that were obtained by this object to be preserved. It effectively locks down all potentially shared authorizations.
95 #[unsafe(method(invalidateCredentials))]
96 #[unsafe(method_family = none)]
97 pub unsafe fn invalidateCredentials(&self);
98
99 #[cfg(feature = "objc2-security")]
100 /// Call obtainWithRight to gain a right to have access to a privilege operation. On success, YES is returned.
101 ///
102 /// Parameter `rightName`: The name of an authorization right.
103 ///
104 /// Parameter `flags`: Authorization flags.
105 ///
106 /// Parameter `error`: Resulting error.
107 ///
108 /// # Safety
109 ///
110 /// - `right_name` must be a valid pointer.
111 /// - `error` might not allow `None`.
112 #[unsafe(method(obtainWithRight:flags:error:))]
113 #[unsafe(method_family = none)]
114 pub unsafe fn obtainWithRight_flags_error(
115 &self,
116 right_name: AuthorizationString,
117 flags: AuthorizationFlags,
118 error: Option<&mut Option<Retained<NSError>>>,
119 ) -> bool;
120
121 #[cfg(feature = "objc2-security")]
122 /// Call obtainWithRights to gain the rights to have access to privileged operations. On success, YES is returned.
123 ///
124 /// Parameter `flags`: Authorization flags.
125 ///
126 /// Parameter `rights`: (input) A rights set (see AuthorizationCreate).
127 ///
128 /// Parameter `environment`: (input/optional) An AuthorizationItemSet containing enviroment state used when making the autorization decision. See the AuthorizationEnvironment type for details.
129 ///
130 /// 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.
131 ///
132 /// Parameter `error`: Resulting error.
133 ///
134 /// # Safety
135 ///
136 /// - `rights` must be a valid pointer.
137 /// - `environment` must be a valid pointer.
138 /// - `authorized_rights` must be a valid pointer.
139 /// - `error` might not allow `None`.
140 #[unsafe(method(obtainWithRights:flags:environment:authorizedRights:error:))]
141 #[unsafe(method_family = none)]
142 pub unsafe fn obtainWithRights_flags_environment_authorizedRights_error(
143 &self,
144 rights: *const AuthorizationRights,
145 flags: AuthorizationFlags,
146 environment: *const AuthorizationEnvironment,
147 authorized_rights: *mut *mut AuthorizationRights,
148 error: Option<&mut Option<Retained<NSError>>>,
149 ) -> bool;
150 );
151}
152
153/// Methods declared on superclass `NSObject`.
154impl SFAuthorization {
155 extern_methods!(
156 #[unsafe(method(new))]
157 #[unsafe(method_family = new)]
158 pub unsafe fn new() -> Retained<Self>;
159 );
160}
161
162/// SFAuthorizationDeprecated.
163impl SFAuthorization {
164 extern_methods!(
165 #[cfg(feature = "objc2-security")]
166 /// DEPRECATED: Use obtainWithRights:flags:environment:authorizedRights:error:
167 ///
168 ///
169 /// Call permitWithRights to gain the rights to have access to privileged operations and to obtain the result.
170 ///
171 /// Parameter `flags`: Authorization flags.
172 ///
173 /// Parameter `rights`: (input) A rights set (see AuthorizationCreate).
174 ///
175 /// Parameter `environment`: (input/optional) An AuthorizationItemSet containing enviroment state used when making the autorization decision. See the AuthorizationEnvironment type for details.
176 ///
177 /// 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.
178 ///
179 /// # Safety
180 ///
181 /// - `rights` must be a valid pointer.
182 /// - `environment` must be a valid pointer.
183 /// - `authorized_rights` must be a valid pointer.
184 #[deprecated]
185 #[unsafe(method(permitWithRights:flags:environment:authorizedRights:))]
186 #[unsafe(method_family = none)]
187 pub unsafe fn permitWithRights_flags_environment_authorizedRights(
188 &self,
189 rights: *const AuthorizationRights,
190 flags: AuthorizationFlags,
191 environment: *const AuthorizationEnvironment,
192 authorized_rights: *mut AuthorizationRights,
193 ) -> OSStatus;
194
195 #[cfg(feature = "objc2-security")]
196 /// DEPRECATED: Use obtainWithRight:flags:error:
197 ///
198 ///
199 /// Call permitWithRight to gain a right to have access to a privilege operation.
200 ///
201 /// Parameter `rightName`: The name of an authorization right.
202 ///
203 /// Parameter `flags`: Authorization flags.
204 ///
205 /// # Safety
206 ///
207 /// `right_name` must be a valid pointer.
208 #[deprecated]
209 #[unsafe(method(permitWithRight:flags:))]
210 #[unsafe(method_family = none)]
211 pub unsafe fn permitWithRight_flags(
212 &self,
213 right_name: AuthorizationString,
214 flags: AuthorizationFlags,
215 ) -> OSStatus;
216 );
217}