Struct security_framework::authorization::Authorization

source ·
pub struct Authorization { /* private fields */ }
Expand description

A wrapper around AuthorizationCreate and functions which operate on an AuthorizationRef.

Implementations§

source§

impl Authorization

source

pub fn default() -> Result<Self>

Creates an authorization object which has no environment or associated rights.

source

pub fn new( rights: Option<AuthorizationItemSetStorage>, environment: Option<AuthorizationItemSetStorage>, flags: Flags, ) -> Result<Self>

Creates an authorization reference and provides an option to authorize or preauthorize rights.

rights should be the names of the rights you want to create.

environment is used when authorizing or preauthorizing rights. Not used in OS X v10.2 and earlier. In macOS 10.3 and later, you can pass icon or prompt data to be used in the authentication dialog box. In macOS 10.4 and later, you can also pass a user name and password in order to authorize a user without user interaction.

source

pub fn from_external_form( external_form: AuthorizationExternalForm, ) -> Result<Self>

👎Deprecated since 2.0.1: Please use the TryFrom trait instead

Internalizes the external representation of an authorization reference.

source

pub fn destroy_rights(self)

By default the rights acquired will be retained by the Security Server. Use this to ensure they are destroyed and to prevent shared rights’ continued used by other processes.

source

pub fn get_right<T: Into<Vec<u8>>>( name: T, ) -> Result<CFDictionary<CFString, CFTypeRef>>

Retrieve’s the right’s definition as a dictionary. Use right_exists if you want to avoid retrieving the dictionary.

name can be a wildcard right name.

If name isn’t convertable to a CString it will return Err(errSecConversionError).

source

pub fn right_exists<T: Into<Vec<u8>>>(name: T) -> Result<bool>

Checks if a right exists within the policy database. This is the same as get_right, but avoids a dictionary allocation.

If name isn’t convertable to a CString it will return Err(errSecConversionError).

source

pub fn remove_right<T: Into<Vec<u8>>>(&self, name: T) -> Result<()>

Removes a right from the policy database.

name cannot be a wildcard right name.

If name isn’t convertable to a CString it will return Err(errSecConversionError).

source

pub fn set_right<T: Into<Vec<u8>>>( &self, name: T, definition: RightDefinition<'_>, description: Option<&str>, bundle: Option<CFBundleRef>, locale: Option<&str>, ) -> Result<()>

Creates or updates a right entry in the policy database. Your process must have a code signature in order to be able to add rights to the authorization database.

name cannot be a wildcard right.

definition can be either a CFDictionaryRef containing keys defining the rules or a CFStringRef representing the name of another right whose rules you wish to duplicaate.

description is a key which can be used to look up localized descriptions.

bundle will be used to get localizations from if not the main bundle.

localeTableName will be used to get localizations if provided.

If name isn’t convertable to a CString it will return Err(errSecConversionError).

source

pub fn copy_info<T: Into<Vec<u8>>>( &self, tag: Option<T>, ) -> Result<AuthorizationItemSet<'_>>

An authorization plugin can store the results of an authentication operation by calling the SetContextValue function. You can then retrieve this supporting data, such as the user name.

tag should specify the type of data the Security Server should return. If None, all available information is retreieved.

If tag isn’t convertable to a CString it will return Err(errSecConversionError).

source

pub fn make_external_form(&self) -> Result<AuthorizationExternalForm>

Creates an external representation of an authorization reference so that you can transmit it between processes.

source

pub fn execute_with_privileges<P, S, I>( &self, command: P, arguments: I, flags: Flags, ) -> Result<()>
where P: AsRef<Path>, I: IntoIterator<Item = S>, S: AsRef<OsStr>,

Runs an executable tool with root privileges. Discards executable’s output

source

pub fn execute_with_privileges_piped<P, S, I>( &self, command: P, arguments: I, flags: Flags, ) -> Result<File>
where P: AsRef<Path>, I: IntoIterator<Item = S>, S: AsRef<OsStr>,

Runs an executable tool with root privileges, and returns a File handle to its communication pipe

Trait Implementations§

source§

impl Debug for Authorization

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for Authorization

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl TryFrom<AuthorizationExternalForm> for Authorization

source§

fn try_from(external_form: AuthorizationExternalForm) -> Result<Self>

Internalizes the external representation of an authorization reference.

§

type Error = Error

The type returned in the event of a conversion error.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.