{
Principal principal = request.getPrincipal();
if (principal instanceof GenericPrincipal)
{
GenericPrincipal genPrincipal = (GenericPrincipal) principal;
String userPrincipalName = genPrincipal.getUserPrincipal().getName();
// In latest negotiation+jbossas genPrincipal.getName() is the session token instead of real kerberos username
if (!genPrincipal.getName().equals(userPrincipalName))
{
if (log.isTraceEnabled())
{
log.trace("GenericPrincipal name: " + genPrincipal.getName() + " will be changed to name: " + userPrincipalName);
}
try
{
Field nameField = GenericPrincipal.class.getDeclaredField("name");
nameField.setAccessible(true);