// authenticate user
if (!authorizationHeader.isNull()
&& this.provider.isSecurityPackageSupported(authorizationHeader.getSecurityPackage())) {
// log the user in using the token
IWindowsIdentity windowsIdentity;
try {
windowsIdentity = this.provider.doFilter(request, response);
if (windowsIdentity == null) {
return;
}
} catch (IOException e) {
LOGGER.warn("error logging in user: {}", e.getMessage());
LOGGER.trace("{}", e);
sendUnauthorized(response, true);
return;
}
if (!this.allowGuestLogin && windowsIdentity.isGuest()) {
LOGGER.warn("guest login disabled: {}", windowsIdentity.getFqn());
sendUnauthorized(response, true);
return;
}
try {
LOGGER.debug("logged in user: {} ({})", windowsIdentity.getFqn(), windowsIdentity.getSidString());
final WindowsPrincipal principal = new WindowsPrincipal(windowsIdentity, this.principalFormat,
this.roleFormat);
LOGGER.debug("roles: {}", principal.getRolesString());
final Authentication authentication = new WindowsAuthenticationToken(principal,
this.grantedAuthorityFactory, this.defaultGrantedAuthority);
SecurityContextHolder.getContext().setAuthentication(authentication);
LOGGER.info("successfully logged in user: {}", windowsIdentity.getFqn());
} finally {
windowsIdentity.dispose();
}
}
chain.doFilter(request, response);
}