示例#1
0
 def create_session(self, request, email, ssid, expiration):
   """
   Encrypt parameters, set valid in DB, set cookie on client
   """
   account = memcache_db.get_entity(email, "Accounts")
   if account != None:
     update_fields = {"cookieKey" : ssid}
     memcache_db.update_fields(email, "Accounts", update_fields)
   
     email_enc = encryption.des_encrypt_str(email)
     ssid_enc = encryption.des_encrypt_str(ssid)
     exp_enc = encryption.des_encrypt_str(expiration)
     
     import base64
     import string
     email_encoded = string.rstrip(base64.encodestring(email_enc), "\n")
     ssid_encoded = string.rstrip(base64.encodestring(ssid_enc), "\n")
     exp_encoded = string.rstrip(base64.encodestring(exp_enc), "\n")
 
     # the email will be set as the key so we can use it to look up in the DB
     request.response.headers.add_header("Set-Cookie", WEB_ADMIN_PARAMS.COOKIE_EMAIL_PARAM + "=" + email_encoded)
     request.response.headers.add_header("Set-Cookie", WEB_ADMIN_PARAMS.COOKIE_KEY_PARAM + "=" + ssid_encoded)
     request.response.headers.add_header("Set-Cookie", WEB_ADMIN_PARAMS.COOKIE_EXPIRATION + "=" + exp_encoded)
     
     """ Create a new session object and return it """
     self.email = email
     self.ssid = ssid
     self.expiration = expiration
     self.account = account
   
     return self
   else:
     return None
示例#2
0
 def get(self):
     from serverside.tools import encryption
     """Do some simple encryption and show results """
     mystr = "hello, world"
     self.response.out.write("encrypt string: " + mystr + "<br/>")
     mystr_enc = encryption.des_encrypt_str("hello, world")
     self.response.out.write("encrypted: " + mystr_enc + "<br/>")
     mystr_dec = encryption.des_decrypt_str(mystr_enc)
     self.response.out.write("decrypted: " + mystr_dec + "<br/>")
示例#3
0
 def get(self):
   from serverside.tools import encryption
   """Do some simple encryption and show results """
   mystr = "hello, world"
   self.response.out.write("encrypt string: " + mystr + "<br/>")
   mystr_enc = encryption.des_encrypt_str("hello, world")
   self.response.out.write("encrypted: " + mystr_enc + "<br/>")
   mystr_dec = encryption.des_decrypt_str(mystr_enc)
   self.response.out.write("decrypted: " + mystr_dec + "<br/>")