Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-03-2008, 04:30 PM
Member
 
Join Date: Jan 2008
Posts: 4
raviprakash is on a distinguished road
Problem with NTLM ,data not posting to the server
Hi all,
we are making use of NTLM authentication techninuqe.
we are making use fo JSF with ADF custom components technology.
IT is throws an Exception when we click on any action button
its throws Exception : java.io.EOFException.....
public CheckAuthorisation()
{
try
{
String auth = request.getHeader("Authorization");
if (auth == null)
{
response.setStatus(response.SC_UNAUTHORIZED);
response.setHeader("WWW-Authenticate", "NTLM");
return;
}
if (auth.startsWith("NTLM "))
{
// System.out.println("Auth"+auth);
byte[] msg = new sun.misc.BASE64Decoder().decodeBuffer(auth.substri ng(5));
int off = 0, length, offset;
String s;

if (msg[8] == 1)
{
off = 18;
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.setStatus(response.SC_UNAUTHORIZED);
response.setHeader("WWW-Authenticate", "NTLM "
+ new sun.misc.BASE64Encoder().encodeBuffer(msg1).trim() );
response.setStatus(response.SC_UNAUTHORIZED);
return;
}
else if (msg[8] == 3)
{
off = 30;
length = msg[off+17]*256 + msg[off+16];
// System.out.println("length::" + length);
offset = msg[off+19]*256 + msg[off+18];
// System.out.println("offset::" + offset);
s = new String(msg, offset, length);
//out.println(s + " ");
// System.out.println("s::"+s);
}
else
return;


length = msg[off+1]*256 + msg[off];
// System.out.println("Second length::" + length);
offset = msg[off+3]*256 + msg[off+2];
// System.out.println("Second offset::" + offset);
s = new String(msg, offset, length);
//out.println(s + " ");
// System.out.println("Second S::" + s);
Pattern pat = Pattern.compile("[a-z,A-Z,0-9,@,.]+");
Matcher mat = pat.matcher(s);
String s1 = "";
while(mat.find())
s1 = s1+mat.group();

// System.out.println("Got Domain: "+s1);
// out.println(s1);
length = msg[off+9]*256 + msg[off+8];
offset = msg[off+11]*256 + msg[off+10];
s = new String(msg, offset, length);
// System.out.println("Third S::" + s);
pat = Pattern.compile("[a-z,A-Z,0-9,@,.]+");
mat = pat.matcher(s);
s1 = "";
while(mat.find())
s1 = s1+mat.group();

// System.out.println("Got name: "+s1);
if(s.indexOf('.')!=-1)
{
// System.out.println("dots!!!");
}
s.replaceAll("[.]","");

StringBuffer userName=new StringBuffer();
for(char c:s.toCharArray())
{
if((int)c!=0)userName.append(c);
}

out.println("Logged User Name is "+userName);
com.tristar.servicedesk.view.handler.ADSHandler adsHandler=new com.tristar.servicedesk.view.handler.ADSHandler();
out.println("Role is "+adsHandler.IdentifyRolesFromADS(userName.toStrin g()));
String userRole=adsHandler.IdentifyRolesFromADS(userName. toString());
// System.out.println("userRole::"+userRole);
// System.out.println("userName::"+userName);
session.setAttribute("loggedUserName",userName);
session.setAttribute("loggedUserRole",userRole);
// System.out.println("user name from session::"+session.getAttribute("loggedUserName")) ;
//response.setStatus(HttpServletResponse.SC_UNAUTHOR IZED);

System.out.println("Request info "+request.getHeaderNames());


if(session.getAttribute("status")==null)
{
session.setAttribute("status","value");
if(userRole!=null)
response.sendRedirect("faces/app/searchRequest.jsp");
else
// response.sendRedirect("faces/app/searchRequest.jsp");
response.sendRedirect("faces/unauthorisation.jsp");
}
}
}
catch (Exception e)
{
session.setAttribute("loggedUserName",null);
session.setAttribute("loggedUserRole",null);
System.out.println("Exception due to "+e);
e.printStackTrace();
}
}


This is my above code.
its working for everything.
problem only when file uploading comes into discussion.


thanks in advance,
ravi.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-03-2008, 04:31 PM
Member
 
Join Date: Jan 2008
Posts: 4
raviprakash is on a distinguished road
Problem with NTML authentication ?
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 01-03-2008, 04:32 PM
Member
 
Join Date: Jan 2008
Posts: 4
raviprakash is on a distinguished road
wat is transient
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 01-03-2008, 04:33 PM
Member
 
Join Date: Jan 2008
Posts: 4
raviprakash is on a distinguished road
how to make use of windows authentication using java ?
i want client side windows authentication ?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sql server connection problem tanvirtonu Database 1 03-31-2008 01:46 PM
querying russian data from db problem mr_empty Database 0 03-04-2008 08:56 AM
Posting codes and help Java_Man New To Java 2 02-16-2008 04:15 AM
Problem for iReport (Data Source ) tlgkumar Advanced Java 1 11-27-2007 08:39 AM
Plugin to Prevent Newbies from Posting to Wrong Forum levent Suggestions & Feedback 1 08-12-2007 02:07 PM


All times are GMT +3. The time now is 09:48 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org