| | |
| | | { |
| | | public $id; |
| | | public $name; |
| | | public $users = array(); |
| | | public $users = array(); |
| | | public $subkeys = array(); |
| | | |
| | | const TYPE_UNKNOWN = 0; |
| | | const TYPE_KEYPAIR = 1; |
| | | const TYPE_PUBLIC = 2; |
| | | const TYPE_PUBLIC = 2; |
| | | |
| | | /** |
| | | * Keys list sorting callback for usort() |
| | |
| | | |
| | | /** |
| | | * Returns true if all user IDs are revoked |
| | | */ |
| | | */ |
| | | function is_revoked() |
| | | { |
| | | foreach ($this->subkeys as $subkey) |
| | |
| | | |
| | | /** |
| | | * Returns true if any user ID is valid |
| | | */ |
| | | */ |
| | | function is_valid() |
| | | { |
| | | foreach ($this->users as $user) |
| | |
| | | |
| | | return false; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Returns true if any of subkeys is not expired |
| | | */ |
| | | */ |
| | | function is_expired() |
| | | { |
| | | $now = time(); |
| | | |
| | | |
| | | foreach ($this->subkeys as $subkey) |
| | | if (!$subkey->expires || $subkey->expires > $now) |
| | | return true; |
| | | |
| | | |
| | | return false; |
| | | } |
| | | |
| | |
| | | static function format_id($id) |
| | | { |
| | | // E.g. 04622F2089E037A5 => 89E037A5 |
| | | |
| | | |
| | | return substr($id, -8); |
| | | } |
| | | |
| | |
| | | */ |
| | | static function format_fingerprint($fingerprint) |
| | | { |
| | | if (!$fingerprint) |
| | | if (!$fingerprint) { |
| | | return ''; |
| | | |
| | | } |
| | | |
| | | $result = ''; |
| | | for ($i=0; $i<40; $i++) { |
| | | if ($i % 4 == 0) |
| | | if ($i % 4 == 0) { |
| | | $result .= ' '; |
| | | } |
| | | $result .= $fingerprint[$i]; |
| | | } |
| | | |
| | | return $result; |
| | | } |
| | | |