0

我的应用程序正在使用基本身份验证,但我必须将其更改为NTLM以使其现在可以工作有人可以指导我是否做正确的事情如果不是请指导我如何将 NTLM 集成到我的应用程序中。

以下是我的 .java 文件

HttpServletRequest req = (HttpServletRequest) servletRequest;
HttpServletResponse resp = (HttpServletResponse) servletResponse;
String auth = req.getHeader("Authorization");
if (nullEmpty(auth) || !auth.startsWith("NTLM "))
{
    needsAuth(resp);
}

String cred = new 
String(Base64.getDecoder().decode(authorization.substring("NTLM ".length(), authorization.length())), "UTF-8");

void needsAuth(HttpServletResponse respo)
{
    respo.setHeader("WWW-Authenticate", "NTLM realm=\"Log In\"");
    respo.setHeader("Content-Type", "text/html");
    respo.setStatus(401);
}
4

0 回答 0