Hi guys,
We need to keep a log of when people logged in and from where. I've
followed the documentation with some success, but I don't know how to
get access to the HttpServletRequest for the URI and IP
I'm doing something like this at the moment, but the URI and IP are
always blank.
onAuthenticationSuccessEvent = { e, appCtx ->
def attr = RequestContextHolder?.getRequestAttributes()
def uri = ""
if (attr?.currentRequest?.request) {
uri = attr.currentRequest.request.getRequestURI()
if (attr.currentRequest.request.getQueryString()) {
uri = uri + "?" +
attr.currentRequest.request.getQueryString();
}
}
def ip = ""
if (attr?.currentRequest?.request) {
ip = attr.currentRequest.request.getRemoteAddr()
}
def authentication = e.getAuthentication()
def accessLogEvent = new AccessLogEvent()
accessLogEvent.actor = authentication.getPrincipal()
accessLogEvent.action = "LOGIN"
accessLogEvent.uri = uri
accessLogEvent.ip = ip
accessLogEvent.dateCreated = new Date()
accessLogEvent.save()
}
Any ideas?
Thanks,
Elias
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email