• Post Reply Bookmark Topic Watch Topic
  • New Topic

user name from HttpServletRequest is null  RSS feed

 
jay vas
Ranch Hand
Posts: 407
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Im trying to use NTLM to
get a user name. I keep getting this
error :

jcifs.smb.SmbException: Timeout trying to open socket

java.io.IOException: Failed to establish session with
IS_NOHRI<00>/192.168.102.148
at jcifs.smb.SmbTransport.run(SmbTransport.java:363)
at java.lang.Thread.run(Unknown Source)


I tried the following :

<code>
public void init(ServletConfig config)
throws ServletException
{
super.init(config);
System.out.println("Initializing Servlet "); }
public void doGet( HttpServletRequest req, HttpServletResponse response throws IOException, ServletException
{


String auth = req.getHeader("Authorization");
if (auth == null)
{
System.out.println("flushing buffer");
response.setStatus(response.SC_UNAUTHORIZED);
response.setHeader("WWW-Authenticate", "NTLM");
response.flushBuffer();
System.out.println("flushing buffer");
return;
}
if (auth.startsWith("NTLM "))
{
byte[] msg = new 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};
response.setHeader("WWW-Authenticate", "NTLM " +
new sun.misc.BASE64Encoder().encodeBuffer(msg1));
response.sendError(response.SC_UNAUTHORIZED);
return;
}
else if (msg[8] == 3)
{
off = 30;

length = msg[off+17]*256 + msg[off+16];
offset = msg[off+19]*256 + msg[off+18];
String remoteHost = new String(msg, offset, length);

length = msg[off+1]*256 + msg[off];
offset = msg[off+3]*256 + msg[off+2];
String domain = new String(msg, offset, length);

length = msg[off+9]*256 + msg[off+8];
offset = msg[off+11]*256 + msg[off+10];
String username = new String(msg, offset, length);

System.out.println("---");
System.out.println("Username:"+username+"<BR>");
System.out.println("RemoteHost:"+remoteHost+"<BR>");
System.out.println("Domain:"+domain+"<BR>");
}
}
}
</code>


please help ? Do I need extra info in my web.xml ? Here it is :

<servlet>
<servlet-name>NTLM Servlet</servlet-name>
<servlet-class>NTLM</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>NTLM Servlet</servlet-name>
<url-pattern>/NTLM</url-pattern>
</servlet-mapping>

<filter>
<filter-name>NtlmHttpFilter</filter-name>
<filter-class>jcifs.http.NtlmHttpFilter</filter-class>
<init-param>
<param-name>jcifs.http.domainController</param-name>
<param-value>192.168.102.148</param-value>
</init-param>
</filter>






-j
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!