Session & request informationΒΆ
Note
You can find these scripts inside the folder
pmis/STND_PMIS/test/console/example
.If you want to execute them, you can use the
Jython Console
from the devtool
menu.filename => ex04.py
from org.springframework.security.context import SecurityContextHolder
from org.springframework.web.context.request import RequestContextHolder
sessionReg = ApplicationContext.get('sessionRegistry')
#list methods available
#print dir(sessionReg)
# ALL SESSION CONNECTED TO THE SERVER
principals = sessionReg.allPrincipals
for principal in principals:
for session in sessionReg.getAllSessions( principal, True ):
print session.principal + ' - ' + session.sessionId
#session.expireNow()
#PERSONAL SESSION INFO
#print SecurityContextHolder.getContext()
#get ServletRequestAttributes
requestAttribute = RequestContextHolder.currentRequestAttributes()
#get Session/Request/ecc...
request = requestAttribute.request
session = request.session
#print requestAttribute.sessionId
securityContext = session.getAttribute('SPRING_SECURITY_CONTEXT')
print securityContext.authentication