DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=36423>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=36423

           Summary: NTLM Authorization does not work (in Tomcat 4 the same
                    code OK)
           Product: Tomcat 5
           Version: 5.5.9
          Platform: PC
        OS/Version: Windows 2000
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Unknown
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: [EMAIL PROTECTED]


I used the following jsp to login under TOMCAT 4 and it works fine. Under Tomcat
5 it does not work. It just passes once in the first if{}.

<%@ page import="jcifs.ntlmssp.Type3Message" %>
<%
String auth = request.getHeader("Authorization");

if (auth == null) {
  response.setContentLength(0);
  response.setStatus(response.SC_UNAUTHORIZED);
  response.setHeader("WWW-Authenticate", "NTLM");
  response.flushBuffer();
  return;
}

if (auth.startsWith("NTLM ")) {
  byte[] msg = new sun.misc.BASE64Decoder().decodeBuffer(auth.substring(5));
  int off = 0, length, offset;
  if (msg[8] == 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};
    out.println(" ");
    response.setContentLength(3);
    response.setHeader("WWW-Authenticate", "NTLM " +
    new sun.misc.BASE64Encoder().encodeBuffer(msg1).trim());
    response.sendError(response.SC_UNAUTHORIZED);
    return;
  }
  else if (msg[8] == 3) {
    logCat.debug("Type3");
    Type3Message type3 = new Type3Message(msg);
    session.setAttribute("osUser",type3.getUser());
    session.setAttribute("osRemoteHost",type3.getWorkstation());
    session.setAttribute("osDomain",type3.getDomain());
    response.sendRedirect("index.jsp");
  }
}
%>

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to