Re: Permission denied

Gregg Wonderly <[email protected]> Fri, 24 Mar 2006 10:56:07 -0600
Newsgroups gmane.comp.java.sun.rmi
Message-ID <[email protected]>
Paulo Melo wrote:
>  No, but it would have to run like in windows, no?
>
>   Or either, without policy file.

For RMI to work, you need to have a security policy active.  You probably need
to put

if( System.getSecurityManager() == null ) {
        System.setSecurityManager( new RMISecurityManager() );
}

into the startup of your application, and you'll then need to put

        -Djava.security.policy=/path/to/java.policy

on the JVM commandline at startup.  In the file located in the directory
/path/to/java.policy, you'll need to specify the appropriate policy for your
application.  For testing purposes on RMI applications that are not on
publically visible networks, you can simply put

        grant {
                permission java.security.AllPermission;
        };

into the java.policy file to summarily allow all remote access with no policy
controls.  This is not something to do lightly.

If you want more control, then for each JAR file in your classpath, put

        grant codebase "file:/path/to/jar/file.jar" {
                permission java.security.AllPermission;
        };

to explictly limit permissions to local classes.  If you are using downloaded
code, then you'll need to also put codebase grants in for the downloaded jars at
a minimum.

All of this stuff is described in the JDK javadocs for RMI and security.

Gregg Wonderly

===========================================================================
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff RMI-USERS".  For general help, send email to
[email protected] and include in the body of the message "help".

For a list of frequently asked RMI questions please refer to:
http://java.sun.com/j2se/1.3/docs/guide/rmi/faq.html

To view past RMI-USERS postings, please see:
http://archives.java.sun.com/archives/rmi-users.html