- public function createMagicEnv($text, $actor)
- {
- $magic_env = new MagicEnvelope();
-
- $user = User::staticGet('id', $actor->id);
- if ($user->id) {
- // Use local key
- $magickey = Magicsig::staticGet('user_id', $user->id);
- if (!$magickey) {
- // No keypair yet, let's generate one.
- $magickey = new Magicsig();
- $magickey->generate($user->id);
- }
- } else {
- throw new Exception("Salmon invalid actor for signing");
- }
-
- try {
- $env = $magic_env->signMessage($text, 'application/atom+xml', $magickey->toString());
- } catch (Exception $e) {
- return $text;
- }
- return $magic_env->toXML($env);
- }
-
-
- public function verifyMagicEnv($text)
- {
- $magic_env = new MagicEnvelope();
-
- $env = $magic_env->parse($text);
-
- return $magic_env->verify($env);