3 Replies Latest reply on Sep 12, 2012 10:34 AM by Faisal WebLogic Wonders

    weblogic authentication programatically

      Hello Experts,

      I have to authenticate the weblogic programatically ,as the client has deployed a serverlet in weblogic, and i have my web-application on the same weblogic.

      my web application has a link , where it try to get a document from the archive server , thorugh the servlet . the web.xml for the server has <auth-method>BASIC</auth-method>

      so from my web application when we click , now the pop-up/login/credential box is coming, I do have the credentials for this , as in the security realms the user is created.

      I want to avoid this pop up and pass the credentials ,and do the authentication progrmatically.

      all in my java I have a string URL="http://localhost:8080/servlet/xxxx?"

      Can any1 suggest or let me know the feasible way

      Edited by: Gkparis on Sep 11, 2012 2:03 AM
        • 1. Re: weblogic authentication programatically
          Kalyan Pasupuleti-Oracle

          As this is basic authentication process which do in-general.

          We have BASIC / FORM / Cert base.

          So I think Authentication is first process you need to fill if you want you can use SSO process to access with authentication every time in such case you can use certbase.

          check few examples.



          any further help let me know.

          • 2. Re: weblogic authentication programatically
            Hi Kalyan,

            I am aware of the auth-method , my constraint is :

            Client has deployed this servlet aling with auth-method -BASIC and client dont want to change any thing in the web.xml or any other configuration changes

            So i am wondering , if this has to be achieved by programming way , maybe some wat like this url :


            still i am stuck because, i have a string strUrl="http://localhost:8080/servlet"

            and the API here
            weblogic.servlet.security.ServletAuthentication.runAs(mySubject, request);

            needs the request object

            Any pointer u can suggest !!!
            • 3. Re: weblogic authentication programatically
              Faisal WebLogic Wonders
              Socket s = new Socket("localhost", 7001);
              BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
              PrintStream out = new PrintStream(s.getOutputStream());
              out.println("POST /servlet/xxxx?");
              out.println("Accept-Encoding: gzip,deflate");
              out.println("Authorization: Basic d2VibG9naWM6d2VibG9naWM=");

              For e.g. if your username and password is weblogic,weblogic, you will have to create a string like this weblogic:weblogic then encode it using base64 and then pass it in the code..


              Hope this helps!