예제 #1
0
 def get_or_create(self, user):
     try:
         user_keypair = UserKeyPair.objects.get(user=user)
     except UserKeyPair.DoesNotExist:
         (mod, exp, private_exp) = magicsigs.generate()
         user_keypair = UserKeyPair(
             user=user, mod=mod, public_exponent=exp,
             private_exponent=private_exp)
         user_keypair.save()
     return user_keypair
예제 #2
0
 def get_or_create(self, user):
     try:
         user_keypair = UserKeyPair.objects.get(user=user)
     except UserKeyPair.DoesNotExist:
         (mod, exp, private_exp) = magicsigs.generate()
         user_keypair = UserKeyPair(user=user,
                                    mod=mod,
                                    public_exponent=exp,
                                    private_exponent=private_exp)
         user_keypair.save()
     return user_keypair
예제 #3
0
    def get_or_create(domain):
        """Loads and returns a MagicKey. Creates it if necessary."""
        key = MagicKey.get_by_id(domain)

        if not key:
            # this uses urandom(), and does nontrivial math, so it can take a
            # while depending on the amount of randomness available.
            pubexp, mod, privexp = magicsigs.generate()
            key = MagicKey(id=domain, mod=mod, public_exponent=pubexp,
                           private_exponent=privexp)
            key.put()

        return key
예제 #4
0
  def get_or_create(uri):
    """Loads and returns a User from the datastore. Creates it if necessary."""
    user = User.get_by_key_name(uri)

    if not user:
      # this uses urandom(), and does some nontrivial math, so it can take a
      # while depending on the amount of randomness available on the system.
      pubexp, mod, privexp = magicsigs.generate()
      user = User(key_name=uri, mod=mod, public_exponent=pubexp,
                  private_exponent=privexp)
      user.put()

    return user
예제 #5
0
    def get_or_create(uri):
        """Loads and returns a User from the datastore. Creates it if necessary."""
        user = User.get_by_key_name(uri)

        if not user:
            # this uses urandom(), and does some nontrivial math, so it can take a
            # while depending on the amount of randomness available on the system.
            pubexp, mod, privexp = magicsigs.generate()
            user = User(key_name=uri,
                        mod=mod,
                        public_exponent=pubexp,
                        private_exponent=privexp)
            user.put()

        return user