IE Apache Tomcat NTLM - error multipart request
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   LEBLANC_Damiens
Posted On:   Thursday, August 30, 2007 01:58 PM

I'm trying to implement NTLM protocol in the following architecture : - Apache 2.0.52 - Mod JK - Tomcat 4 For the "Multipart request" forms, the NTLM protocol stops at the first request when the WWW-Authenticate line of the header value is "NTLM 1". The code of the filter is this : public NTLMUserInformation negociateNTLM(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { NTLMUserInformation userInfo = new NTLMUserInformation(); String auth = request.getHeader("Authorization"); if (auth == null) { logger.debug("NTLM AUT   More>>

I'm trying to implement NTLM protocol in the following architecture :

- Apache 2.0.52

- Mod JK

- Tomcat 4




For the "Multipart request" forms, the NTLM protocol stops at the first request when the WWW-Authenticate line of the header value is "NTLM 1".



The code of the filter is this :

			
public NTLMUserInformation negociateNTLM(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

NTLMUserInformation userInfo = new NTLMUserInformation();

String auth = request.getHeader("Authorization");
if (auth == null)
{
logger.debug("NTLM AUTH == NULL");
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
response.setHeader("WWW-Authenticate", "NTLM");
response.flushBuffer();
return null;
}
if (auth.startsWith("NTLM "))
{
byte[] msg = new sun.misc.BASE64Decoder().decodeBuffer(auth.substring(5));
int off = 0, length, offset;
if (msg[8] == 1)
{
logger.debug("NTLM MSG == 1");
byte z = 0;
byte[] msg1 = {(byte)'N', (byte)'T', (byte)'L', (byte)'M', (byte)'S', (byte)'S', (byte)'P', z,(byte)2, z, z, z, z, z, z, z,(byte)40, z, z, z, (byte)1, (byte)130, z, z,z, (byte)2, (byte)2, (byte)2, z, z, z, z, z, z, z, z, z, z, z, z};
response.setHeader("WWW-Authenticate", "NTLM " + new sun.misc.BASE64Encoder().encodeBuffer(msg1));
response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
response.flushBuffer();
return null;
}
else if (msg[8] == 3)
{
logger.debug("NTLM MSG == 3, authenticated");
off = 30;
length = msg[off+17]*256 + msg[off+16];
offset = msg[off+19]*256 + msg[off+18];
userInfo.setNTLMUserHostname(new String(msg, offset, length, "UTF-16LE"));

length = msg[off+1]*256 + msg[off];
offset = msg[off+3]*256 + msg[off+2];
userInfo.setNTLMUserDomain(new String(msg, offset, length, "UTF-16LE"));

length = msg[off+9]*256 + msg[off+8];
offset = msg[off+11]*256 + msg[off+10];
userInfo.setNTLMUserLogin(new String(msg, offset, length, "UTF-16LE"));

logger.debug("NTLM_USER : " + userInfo.getNTLMUserLogin());
logger.debug("ROLE : " + userInfo.getUserRole());
}
}

return userInfo;
}



Any idea will help me very much,
Thanks in advance,
Damiens.    <<Less
About | Sitemap | Contact