Issue #1614 made authentication extensible in request log (#2004) Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
parent
2067eac701
commit
15c0f79593
|
@ -127,8 +127,9 @@ public abstract class AbstractNCSARequestLog extends AbstractLifeCycle implement
|
||||||
|
|
||||||
buf.append(addr);
|
buf.append(addr);
|
||||||
buf.append(" - ");
|
buf.append(" - ");
|
||||||
Authentication authentication = request.getAuthentication();
|
|
||||||
append(buf,(authentication instanceof Authentication.User)?((Authentication.User)authentication).getUserIdentity().getUserPrincipal().getName():null);
|
String auth = getAuthentication(request);
|
||||||
|
append(buf,auth==null?"-":auth);
|
||||||
|
|
||||||
buf.append(" [");
|
buf.append(" [");
|
||||||
if (_logDateCache != null)
|
if (_logDateCache != null)
|
||||||
|
@ -221,6 +222,23 @@ public abstract class AbstractNCSARequestLog extends AbstractLifeCycle implement
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract the user authentication
|
||||||
|
* @param request The request to extract from
|
||||||
|
* @return The string to log for authenticated user.
|
||||||
|
*/
|
||||||
|
protected String getAuthentication(Request request)
|
||||||
|
{
|
||||||
|
Authentication authentication = request.getAuthentication();
|
||||||
|
|
||||||
|
if (authentication instanceof Authentication.User)
|
||||||
|
return ((Authentication.User)authentication).getUserIdentity().getUserPrincipal().getName();
|
||||||
|
|
||||||
|
// TODO extract the user name if it is Authentication.Deferred and return as '?username'
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes extended request and response information to the output stream.
|
* Writes extended request and response information to the output stream.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue