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

@@ -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(