MagicEnvelope object orientation (no passing arrays)

MagicEnvelope now uses object properties instead of passing arrays
around everywhere.
This commit is contained in:
Mikael Nordfeldth
2014-05-27 11:32:12 +02:00
parent 14251d26ad
commit 41773d3f67
6 changed files with 136 additions and 161 deletions

View File

@@ -46,20 +46,15 @@ class SalmonAction extends Action
$this->clientError(_m('Salmon requires "application/magic-envelope+xml".'));
}
$xml = file_get_contents('php://input');
// Check the signature
$salmon = new Salmon;
if (!$salmon->verifyMagicEnv($xml)) {
$envxml = file_get_contents('php://input');
$magic_env = new MagicEnvelope($envxml); // parse incoming XML as a MagicEnvelope
if (!$magic_env->verify()) {
common_log(LOG_DEBUG, "Salmon signature verification failed.");
// TRANS: Client error.
$this->clientError(_m('Salmon signature verification failed.'));
} else {
$magic_env = new MagicEnvelope();
$env = $magic_env->parse($xml);
$xml = $magic_env->unfold($env);
}
$xml = $magic_env->unfold(); // return the enveloped XML (the actual data)
$dom = DOMDocument::loadXML($xml);
if ($dom->documentElement->namespaceURI != Activity::ATOM ||
$dom->documentElement->localName != 'entry') {