On Tue, 29 May 2001, Scott M Stark wrote:

> > As I said don't like the firewall option overall. In past projects I've
> > been securing RMI by using custom socket factories and doing check in
> > accept(), but for JNP this option was not an enabled possibility unless
> > defining own RMISocketFactory as default so the MarshallObject
> > would use it.
>
> I'll add support for externalizing the RMI socket factories so that you
> can use that approach. A future version of the jnp provider will allow
> for secured access based on Java2 permissions.

Well, deep in the Sun's reference implementation it already uses
java.rmi.server.RMISocketFactory as default RMI socket factory. You can
use RMISocketFactory.setSocketFactory() to set it to point to your own class.
So why to dublicate the effort and create another in jnp? I think it
should check the credentials but no SocketFactory is needed.

jnp provider uses MarshallObject.exportObject() from java.rmi.server
packet and this refers to Sun's reference implementation. So if you don't
give the SocketFactory to this call, the one set via RMISocketFactory
should be used.

I did not test this yet, but I think this should work.

What I did test was to unbind everything from my JNDI with jnp-client.jar
from remote machine and that worked very well.

So using Java2 permissions would just require me to write new jar
holding my new ServerSocket implementation and put it into different
directory and I would be able to use policy file to define the where to
accept connections from.

Altought Java still might not check the policy file because RMI might run
itself as privileged. In this case we would need to overload checkAccept()
in SecurityManager so that we would have something in stack to provoke
Java to check the permissions.

So I guess writing a MBean that contains something like below should do
the trick.

Do you think otherwise?

-- snip
public class SecureCheckingServerSocket
        extends ServerSocket {
        public Socket accept() {
                boolean fine = false;
                try {
                        while(!fine) {
                                Socket s = new Socket();
                                try {
                                        acceptImpl(s);
                                        fine = true;
¨                                       return s;
                                } catch (AccessControlException pe) {
                                        // ignore this or RMI might fail
                                }
                        }
                }
        }
}

public class SecureCheckingRMISocketFactory
        extends RMISocketFactory {
        public ServerSocket createServerSocket() {
                return new SecureCheckingServerSocket();
        }
}


...


RMISocketFactory secureCheckingWhatEver =
        new SecureCheckingRMISocketFactory();
RMISocketFactory.setSocketFactory(secureCheckingWhatEver);


..

-- snip


 - Sampsa Ranta
   [EMAIL PROTECTED]


_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to