Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F545840
PhabricatorKeyring.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
PhabricatorKeyring.php
View Options
<?php
final
class
PhabricatorKeyring
extends
Phobject
{
private
static
$hasReadConfiguration
;
private
static
$keyRing
=
array
();
public
static
function
addKey
(
$spec
)
{
self
::
$keyRing
[
$spec
[
'name'
]]
=
$spec
;
}
public
static
function
getKey
(
$name
,
$type
)
{
self
::
readConfiguration
();
if
(
empty
(
self
::
$keyRing
[
$name
]))
{
throw
new
Exception
(
pht
(
'No key "%s" exists in keyring.'
,
$name
));
}
$spec
=
self
::
$keyRing
[
$name
];
$material
=
base64_decode
(
$spec
[
'material.base64'
],
true
);
return
new
PhutilOpaqueEnvelope
(
$material
);
}
public
static
function
getDefaultKeyName
(
$type
)
{
self
::
readConfiguration
();
foreach
(
self
::
$keyRing
as
$name
=>
$key
)
{
if
(!
empty
(
$key
[
'default'
]))
{
return
$name
;
}
}
return
null
;
}
private
static
function
readConfiguration
()
{
if
(
self
::
$hasReadConfiguration
)
{
return
true
;
}
self
::
$hasReadConfiguration
=
true
;
foreach
(
PhabricatorEnv
::
getEnvConfig
(
'keyring'
)
as
$spec
)
{
self
::
addKey
(
$spec
);
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, May 12, 1:01 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
109487
Default Alt Text
PhabricatorKeyring.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment