objc2_security/generated/
SecSharedCredential.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_core_foundation::*;
6
7use crate::*;
8
9extern "C" {
10    /// Predefined key constants used to get values in a dictionary
11    /// of credentials returned by SecRequestWebCredential.
12    ///
13    /// shared password. You use this key to get a value of type CFStringRef
14    /// that contains a password.
15    ///
16    /// See also [Apple's documentation](https://developer.apple.com/documentation/security/ksecsharedpassword?language=objc)
17    pub static kSecSharedPassword: &'static CFString;
18}
19
20extern "C-unwind" {
21    /// Asynchronously store (or update) a shared password for a website.
22    ///
23    /// Parameter `fqdn`: The fully qualified domain name of the website requiring the password.
24    ///
25    /// Parameter `account`: The account name associated with this password.
26    ///
27    /// Parameter `password`: The password to be stored. Pass NULL to remove a shared password if it exists.
28    ///
29    /// Parameter `completionHandler`: A block which will be invoked when the function has completed. If the shared password was successfully added (or removed), the CFErrorRef parameter passed to the block will be NULL. If the error parameter is non-NULL, an error occurred and the error reference will hold the result. Note: the error reference will be automatically released after this handler is called, though you may optionally retain it for as long as needed.
30    ///
31    /// This function adds a shared password item which will be accessible by Safari and applications that have the specified fully-qualified domain name in their 'com.apple.developer.associated-domains' entitlement. If a shared password item already exists for the specified website and account, it will be updated with the provided password. To remove a password, pass NULL for the password parameter.
32    ///
33    /// Note: since a request involving shared web credentials may potentially require user interaction or other verification to be approved, this function is dispatched asynchronously; your code provides a completion handler that will be called once the results (if any) are available.
34    #[cfg(feature = "block2")]
35    pub fn SecAddSharedWebCredential(
36        fqdn: &CFString,
37        account: &CFString,
38        password: Option<&CFString>,
39        completion_handler: &block2::DynBlock<dyn Fn(*mut CFError)>,
40    );
41}
42
43extern "C-unwind" {
44    /// Asynchronously obtain one or more shared passwords for a website.
45    ///
46    /// Parameter `fqdn`: (Optional) Fully qualified domain name of the website for which passwords are being requested. If NULL is passed in this argument, the domain name(s) listed in the calling application's 'com.apple.developer.associated-domains' entitlement are searched implicitly.
47    ///
48    /// Parameter `account`: (Optional) Account name for which passwords are being requested. The account may be NULL to request all shared credentials which are available for the site, allowing the caller to discover an existing account.
49    ///
50    /// Parameter `completionHandler`: A block which will be called to deliver the requested credentials. If no matching items were found, the credentials array will be empty, and the CFErrorRef parameter will provide the error result. Note: the credentials and error references will be automatically released after this handler is called, though you may optionally retain either for as long as needed.
51    ///
52    /// This function requests one or more shared passwords for a given website, depending on whether the optional account parameter is supplied. To obtain results, the website specified in the fqdn parameter must be one which matches an entry in the calling application's 'com.apple.developer.associated-domains' entitlement.
53    ///
54    /// If matching shared password items are found, the credentials provided to the completionHandler will be a CFArrayRef containing CFDictionaryRef entries. Each dictionary entry will contain the following pairs (see Security/SecItem.h):
55    /// key: kSecAttrServer     value: CFStringRef (the website)
56    /// key: kSecAttrAccount    value: CFStringRef (the account)
57    /// key: kSecSharedPassword value: CFStringRef (the password)
58    ///
59    /// If the found item specifies a non-standard port number (i.e. other than 443 for https), the following key may also be present:
60    /// key: kSecAttrPort       value: CFNumberRef (the port number)
61    ///
62    /// Note: since a request involving shared web credentials may potentially require user interaction or other verification to be approved, this function is dispatched asynchronously; your code provides a completion handler that will be called once the results (if any) are available.
63    #[cfg(feature = "block2")]
64    #[deprecated = "Use ASAuthorizationController to make an ASAuthorizationPasswordRequest (AuthenticationServices framework)"]
65    pub fn SecRequestSharedWebCredential(
66        fqdn: Option<&CFString>,
67        account: Option<&CFString>,
68        completion_handler: &block2::DynBlock<dyn Fn(*const CFArray, *mut CFError)>,
69    );
70}
71
72/// Returns a randomly generated password.
73///
74/// Returns: CFStringRef password in the form xxx-xxx-xxx-xxx where x is taken from the sets "abcdefghkmnopqrstuvwxy", "ABCDEFGHJKLMNPQRSTUVWXYZ", "3456789" with at least one character from each set being present.
75#[inline]
76pub unsafe extern "C-unwind" fn SecCreateSharedWebCredentialPassword(
77) -> Option<CFRetained<CFString>> {
78    extern "C-unwind" {
79        fn SecCreateSharedWebCredentialPassword() -> Option<NonNull<CFString>>;
80    }
81    let ret = unsafe { SecCreateSharedWebCredentialPassword() };
82    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
83}