more cleanup

This commit is contained in:
James Walker 2010-02-26 04:07:58 -05:00
parent d1256b547f
commit ab8bb4d79e
3 changed files with 20 additions and 7 deletions

View File

@ -1305,7 +1305,7 @@ class Ostatus_profile extends Memcached_DataObject
case Discovery::UPDATESFROM:
$feedUrl = $link['href'];
break;
case Webfinger::HCARD:
case Discovery::HCARD:
$hcardUrl = $link['href'];
break;
default:

View File

@ -111,6 +111,10 @@ class Discovery
}
public static function getService($links, $service) {
if (!is_array($links)) {
return false;
}
foreach ($links as $link) {
if ($link['rel'] == $service) {
return $link;

View File

@ -52,12 +52,17 @@ class MagicEnvelope
{
$disco = new Discovery();
$xrd = $disco->lookup($signer_uri);
if ($link = Discovery::getService($xrd->links, Magicsig::PUBLICKEYREL)) {
list($type, $keypair) = explode(';', $link['href']);
return $keypair;
try {
$xrd = $disco->lookup($signer_uri);
} catch (Exception $e) {
return false;
}
if ($xrd->links) {
if ($link = Discovery::getService($xrd->links, Magicsig::PUBLICKEYREL)) {
list($type, $keypair) = explode(';', $link['href']);
return $keypair;
}
}
throw new Exception('Unable to locate signer public key');
}
@ -70,7 +75,11 @@ class MagicEnvelope
throw new Exception("Unable to determine entry author.");
}
$signature_alg = Magicsig::fromString($this->getKeyPair($signer_uri));
$keypair = $this->getKeyPair($signer_uri);
if (!$keypair) {
throw new Exception("Unable to retrive keypair for ". $signer_uri);
}
$signature_alg = Magicsig::fromString($keypair);
$armored_text = base64_encode($text);
return array(