summaryrefslogtreecommitdiff
path: root/plugins/OStatus/lib/salmon.php
diff options
context:
space:
mode:
authorJames Walker <walkah@walkah.net>2010-02-26 15:39:30 -0500
committerJames Walker <walkah@walkah.net>2010-02-26 15:39:58 -0500
commite4c462570f8010f751caf214f329617c08bf7105 (patch)
treeaadfb31e97a92aadc85ef7b8d60e934546227948 /plugins/OStatus/lib/salmon.php
parentf23a877cd8ad8d583b74c312c7e9baa842b5a86a (diff)
move salmon posting to send application/magic-envelope+xml per http://salmon-protocol.googlecode.com/svn/trunk/draft-panzer-salmon-00.html#RPF
Diffstat (limited to 'plugins/OStatus/lib/salmon.php')
-rw-r--r--plugins/OStatus/lib/salmon.php18
1 files changed, 11 insertions, 7 deletions
diff --git a/plugins/OStatus/lib/salmon.php b/plugins/OStatus/lib/salmon.php
index 6e2459544..68883a410 100644
--- a/plugins/OStatus/lib/salmon.php
+++ b/plugins/OStatus/lib/salmon.php
@@ -48,12 +48,17 @@ class Salmon
return false;
}
- if (!common_config('ostatus', 'skip_signatures')) {
+ try {
$xml = $this->createMagicEnv($xml, $actor);
+ } catch (Exception $e) {
+ common_log(LOG_ERR, "Salmon unable to sign: " . $e->getMessage());
+ return false;
}
- $headers = array('Content-Type: application/atom+xml');
+ $headers = array('Content-Type: application/magic-envelope+xml');
+ common_log(LOG_DEBUG, "Salmon: going to post " . $xml);
+
try {
$client = new HTTPClient();
$client->setBody($xml);
@@ -72,7 +77,6 @@ class Salmon
public function createMagicEnv($text, $actor)
{
- common_log(LOG_DEBUG, "Got actor as : ". print_r($actor, true));
$magic_env = new MagicEnvelope();
$user = User::staticGet('id', $actor->id);
@@ -84,7 +88,6 @@ class Salmon
$magickey = new Magicsig();
$magickey->generate($user->id);
}
- common_log(LOG_DEBUG, "Salmon: Loaded key for ". $user->id);
} else {
throw new Exception("Salmon invalid actor for signing");
}
@@ -95,15 +98,16 @@ class Salmon
common_log(LOG_ERR, "Salmon signing failed: ". $e->getMessage());
return $text;
}
- return $magic_env->unfold($env);
+ return $magic_env->toXML($env);
}
- public function verifyMagicEnv($dom)
+ public function verifyMagicEnv($text)
{
+ common_log(LOG_DEBUG, "Going to verify ". $text);
$magic_env = new MagicEnvelope();
- $env = $magic_env->fromDom($dom);
+ $env = $magic_env->parse($text);
return $magic_env->verify($env);
}