|
34 |
import cherrypy |
34 |
import cherrypy |
35 |
import httplib |
35 |
import httplib |
36 |
import os |
36 |
import os |
37 |
import threading |
|
|
38 |
import Queue |
37 |
import Queue |
39 |
from optparse import OptionParser |
38 |
from optparse import OptionParser |
40 |
import simplejson |
39 |
import simplejson |
|
75 |
except (cherrypy.HTTPError, cherrypy.HTTPRedirect): |
74 |
except (cherrypy.HTTPError, cherrypy.HTTPRedirect): |
76 |
# ignore common cherrypy exceptions |
75 |
# ignore common cherrypy exceptions |
77 |
raise |
76 |
raise |
|
|
77 |
except (KeyboardInterrupt, SystemExit): |
78 |
# ignore |
79 |
raise |
78 |
except Exception, ex: |
80 |
except Exception, ex: |
79 |
CORE.error('Traceback in %s(%r, %r):\n%s' % (f.__name__, args, kwargs, traceback.format_exc())) |
81 |
CORE.error('Traceback in %s(%r, %r):\n%s' % (f.__name__, args, kwargs, traceback.format_exc())) |
80 |
raise |
82 |
raise |
|
420 |
self._log(99, 'sessionid="%s"' % (sessionid)) |
422 |
self._log(99, 'sessionid="%s"' % (sessionid)) |
421 |
return sessionid |
423 |
return sessionid |
422 |
|
424 |
|
|
|
425 |
def set_session_id(self, sessionid): |
426 |
# set the cookie once during successful authentication |
427 |
# force expiration of cookie in 5 years from now on... |
428 |
# IE does not support max-age |
429 |
expiration = datetime.datetime.now() |
430 |
expiration = expiration.replace(year=expiration.year + 5) |
431 |
expirationStr = expiration.strftime("%a, %d-%b-%Y %H:%M:%S GMT") |
432 |
cherrypy.response.cookie['UMCSessionId'] = sessionid |
433 |
cherrypy.response.cookie['UMCSessionId']['expires'] = expirationStr |
434 |
cherrypy.response.cookie['UMCSessionId']['version'] = 1 |
435 |
cherrypy.response.cookie['UMCSessionId']['path'] = '/' |
436 |
|
423 |
@logExceptions |
437 |
@logExceptions |
424 |
def load_json(self, body): |
438 |
def load_json(self, body): |
425 |
try: |
439 |
try: |
|
511 |
# update IP address of sesssion ==> address changes during single sign on |
525 |
# update IP address of sesssion ==> address changes during single sign on |
512 |
UMCP_Dispatcher.sessions[login_token.sessionid].ip = self.get_ip_address() |
526 |
UMCP_Dispatcher.sessions[login_token.sessionid].ip = self.get_ip_address() |
513 |
|
527 |
|
514 |
# set the cookie once during successful authentication |
528 |
self.set_session_id(login_token.sessionid) |
515 |
# force expiration of cookie in 5 years from now on... |
|
|
516 |
# IE does not support max-age |
517 |
expiration = datetime.datetime.now() |
518 |
expiration = expiration.replace(year=expiration.year + 5) |
519 |
expirationStr = expiration.strftime("%a, %d-%b-%Y %H:%M:%S GMT") |
520 |
cherrypy.response.cookie['UMCSessionId'] = login_token.sessionid |
521 |
cherrypy.response.cookie['UMCSessionId']['expires'] = expirationStr |
522 |
cherrypy.response.cookie['UMCSessionId']['version'] = 1 |
523 |
cherrypy.response.cookie['UMCSessionId']['path'] = '/' |
524 |
cherrypy.response.cookie['UMCUsername'] = login_token.username |
529 |
cherrypy.response.cookie['UMCUsername'] = login_token.username |
525 |
cherrypy.response.cookie['UMCUsername']['expires'] = expirationStr |
530 |
cherrypy.response.cookie['UMCUsername']['expires'] = expirationStr |
526 |
cherrypy.response.cookie['UMCUsername']['version'] = 1 |
531 |
cherrypy.response.cookie['UMCUsername']['version'] = 1 |
|
683 |
# add new one time session |
688 |
# add new one time session |
684 |
UMCP_Dispatcher.logintokens.add_session(response.body.get('sessionid'), json[ 'options' ].get('username','')) |
689 |
UMCP_Dispatcher.logintokens.add_session(response.body.get('sessionid'), json[ 'options' ].get('username','')) |
685 |
|
690 |
|
686 |
# set the cookie once during successful authentication |
691 |
self.set_session_id(response.body.get('sessionid')) |
687 |
# force expiration of cookie in 5 years from now on... |
|
|
688 |
# IE does not support max-age |
689 |
expiration = datetime.datetime.now() |
690 |
expiration = expiration.replace(year=expiration.year + 5) |
691 |
expirationStr = expiration.strftime("%a, %d-%b-%Y %H:%M:%S GMT") |
692 |
cherrypy.response.cookie['UMCSessionId'] = response.body.get('sessionid') |
693 |
cherrypy.response.cookie['UMCSessionId']['expires'] = expirationStr |
694 |
cherrypy.response.cookie['UMCSessionId']['version'] = 1 |
695 |
cherrypy.response.cookie['UMCSessionId']['path'] = '/' |
696 |
|
692 |
|
697 |
return "" |
693 |
return "" |
698 |
|
694 |
|