final boolean logoutSession)
throws LoginException {
final String sudoUser = getSudoUser(authenticationInfo);
if (sudoUser != null && !session.getUserID().equals(sudoUser)) {
try {
final SimpleCredentials creds = new SimpleCredentials(sudoUser,
new char[0]);
copyAttributes(creds, authenticationInfo);
creds.setAttribute(ResourceResolver.USER_IMPERSONATOR,
session.getUserID());
return session.impersonate(creds);
} catch (final RepositoryException re) {
throw getLoginException(re);
} finally {