Calling from javascript a method which uses accesscontroller.dopriviledged

Hello everybody!
I've a problem in accessing my pc resources from a signed applet when calling methods from Javascript.
If I try from start() or init() methods, I can do it, but as soon as I try from anoter method defined by myself, it throws this me an AccessControlException:access denied.
I googled and found that I should use this code:
KeyStore smartCardKeyStore= (KeyStore)
             AccessController.doPrivileged(
                       new PrivilegedExceptionAction() {
                         public Object run() throws KeyStoreException, NoSuchProviderException, NoSuchAlgorithmException, CertificateException, IOException {
                             KeyStore alfa;
                             alfa = KeyStore.getInstance("PKCS11",pkcs11Provider.getName());
                             alfa.load(null,null);//this is the point where it trhew the AccessControlException
                             return alfa;
                     );The problem is that with this code, I can't get it work with Firefox (which doesn't throw any exception, just won't work!) neither with IE, which throws this:
netscape.javascript.JSException: Nome sconosciuto.
java.lang.Exception: netscape.javascript.JSException: Nome sconosciuto.
     at sun.plugin.com.DispatchImpl.invokeImpl(Unknown Source)
     at sun.plugin.com.DispatchImpl$1.run(Unknown Source)
     at java.security.AccessController.doPrivileged(Native Method)
     at sun.plugin.com.DispatchImpl.invoke(Unknown Source)Please, help me! I'm in a big trouble, since I should finish my project asap and I am not able to pass this cumbersome obstacle...
Thank you in advance! :)

Hi! Don,
You cannot call methods which breach Security from Javascript. That is what SUN says.
But there is a hack, or a work around...
Declare a boolean Variable , say named buttonClicked.
Initailly keep its value false(default).
Write an inner class that extends a thread class whose RUN method will contain the following piece of Code:
public void run(){
    while(buttonClicked){
                 KeyStore smartCardKeyStore= (KeyStore)
             AccessController.doPrivileged(
                       new PrivilegedExceptionAction() {
                         public Object run() throws KeyStoreException, NoSuchProviderException, NoSuchAlgorithmException, CertificateException, IOException {
                             KeyStore alfa;
                             alfa = KeyStore.getInstance("PKCS11",pkcs11Provider.getName());
                             alfa.load(null,null);//this is the point where it trhew the AccessControlException
                             return alfa;
}You start the Thread inner class in your init method.
So, its RUN method will continuously be waiting to go into the while loop.
And in your start method you will set the +"buttonClicked"+ variable to true upon a Javascript onclick event of a button.
So, the moment you click a button, you only set the buttonClciked variable to true in your start method--------
This does, in no way breach security. So no exception is thrown.. But the code which breaches security is initiated by another thread other than that spawned the Applet; so the browser does not care anything about its privileges. It just lets the execution of the code.
I hope it works for you; be in contact, if it doesn't.
Thanks and Regards,
Samba

Similar Messages

  • I have just bought an iMac, and when I had my PC I had all my mp3 music on external hard drive and used to stream using software called ps3 server and tveristy which used to pick up on my Roberts radio via network wi fi hiw do I get iMac to do it

    I have just bought an iMac, and when I had my PC I had all my mp3 music on external hard drive and used to stream using software called ps3 server and tveristy which used to pick up on my Roberts radio via network wi fii and on my iPad via AirPlay. How can I do the same with iMac as this software isn't compatible

    To install apps from developers Apple doesn't recognize go to Security and Privacy in the System Preferences and change Allow apps downloaded from anywhere

  • How can I print to my HP OfficeJet 6500 Wireless Printer from my iPhone 4S which used to work before AirPrint printers were even available? (running Mac Lion OS, all software and HP sw updates are all performed)

    How can I print to my HP OfficeJet 6500 Wireless Printer from my iPhone 4S which used to work (on prior iPhones) before AirPrint printers were even available? (running Mac Lion OS, all software and HP sw updates are all performed)
    I don't get it, I read one post about why would we have to buy an AirPrint Printer when we have used the "print to a wifi printer" just fine in the past?  Yes I feel that's exactly what's happening to me now too. I want to print from my iPhone and iPad to my WiFi Printer which is also now connected to my Airport Express WiFi network just fine. No problems.

    Very glad you added that bit of information because I see different problems similar to this.  I want to share with them what you did and hopefully you not only fixed your specific problem but you can lend some more advice to others with problems like this. Thanks!
    Don't forgot to say thanks by giving "Kudos" if I helped solve your problem.
    When a solution is found please mark the post that solves your issue.
    Every problem has a solution!

  • Process and Forms - Issue with Method which Uses Imported Form Values

    We are doing a project to implement ESS and MSS. Using Adobe Process and Forms we generated a process with form and workflow.
    The workflow's first step uses a version of TS17900110 task to move the form to the workflow container.
    Binding:
    export:
    &FORM_STANDARD& @0E\QAssign Value@ @9T\QGets data for...@ &FORM&
    'USER_ID' @0E\QAssign Value@ @9T\QGets data for...@ &FORM_FIELD_NAME_1&
    'PERNR' @0E\QAssign Value@ @9T\QGets data for...@ &FORM_FIELD_NAME_2&
    'AWART' @0E\QAssign Value@ @9T\QGets data for...@ &FORM_FIELD_NAME_3&
    Binding
    import:
    &EMPL_USERID.OBJID& @9S\QReceives data from...@ @0D\QAssign Value@ &FORM_FIELD_VALUE_1&
    &PERNR& @9S\QReceives data from...@ @0D\QAssign Value@ &FORM_FIELD_VALUE_2&
    &AWART& @9S\QReceives data from...@ @0D\QAssign Value@ &FORM_FIELD_VALUE_3&
    The workflow is bringing values for: EMPL_USERID, PERNR, AWART.
    We need to write these field values to a table using a method.  We are using a custom task to do this.
    The task triggers a method which calls a FM which makes the update to the table.
    The step with the custom task is a foreground step which the workflow stops for so we can test execute it.
    When we execute there is a breakpoint in the ABAP code which stopps us at the point where the values are being read.
    We are trying to read values:  'USER_ID', 'PERNR', and 'AWART' but the debugger is not showing any values being brought in.
    The binding we currently have for the step we feel is the problem:
    This is all we have in there so far - NEED suggestions/advice:
    Binding export:
    &ZABSREQ&     @0E\QAssign Value@     @9T\QGets data for...@     &_WI_OBJECT_ID&
    (&ZABSREQ& - This is a BOR)
    Any information is appreciated.
    alicia.morante at gmail.com
    alicia.morante at us.army.mil
    Edited by: Alicia Morante on Jan 23, 2012 8:43 PM

    We were very anxious to solve this issue.
    While I was posting my counterpart realized that we did not have target containers setup to receive the values from the workflow.
    Once those were set the values were able to be read from the FM.
    Here's the binding updated to:
    &EMPL_NUM&     @0E\QAssign Value@     @9T\QGets data for...@     &EMPL_NUM&
    &SUBTYPE&     @0E\QAssign Value@     @9T\QGets data for...@     &SUBTYPE&
    Still gave you some points for helping - Thank you.

  • Passing Parameters from JavaScript to method in backingbean

    Hi,
    I use JDev 11.1.1.2.0
    I want when I press a button I call a javaScript function, This function get IP Address and Mac Address of the client machine and send it to the method in backingbean.
    How can I get the IP Address and Mac Address and send it to the method in backingbean?
    Thank You...
    Sameh Nassar

    Thank you Arunkumar.
    I get the Mac Address by this method
    function call(event) {
    var source = event.getSource();
    var obj = new ActiveXObject("WbemScripting.SWbemLocator");
         var s = obj.ConnectServer(".");
         var properties = s.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration");
         var e = new Enumerator (properties);
            var mac;
         while(!e.atEnd())
              e.moveNext();
              var p = e.item();
              if(!p) continue;
              if(p.Caption == "[00000008] Intel(R) PRO/100 VE Network Connection"){
                                        alert(p.MACAddress);
                                        mac=p.MACAddress;
                                        break;
    AdfCustomEvent.queue(source,"callServer",{sa:mac},false);
    }and the passing the parameters working fine.
    Thank You...
    Sameh Nassar

  • Applet function call from javascript

    Hi,
    I'm haveing a problem with accesing applet's functions from Javascript in Mozilla. IE works fine but in Mozilla I get the following error:
    Error: document.applets[0] has no properties
    The code used is: document.applets[0].test();
    The applet has the following 2 tags defined, I don't know if they are necessary here but I'm doing the reverse too (applet functions call javascript).
    <PARAM name="MAYSCRIPT" value="Y">
    <PARAM name="SCRIPTABLE" value="Y">
    If you have any ideea please help.
    Thanks

    in javascript try document.getElementById("idOfTheApplet")
    use object tag instead of applet tag:
         <object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
                  height="300" width="450" >
            <param name="code" value="appTest.class" />
            <!--[if !IE]> Mozilla/Netscape and its brethren -->
            <object classid="java:appTest.class"
                    height="300" width="450"
                    >
              <param name="mayscript" value=Y" />
            </object>
            <!-- <![endif]-->
          </object>or check out HtmlConverter.exe in the jdk bin dir.

  • Can 3D toobar commands be called from Javascript?

    I can call "One Full Page" from the acrobat toobar by using "this.zoomType = zoomtype.fitP;". Is it possible to do the same with 3D tools? I would like to have javascript call "Zoom To Part" from the 3D toolbar.
    Thanks in advance!

    The 'fit to part' action is actually a lot more complicated than it seems (calculating the bounding box extents from the camera position is one thing, but it then has to allow for other parts being in the way). You could try to implement your own code to do all of that, but the simpler approach is to define a series of views for each 'spare' part (set the fit-to-part option before defining the view so your gimbals are in the right place), then you can use the 3D JavaScript runtime.setView() command to pick them by name.

  • Signed applets called from javascript - how/where to load policy file?

    I'm running into some apparently well-known problems with signed applets accessing a client machine's hard drive.
    So, I can get things to work if I place the following two lines in my 'local' JDK installation:
    permission java.io.FilePermission "${user.home}/x.properties", "read,write";
    permission java.util.PropertyPermission "user.home", "read";These let me a) read the user's home directory and b) read/write a file that's located there.
    What I don't want to do is edit the java.policy file, but I'm having problems loading a separate policy file. The app server we run with our product is jetty, and I'm assuming I would be passing in the '-Djava.security.policy=='filename' with the other jetty start-up parameters- is this a correct assumption? And, what path do I give for the file, will I need to put it somewhere in the .war file we distribute, or in the JDK installation on the server? If it's on the server, will client machine's know about these extra rights?
    I'd REALLY appreciate any help I could get on this...
    thanks in advance,
    +0^^

    Maybe you didn't realize but my previous post was sarcastically ment:
    "hello SUN security stop bugging me in writhing this malicious program"
    and
    "hello SUN security, I'm a good boy now trust what I'm doing"
    Are in a practical sense exactly the same.
    SUN should either remove the stack check or the doprivileged. The stack check takes up
    valuable resources for nothing since a malicious program can easily circumvent that.
    Your post about a malicious user abusing your (CA) signed applet to ruine someone's
    system is correct, it would not be difficult. A CA signed applet will not even ask a user to
    trust or not. This is one of the reasons we have the usepolicy in affect, but this cannot be
    used on "grandma's old PC" since it's too complicated for users to do such things.
    YOU seem to be the one to blame, not the hacker! (The user accepted YOUR
    certificate!).Actually you are to blame, because you made software that exposes a vonurability
    other people can take advantage of.
    what you can do before calling the doprivileged private method is check the call stack.
    So your signed applet has a public method checking the callstack, if this lookes OK
    that method will call the private doprivileged method.
    Here is the example
    package t;
    import java.util.Properties;
    import java.applet.Applet;
    public class test extends Applet {
             public test(){
                   startingPrivileged();
             public void startingPrivileged(){
                   System.out.println("this is the stack");
                   try{
                        throw new Exception("get the call stack");
                   }catch(Exception e){
                        StackTraceElement stack[] = e.getStackTrace();
                        for (int i=0; i<stack.length; i++) {
                             System.out.println("file: " + stack.getFileName() + " method: " + stack[i].getMethodName() + " class: " + stack[i].getClassName() + " at " + new Integer(i).toString());
                        // this is a really simple check to see if this method was started from the t. package
                        // a good hacker can just create it's own package named t and take advantage of this method
                        // if this method was started from the same package there is no reason to make this method
                        // public, protected would work.
                        // there must be a better way to check if this method was called by "your" or "trusted" code
                        if(stack[1].getClassName().startsWith("t.")){
                             dosomePrivileged();
              private void dosomePrivileged(){
                   System.out.println("this is the method that does privileged stuff");
         public static void main(String args[]) {
              new test();

  • How can I move an existing iTunes library from a Dell PC (which uses Windows Vista) to a MacBook Pro?  I have tried to copy the library from the PC onto a memory stick but cannot move from the stick onto the MacBook Pro.

    I have tried to copy my iTunes library from my old (2008) Dell PC to a 32 GB memory stick and then copy it from the stick to the iTunes library in the new MacBook Pro which I purchased recently from a reputable dealer which resells refurbished Macs, (lease returns, etc).  The dealer was Computer Trends store in Saskatoon.  They told me how to move my existing iTunes libary from the PC to the Mac but I cannot seem to achieve that objective.  The Mac does not seem to recognize the memory stick.  I thought the Mac would recognize that the memory stick held iTunes files and would then transfer them without prompting to its own iTunes libary.  It did not do so.  I have therefore tried to find the command sequence within iTunes (on the Mac) for moving the material from the memory stick to the iTunes library.  Cannot find those commands.  Does anybody know where to find such commands.  I have to say, I am really disappointed that such a simple function would prove to be beyond my capabilities.  I thought the Mac was supposed to be easier than a PC.  !!!  Oh well, I am hoping this forum will help !!!

    iTunes: How to move [or copy] your music to a new computer [or another drive] - http://support.apple.com/kb/HT4527
    Quick answer if you use iTunes default preferences settings:  Copy the entire iTunes folder (and in doing so all its subfolders and files) intact to the other drive.  Start iTunes with the option (shift on Windows) key held down and guide it to the new location of the library.
    So, you can see your whole iTunes folder on the memory stick after copying from the PC?

  • Computerised call from PC to a mobile using java applets

    i want to know whether it is possible to make a call from PC to mobile using java applets. Please give me a correct reply with proof.

    The situation is like this.
    We are transfering the JAR file from the PC to the Mobile using Bluetooth.
    Our J2ME project is already install on Nokia's 6600 and given to the salesman's on the field. Now i have updated my software and i want to upgrade the same on their mobiles. For this i can't call all the 2000 salesman's who are all over the country (India) to my place to get the latest software installed and configure.
    If i have a GPRS like solution for transfering my file from my PC to the remote mobile. I would be better. If you know any this related to this kindly reply me.

  • CodeBase for Applet called from Javascript

    I have a Search applet that is called from an HTML form in a browser when a button in the form is pressed. The Applet searches files in a folder/subfolders and uses a JSObject to create a new page for the browser with results. Up until recently I was using the plugin from jre 1.3.1 with the appropriate FilePermission entries in the .java.policy file and the applet worked as expected. IE if I added new folders to be searched, I had to add new entries to the policy file to give permission.
    I then installed jre 1.4.2 and the applet started getting Security problems stating the program did NOT have FilePermission. I tried several changes to the policy file and finally found that if I put the FilePermission entries in the empty(Global) codeBase the applet would work.
    What changed between jre 1.3.1 and 1.4.2?
    I would like to understand how the system works, ie where is the true codeBase and not cop-out with giving global permission.
    Any suggestions?
    Also the Java Tutorial shows a Windows syntax for a path (uses \) : C:\testing\-
    The policytool gets confused when I try to enter this. I use double \\ and it takes it OK when I do a Save. But later if I use policytool again to make changes somewhere else in the policy file, the \\ are removed and I end up with: C:testing- in the policy file. So I do it manually with an editor.
    Norm

    I would agree. Remember that the changes you make to the policy file apply to all applets that will ever be run on the system, not only to your applet.

  • Writing JUnit test app to test a method which uses AppResources

    Recently I was given a requirement to write a JUnit class( with main) to test a method in a Processor class which is running in weblogic. But this method in processor class makes use of AppResources like this: AppResources appResources = new AppResources("ApplicationResources"); String ruleFileName = appResources.getResourceString("rule.file.irlfile"); But when I try to run my JUnit test (stand alone app with main class) I am getting "java.util.MissingResourceException: Can't find bundle for base name ApplicationResources" exception. The appResources is null... Any ideas how to work around this problem?

    It doesn't sound like the Process class was designed for testability outside of its J2EE server container, probably. So writing a unit test for it, under its current design, may be an exercise in futility. You might want to look into "Cactus" tests (search for JUnit Cactus on the web), to test it in its container. Or, redesign the class for testability, separating its business logic better (that's a lot of work to do though) so that it can be instantiated and exercised independently of its environment.

  • Calling from South Africa to Madagascar using Mobi...

    I have a Skype account set up in the USA using a Skype To Go number to call Madagascar.  I am now living temporarily in South Africa and want to call Madagascar.  I have a cheap prepaid Nokia without internet access in South Africa.  Can I set up Skype to phone Madagascar?  Person in Madagascar does not have access to internet so no computer Skyping capabilities, only a mobile.
    EPE

    EPE wrote:
    1. Can I set up Skype to phone Madagascar?  
    2. Person in Madagascar does not have access to internet so no computer Skyping capabilities, only a mobile.
    Hello,
    1. Yes. Change your SkypeToGo location to South Africa and register your Madagascar contact's #.
    2. You don't need an internet connection to use STG.
    TIME ZONE - US EASTERN. LOCATION - PHILADELPHIA, PA, USA.
    I recommend that you always run the latest Skype version: Windows & Mac
    If my advice helped to fix your issue please mark it as a solution to help others.
    Please note that I generally don't respond to unsolicited Private Messages. Thank you.

  • Can anyone provide better to find a caller from the callee method

    We are using currently
    public boolean isCheckNeeded()
    boolean flag = false;
    Throwable t = new Throwable();
    StackTraceElement ste[] = t.getStackTrace();
    for(int i = 0; i < ste.length; i++)
    if(!ste.getClassName().equals("com.test.mySericeBean"))
    continue;
    flag = true;
    System.out.println((new StringBuilder("flag:")).append(flag).append(" ").append(ste[i].getClassName()).toString());
    break;
    return flag;
    Can some provide me the better approach to do the same.
    thanks in advance

    viswamy2k wrote:
    ... our intention here is to check if the request is coming via a particular class(say MyserviceBean) or not.
    If its coming from MyserviceBean then we need to do different operations from usual.
    There may exist many classes between MyServiceBean and the callee.
    Just we need to see if the request has passed through MyServiceBean or not.You could use a static ThreadLocal to keep track of this from within MyServiceBean.
    Getting the class context from SecurityManager would be better than parsing stack traces.
    public final class ClassUtils {
        public static final Class[] getClassContext() {
            return new SecurityManager() {
                protected Class[] getClassContext(){
                    return super.getClassContext();
            }.getClassContext();
        public static final boolean isClassInContext(Class target) {
            for(Class c : getClassContext()) {
                if (c.equals(target)) return true;
            return false;
    }

  • Printing from a Dos Program which uses LPT1 running a Virtual XP under Windows 7 Professional.

    The Virtual XP uses the printer assigned to Windows 7 Professional by using Microsoft Terminal Services so you see a TS... pointing the the printer
    in Windows 7.
    It works fine in the Virtual XP system.
    When you open the DOS application to print you must first do a Net Use lpt1: 
    \\Virtual XP computer name\Shared name you assigned to the printer you want to use /persisent:yes
    This works well when you are running in a regular XP machine, but will not work from the Virtual XP machine running under Windows & Professional.
    I believe it has to do with the fact that the Virtual XP machine is connecting to the Windows 7 printer that is connected via a Net Use command
    for the TSclient  prn12 pointing to the Windows 7 HP network printer.
    Has anyone encountered this situation and if so is there a way to correct it.
    The error message I get in the DOS application says the printer is offline or not connected.

    Have you tried to share the printer over the network in the Windows 7 environment - and then do a net use from inside the virtual machine (rather than using the terminal services printer redirection)? Note that for this to work you will need to be using
    a direct network connection on the virtual machine - and not shared networking.
    Cheers,
    Benjamin Armstrong
    ============================
    Windows Virtualization
    Senior Lead Program Manager
    This posting is provided AS IS with no warranties, and confers no rights. You assume all risk for your use.

Maybe you are looking for