Hessian Web service invocation from a JavaFX Applet - java

I'm trying to invoke a Hessian Web Service from a JavaFX applet. I know it needs some reflection permissions so I signed it myself for testing but even then it doesn't work. The browser asks me if I accept the certificate, I click yes but I receive the permission exceptions anyway:
com.caucho.hessian.client.HessianRuntimeException: java.security.AccessControlException: access denied (java.net.SocketPermission 192.168.0.112:8080 connect,resolve)
java.security.AccessControlException: access denied (java.lang.reflect.ReflectPermission suppressAccessChecks
java.security.AccessControlException: access denied (java.lang.RuntimePermission accessDeclaredMembers)
Am I missing something?
Thank you in advance.

According to Sun's documentation:
a signed applet has the AllPermission permission only if Java Plug-in can verify the signers
Since you are self-signing, I think you'll want to setup a policy file to grant yourself permission (will NOT work for others). Here is a tutorial.

Related

java.security.AccessControlException: access denied ("java.io.FilePermission" "C:\tempFolder" "read") on GAE

I am migrating my application from Tomcat to Google App Engine (1.9.1). I am running jsf 2.2 on servlet 2.5 and I am facing an issue with reading files from file system. I have code that creates a file on the file system as follows:
File file = new File("C:\\tempFolder");
if(file.isDirectory()){
// do writing stuff here
}
On Tomcat I was not getting any exceptions on the above code, but on Google App Engine I am getting the following exception:
Caused by: java.security.AccessControlException: access denied ("java.io.FilePermission" "C:\tempFolder" "read")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:372)
at java.security.AccessController.checkPermission(AccessController.java:559)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkPermission(DevAppServerFactory.java:429)
Why am I getting this exception, and how to fix it?
why i am getting this exception
GAE environment is sandboxed for a number of reasons. This means that you cannot do a lot of things you could normally do on your local machine.
This also includes write access to the file system.
how to fix it
Find another way to persist your data (database, for example).
You can read a little bit more on sandbox restrictions here.

error running javadb in jre 8 / netbeans 7.4

I recently updated to jre8. It seem that the present security settings are really nasty. I am unable to run javadb
I get the following error
Mon Mar 31 02:04:54 IST 2014 : Security manager installed using the Basic server security policy.
Mon Mar 31 02:04:54 IST 2014 : access denied ("java.net.SocketPermission" "localhost:1527" "listen,resolve")
java.security.AccessControlException: access denied ("java.net.SocketPermission" "localhost:1527" "listen,resolve")
what are the steps taken by me
changed the permission in java.policy file to listen to 1527 (also added resolve)-but to no avail
this is what http://www.oracle.com/technetwork/java/javase/8-known-issues-2157115.html gives out
Bug 8030961
Area: Java DB Synopsis An additional permission may be needed to
bring up the Java DB network server. In particular, the startup
scripts in may fail to boot the network server.
While attempting to boot, the network server may fail and raise the
following error:
access denied ("java.net.SocketPermission" "localhost:1527"
"listen,resolve") java.security.AccessControlException: access denied
("java.net.SocketPermission" "localhost:1527" "listen,resolve") To fix
this problem, you must bring up the network server with a security
policy that includes the missing permission. Instead of booting the
network server as:
java org.apache.derby.drda.NetworkServerControl start boot the network
server as follows:
java -Djava.security.manager -Djava.security.policy=${yourPolicyFile}
org.apache.derby.drda.NetworkServerControl start where
${yourPolicyFile} is a file containing a customized version of the
policy file described in the Java DB Admin Guide section titled Basic
Network Server security policy. You must customize that generic policy
file to fit your application. In addition, you must add the following
permission to the permissions block granted to the
${derby.install.url}derbynet.jar codebase:
permission java.net.SocketPermission "localhost:${port}", "listen";
where ${port} should be replaced by the port number where the network
server listens for incoming connection requests. By default, that is
port 1527.
now I exactly not sure what to do
*do I need to do any additional stuff
*found derbynet.jar ( as an executable jar file) how do I edit, what do I edit
Thanks,
Think you need to show
1) How your start the server (cmdline)
2) The stacktrace you get
3) Content of your policy file
Alternatively you could study the comments in the corresponding Derby Jira issue

Can't get applet to read text file

I've tried to get my Java Applet to read from my text file, but I do not have sufficient privaleges to read the file when i run the applet in my browser.
I have tried to use policy files but I cannot seem to get them to work.
I later tried
System.setProperty("java.security.policy", "*filelocation*");
but i got this error
java.security.AccessControlException: access denied (java.util.PropertyPermission java.security.policy 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 BIT.init(BIT.java:35)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
What ways can I get my applet to run in my browser? It works fine in Eclipse's applet viewer.
The reason is specified within the What Applets Can and Cannot Do. It clearly specifies that:
Applets that are not signed are restricted to the security sandbox,
and run only if the user accepts the applet. Applets that are signed
by a certificate from a recognized certificate authority can either
run only in the sandbox, or can request permission to run outside the
sandbox. In either case, the user must accept the applet's security
certificate, otherwise the applet is blocked from running.
Later it states that:
Sandbox applets cannot perform the following operations:
They cannot access client resources such as the local filesystem, executable files, system clipboard, and printers.
They cannot connect to or retrieve resources from any third party server (any server other than the server it originated from).
They cannot load native libraries.
They cannot change the SecurityManager.
They cannot create a ClassLoader.
They cannot read certain system properties. See System Properties for a list of forbidden system properties.
To know about how to sign an Applet look here : How to Sign Applets Using RSA-Signed Certificates
You really ought to consider signing the applet.
This (short!) FAQ discusses both policies and signing:
http://www.coderanch.com/how-to/java/HowCanAnAppletReadFilesOnTheLocalFileSystem
Here is the offician documentation:
http://docs.oracle.com/javase/6/docs/technotes/guides/security/doprivileged.html
http://docs.oracle.com/javase/tutorial/deployment/applet/security.html
And here is a good (albeit old) tutorial:
http://faculty.kutztown.edu/spiegel/CSc421/SigningAnApplet.htm

java RMID example

I want to experiment with Activatable objects in RMI. Is there a simple example somewhere that works? I'm trying to use Oracle's tutorial but I get java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:1098 connect,resolve)
Try to add this as first argument to your java-vm
-Djava.security.policy=rmi.security
example of rmi.security (could be more specific, created with policytool)
grant {
permission java.security.AllPermission;
};

Access control Exception

When I am running RMI Server in netbeans I am getting java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:1099 connect,resolve)
What to do?
You need to set the permissions within a policy file. An example can be found at the RMI tutorial site and also further information concering policy files.

Categories

Resources