setProperty-access in start-method but not in other methods of my applet ?

Hi,

User downloads html withsigned applet, the applet started after trust.

Then I want to set the keystore property with a method that I call from javascript in the html-page. I get a java.security.AccessControlException: access denied (java.util.PropertyPermission javax.net.ssl.keyStore write)

When I set my keystore-property in the start-method of my class, I get no exception and it works. But thats no option because I ask the keystore and the psw in the html-page and want to forward it to the applet.

Thanks for any help!!

HTML-page

<script language="javascript">

function sendKeystore(keystore, keystorepsw){

var appl = document.applets["ECommerceUserApplet"];

appl.setKeystore(keystore,keystorepsw);

}

</script>

The code of my applet

publicvoid setKeyStore(String keystore, String keystorepsw){

System.setProperty("javax.net.ssl.keyStore", keystore);

System.setProperty("javax.net.ssl.keyStorePassword", keystorepsw);

The exception

java.security.AccessControlException: access denied (java.util.PropertyPermission javax.net.ssl.keyStore write)

at java.security.AccessControlContext.checkPermission(Unknown Source)

at java.security.AccessController.checkPermission(Unknown Source)

at java.lang.SecurityManager.checkPermission(Unknown Source)

at java.lang.System.setProperty(Unknown Source)

at eCommerceUser.ECommerceUserApplet.setKeyStore(ECommerceUserApplet.java:33)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at sun.plugin.javascript.invoke.JSInvoke.invoke(Unknown Source)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at sun.plugin.javascript.JSClassLoader.invoke(Unknown Source)

at sun.plugin.com.MethodDispatcher.invoke(Unknown Source)

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)

java.lang.Exception: java.security.AccessControlException: access denied (java.util.PropertyPermission javax.net.ssl.keyStore write)

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)

[3179 byte] By [Jurgena] at [2007-10-2 2:41:31]
# 1

I already know a solution:-)

I signed applet can do this?

somemethod() {

...normal code here...

AccessController.doPrivileged(new PrivilegedAction() {

public Object run() {

// privileged code goes here, for example:

System.loadLibrary("awt");

return null; // nothing to return

}

});

...normal code here...

}

Jurgena at 2007-7-15 20:33:57 > top of Java-index,Security,Signed Applets...
# 2
That is correct: http://forum.java.sun.com/thread.jsp?forum=63&thread=524815second post and reply 18 for the java class file using doprivileged
harmmeijera at 2007-7-15 20:33:57 > top of Java-index,Security,Signed Applets...