Ignore:
Timestamp:
14/06/06 22:43:03 (14 years ago)
Author:
astephen
Message:

Safe version pre-security installation and zsi versioning.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI03-DataExtractor/trunk/pydxc/SecurityViaCGI.py

    r794 r1184  
    3636        self.username=username 
    3737        self.password=password 
     38        # Note secureToken is not used by browser client which gets input from  
     39        # os.environ["HTTP_COOKIE"] 
    3840        self.secureToken=secureToken 
    3941 
     
    4547        # First check if the user is valid via a cookie 
    4648        cookieCheck=self._checkCookie() 
    47 #       o=open('/tmp/tmp/cook.txt','w'); o.write(str(cookieCheck)) ; o.close() 
     49        #o=open('/tmp/tmp/cook.txt','w'); o.write(str(cookieCheck)) ; o.close() 
    4850 
    4951        if type(cookieCheck)==type(""): 
     
    7981            return "Username '%s' unknown." % self.username 
    8082 
     83    def dummy(self): 
     84        c=Cookie.SimpleCookie() 
     85        c["DX"]="somethingOrother" 
     86        c["DX"]["domain"]="localhost" 
     87        c["DX"]["path"]="/" 
     88        print c 
     89 
    8190    def _createCookie(self, username, userRoles, expiryTime=None): 
    8291        """ 
    8392        Writes a cookie to the user's browser cookie cache. 
    8493        """ 
     94        self.dummy() 
    8595        # NOTE: This should be brought up to date with W3C spec on Cookies 
    86         cookieString="%s:%s:%s" % (username, string.join(userRoles, ","), time.time()+TOKEN_VALID_LIFETIME) 
     96        endTime=time.time()+TOKEN_VALID_LIFETIME 
     97        endTimeString=time.strftime("%d/%m/%y %H:%M%S", time.localtime(endTime)) 
     98        cookieString="%s:%s:%s" % (username, string.join(userRoles, ","), endTime) 
    8799        cookieMaker=Cookie.SimpleCookie() 
    88100        cookieMaker[COOKIE_NAME]=cookieString 
    89         cookieMaker[COOKIE_NAME]["domain"]=TOKEN_DOMAIN 
     101        #cookieMaker[COOKIE_NAME]["domain"]=TOKEN_DOMAIN 
     102        cookieMaker[COOKIE_NAME]["path"]="/" 
    90103 
    91104        # Use expiry time of zero to delete a cookie, or other time if used 
    92105        if expiryTime!=None: 
    93             cookieMaker[COOKIE_NAME]["expires"]=expiryTime 
     106            expiryTime=endTimeString 
     107                 
     108        cookieMaker[COOKIE_NAME]["expires"]=expiryTime 
    94109 
    95110        # Set the cookie 
    96111        print cookieMaker 
    97         #o=open('/tmp/tmp/out.txt', 'w'); o.write("%s" % cookieString) ; o.close() 
     112        #o=open('/tmp/tmp/out.txt', 'w'); o.write("%s" % (cookieString+"\n"+TOKEN_DOMAIN)) ; o.close() 
    98113         
    99114        return cookieString 
     
    142157        if not os.environ.has_key("HTTP_COOKIE"): 
    143158            cookieString=None 
     159            #out=open("/tmp/tmp/iscookie.txt","w");out.write("%s" % cookieString); out.close() 
    144160        else: 
    145161            cookieReader.load(os.environ["HTTP_COOKIE"]) 
Note: See TracChangeset for help on using the changeset viewer.