Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F103246369
PhabricatorKeyring.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Feb 28, 12:33
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Mar 2, 12:33 (2 d)
Engine
blob
Format
Raw Data
Handle
24480333
Attached To
rPH Phabricator
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
);
}
}
}
Event Timeline
Log In to Comment