Fetching NT Authentication details using java

I am accesing a jsp page of tomcat server in my machine from a browser client in another machine.I have to fetch the OS User name with which the user logged in the client machine using java.I tried using request.getRemoteHost() but it returned null.
I tried using NTLM .This is the code which i used
<%@ page language="java" import="java.io.*,java.util.*,java.lang.* " %>
<%@ page import="org.castor.util.*"%>
<%
String auth = request.getHeader("Authorization");
if (auth == null)
  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};
    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);
    out.println("Username:"+username+"<BR>");
    out.println("RemoteHost:"+remoteHost+"<BR>");
    out.println("Domain:"+domain+"<BR>");
%>But it didnt work.Should i configure my environment in any way for NTLM to work?
Is there anyother way to do this.Any code will be appreciated.
Thanks,
Vignesh

JSP's execute on the server and not on the client machine. So I'm not sure how you exect to get details from the client here. Not to mention that JSP you wrote is pretty nasty IMO.

Similar Messages

  • Retrieve NT Authentication details using java

    Need to get the OS user name and password of the remote client machine from which accesses the server Application in my machine.
    How to do this using java? Is there any java API to get this?
    Also tried the NTLM code but its not working.
    Any code will be appreciated.

    Need to get the OS user name and password of the
    remote client machine from which accesses the
    server Application in my machine.
    How to do this using java? Is there any java API to
    get this?
    Also tried the NTLM code but its not working.
    Any code will be appreciated.Forget it. You can't get the password unless you ask the user for it.
    Kaj

  • Need help in getting MDM relationship details using Java Apis

    Hi,
    Is it possible to search records which are in relationship using Java Apis? Suppose Record A is Parent record and Record B,C,D ... are child records.
    I have to search all the records which are in relationship with record A.
    Can any one send code snippet on this.
    Regards,
    Niraj

    Hi Niraj,
    You can use RetrieveRelationshipsCommand api to get the relationship child of the Anchor Record.
    RetrieveRelationshipsCommand command = new RetrieveRelationshipsCommand(connectionAccesor);
    command.setSession(session);
    command.setAnchorRecord(anchorRecord); / command.setAnchorRecordId(anchorRecordId); (use any of the two statements)
    command.setRelationship(relationshipId); //For child int type is 10, and for Parent_child int type is 5
    command.setMemberResultDefinition(resultDefinition);
    command.execute();
    //Get Member Records' resuld definition
    ResuldDefinition rd = command.getMemberResultDefinition();
    Hope this helps you.

  • Connectiing to PAMS - Pluggable Authentication Module using JAVA

    Hi,
    I am working on a security issue where there is PAM on the unix machine. How can I connect to that PAM using java? As I am new to this PAM concept, please give me a lead as of how can I do it using JAVA.
    Thanks in advance

    Hi,
    The usually procedure is to use ipsadmin change component iwtauth cust_auth.xml where cust_auth.xml has the attributes and values for the new module you have added. In your case you can try changing the client detection attribute alone using the ipsadmin command.
    The first step is to modify the existing
    <b> iwtAuth-clientDetectionEnabled </b>
    attribute to have a new value and changeing again to have the right(correct) value.
    Regards,
    Raj_indts
    Developer Technical Support
    Sun Microsystems http://www.sun.com/developers/support

  • How to fetch the BCC address using java mail

    Hi,
    I want to extract the mail address given in the Bcc address field of an email which I fetch it from the IMAP store !!
    I will be very much thankful if this problem is solved !!
    Thanks!!

    You can read the Bcc addresses just like the To and Cc addresses. But.... Note that Bcc addresses
    won't be present in any message you receive; if you could see the Bcc addresses it wouldn't be a
    blind carbon copy. If you create a message with Bcc addresses and save that message in your
    "Sent Items" folder, you'll be able to read the Bcc addresses in that message.

  • To fetch data from MS Outlook using JAVA

    Hi,
    I want to know about any api that helps in fetching MS Outlook data using JAVA code. Any help will be appreciated.
    Thanks
    Rohit

    Hi,
    I have to write data to an Excel sheet through servlet. But I'll also look in to resding data from MS Excel. will tell you if I am able to do that.
    Akhilesh Pathodia

  • Master detail using using java

    Hi ,
    I am using jdev 11.1.1 5
    My requirement to create master detail using java code.My view don't have view link.How to achive through code

    Why cant u use view link..
    btw you can see this
    http://www.techartifact.com/blogs/2013/08/master-detail-iterations-using-tree-component-by-managed-bean.html

  • How to set proxy authentication using java properties at run time

    Hi All,
    How to set proxy authentication using java properties on the command line, or in Netbeans (Project => Properties
    => Run => Arguments). Below is a simple URL data extract program which works in absence of firewall:
    import java.io.*;
    import java.net.*;
    public class DnldURLWithoutUsingProxy {
       public static void main (String[] args) {
          URL u;
          InputStream is = null;
          DataInputStream dis;
          String s;
          try {
              u = new URL("http://www.yahoo.com.au/index.html");
             is = u.openStream();         // throws an IOException
             dis = new DataInputStream(new BufferedInputStream(is));
             BufferedReader br = new BufferedReader(new InputStreamReader(dis));
          String strLine;
          //Read File Line By Line
          while ((strLine = br.readLine()) != null)      {
          // Print the content on the console
              System.out.println (strLine);
          //Close the input stream
          dis.close();
          } catch (MalformedURLException mue) {
             System.out.println("Ouch - a MalformedURLException happened.");
             mue.printStackTrace();
             System.exit(1);
          } catch (IOException ioe) {
             System.out.println("Oops- an IOException happened.");
             ioe.printStackTrace();
             System.exit(1);
          } finally {
             try {
                is.close();
             } catch (IOException ioe) {
    }However, it generated the following message when run behind the firewall:
    cd C:\Documents and Settings\abc\DnldURL\build\classes
    java -cp . DnldURLWithoutUsingProxy
    Oops- an IOException happened.
    java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
    at java.net.Socket.connect(Socket.java:452)
    at java.net.Socket.connect(Socket.java:402)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:139)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:402)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:618)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:306)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:267)
    at sun.net.www.http.HttpClient.New(HttpClient.java:339)
    at sun.net.www.http.HttpClient.New(HttpClient.java:320)
    at sun.net.www.http.HttpClient.New(HttpClient.java:315)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:510)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:487)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:615) at java.net.URL.openStream(URL.java:913) at DnldURLWithoutUsingProxy.main(DnldURLWithoutUsingProxy.java:17)
    I have also tried the command without much luck either:
    java -cp . -Dhttp.proxyHost=wwwproxy -Dhttp.proxyPort=80 DnldURLWithoutUsingProxy
    Oops- an IOException happened.
    java.io.IOException: Server returned HTTP response code: 407 for URL: http://www.yahoo.com.au/index.html
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1245) at java.net.URL.openStream(URL.java:1009) at DnldURLWithoutUsingProxy.main(DnldURLWithoutUsingProxy.java:17)
    All outgoing traffic needs to use the proxy wwwproxy (alias to http://proxypac/proxy.pac) on port 80, where it will prompt for valid authentication before allowing to get through.
    There is no problem pinging www.yahoo.com from this system.
    I am running jdk1.6.0_03, Netbeans 6.0 on Windows XP platform.
    I have tried Greg Sporar's Blog on setting the JVM option in Sun Java System Application Server (GlassFish) and
    Java Control Panel - Use browser settings without success.
    Thanks,
    George

    Hi All,
    How to set proxy authentication using java properties on the command line, or in Netbeans (Project => Properties
    => Run => Arguments). Below is a simple URL data extract program which works in absence of firewall:
    import java.io.*;
    import java.net.*;
    public class DnldURLWithoutUsingProxy {
       public static void main (String[] args) {
          URL u;
          InputStream is = null;
          DataInputStream dis;
          String s;
          try {
              u = new URL("http://www.yahoo.com.au/index.html");
             is = u.openStream();         // throws an IOException
             dis = new DataInputStream(new BufferedInputStream(is));
             BufferedReader br = new BufferedReader(new InputStreamReader(dis));
          String strLine;
          //Read File Line By Line
          while ((strLine = br.readLine()) != null)      {
          // Print the content on the console
              System.out.println (strLine);
          //Close the input stream
          dis.close();
          } catch (MalformedURLException mue) {
             System.out.println("Ouch - a MalformedURLException happened.");
             mue.printStackTrace();
             System.exit(1);
          } catch (IOException ioe) {
             System.out.println("Oops- an IOException happened.");
             ioe.printStackTrace();
             System.exit(1);
          } finally {
             try {
                is.close();
             } catch (IOException ioe) {
    }However, it generated the following message when run behind the firewall:
    cd C:\Documents and Settings\abc\DnldURL\build\classes
    java -cp . DnldURLWithoutUsingProxy
    Oops- an IOException happened.
    java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
    at java.net.Socket.connect(Socket.java:452)
    at java.net.Socket.connect(Socket.java:402)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:139)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:402)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:618)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:306)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:267)
    at sun.net.www.http.HttpClient.New(HttpClient.java:339)
    at sun.net.www.http.HttpClient.New(HttpClient.java:320)
    at sun.net.www.http.HttpClient.New(HttpClient.java:315)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:510)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:487)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:615) at java.net.URL.openStream(URL.java:913) at DnldURLWithoutUsingProxy.main(DnldURLWithoutUsingProxy.java:17)
    I have also tried the command without much luck either:
    java -cp . -Dhttp.proxyHost=wwwproxy -Dhttp.proxyPort=80 DnldURLWithoutUsingProxy
    Oops- an IOException happened.
    java.io.IOException: Server returned HTTP response code: 407 for URL: http://www.yahoo.com.au/index.html
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1245) at java.net.URL.openStream(URL.java:1009) at DnldURLWithoutUsingProxy.main(DnldURLWithoutUsingProxy.java:17)
    All outgoing traffic needs to use the proxy wwwproxy (alias to http://proxypac/proxy.pac) on port 80, where it will prompt for valid authentication before allowing to get through.
    There is no problem pinging www.yahoo.com from this system.
    I am running jdk1.6.0_03, Netbeans 6.0 on Windows XP platform.
    I have tried Greg Sporar's Blog on setting the JVM option in Sun Java System Application Server (GlassFish) and
    Java Control Panel - Use browser settings without success.
    Thanks,
    George

  • How to fetch Properties of all Survey Lists from site collection using Java Script in SharePoint 2013

    Hi,
    I am trying to fetch properties of all lists of "Survey Type" from my site collection in SharePoint 2013 using script editor web part. I am able to fetch properties of one list by mentioning its name explicitly in code but not all survey
    list.
    My task is to display Survey name , description ,Time created and URLs of all survey lists using java script in script editor web part.
    And let me know , if there is any other OOB feature of SharePoint 2013 to achieve the same. 
    Here is the code  :
    <script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    SP.SOD.executeFunc('sp.js', 'SP.ClientContext', sharePointReady);
    function sharePointReady() {
         GetSurveyList();
     function GetSurveyList() {
            var spListTitle = " List Name";
             var clientContext = new SP.ClientContext.get_current();
            var oWeb = clientContext.get_web();
            this.surveyList = oWeb.get_lists().getByTitle(spListTitle);
            clientContext.load(surveyList);
            clientContext.executeQueryAsync(Function.createDelegate(this, this.GetListProperties),Function.createDelegate(this, this.onFailure));
     function GetListProperties() {
            $("#SurveyList").text("");
            var surveyTable = "<table border=1>";
            surveyTable = surveyTable.concat("<tr><td>Survey Name</td>");
            surveyTable = surveyTable.concat("<td>Survey Description</td>");
            surveyTable = surveyTable.concat("<td>Time Created</td>");
            surveyTable = surveyTable.concat("<tr><td>" + surveyList.get_title() + "</td>");
            surveyTable = surveyTable.concat("<td>" + surveyList.get_description() + "</td>");
            surveyTable = surveyTable.concat("<td>" + surveyList.get_created().format("MM/dd/yyyy hh:mm tt")+ "</td>");
                 surveyTable = surveyTable.concat("</table>");
            $("#SurveyList").append(surveyTable);
        function onFailure(sender, args) {
            alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
    </script>
    <div id="SurveyList"></div>

    Shifa,
    Please use search result webpart or content query webpart to list all survey list.
    Please 'propose as answer' if it helped you, also 'vote helpful' if you like this reply.

  • How to make use of Windows authentication from my Java application

    I have a Java application, Instead I design one more login page for my application, I want to make use of Windows Authentication.
    How should I use that windows authentication in my java application
    can any help me in suggesting a solution

    How will they be able to access your application if they aren't users of the system?

  • How & where to use Java script to create new button in object detail page

    Hi All,
    I want to create "New/Add button" in object detail page. If i am not wrong i need to use java script for that but could you please let me know how & where to use Java script to create new button in object detail page in CRMOD.
    Thanks in advance.
    Regards,
    Manish

    Any related object on the detail page should have an "Add" or "New" or both buttons by default - This is vanilla functionality and will do the required action.
    If you want to modify this behaviour and do something tricky you will potentially have to go for javascript. You should add the javascript on a custom web tab on that Object.
    Admin --> Application Customization --> Contact -->Contact Web Applet
    Now, add your javascript in the code area, after you select the type = HTML for this web applet, expose this web applet on the Contact detail layout and your javascript will be invoked whenever this page is loaded.
    Check this online document to see how javascript can be embedded in CRM on Demand http://helponmyproject.com/TTOCOD/
    Cheers!
    Royston

  • Windows Ad Authentication using java

    Hi,
    My Requirement: We are using Java, JSP, Struts in our application.
    We have a user login jsp page. Whenever user try signing by using the logiin page we have to use Ad(Active Directory) userid and Ad password available from operating system.
    Can any one please suggest me how I can achieve this?
    Thanks in advance
    Best Regards,
    Satish

    1. Given a user name password and perhaps other information find out via the windows API how to 'log in'. This has nothing to do with java.
    2. Write some C/C++ code that uses 1 to wrap that functionality in such a way that it describes what you want to do in your application. This has nothing to do with java.
    3. Write a jni java class and C JNI code to wrap 2. This has something to do with java.

  • Using Java Webservices provided by xRPM 4.0 in PPM 5.0

    Hi,
    We have developed some custom WD ABAP applications in PPM 4.5 which were using Java webservices provided by xRPM 4.0 to get the UI context.
    The details are provided in the document
    https://websmp109.sap-ag.de/~sapidb/012006153200000315412008E/How_to_xRPM_custom_iView.pdf
    We have upgraded to PPM 5.0 and the custom webDynpro application is not able to fetch the UI context and get the portfolio GUID. I have verified that the RFC destination and Logical port required to call Java webservices is maintained as mentioned in the above document.
    Are these SAP standard Java webservices available for use in PPM 5.0 ? Please let me know if we need to change the custom code to fetch the UI context in PPM 5.0
    Thanks,
    Yomesh

    Thanks Amit for the confirmation. I am following SAP Note 0001399319 which mentions about how to develop for custom WD ABAP applications in PPM 5.0.
    The example WDA component mentioned in the note is /RPM/CUSTOM_COMPONENT. I am developed a custom WD ABAP application in lines with the SAP note and still not able to get the GUID in the context.
    The code written in WDDOINIT of these applications is as below,
      instantiate session state class
        wd_this->mr_session_state = cl_inm_session_state=>get_instance( ).
    Obtain current context from session state.
        CALL METHOD wd_this->mr_session_state->get_current_context
          IMPORTING
            es_context = wd_this->ms_context.
    I am getting null in ms_context.
    Please let me know if you have tried to implement an custom WDA application in PPM 5.0. Not sure what am I missing in the above scenario.
    Thanks,
    Yomesh

  • New "Windows Programming Using Java" Website

    Our newly created "Windows Programming Using Java" website (http://fivedots.coe.psu.ac.th/~ad/winJava/) is for programmers who want to extend Java's capabilities on Windows XP and/or Vista, but aren't sure where to start. One of the drawbacks of Java's portability is that many Java programmers have a rather sketchy knowledge of Windows-specific programming.
    We plan to explain how Java applications can utilize Windows application software, OS features, and hardware beyond the reach of Java's standard libraries. A variety of Java/Windows programming techniques will be explained, including:
    * Java's employment of the Win32 API via C, JNI, and J/Invoke.
    * Java's utilization of Window's Command Line Interface (CLI) and batch files, accessed through Java's Runtime, ProcessBuilder, and Process classes.
    * Java and Windows object-based scripting, centered around the use of VBScript, Windows Script Host (WSH), and Windows Management Instrumentation (WMI).
    * Java interoperability with COM, including hosting of ActiveX controls in Swing containers using jacoZoom.
    This website is a work in progress, with four chapters available for download at the moment. We'll be adding more regularly, and would love feedback on what we're doing.
    Thanks,
    Gayathri Singh and Andrew Davison
    [email protected] and [email protected]
    Edited by: AndrewDavison on Jun 20, 2008 1:36 AM

    Hi, I am looking the similar kind of requirement that you had done.. Do you have any more details on the code that is working for you . All i need is if the user logs in successfully in windows, the the app should be accessible. Please let me know if you have the code with you on this problem.
    Thanks in advance
    "what i meant is the we b applications running in my system, when i access the application iam able to to login automatically with windows authentication and now in case of other users following process happened:"

  • HI, Iam  trying to Integrate Exchange server using Java Mail

    Here is what iam stuck with, I have a problem while conneting to Exchange Server using imap over ssl.
    My code looks like this
    props.put("mail.imap.host",host);
    props.put("mail.imap.sasl.authorizationid","user1");
    props.put("mail.imap.sasl.enable","true");
    props.setProperty("mail.imap.socketFactory.class","javax.net.ssl.SSLSocketFactory");
    props.setProperty("mail.imap.socketFactory.fallback","true");
    props.setProperty("mail.imap.socketFactory.port","993");
    Authenticator auth = new myauthenticator(AdminUserName,AdminPassword);
    Session session = Session.getInstance(props,auth);
    session.setDubug(true);
    Store store = session.getStore("imap");
    store.connect();
    I get the following Exception as
    javax.mail.MessagingException: Software caused connection abort: recv failed;
    nested exception is:
    java.net.SocketException: Software caused connection abort: recv failed
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:571)
    at javax.mail.Service.connect(Service.java:310)
    at javax.mail.Service.connect(Service.java:169)
    at javax.mail.Service.connect(Service.java:118)
    at MoveCalendar.move(MoveCalendar.java:63)
    at SendCalendar.send(SendCalendar.java:74)
    at SendCalendar.main(SendCalendar.java:40)
    Caused by: java.net.SocketException: Software caused connection abort: recv failed
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(Unknown Source)
    at com.sun.net.ssl.internal.ssl.InputRecord.a(Unknown Source)
    at com.sun.net.ssl.internal.ssl.InputRecord.read(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.j(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(Unknown Source)
    at com.sun.net.ssl.internal.ssl.AppInputStream.read(Unknown Source)
    at com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:110)
    at java.io.BufferedInputStream.fill(Unknown Source)
    at java.io.BufferedInputStream.read(Unknown Source)
    at com.sun.mail.iap.ResponseInputStream.readResponse(ResponseInputStream.java:97)
    at com.sun.mail.iap.Response.<init>(Response.java:96)
    at com.sun.mail.imap.protocol.IMAPResponse.<init>(IMAPResponse.java:61)
    at com.sun.mail.imap.protocol.IMAPResponse.readResponse(IMAPResponse.java:135)
    at com.sun.mail.imap.protocol.IMAPProtocol.readResponse(IMAPProtocol.java:261)
    at com.sun.mail.iap.Protocol.<init>(Protocol.java:114)
    at com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMAPProtocol.java:104)
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:538)
    ... 6 more
    DEBUG: setDebug: JavaMail version 1.4.1
    DEBUG: getProvider() returning javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc]
    DEBUG: mail.imap.fetchsize: 16384
    DEBUG: enable SASL
    DEBUG: mail.imap.sasl.authorizationid: user1
    If i change the sessionFactory.class or if I remove this property I donot get any Exception It gets Executed well, but IT goes directly to the Adminstrators Mail account but not to the AuthorizationId I gave it. Can any one give me sugssion upon this issue.I don't understand whether the problem was with the Exchange Server I was trying to connect or with my local Environment

    hi,
    Iam very thankful for your reply here's the requested debug steps
    DEBUG: setDebug: JavaMail version 1.4.1
    DEBUG: getProvider() returning javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc]
    DEBUG: mail.imap.fetchsize: 16384
    DEBUG: enable SASL
    DEBUG: mail.imap.sasl.authorizationid: user1
    DEBUG: protocolConnect returning false, host=india.lendingspace.com, user=PMaganti, password=<null>
    * OK Microsoft Exchange 2000 IMAP4rev1 server version 6.0.6249.0 (lsinmail.india.lendingspace.com) ready.
    A0 CAPABILITY
    * CAPABILITY IMAP4 IMAP4rev1 IDLE LOGIN-REFERRALS MAILBOX-REFERRALS NAMESPACE LITERAL+ UIDPLUS CHILDREN AUTH=NTLM
    A0 OK CAPABILITY completed.
    IMAP DEBUG: AUTH: NTLM
    DEBUG: protocolConnect login, host=****, user=AdminUserName, password=<non-null>
    IMAP SASL DEBUG: Mechanisms: NTLM
    IMAP SASL DEBUG: No SASL support
    A1 LOGIN AminUserName AdminPassword
    A1 OK LOGIN completed.
    A2 CAPABILITY
    * CAPABILITY IMAP4 IMAP4rev1 IDLE LOGIN-REFERRALS MAILBOX-REFERRALS NAMESPACE LITERAL+ UIDPLUS CHILDREN AUTH=NTLM
    A2 OK CAPABILITY completed.
    IMAP DEBUG: AUTH: NTLM
    DEBUG: connection available -- size: 1
    A3 SELECT INBOX
    * 1 EXISTS
    * 1 RECENT
    * FLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)
    * OK [PERMANENTFLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)] Permanent flags
    * OK [UNSEEN 1] Is the first unseen message
    * OK [UIDVALIDITY 261914] UIDVALIDITY value
    A3 OK [READ-WRITE] SELECT completed.
    No of Messages msgs 1
    A4 FETCH 1 (ENVELOPE INTERNALDATE RFC822.SIZE)
    * 1 FETCH (ENVELOPE ("5 Mar 2009 13:25:19 +0530" "Outlook Calendar Events Using Java" ((NIL NIL "XXXXX" "XXXXX")) ((NIL NIL "XXXXX" "XXXXX")) ((NIL NIL "XXXXX" "XXXXX")) ((NIL NIL "XXXX" "XXXX")) NIL NIL NIL "<XXXXX>") INTERNALDATE " 5-Mar-2009 13:25:19 +0530" RFC822.SIZE 1348)
    A4 OK FETCH completed.
    FROM: XXXX
    SUBJECT: Outlook Calendar Events Using Java
    DATE: Thu Mar 05 13:25:19 IST 2009
    A5 FETCH 1 (BODYSTRUCTURE)
    * 1 FETCH (BODYSTRUCTURE (("TEXT" "CALENDAR" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 598 10 NIL NIL NIL) "mixed" ("boundary" "----=_Part_0_18680399.1236239719654") NIL NIL))
    A5 OK FETCH completed.
    [ Multipart Message ]
    CONTENT:TEXT/CALENDAR; charset=US-ASCII
    A6 STORE 1 +FLAGS (\Answered)
    * 1 FETCH (FLAGS (\Answered \Recent))
    A6 OK STORE completed.
    A7 COPY 1 CALENDAR
    A7 OK [COPYUID 262745 258 23] COPY completed, 1 messages copied.
    A8 EXAMINE INBOX
    * 1 EXISTS
    * 0 RECENT
    * FLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)
    * OK [PERMANENTFLAGS ()] Permanent flags
    * OK [UNSEEN 1] Is the first unseen message
    * OK [UIDVALIDITY 261914] UIDVALIDITY value
    A8 OK [READ-ONLY] EXAMINE completed.
    A9 CLOSE
    A9 OK CLOSE completed.
    DEBUG: added an Authenticated connection -- size: 1
    A10 LOGOUT
    * BYE Microsoft Exchange 2000 IMAP4rev1 server version 6.0.6249.0 signing off.
    A10 OK LOGOUT completed.
    DEBUG: IMAPStore connection dead
    DEBUG: IMAPStore cleanup, force false
    DEBUG: IMAPStore cleanup done
    Actually what iam doing is read a mail which was more recent in inbox and If it is an Calendar event Iam copying that mail to Calendar Folder. So that Microsoft OUTLOOK automatically recongnizes them and secudles them in it's Calendars
    This is actually done for adminstrator's Account but not for the user1
    As you have suggested I removed the socketFactory class stuff and did this.
    and this is my modified Code
    props.put("mail.imap.host",imapHost);
    props.put("mail.imap.sasl.enable", "true");
    props.put("mail.imap.sasl.authorizationid", "user1");
    Authenticator auth=new myauthentication(imapUserName,imapPassword);
    Session session = Session.getInstance(props,auth);
    session.setDebug(true);
    store = session.getStore("imap");
    store.connect();
    And that goes like that.

Maybe you are looking for