Class Keychain
Enables easy access to parts of the Keychain for secure password storage / retrieval
Uses the security
command in order to add / retrieve / delete passwords. Note: we use
only the "generic" password functions and not the "internet" password functions.
Namespace: Alphred
See:
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/security.1.html security(1)
Located at Keychain.php
Methods summary
public
|
#
__construct( )
Throws an exception if you try to instantiate it
Throws an exception if you try to instantiate it
Throws
|
public static
boolean
|
#
save_password( string $account, string $password, boolean $update = true, string $service = null )
Saves a password to the keychain
Saves a password to the keychain
Parameters
- $account
- the name of the account
- $password
- the new password
- $update
- whether or not to update an old password (defaults to
true )
- $service
- optional: defaults to the bundleid of the workflow (if set)
Returns
boolean whether or not it was successful (usually true)
Throws
Alphred\PasswordExists (indirectly )when trying to add a password that already exists
without specifying 'update'
Used by
|
public static
string
|
#
find_password( string $account, string $service = null )
Retrieves a password from the keychain
Retrieves a password from the keychain
Parameters
- $account
- the name of an account
- $service
- optional: defaults to the bundleid of the workflow (if set)
Returns
string the password
Throws
Used by
|
public static
boolean
|
#
delete_password( string $account, string $service = null )
Deletes a password from the keychain
Deletes a password from the keychain
Parameters
- $account
- the name of the account
- $service
- optional: defaults to the bundleid of the workflow (if set)
Returns
boolean success of command
Used by
|
private
string|boolean
|
#
call_security( string $action, string $service, string $account, string $args )
Interfaces directly with the security command
Interfaces directly with the security command
Parameters
- $action
- one of 'add-', 'delete-', or 'find-generic-password'
- $service
- the "owner" of the action; usually the bundle id
- $account
- the "account" of the password
- $args
- extra arguments for the security command
Returns
string|boolean either a found password or true
Throws
|
private
|
#
set_service( $service )
Sets the service appropriately, usually to the bundle id of the workflow
Sets the service appropriately, usually to the bundle id of the workflow
|
Magic methods summary