1 45 package org.exolab.jms.net.rmi; 46 47 import java.rmi.RemoteException ; 48 import java.rmi.AccessException ; 49 import java.rmi.server.RemoteObject ; 50 import java.security.Principal ; 51 52 import org.exolab.jms.net.connector.ManagedConnectionAcceptorListener; 53 import org.exolab.jms.net.connector.Authenticator; 54 import org.exolab.jms.net.connector.ResourceException; 55 import org.exolab.jms.net.uri.URIHelper; 56 57 58 64 public class RMIInvokerFactoryImpl 65 extends RemoteObject implements RMIInvokerFactory { 66 67 70 private final Authenticator _authenticator; 71 72 75 private final RMIManagedConnectionAcceptor _acceptor; 76 77 80 private final ManagedConnectionAcceptorListener _listener; 81 82 83 90 public RMIInvokerFactoryImpl(Authenticator authenticator, 91 RMIManagedConnectionAcceptor acceptor, 92 ManagedConnectionAcceptorListener listener) { 93 _authenticator = authenticator; 94 _acceptor = acceptor; 95 _listener = listener; 96 97 } 98 99 109 public RMIInvoker createInvoker(Principal principal, RMIInvoker client, 110 String uri) 111 throws RemoteException { 112 try { 113 if (!_authenticator.authenticate(principal)) { 114 throw new AccessException ("Failed to authenticate"); 115 } 116 } catch (ResourceException exception) { 117 throw new AccessException ("Failed to authenticate", exception); 118 } 119 RMIInvokerImpl invoker = new RMIInvokerImpl(); 120 RMIManagedConnection connection = 121 new RMIManagedConnection(principal, invoker, _acceptor.getURI(), 122 client, URIHelper.parse(uri)); 123 _listener.accepted(_acceptor, connection); 124 return invoker; 125 } 126 127 } 128 | Popular Tags |