3 final class PhabricatorKeyring
extends Phobject
{
5 private static $hasReadConfiguration;
6 private static $keyRing = array();
8 public static function addKey($spec) {
9 self
::$keyRing[$spec['name']] = $spec;
12 public static function getKey($name, $type) {
13 self
::readConfiguration();
15 if (empty(self
::$keyRing[$name])) {
18 'No key "%s" exists in keyring.',
22 $spec = self
::$keyRing[$name];
24 $material = base64_decode($spec['material.base64'], true);
25 return new PhutilOpaqueEnvelope($material);
28 public static function getDefaultKeyName($type) {
29 self
::readConfiguration();
31 foreach (self
::$keyRing as $name => $key) {
32 if (!empty($key['default'])) {
40 private static function readConfiguration() {
41 if (self
::$hasReadConfiguration) {
45 self
::$hasReadConfiguration = true;
47 foreach (PhabricatorEnv
::getEnvConfig('keyring') as $spec) {