Alphred
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
  • Download

Namespaces

  • Alphred
  • None

Classes

  • Alfred
  • AppleScript
  • Choose
  • Config
  • Date
  • Dialog
  • Filter
  • Globals
  • i18n
  • Ini
  • Keychain
  • Log
  • Notification
  • Request
  • Result
  • ScriptFilter
  • Text

Interfaces

  • ConfigKeyNotSet
  • Exception
  • FileDoesNotExist
  • InvalidKeychainAccount
  • InvalidScriptFilterArgument
  • InvalidSecurityAction
  • InvalidXMLProperty
  • PasswordExists
  • PasswordNotFound
  • PluginFunctionNotFound
  • RunningOutsideOfAlfred
  • ShouldBeBool
  • TooManyArguments
  • UnknownSecurityException
  • UseOnlyAsStatic

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

Alphred\UseOnlyAsStatic
if you try to institate a Globals object
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

Alphred::save_password()
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

Alphred\InvalidKeychainAccount
on an empty account

Used by

Alphred::get_password()
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

Alphred::delete_password()
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

Alphred\PasswordExists
when trying to add a password that already exists without specifying 'update'
Alphred\PasswordNotFound
when trying to find a password that does not exist
Alphred\UnknownSecurityException
when something weird happens
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

Alphred API documentation generated by ApiGen