Skip to content
Snippets Groups Projects
Commit 44d003cb authored by sveseli's avatar sveseli
Browse files

added SSO interfaces

parent 77039753
No related branches found
No related tags found
No related merge requests found
......@@ -4,10 +4,14 @@
# Implementation for user info controller.
#
import datetime
import cherrypy
from dm.common.constants import dmRole
from dm.common.objects.authorizationPrincipal import AuthorizationPrincipal
from dm.common.objects.dmObjectManager import DmObjectManager
from dm.common.objects.dmSession import DmSession
from dm.common.db.api.userDbApi import UserDbApi
from dm.common.exceptions.objectNotFound import ObjectNotFound
class AuthSessionControllerImpl(DmObjectManager):
""" User info controller implementation class. """
......@@ -26,4 +30,22 @@ class AuthSessionControllerImpl(DmObjectManager):
principal.setRole(dmRole.DM_ADMIN_ROLE)
return principal
def addSession(self, sessionId, sessionInfo):
sessionCache = cherrypy.session.cache
self.logger.debug('Session cache length: %s' % (len(sessionCache)))
sessionCache[sessionId] = (sessionInfo, datetime.datetime.now())
self.logger.debug('Session cache: %s' % (sessionCache))
return DmSession(sessionInfo)
def checkSession(self, sessionId):
sessionCache = cherrypy.session.cache
sessionTuple = sessionCache.get(sessionId)
if not sessionTuple:
raise ObjectNotFound('Session %s not found in cache.' % sessionId)
sessionInfo = sessionTuple[0]
oldTimestamp = sessionTuple[1]
newTimestamp = datetime.datetime.now()
self.logger.debug('Updated timestamp from %s to %s for session id %s' % (oldTimestamp, newTimestamp, sessionId))
sessionCache[sessionId] = (sessionInfo, newTimestamp)
return DmSession(sessionInfo)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment