GetUserPrincipalName() in application module or Java class?

Hi,
in my application I have a web service as Java class (POJO) which invoke the business logic in an application module.
The web service is secured with basic HTTP authentication with JAZN in 10.1.2 which works without any problems.
This means that all configurations with JAZNUserManager and web.xml (user-role-mappings) are correct.
But what is the right API to get the user informations of the web service consumer with JAZN? I mean a method like getUserPrincipalName()?
One way I tried is getUserPrincipalName() in the application module.
- The steps in http://www.oracle.com/technology/products/jdev/howtos/bc4j/bc4jvpdjaas.html#authentication for BC4J must be configured.
- Then the application module can be tested with the Component Browser http://www.oracle.com/technology/products/jdev/howtos/bc4j/bc4jvpdjaas.html#running
But my web service client delivers this exception:
JBO-29000: Unexpected exception caught: oracle.jbo.JboException, msg=JBO-33021: Failed authenticate user null at
This is equivalent to Application Module Security but there is no answer.
What´s the problem?
Is there a way to get the getUserPrincipalName() in the web service (Java class (POJO)) directly?
Best regards,
Tobias

Hello,
You are a standard way to do that by retrieving the ServletEndpointContext that is available from the the Service context
To get this you have to:
1- Implement the[i]javax.xml.rpc.server.ServiceLifecycle; (usually your implementation class)
2- Implement the init(object context) method
public void init(Object context) {
_servletEndpointContext = (ServletEndpointContext)context;
3. Then when needed you can call the getUserPrincipal
if (_servletEndpointContext.getUserPrincipal() != null) {
java.security.Principal userPrincipal = _servletEndpointContext.getUserPrincipal();
System.out.println( userPrincipal.getName() );
I have tested this code with WS-Security username token authentication, should be available also using basic auth. Let me know if you have any issue.
Regards
Tugdual Grall

Similar Messages

  • Standard B2C application Order page Java class called on Update?

    Hi All,
    On the Standard B2C application, on adding CampaignKey to the order or Changing the Quantity of the Items. We click UPDATE to update the sales order.
    Please can anyone help to find out which JAVA action Class is linked with the Update button.
    I need to create one Z java action class to update the order.
    Thanks a lot!
    Ekta

    Hi
    I used session logging to trace the class called. I am not able to use HTTP Watch. It is on the Client's network using Citrix. Hence cannot install it. but no doubt that is a better way.
    Classes and the action path is
    main java action class 
    MaintainBasketB2CDispatcherAction"
    linked action path for Update is
    Action path="/b2c/maintainBasket"
    Forward path name   
    <forward name="update" path="/b2c/basketupdate.do"/>
    and for action path
    action path="/b2c/basketupdate"
    java action class :
    MaintainBasketB2CUpdateAction"
    I am making Z action claa for MaintainBasketB2CUpdateAction" and i am updating the condig.xml file.
    I am making this thread open. To trace the flow if in case i get some problem
    Thanks to all of you for your support!
    Thanks
    Ekta

  • How to get application module instance from java bundle?

    Hi!
    I would like to build an application that would get all translations from a database table.
    So I created application module for translations that contains a view object which is selecting translations for specific language from a database table. I exposed a method in application module as client interface which returns HashMap<String, String> for all translations for specific language. When I test my view and client interface method call they work fine.
    Then I created java bundle classes to get translations for specific language. Then I tried to override public Object[][] getContents() method.
    I tried to get my translations application module like this:
    SharedTranslationsAppModuleImpl am = new SharedTranslationsAppModuleImpl();
    Map<String, String> translationsMap = am.getTranslations(this.getLocaleCode); // Client interface method call
    In getTranslations(String LocaleCode) I try to get that view (which would select translations from database) but it returns NULL and I get NPE error message.
    So what is the right way to get application module from java bundle file? Now everytime application wants to get translations, application stops and displays NPE message.
    Regards, Marko
    I use JDeveloper 11.1.2.1.0

    Marko,
    you can't just instantiate an application module. An application module has to be set up, db connections and memory pools have to be initialized and ....
    Can you describe why and when you try to read the resource bundle from the db and where the resource bundle is used?
    This blog may be what you are looking for http://technology.amis.nl/2012/08/10/implement-resource-bundles-for-adf-applications-in-a-database-table/
    Timo

  • Java class how to load a JavaFX class?

    I want to start a JavaFX application from a Java class,how can implement it?
    Thank you so much!

    I want to start a JavaFX application from a Java class,how can implement it?
    Thank you so much!

  • Creating an application module in a Java class

    Hi everyone,
    I'm trying to create an application module from a normal Java class where I don't have access to any HttpSession objects.
    I tried to use the method in the documentation
    appMod = Configuration.createRootApplicationModule(
                        "full.class.Name",
                        "ConfigurationName");
    It's not working though, complaining that it can not find the configuration file which it's trying to locate at full/class/common/bc4j.xcfg.
    This file exists at the same path in the BC4J project which this project has a dependency on in the Project Settings dialog.
    Is this the right way to create an application module? Can someone please provide a reference to an example.
    Thanks

    Thanks Frank, but this example is about a stand-alone application, my problem occurs with an application hosted on the application server.
    I did more experiments and came up with some ideas but unfortunately, I hit a dead end.
    I thought that in order to work around the fact that I cannot set the class loader of the timer, I could change the class loader of the running thread before I create the timer as follows:
    Thread.currentThread().setContextClassLoader(
              this.getClass().getClassLoader());
    I thought this would give me a SecurityException for sure, but strangely enough it worked perfectly.
    Now, all I needed was to move this code from the JSP to my listener. Unfortunately, it didn't work in the listener, also a test that I did in the JSP to make sure that the classloader before and after the above statment is different, showed that in the listener, the classloader of the thread is the same as the one used to load the listener class:
    System.out.println(Thread.currentThread().getContextClassLoader()
              .equals(this.getClass().getClassLoader()));
    I thought, maybe this is a listener thing, but if I do it in the init() method of a servlet that I could specify to load on startup, it could work, but still, it didn't.
    I cannot understand, why is it that the only correct class loader is the one used to load the compiled JSP class?!
    Does anyone have any other ideas?
    Thanks

  • Default Code Generation for a Custom Class for an Application Module

    hi all
    Oracle® Fusion Middleware
    Fusion Developer’s Guide for Oracle Application Development
    Framework
    11g Release 1 (11.1.1)
    with Jdeveloper TP3 ,
    By default, the application module Java class will look similar to what you see in
    Example below when you've first enabled it. Of interest, it contains:
    ■ Getter methods for each view object instance in the data model
    ■ A main() method allowing you to debug the application module using the
    Business Components Browser
    [package devguide.model;
    import devguide.model.common.StoreServiceAM;
    import oracle.jbo.server.ApplicationModuleImpl;
    import oracle.jbo.server.ViewLinkImpl;
    import oracle.jbo.server.ViewObjectImpl;
    // --- File generated by Oracle ADF Business Components Design Time.
    // --- Custom code may be added to this class.
    // --- Warning: Do not modify method signatures of generated methods.
    public class StoreServiceAMImpl extends ApplicationModuleImpl {
    /** This is the default constructor (do not remove) */
    public SRServiceImpl() { }
    /** Sample main for debugging Business Components code using the tester */
    public static void main(String[] args) {
    launchTester("devguide.model", /* package name */
    "SRServiceLocal" /* Configuration Name */);
    /** Container's getter for YourViewObjectInstance1 */
    public ViewObjectImpl getYourViewObjectInstance1() {
    return (ViewObjectImpl)findViewObject("YourViewObjectInstance1");
    // ... Additional ViewObjectImpl getters for each view object instance
    // ... ViewLink getters for view link instances here
    when i try this i didn't find the default generation for main method
    have i do something before enable custom java file for Application module
    hope to hear from you soon

    hi nonStop
    Since you are using Jdeveloper TP3, this might be a better place to ask your question:
    "JDeveloper and OC4J 11g Technology Preview"
    JDeveloper and OC4J 11g Technology Preview
    success
    Jan Vervecken

  • Finding Application Module name in read-only view object classes

    Hi all,
    I have a fairly basic question about finding application module name when we are coding in ViewObject java classes.
    I want to know how can I obtain <<application module>> NAME that our current view object is contained in it at run-time. I think there should be a way to find current application module NAME, when we are in ViewObject classes including View Object, View Row or view object definition classes (I've overridden all mentioned classes).
    I should notify that since our view object is read-only I may not count on view object's entity classes, coz as you know a read-only view object don't have any entity in it!
    So, if you have any idea about finding current application module name in view object java classes please let me know.
    Appreciate for your replies,
    Nasser

    Thanks guy, it was helpful:)
    Now i can access application module name through viewObject classes.
    But another question is raised...sorry if i m boring:( I promise its the final question ;)
    Is there a way to get application module name in an extended version of JboException class?
    Thanks again for your reply:)
    Nasser

  • 9.7.3 Default Code Generation for a Custom Class for an Application Module

    hi all
    Oracle® Fusion Middleware
    Fusion Developer’s Guide for Oracle Application Development
    Framework
    11g Release 1 (11.1.1)
    with Jdeveloper TP3 ,
    By default, the application module Java class will look similar to what you see in
    Example below when you've first enabled it. Of interest, it contains:
    ■ Getter methods for each view object instance in the data model
    ■ A main() method allowing you to debug the application module using the
    Business Components Browser
    [package devguide.model;
    import devguide.model.common.StoreServiceAM;
    import oracle.jbo.server.ApplicationModuleImpl;
    import oracle.jbo.server.ViewLinkImpl;
    import oracle.jbo.server.ViewObjectImpl;
    // --- File generated by Oracle ADF Business Components Design Time.
    // --- Custom code may be added to this class.
    // --- Warning: Do not modify method signatures of generated methods.
    public class StoreServiceAMImpl extends ApplicationModuleImpl {
    /** This is the default constructor (do not remove) */
    public SRServiceImpl() { }
    /** Sample main for debugging Business Components code using the tester */
    public static void main(String[] args) {
    launchTester("devguide.model", /* package name */
    "SRServiceLocal" /* Configuration Name */);
    /** Container's getter for YourViewObjectInstance1 */
    public ViewObjectImpl getYourViewObjectInstance1() {
    return (ViewObjectImpl)findViewObject("YourViewObjectInstance1");
    // ... Additional ViewObjectImpl getters for each view object instance
    // ... ViewLink getters for view link instances here
    when i try this i didn't find the default generation for main method
    have i do something before enable custom java file for Application module
    hope to hear from you soon

    hi nonStop
    Since you are using Jdeveloper TP3, this might be a better place to ask your question:
    "JDeveloper and OC4J 11g Technology Preview"
    JDeveloper and OC4J 11g Technology Preview
    success
    Jan Vervecken

  • POJOs or EJBs for worker classes spawned from Application Module?

    Hello,
    I'm running JDev 11.1.2.3.0.
    I need to create a couple of worker classes that will be instantiated from my Application Module. The first will invoke PL/SQL via createCallableStatement. The second sends a message to a jabber server.
    In the Java EE world, I'd do this with stateless EJBs and use the @PreConstruct and @PostDestroy annotations to control the lifecycle.
    What is the recommended approach with ADF when using Classes to make these calls from an Application Module? Should one use POJOs and rely on WebLogic to handle garbage collection, or should/can one use EJB 3.0 stateless session beans?
    Many thanks.
    Edited by: user576183 on May 11, 2013 9:24 AM

    Stateless session beans is the recommended approach with ADF BC too.
    http://docs.oracle.com/cd/E14571_01/web.1111/b31974/bcextservices.htm
    http://technology.amis.nl/2013/01/20/adf-interaction-with-business-service-an-ongoing-discussion/

  • How do I call an Application Module method from a EntityImpl class?

    Guys and Gals,
    Using Studio Edition Version 11.1.1.3.0.
    I've got a price update form, that when submitted, takes the part numbers and prices in the form and updates the corresponding Parts' price in the Parts table. Anytime this Parts view object's ReplacementPrice attribute is changed, an application module method needs to be called which updates a whole slew of related view objects. I know you can modify view objects via associations (How do I call an Application Module method from a ViewObjectImpl class? but that's not what I'm trying to do. These AppModuleImpl methods are the hub for all price updates, as many different operations may affect related pricing (base price lists, price buckets, etc) and hence, call the updatePartPricing(key) method.
    For some reason, the below code does not call / run / activate the application module's method. The AppModuleDataControl exists and recordPartHistory(key) is registered and public. At runtime, the am.<method> code is simply ignored, and as a weird side-effect, I cannot navigate out of my current page flow.
      public void setReplacementPrice(Number value)
        setAttributeInternal(REPLACEMENTPRICE, value);
        AppModuleImpl am = (AppModuleImpl)this.getDBTransaction().findApplicationModule("AppModuleDataControl");
        Key key = new Key(new Object[]
            { getPartNumber() });
        am.recordPartHistory(key);  // AppModuleImpl method which records pricing history
        am.updatePartPricing(key); // AppModuleImpl method which updates a whole slew of related pricing tables
      }Any ideas?

    Thanks Timo.
    Turns out the code provided was correct, but the AppModuleImpl method being called was not. A dependent ViewObject wasn't returning the row I was expecting. I then tried to perform some operations on that row, which in turn ... just stopped everything, but didn't give me an error.
    It was the lack of the error that threw me off. I had never messed with calling an AppModuleImpl method from the EntityImpl so I assumed that's what was messing up.
    You are correct. It is available from the ViewRow, but I thought it better to put it in the EntityImpl. This method will be called every time the replacement cost is modified. If I didn't put it in the EntityImpl, I'd have to remember to call it every time a replacement cost changed.

  • How can I execute a java class with arguments from an air application built from mxml?

    I have an mxml application. It has a button, and when that button select event occurs, I want my mxml air app to pass arguments to a java class I have built, which resides in a package path on my system. I need to be able to pass several arguments to my java method from my mxml call. How do I do this, and what config files are necessary? For the simple task I want to engineer, can you show me an example of a properly configured config file? My java class has been executed at the command line in the past as follows:
    java -cp %CP% com.abc.prism.queue.EmitMessage XYZ "my message text" 192.12.13.14 5672
    where %CP% is an env variable that tells my class the classpath it runs with, and XYZ, "my message text", the IP address, and the port are the arguments I must pass from mxml to my java class. How do I accomplish this?
    How do I make known to the java class I call from mxml the %CP% class path? It tells my java class where to find various rabbitMQ jars.

    Hi,
    You need to use Integration technology like BlazeDS or LCDS.

  • How to load a java class when application is at first time browsed.

    Hi
    How can i load a simple java class on application startup.
    For servlet it could be done using "load on startup" tag in web.xml
    but how could the same be achieved for a simple java class.
    Thanks

    Hi
    Code is given below....
    package com;
    import java.io.IOException;
    import javax.servlet.RequestDispatcher;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class Test {
    Test()
         HttpServletRequest request=null;
         HttpServletResponse response=null;
         RequestDispatcher requestDispatcher = request.getRequestDispatcher("a.jsp");
         try {
              requestDispatcher.forward(request,response);
         } catch (ServletException e) {
              System.out.println("success");
              e.printStackTrace();
         } catch (IOException e) {
              System.out.println("success 1");
              e.printStackTrace();
         finally
              System.out.println("success 2");
         System.out.println("success 3");
    }Web.xml :
    <servlet>
            <servlet-name>simple</servlet-name>
            <servlet-class>com.Test</servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>
      <servlet-mapping>
          <servlet-name>simple</servlet-name>
          <url-pattern>/init.do</url-pattern>
        </servlet-mapping>Error Trace :
    org.apache.catalina.core.StandardContext loadOnStartup
    SEVERE: Servlet /DispatcherTest threw load() exception
    java.lang.IllegalAccessException: Class org.apache.catalina.core.StandardWrapper can not access a member of class com.Test with modifiers ""
         at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)
         at java.lang.Class.newInstance0(Class.java:344)
         at java.lang.Class.newInstance(Class.java:303)
         at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1048)
         at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:925)
         at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3857)
         at org.apache.catalina.core.StandardContext.start(StandardContext.java:4118)
         at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1069)
         at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1162)
         at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:293)
         at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
         at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1304)
         at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1568)
         at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1577)
         at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1557)
         at java.lang.Thread.run(Thread.java:595)

  • Java class reference error in Portal Application

    Hello,
    I have created a Portal Application Project with the Class
    "public class TEST extends AbstractTestComponent implements ITestable"
    in order to test the application.
    The test works fine with a simple code.
    Instead, using the external class HSSFWorkbook in order to create an excel file, the Enterprise Portal Unit Test return the following error:
    "java.lang.NoClassDefFoundError: org/apache/poi/hssf/usermodel/HSSFWorkbook"
    I have tried to put the ZIP file of class into the folder "dist/PORTAL-INF/lib" and "dist/PORTAL-INF/exlib" but it doesn't work.
    Can someone tell me what I have to do?
    Thanks and best regards,
    Matteo.
    Edited by: Matteo De Santis on Feb 10, 2009 7:22 PM

    Hi,
    note that a portal application has two classloaders. one for the public part (src.api) and one for the private one (src.core).
    portal components reside in src.core by default. this means you need to load your jar file to the private class loader.
    so instead of dist/PORTAL-INF/lib use dist/PORTAL-INF/private/lib
    Regards, Lior

  • How can I compile and run other java classes from within an application?

    Hello there everyone! I really hope that someone can help me. I am writing a program that must be able to compile and run other java classes that are in different files, much like development environments like Kawa or Forte allow you to do.
    There has to be a way of doing this ( I hope!! ), but i can't seem to find it!!
    I have tried using this command to compile:
    Runtime.getRuntime().exec ("c:\\programs\\javac className.java");
    ...and this one to run:
    Runtime.getRuntime().exec ("c:\\programs\\java className");
    ...but neither works!!! I can compile and run classes that are in the same file as my application, but I can't get it to work at all for files in different directories or files.
    PLEASE, PLEASE, PLEASE help me - i've run out of ideas, and i need this to be working in 3 days!!!
    Thank you very much for any help anyone can give me, I really appreciate it!! Thanks again!!
    Adrian ( ...in distress!! )

    public class JavaCompiler{
       public static void main(String[] args)throws Exception{ //sorry bout the laziness
          if(args == null || args.length != 1){
             System.out.println("Usage: java JavaCompiler MyClass.java");
             System.exit(0);
          String className = args[0];
          Runtime rt = Runtime.getRuntime();
          Process p = rt.exec("javac " + className); //consider setting cpath for this
          p.waitFor();
          //now try to run after it is done.
          p = rt.exec("java " + className.substring(0, (className.length() - ".java".length()));
          p.waitFor();
          //do some other stuff
    }This should get you going. You may consider looking into the System.getProperty() method in order to determine the type of OS it is running on in order to findo out what command to run. I know that the sun tool listed above is nice, but by my understanding the sun tools provided are not guaranteed to stay the same. I'm no expert on this matter, but that is one of the reasons there is no API documentation for those tools. Also, I don't believe those tools come packaged with the JRE. (Of course if you are making an IDE it will be expected that the user has an sdk installed. Good luck with figuring this thing out.

  • Calling a java application from within another class

    I have written a working java application that accepts command line parameters through public static void main(String[] args) {} method.
    I'm using webMethods and I need to call myapplication from within a java class created in webMethods.
    I know I have to extend my application class within the webMethods class but I do not understand how to pass the parameters.
    What would the syntax look like?
    Thanks in advance!

    why do you want to call the second class by its main method ??
    Why not have another static method with a meaningfull name and well defined parameters ?
    main is used by the jvm as an entry point in your app. it is not really meant for two java applications to communicate with each other but main and the code is not really readable.
    Have a look at his sample
    double myBalance = Account.getBalance(myAccountId);
    here Account is a class with a static method getBalance which return the balance of the account id you passed.
    and now see this one, here Account has a main method which is implemented to call getBalance.
    String[] args = new String[1];
    args[0] = myAccountId;
    Account.main(args);
    the problem with the code above is
    main doesn't return anything so calling it does do much good. two the code is highly unreadable because no one know what does the main do... unlike the sample before this one where the function name getBalance clearly told what is the function doing without any additional comments.
    hope this helps.... let me know if you need any additional help.
    regards,
    Abhishek.

Maybe you are looking for

  • Can the cell lines be removed from a table inserted in a Pages document?

    Can the cell lines be removed from a table inserted in a Pages document?

  • How to Publish Pages to WebServer from DreamWeaver

    How to Publish Pages to Webserver from Dreamweaver.. Please Advice.. Kinda forget :( Or shall i use FTP software, which one is good?

  • Issue in Profitability segment in ITS for FV50

    Dear All, I am creating ITS for FV50 tcode and testing the same. Here every thing goes fine except profitability segment. I am cliking on Profitability segment (PS) and Window popup is opening. Here when I am passing Profit center and try to go back

  • IWeb freezing

    I'm new to Macs, so i'm not quite sure how to solve this. After i create a section with photo albums and add a effect to the album cover, everything freezes and literally nothing helps! That stupid beach ball keeps on spinning and force quit won't re

  • BAM fetch data

    Hello, imtrying to fetch data from a external database into BAM to create some reports and send them via Email. The first thing i tryied is to generate a BPEL process with a customized query and getting that data into bpel variable, now what i need t