Salmon posts can only be made for local users. More typing!

Since we of course don't have the remote party's private keys anyway.

I made some small fixes in Magicsig class too, removing unnecessary code.
This commit is contained in:
Mikael Nordfeldth
2014-06-02 19:44:57 +02:00
parent 2cd25039af
commit 537dff7987
6 changed files with 22 additions and 57 deletions

View File

@@ -324,25 +324,21 @@ class MagicEnvelope
* on some systems.
*
* @param string $text XML fragment to sign, assumed to be Atom
* @param Profile $actor Profile of a local user to use as signer
* @param User $user User who cryptographically signs $text
*
* @return string XML string representation of magic envelope
*
* @throws Exception on bad profile input or key generation problems
* @fixme if signing fails, this seems to return the original text without warning. Is there a reason for this?
*/
public static function signForProfile($text, Profile $actor)
public static function signAsUser($text, User $user)
{
// We only generate keys for our local users of course, so let
// getUser throw an exception if the profile is not local.
$user = $actor->getUser();
// Find already stored key
$magicsig = Magicsig::getKV('user_id', $user->id);
if (!$magicsig instanceof Magicsig) {
// No keypair yet, let's generate one.
$magicsig = new Magicsig();
$magicsig->generate($user->id);
$magicsig->generate($user);
}
$magic_env = self::signMessage($text, 'application/atom+xml', $magicsig);