How to get caller principal in a Java class?

I understand if I implement the web service with an EJB, I should be able to get
the caller's principal using EJBContext. How do I get the caller's principal if
I implement a web service with WL70 using a Java class?
Thanks,
- Hao

Bruce, thank you for your response.
However, the getCurrentUser() method does not seem to work. It throws an exception
but I couldn't see what exception it throws. The documention also says that class
and its methods are deprecated.
Is there any other Weblobic class that is doing similar thing?
- Hao
"bruce leroy" <[email protected]> wrote:
>
i think you could use the getcurrentuser method
http://e-docs.bea.com/wls/docs70/javadocs/weblogic/security/acl/Security.html#getCurrentUser()
"Hao" <[email protected]> wrote:
I understand if I implement the web service with an EJB, I should be
able to get
the caller's principal using EJBContext. How do I get the caller's principal
if
I implement a web service with WL70 using a Java class?
Thanks,
- Hao

Similar Messages

  • How to get database connection in common java class

    hi friendz,
    plz help me...
    I am using JDEV 11.1.2.2.0 version.
    my problem is I'm writing common java class which can reuse any application.
    in this case when im create database connection like this,
    String username = "a";
    String password = "b";
    String thinConn = "jdbc:oracle:thin:@IP:1521:database";
    DriverManager.registerDriver(new OracleDriver());
    Connection conn =
    DriverManager.getConnection(thinConn, username, password);
    conn.setAutoCommit(false);
    return conn;
    but this statement not working in java class.its working only backing bean.
    import oracle.jdbc.OracleDriver;
    DriverManager.registerDriver(new OracleDriver());
    how can i do that??
    hope your help
    -Harsh-

    What is the error message in Java class?
    With JDBC 4.0 driver the DriverManager class has added support for the Java SE Service Provider mechanism to the getConnection() and getDrivers() methods using which JDBC drivers may be loaded automatically. The following Class.forName() method is not required to be invoked.
    Class.forName(“oracle.jdbc.OracleDriver”);
    Only the following is required to obtain a connection.
    String url="jdbc:oracle:thin:@localhost:1521:ORCL";
    Connection connection = DriverManager.getConnection(url,"oe", "pw");

  • How to get af:commandbutton id in java code when it is triggered?

    Hi All
    In my application's homepage, I am using 2 af:commandbuttons and each using action attribute to call a method. Both are calling the same method, and based on its id, it should perform different operations. Could anyone please tell me how to get command buttons id in java code, when it is triggered.
    Regards
    Venkat

    Venkat,
    why not call different methods from each button?
    public String actionButton1()
    return doAction("button1");
    public String actionButton2()
    return doAction("button2");
    public String doAction(String aBuuton)
    if ("button1".equalsIgnoreCase(aButton))
    // do work for button 1
    return "abc";
    }else {
    // do work for button 2
    return "abc";
    }Now you user actionbutton1 for the first button and actionButton2 for the second.
    Or you directly implement two different methods in the bean and call each one directly from the button.
    Timo

  • How to get the context data using java script in interactive forms

    Hi All,
    How to get the context data using java script in interactive forms by adobe,  am using web dynpro java
    thanks.

    Hi venkat,
    Please Refer this link.
      Populating one Drop-Down list from the selection of another Drop-down list
    Thanks,
    Raju.

  • How to get the source code of Java Concurrent Program?

    Hi,
    How to get the source code of Java Concurrent Program?
    Example
    Programe Name:Format Payment Instructions
    Executable:Format Payment Instructions
    Execution File Name:FDExtractAndFormatting
    Execution File Path:oracle.apps.iby.scheduler
    Thanks in advance,
    Senthil

    Go on Unix box at $JAVA_TOP/oracle/apps/iby/scheduler
    You will get class file FDExtractAndFormatting.
    Decompile it to get source code.
    Thanks, Avaneesh

  • How to get call assistant working again??

    I just manged to get caller id working on the tv's again by this procedure
    http://forums.verizon.com/t5/Home-Phone-Landline-or-Digital/How-to-get-Caller-ID-on-TV-working-again...
    Is there some similar procedure that I can perform to get VCA working again.  Ever since we got power back the call register shows new call date 10/21/2011 and vm's date 3/2/2011.  They never update and caller id has apperntly ceased working.
    Of course it could be because I get the message signon failed and it shows as offline, however I know of no way to retrieve my password as the forgot id/password button just goes to a general search function that returns me 46,400 answers! - a very helpful feature and another fine example of poor QA testing of the product.
    Anybody have any hints on how to get it going again?

    WOW, what a mess this is.
    I tried logging in to the online VCA client on another machine and found it would not accept the credentials that I was using on the first machine.  Then went to the VCA page on the the Verizon web site.  When I logged on there with my VCA credentials it told me that the credential check had been changed to use the SSO id for MyVerizon - guess that change was made at the same time that the id on my forum access was changed. 
    However I still cannot logon to the VCA pc client with those credentials on the second machine nor on the first machine.  After trying my SSO credentials on the first machine I reverted back to the credentials that were giving me the erroneous information and now find that I can no longer use thos either.
    A well controlled migration!!

  • How to get a char from a String Class?

    How to get a char from a String Class?

    Use charAt(int index), like this for example:
    String s = "Java";
    char c = s.charAt(2);
    System.out.println(c);

  • How to get maximal value from the data/class for show in Map legend

    I make WAD report that using Map Web Item.
    I devide to four (4) classes for legend (Generate_Breaks).
    I want to change default value for the class by javascript and for this,
    I need to get maximal value from the class.
    How to get maximal value from the data/class.
    please give me solution for my problem.
    Many Thx
    Eddy Utomo

    use this to get the following End_date
    <?following-sibling::../END_DATE?>
    Try this
    <?for-each:/ROOT/ROW?>
    ==================
    Current StartDate <?START_DATE?>
    Current End Date <?END_DATE?>
    Next Start Date <?following-sibling::ROW/END_DATE?>
    Previous End Date <?preceding-sibling::ROW[1]/END_DATE?>
    ================
    <?end for-each?>
    o/p
    ==================
    Current StartDate 01-01-1980
    Current End Date 01-01-1988
    Next Start Date 01-01-1990
    Previous End Date
    ================
    ==================
    Current StartDate 01-01-1988
    Current End Date 01-01-1990
    Next Start Date 01-01-2005
    Previous End Date 01-01-1988
    ================
    ==================
    Current StartDate 01-01-2000
    Current End Date 01-01-2005
    Next Start Date
    Previous End Date 01

  • Calling a servlet in java class

    Hello,
    I try to call a servlet from java class
    but is dose not work
    what should be the problem
       public void callServlet()
              try
                            // xxservlet is the servlet name
                   URL url = new URL("http://www.mydomain.com/xxservlet");
                   URLConnection hpCon = url.openConnection();
                   hpCon.setDoOutput(true);
                   OutputStreamWriter out = new OutputStreamWriter(hpCon.getOutputStream());
                   out.write("This Is a Test");
                   out.flush();
                   out.close();
              }catch(Exception ex){ex.printStackTrace();}     
    // My Servlet  is in package servlets
    public class XXServlet extends HttpServlet
        public void service(HttpServletRequest req, HttpServletResponse resp) {
            try {
                 ServletInputStream sin = req.getInputStream();
                 int len = req.getContentLength();
                    byte[] input = new byte[len];
                    ServletInputStream sin = req.getInputStream();
                   int c, count = 0 ;
                   while ((c = sin.read(input, count, input.length-count)) != -1) {
                       count +=c;
                  sin.close();
                  String inString = new String(input);
                  System.out.println("Servlet is running ...."+inString);
            } catch (IOException e) {
                try{
                    resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
                    resp.getWriter().print(e.getMessage());
                    resp.getWriter().close();
                } catch (IOException ioe) {
    // web.xml
    <servlet>
           <servlet-name>xxservlet</servlet-name>
           <servlet-class>servlets.XXServlet</servlet-class>
        </servlet>
       <servlet-mapping>
        <servlet-name>xxservlet</servlet-name>
        <url-pattern>/xxservlet</url-pattern>
      </servlet-mapping>
    }regards
    Edited by: the_Orient on Mar 30, 2009 3:16 AM

    I have start servlet from brwoser only to test that servlet works fine
    A gain what I need
    I want to call a servlet from a javs class
    URL url = new URL("http://www.mydomain.com/myservlet");
      URLConnection hpCon = url.openConnection();
      hpCon.setDoOutput(true);
      OutputStreamWriter out = new OutputStreamWriter(hpCon.getOutputStream());
      out.write("Hello Woprld");
      out.flush();
      out.close();// Servlet
    public void doGet(HttpServletRequest req, HttpServletResponse resp) {
            try {
                  String xp =req.getSession().getServletContext().getRealPath("/");
                  File f = new File(xp+"/students/info.txt");
                  f.createNewFile();
            } catch (IOException e) {
                try{
                    resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
                    resp.getWriter().print(e.getMessage());
                    resp.getWriter().close();
                } catch (IOException ioe) {
    problem file can not be created
        public void doPost(HttpServletRequest req, HttpServletResponse resp)
    }I hope that is clear

  • How do you call a method from  another class without extending as a parent?

    How do you call a method from another class without extending it as a parent? Is this possible?

    Why don't you just create an instance of the class?
    Car c = new Car();
    c.drive("fast");The drive method is in the car class, but as long as the method is public, you can use it anywhere.
    Is that what you were asking or am I totally misunderstanding your question?
    Jen

  • How can i open the popup from java class

    Hi,
    Please tell me how can i open the popup from java class.
    I am using jdev 11.1.1.7.0
    I have used the below code which works fine in jdev 2.1 but it will have some errors in 11.1.1.7.0.
    Please tell me some way to do this in all jdev versions.
    Bean obj = (Bean)RequestContext.getCurrentInstance.getExternalContext.getPageFlowScope(“obj”);
    Code for hide pop-up
    FacesContext context = FacesContext.getCurrentInstance();
    String popupId = obj.getPopUpBind().getClientId()
    ExtendedRenderKitService service = Service.getRenderKitService(FacesContext.getCurrentInstance(),
    ExtendedRenderKitService.class);
    String hidePopup = "var popupObj=AdfPage.PAGE.findComponent('" + popupId +
    "'); popupObj.hide();";
    service.addScript(FacesContext.getCurrentInstance(), hidePopup);
    Code to Show pop-up
    StringBuffer showPopup = new StringBuffer();
    showPopup.append("var hints = new Object();");
    showPopup.append("var popupObj=AdfPage.PAGE.findComponent('" +
    obj.getPopUpBind().getClientId() + "');popupObj.show(hints);");
    service.addScript(FacesContext.getCurrentInstance(), showPopup.toString());
    Code need to be added in jsff pop tag
    binding="#{pageFlowScope.bean.popUpBind}
    Variable need to be added in Bean.java
    private RichPopup popUpBind;

    Hari,
    Since you're using a non-public build of JDeveloper, you should be using a non-public forum.
    John

  • How do I call a function in java?

    I'm calling a function called lightParse() from the method. But, I'm getting an error:
    F:\Data>javac -classpath xerces.jar;xalan.jar;classpath%; Test.java
    Test.java:22: lightParse(java.lang.String) in Test cannot be applied to ()
    lightParse();
    ^
    The scenario or code portion is :
    import javax.swing.*;
    import java.awt.*;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import org.w3c.dom.Document;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    import org.xml.sax.SAXException;
    public class Test extends JFrame
         JList list;
         JScrollPane listContainer;
         public Test()
              setSize(300, 300);
              setVisible(true);
              initialize();
              lightParse(); // calling the function
         public void initialize()
              list = new JList(new DefaultListModel()); // Set the initial model
              listContainer = new JScrollPane(list);
              listContainer.setSize(new Dimension(200, 200));
              getContentPane().setLayout(new BorderLayout());
              getContentPane().add(listContainer, "Center");
              validate(); // Validate the screen
    // The function is the following
         public void lightParse(String url)
              DocumentBuilder parser;
              DocumentBuilderFactory factory =
                        DocumentBuilderFactory.newInstance();
              try {
                        parser = factory.newDocumentBuilder();
                        Document doc = parser.parse(url);
    How do I call the function correctly with the right parameter?
    Thanks in advance for the answer.

    u r calling lightParse method without passing the expected "String" argument. There must not be an overloaded method for lightParse without any arguments.
    So u should use this:
    lightParse(some string here);
    Hope this explains.
    I'm calling a function called lightParse() from the
    method. But, I'm getting an error:
    F:\Data>javac -classpath
    xerces.jar;xalan.jar;classpath%; Test.java
    Test.java:22: lightParse(java.lang.String) in Test
    cannot be applied to ()
    lightParse();
    ^
    The scenario or code portion is :
    import javax.swing.*;
    import java.awt.*;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import org.w3c.dom.Document;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    import org.xml.sax.SAXException;
    public class Test extends JFrame
    JList list;
    JScrollPane listContainer;
    public Test()
    setSize(300, 300);
    setVisible(true);
    initialize();
    lightParse(); // calling the function
    public void initialize()
    list = new JList(new DefaultListModel()); // Set the
    e initial model
    listContainer = new JScrollPane(list);
    listContainer.setSize(new Dimension(200, 200));
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(listContainer, "Center");
    validate(); // Validate the screen
    // The function is the following
    public void lightParse(String url)
    DocumentBuilder parser;
    DocumentBuilderFactory factory =
    DocumentBuilderFactory.newInstance();
    try {
    parser = factory.newDocumentBuilder();
    Document doc = parser.parse(url);
    How do I call the function correctly with the right
    parameter?
    Thanks in advance for the answer.

  • How to get caller object reference from a method

    Hi,
    I am working a already existing Java Swing project, now I got a problem, in a method I need to get the caller object reference otherwise, I can't succeed this operation. So please tell me a way how to get the caller object reference from a method. that method would be static or regular method anything will do for me.
    Edited by: navaneeth.j on Jan 29, 2010 11:20 PM

    navaneeth.j wrote:
    Actually my doubt is, I have a method "addition" method, which is using by many classes so my requirement is in the addition method I want to write a code snippet which will identify and get the the caller object. Actually I tried Reflection.getcallerclass but there I am getting "CLASS" object not the actual object reference, but I want object reference.
    Actually we have a huge project which is writen plain JAVA, so in this project the authors written the Database connection package for single database transaction. so now we are using this project source code for JSF application in this web application the DB package has serve based on the dynamic db connection parameters, so if we want to change this package fully means need to solve the dependency problem in hundreds of classes, so my point is if I can access the caller object in the DB package when ever it gets called by any class from any where of the project. So actually I liked Reflection.getcallerclass, the way of implementation perfectly works for me but it is not giving caller object reference, if something gives the caller object then I can get the DB connection parameters then there is no need to pass the parameters in the hierarchy.You can add a parameter (of type Object) to your addition() method
    and everywhere you call the addition() method also pass this (which from the POW of the addition() method will be a reference to the calling class instance).
    There may be alternative solutions
    but none that require less effort.

  • How can I call external exe in java

    Hi ,
    Is It Possible to call external exe in java.
    I read Runtime.exe("some exe") but actually my exe expects some input to process for that how can i pass the input to my exe and how can get the response from exe to my java class.
    any sample code is welcome.
    Thanks
    Babu H

    example
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.KeyAdapter;
    import java.awt.event.KeyEvent;
    import java.io.*;
    public class RuntimeExample extends JFrame {
        private JTextArea textArea;
        private JTextField textField;
        private PrintWriter writer;
        public RuntimeExample()
            init();
            initProcess();
        public void init()
            textArea = new JTextArea(20, 80);
            textArea.setEditable(false);
            textField = new JTextField(30);
            textField.addKeyListener(new KeyAdapter()
                public void keyPressed(KeyEvent event) {
                    if (event.getKeyCode() == KeyEvent.VK_ENTER)
                        if (writer != null)
                            textArea.setText("");
                            writer.print(textField.getText() + "\r\n");
                            writer.flush();
                            textField.setText("");
            Container container = getContentPane();
            JScrollPane scrollPane = new JScrollPane();
            scrollPane.setViewportView(textArea);
            container.add(scrollPane, BorderLayout.CENTER);
            container.add(textField, BorderLayout.SOUTH);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            pack();
            textField.grabFocus();
            setVisible(true);
        public static void main(String[] args) {
            new RuntimeExample();
        public void initProcess()
            Runtime rt = Runtime.getRuntime();
            try
                //Process p = rt.exec(new String [] {"cmd", "/C", textField.getText()});
                //textArea.setText("");
                //textField.setText("");
                Process p = rt.exec("cmd");
                writer = new PrintWriter(p.getOutputStream());
                Thread thread1 = new Thread(new StreamReader(p.getErrorStream()));
                Thread thread2 = new Thread(new StreamReader(p.getInputStream()));
                thread1.start();
                thread2.start();
                System.out.println("Exit Value = " + p.waitFor());
            catch (Exception ex)
                textArea.append(ex.getMessage());
                ex.printStackTrace();
        public class StreamReader implements Runnable
            InputStream is;
            public StreamReader(InputStream is)
                this.is = is;
            public void run()
                try
                    BufferedReader reader = new BufferedReader(new InputStreamReader(is));
                    String data;
                    while ((data = reader.readLine()) != null)
                        textArea.append(data + "\n");
                    reader.close();
                catch (IOException ioEx)
                    ioEx.printStackTrace();
    }you can pass input to the exe by using getOutputStream() from Process and get the output from getInputStream() from Process

  • How to get system popup menu in java?

    I want to know how to get windows xp or any operating systems default popupmenu in java.
    And i also have problem for using mnemonic for JPopupMenu, it works well when i first press right click of my mouse and use the specified mnemonic for that the action specifed for that is triggered but when is use mnemonic without the using my mouse it doesn't trigger why.

    Please how to get native(e.g windows explorer) popup menu in jfilechooser

Maybe you are looking for

  • External HD with USB Connection no longer recognized

    Hi, I have read all the posts here and in most cases the problems are with an external HD that uses Firewire. Mine uses USB. It has been working fine for a year and now it won't show up on the desktop. I went to Disk Utility and it was there. When I

  • S-video output not working for Satellite A60

    The s-video output on my laptop is not working. i have tried the Fn-F5 hotkey, but i don't get a damn output on the tv.

  • BI Content Transformation Rule for Data Source 2LIS_03_BX

    Hi All, I am using BI content info cube 0RT_C54 for queries. I am uanble to find BI content transformation rules for the Data Source 2LIS_03_BX. In "Network Display of the data flow" I am able to see the transformation rules for this data source. How

  • TABSTRIP - FILA_HELP_COPY_ALL_TAMLAY_TABS

    Hi experts, I'd need some advice on dynpros tabstrib matter, I'm enhacing IS-U contract transaction by SAPLXES20 function pool filling customer exit within; Now I've been asked to change Tabstrip titles and furthermore to shift additional custom data

  • Safari Crashes whenever I try to upload photos/music/video to Facebook, Tumblr etc??

    If anyone could please help me with this situation I would really appreciate it! Every time I click to upload a photo or a music clip to facebook, tumblr or any other social media website that has to access my photos/files Safari crashes and sends me