Extraido do JavaTutorial ;-)

Running the Example Programs
A Note about Security
The JDK 1.2 security model is more sophisticated than the model used for JDK
1.1. JDK 1.2 contains enhancements for finer-grained security and requires
code to be granted specific permissions to be allowed to perform certain
operations.
In JDK 1.1 code in the class path is trusted and can perform any operation;
downloaded code is governed by the rules of the installed security manager.
If you run this example in JDK 1.2, you need to specify a policy file when
you run your server and client. Here is a general policy file that allows
downloaded code, from any code base, to do two things:

Connect to or accept connections on unprivileged ports (ports greater than
1024) on any host
Connect to port 80 (the port for HTTP)
Here is the code for the general policy file:

grant {
    permission java.net.SocketPermission "*:1024-65535",
        "connect,accept";
    permission java.net.SocketPermission "*:80", "connect";
};

If you make your code available for downloading via HTTP URLs, you should
use the preceding policy file when you run this example. However, if you use
file URLs instead, you can use the following policy file. Note that in
Windows-style file names, the backslash character needs to be represented by
two backslash characters in the policy file.

grant {
    permission java.net.SocketPermission "*:1024-65535",
        "connect,accept";
    permission java.io.FilePermission
        "c:\\home\\ann\\public_html\\classes\\-", "read";
    permission java.io.FilePermission
        "c:\\home\\jones\\public_html\\classes\\-", "read";
};




-----Mensagem original-----
De: sreng sreng [mailto:[EMAIL PROTECTED]]
Enviada: segunda-feira, 18 de março de 2002 16:55
Para: [EMAIL PROTECTED]
Assunto: [java-list] Cliente RMI




  Estou criando um cliente RMI para se conectar com um servidor em execução
em outra máquina remota (nos testes, tenho um servidor RMI em Linux e
Cliente em Windows):

. . .

import java.rmi.*;

public class TesteServer{


public static void main(String args[]){
  try{
        System.setSecurityManager(new RMISecurityManager());
        PersistenceServer p =
(PersistenceServer)Naming.lookup("//<ipdamaquina>/server");
        Usuario[] u = p.getUserList();
        for(int i=0; i<u.length; i++){
                System.out.println(u[i].getID() + "\t" + u[i].getNome());
        }
  }catch(Exception e){ e.printStackTrace(); }

}

}

   Ao executar, recebo a seguinte exceção:

java.security.AccessControlException: access denied
(java.net.SocketPermission 1
64.137.86.229:1099 connect,resolve)
        at
java.security.AccessControlContext.checkPermission(AccessControlConte
xt.java:272)
        at
java.security.AccessController.checkPermission(AccessController.java:
399)
        at
java.lang.SecurityManager.checkPermission(SecurityManager.java:545)
        at java.lang.SecurityManager.checkConnect(SecurityManager.java:1044)
        at java.net.Socket.<init>(Socket.java:262)
        at java.net.Socket.<init>(Socket.java:100)
        at
sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirect
SocketFactory.java:25)
        at
sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMaster
SocketFactory.java:120)
        at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:499)
        at
sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:190
)
        at
sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:174)
        at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:318)
        at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
        at java.rmi.Naming.lookup(Naming.java:84)
        at TesteServer.main(testeServer.java:11)

  Suponho que minha jre não tenha permissão para acessar um servidor RMI
remoto. Alguém sabe como corrigir o problema?


                                            Sreng





_________________________________________________________________
Associe-se ao maior serviço de e-mail do mundo através do MSN Hotmail.
http://www.hotmail.com/br


------------------------------ LISTA SOUJAVA ----------------------------
http://www.soujava.org.br  -  Sociedade de Usuários Java da Sucesu-SP
dúvidas mais comuns: http://www.soujava.org.br/faq.htm
regras da lista: http://www.soujava.org.br/regras.htm
historico: http://www.mail-archive.com/java-list%40soujava.org.br
para sair da lista: envie email para [EMAIL PROTECTED]
-------------------------------------------------------------------------

______________________________________________________________________
This messsage was sent using the trial version of the 
1st Class Mail Server software.  You can try it for free
at http://www.1cis.com/download/1cismail.asp

Is this unsolicited email?  Instructions for reporting unsolicited
email can be found at at http://www.1cis.com/articles/spam.asp

------------------------------ LISTA SOUJAVA ---------------------------- 
http://www.soujava.org.br  -  Sociedade de Usuários Java da Sucesu-SP 
dúvidas mais comuns: http://www.soujava.org.br/faq.htm
regras da lista: http://www.soujava.org.br/regras.htm
historico: http://www.mail-archive.com/java-list%40soujava.org.br
para sair da lista: envie email para [EMAIL PROTECTED] 
-------------------------------------------------------------------------

Responder a