Results 1 to 4 of 4
  1. #1
    raviprakash is offline Member
    Join Date
    Jan 2008
    Posts
    4
    Rep Power
    0

    Thumbs up 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.

  2. #2
    raviprakash is offline Member
    Join Date
    Jan 2008
    Posts
    4
    Rep Power
    0

    Default

    Problem with NTML authentication ?

  3. #3
    raviprakash is offline Member
    Join Date
    Jan 2008
    Posts
    4
    Rep Power
    0

    Default

    wat is transient

  4. #4
    raviprakash is offline Member
    Join Date
    Jan 2008
    Posts
    4
    Rep Power
    0

    Default

    how to make use of windows authentication using java ?
    i want client side windows authentication ?

Similar Threads

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •