当前位置: 首页>>代码示例>>Java>>正文


Java LocateRegistry.getRegistry方法代码示例

本文整理汇总了Java中java.rmi.registry.LocateRegistry.getRegistry方法的典型用法代码示例。如果您正苦于以下问题:Java LocateRegistry.getRegistry方法的具体用法?Java LocateRegistry.getRegistry怎么用?Java LocateRegistry.getRegistry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.rmi.registry.LocateRegistry的用法示例。


在下文中一共展示了LocateRegistry.getRegistry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRegistroRMInodoRemoto

import java.rmi.registry.LocateRegistry; //导入方法依赖的package包/类
public static Registry getRegistroRMInodoRemoto (String identHost){

   // Si no existe se crea el registro en el nodo local y en el puerto por defecto
//       if (registroRMILocalCreado ) return registroRMILocal ;

         try {
//             hostRMI =  getIPLocal();
//             hostRMI = InetAddress.getLocalHost().getHostName();
////             hostRMI = InetAddress.getByName("SERTORIUS").toString();
//             puertoRMIOrganizacionconfigurado = configuracionOrganizacion.getPropiedadesGlobales().getProperty("PuertoRMI");
//             if (puertoRMIOrganizacionconfigurado != null)puertoRMI = Integer.parseInt (puertoRMIOrganizacionconfigurado);
//             registroRMILocal = LocateRegistry.createRegistry(puertoRMI);
//             registroRMILocalCreado = true;
            return LocateRegistry.getRegistry(identHost);

            } catch (Exception e) {

                logger.error("Error al localizar el registro de la organizacion  en el nodo--: "+ hostRMI + " Es posible que no se haya creado: Revisar la descripcion de la organizacion" );
                trazas.aceptaNuevaTraza(new InfoTraza("AdaptadorRegRMI",
						"La direccion IP del registro RMI es NULA  "+ hostRMI + "-- Es posible que no se haya creado: Revisar la descripcion de la organizacion" ,
						InfoTraza.NivelTraza.error));
//
                return null;
            }

    }
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:27,代码来源:AdaptadorRegRMI.java

示例2: getRemoteScheduler

import java.rmi.registry.LocateRegistry; //导入方法依赖的package包/类
protected RemotableQuartzScheduler getRemoteScheduler()
    throws SchedulerException {
    if (rsched != null) {
        return rsched;
    }

    try {
        Registry registry = LocateRegistry.getRegistry(rmiHost, rmiPort);

        rsched = (RemotableQuartzScheduler) registry.lookup(schedId);

    } catch (Exception e) {
        SchedulerException initException = new SchedulerException(
                "Could not get handle to remote scheduler: "
                        + e.getMessage(), e);
        initException
                .setErrorCode(SchedulerException.ERR_COMMUNICATION_FAILURE);
        throw initException;
    }

    return rsched;
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:23,代码来源:RemoteScheduler.java

示例3: buscarAgenteRemoto

import java.rmi.registry.LocateRegistry; //导入方法依赖的package包/类
public static ItfUsoAgenteReactivo buscarAgenteRemoto(String ip, int puerto, String nombreAgente) throws java.rmi.RemoteException {
        Registry regCliente = LocateRegistry.getRegistry(ip, puerto);
        ItfUsoAgenteReactivo agenteRemoto = null;
//        ItfUsoRecursoTrazas trazas = Directorio.getRecursoTrazas();
        try {            
            if (regCliente == null) {
                System.err.println("buscarAgenteRemoto regCliente == null");
                if (trazas != null)
                trazas.aceptaNuevaTraza(new InfoTraza("ControlRMI (null)", "No consigo encontrar al agente: "+
                        nombreAgente + " en ip:" + ip + " puerto:" + puerto, NivelTraza.error));
            }
            agenteRemoto = (ItfUsoAgenteReactivo) regCliente.lookup(nombreAgente);
            return agenteRemoto;
        } catch (Exception ex) {
            System.err.println("Fallo buscaAgenteRemoto\n"+ ex.getMessage());
            if (trazas != null)
            trazas.aceptaNuevaTraza(new InfoTraza("ControlRMI (Excepcion)", "No consigo encontrar al agente: "+
                        nombreAgente + " en ip:" + ip + " puerto:" + puerto, NivelTraza.error));
//            Logger.getLogger(ComunicacionAgentes.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
    }
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:23,代码来源:ControlRMI.java

示例4: getRegistry

import java.rmi.registry.LocateRegistry; //导入方法依赖的package包/类
/**
 * Returns the registry at a given host, port and socket factory.
 * If "host" is null, uses default host.
 * If "port" is non-positive, uses default port.
 * If "socketFactory" is null, uses the default socket.
 */
private static Registry getRegistry(String host, int port,
            RMIClientSocketFactory socketFactory)
        throws NamingException
{
    // %%% We could cache registry connections here.  The transport layer
    // may already reuse connections.
    try {
        if (socketFactory == null) {
            return LocateRegistry.getRegistry(host, port);
        } else {
            return LocateRegistry.getRegistry(host, port, socketFactory);
        }
    } catch (RemoteException e) {
        throw (NamingException)wrapRemoteException(e).fillInStackTrace();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:RegistryContext.java

示例5: getRegistry

import java.rmi.registry.LocateRegistry; //导入方法依赖的package包/类
/**
 * Locate or create the RMI registry.
 * @param registryPort the registry port to use
 * @return the RMI registry
 * @throws RemoteException if the registry couldn't be located or created
 */
protected Registry getRegistry(int registryPort) throws RemoteException {
	if (this.alwaysCreate) {
		logger.info("Creating new RMI registry");
		this.created = true;
		return LocateRegistry.createRegistry(registryPort);
	}
	if (logger.isInfoEnabled()) {
		logger.info("Looking for RMI registry at port '" + registryPort + "'");
	}
	synchronized (LocateRegistry.class) {
		try {
			// Retrieve existing registry.
			Registry reg = LocateRegistry.getRegistry(registryPort);
			testRegistry(reg);
			return reg;
		}
		catch (RemoteException ex) {
			logger.debug("RMI registry access threw exception", ex);
			logger.info("Could not detect RMI registry - creating new one");
			// Assume no registry found -> create new one.
			this.created = true;
			return LocateRegistry.createRegistry(registryPort);
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:RmiRegistryFactoryBean.java

示例6: unBind

import java.rmi.registry.LocateRegistry; //导入方法依赖的package包/类
/**
 * <p>
 * Un-bind the scheduler from an RMI registry.
 * </p>
 */
private void unBind() throws RemoteException {
    String host = resources.getRMIRegistryHost();
    // don't un-export if we're not configured to do so...
    if (host == null || host.length() == 0) {
        return;
    }

    Registry registry = LocateRegistry.getRegistry(resources
            .getRMIRegistryHost(), resources.getRMIRegistryPort());

    String bindName = resources.getRMIBindName();
    
    try {
        registry.unbind(bindName);
        UnicastRemoteObject.unexportObject(this, true);
    } catch (java.rmi.NotBoundException nbe) {
    }

    getLog().info("Scheduler un-bound from name '" + bindName + "' in RMI registry");
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:26,代码来源:QuartzScheduler.java

示例7: main

import java.rmi.registry.LocateRegistry; //导入方法依赖的package包/类
public static void main(String[] args) {
    try {
        int registryPort =
            Integer.parseInt(System.getProperty("rmi.registry.port"));
        Registry registry =
            LocateRegistry.getRegistry("", registryPort);
        Remote stub = registry.lookup(LeaseCheckInterval.BINDING);
        Runtime.getRuntime().halt(0);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:SelfTerminator.java

示例8: setupRegistry

import java.rmi.registry.LocateRegistry; //导入方法依赖的package包/类
@BeforeSuite
static void setupRegistry() {
    try {
        impl = TestLibrary.createRegistryOnEphemeralPort();
        port = TestLibrary.getRegistryPort(impl);
        registry = LocateRegistry.getRegistry("localhost", port);
    } catch (RemoteException ex) {
        Assert.fail("initialization of registry", ex);
    }

    System.out.printf("RMI Registry filter: %s%n", registryFilter);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:13,代码来源:RegistryFilterTest.java

示例9: getItfUsoRecursoRemoto

import java.rmi.registry.LocateRegistry; //导入方法依赖的package包/类
public static Remote getItfUsoRecursoRemoto(String identHost, String nombreRecurso) throws RemoteException, NotBoundException {
            Registry regCliente = LocateRegistry.getRegistry(identHost);
            InterfazGestion agenteRemoto = null;
            if (regCliente == null) return null;
         else
//            agenteRemoto = (ItfUsoAgenteReactivo) regCliente.lookup(nombreAgente);
//            return agenteRemoto;
//        }
        return regCliente.lookup(NombresPredefinidos.ITF_USO+nombreRecurso);
    }
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:11,代码来源:AdaptadorRegRMI.java

示例10: main

import java.rmi.registry.LocateRegistry; //导入方法依赖的package包/类
public static void main(final String[] args) throws Exception {
	final String host = args[0];
	final int port = Integer.parseInt(args[1]);
	final String command = args[3];
	final Registry registry = LocateRegistry.getRegistry(host, port);
	final String className = CommonsCollections1.class.getPackage().getName() +  "." + args[2];
	final Class<? extends ObjectPayload> payloadClass = (Class<? extends ObjectPayload>) Class.forName(className);

	// ensure payload doesn't detonate during construction or deserialization
	exploit(registry, payloadClass, command);
}
 
开发者ID:pimps,项目名称:ysoserial-modified,代码行数:12,代码来源:RMIRegistryExploit.java

示例11: getItfEntidadRemota

import java.rmi.registry.LocateRegistry; //导入方法依赖的package包/类
public static Remote getItfEntidadRemota(String identHost, String identEntity) throws RemoteException, NotBoundException {
            Registry regCliente = LocateRegistry.getRegistry(identHost);
         //   InterfazGestion itfGesagenteRemoto = null;
            if (regCliente == null) return null;
             return   regCliente.lookup(NombresPredefinidos.ITF_GESTION+identEntity);
  //           if (objInRegistry != null) itfGesagenteRemoto = (InterfazGestion) objInRegistry;
   //         return itfGesagenteRemoto;

//        return (InterfazGestion)regCliente.lookup(NombresPredefinidos.ITF_GESTION+identEntity);
    }
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:11,代码来源:AdaptadorRegRMI.java

示例12: canAttackEndpoint

import java.rmi.registry.LocateRegistry; //导入方法依赖的package包/类
/*******************
 * Check if the given endpoint can be attacked.
 * 
 * This check is performed by executing a dummy attack against the
 * endpoint and observing the resulting exception.
 * 
 * @param ep An enumerated RMI endpoint.
 * @return True if we can attack it.
 ******************/
public boolean canAttackEndpoint(RMIEndpoint ep) {
	RMIBindExploitProxy proxy = null;
	Registry reg;
	
	//Execute a dummy attack
	try {
		//Start a bind exploit proxy
		proxy = new RMIBindExploitProxy(InetAddress.getByName(ep.getEndpoint().getHost()), ep.getEndpoint().getPort(), this._options, this._dummyPayload);
		proxy.startProxy();
		
		//Get a proxied RMI registry reference
		reg = LocateRegistry.getRegistry(proxy.getServerListenAddress().getHostAddress(), proxy.getServerListenPort());
		
		//Bind a dummy object in an attempt to trigger the vulnerability
		reg.bind(this.generateRandomString(), new BaRMIeBindExploit());
	} catch(BaRMIeException | UnknownHostException | RemoteException | AlreadyBoundException ex) {
		//An up to date RMI registry will, by default, reject the dummy object
		if(ex instanceof ServerException && ex.getCause() != null && ex.getCause() instanceof UnmarshalException && ex.getCause().getCause() != null && ex.getCause().getCause() instanceof InvalidClassException) {
			//Check for "filter status: REJECTED"
			if(ex.getCause().getCause().toString().contains("filter status: REJECTED")) {
				//Test payload was filtered, likely this attack isn't possible
				return false;
			}
		}
	} finally {
		//Stop the proxy
		if(proxy != null) {
			proxy.stopProxy(true);
		}
	}
	
	//In all other cases we should be able to attack the registry
	return true;
}
 
开发者ID:NickstaDB,项目名称:BaRMIe,代码行数:44,代码来源:IllegalRegistryBind.java

示例13: executeAttack

import java.rmi.registry.LocateRegistry; //导入方法依赖的package包/类
/*******************
 * Execute the deserialization attack against the given RMI endpoint using
 * the given payload.
 * 
 * @param ep The enumerated RMI endpoint.
 * @param payload The deserialization payload to deliver.
 * @param cmd The command to use for payload generation.
 ******************/
public void executeAttack(RMIEndpoint ep, DeserPayload payload, String cmd) throws BaRMIeException {
	RMIBindExploitProxy proxy = null;
	Registry reg;
	
	//Launch the attack
	try {
		//Start a bind exploit proxy
		System.out.println("[~] Starting RMI registry proxy...");
		proxy = new RMIBindExploitProxy(InetAddress.getByName(ep.getEndpoint().getHost()), ep.getEndpoint().getPort(), this._options, payload.getBytes(cmd, 0));
		proxy.startProxy();
		System.out.println("[+] Proxy started");
		
		//Get a proxied RMI registry reference
		System.out.println("[~] Getting proxied RMI Registry reference...");
		reg = LocateRegistry.getRegistry(proxy.getServerListenAddress().getHostAddress(), proxy.getServerListenPort());
		
		//Bind a dummy object in an attempt to trigger the vulnerability
		System.out.println("[~] Calling bind(PAYLOAD, null)...");
		reg.bind(this.generateRandomString(), new BaRMIeBindExploit());
	} catch(Exception ex) {
		//Check the exception for useful info
		this.checkDeserException(ex);
	} finally {
		//Stop the proxy
		if(proxy != null) {
			proxy.stopProxy(true);
		}
	}
}
 
开发者ID:NickstaDB,项目名称:BaRMIe,代码行数:38,代码来源:IllegalRegistryBind.java

示例14: getProxiedObjectWithUIDHack

import java.rmi.registry.LocateRegistry; //导入方法依赖的package包/类
/*******************
 * Chain a full RMI proxy to a serialVersionUID fixing proxy in order to
 * retrieve a fully proxied remote object reference even if the
 * serialVersionUID does not match that of the local class.
 * 
 * @param ep An enumerated RMI endpoint.
 * @param name The name of the object to look up.
 * @param payload The raw bytes of the deserialization payload to use.
 * @param marker The bytes that the method call proxy should replace with the payload bytes.
 * @return The remote object reference.
 ******************/
private final Object getProxiedObjectWithUIDHack(RMIEndpoint ep, String name, byte[] payload, byte[] marker) throws BaRMIeException {
	RMIObjectUIDFixingProxy uidFixer = null;
	RMIObjectProxy objProxy;
	Registry reg;
	Object obj = null;
	
	try {
		//Start a UID fixing proxy
		uidFixer = new RMIObjectUIDFixingProxy(InetAddress.getByName(ep.getEndpoint().getHost()), ep.getEndpoint().getPort(), this._options);
		uidFixer.startProxy();
		this._proxies.add(uidFixer);
		
		//Start an RMI object proxy and chain it to the UID fixing proxy
		objProxy = new RMIObjectProxy(uidFixer.getServerListenAddress(), uidFixer.getServerListenPort(), this._options, payload, marker);
		objProxy.startProxy();
		this._proxies.add(objProxy);
		
		//Retrieve a proxied RMI registry instance
		reg = LocateRegistry.getRegistry(objProxy.getServerListenAddress().getHostAddress(), objProxy.getServerListenPort());
		
		//Lookup the target remote object
		obj = reg.lookup(name);
	} catch(Exception ex) {
		throw new BaRMIeGetObjectException("Failed to retrieve proxied object using serialVersionUID hack.", ex);
	}
	
	//Return the remote object
	return obj;
}
 
开发者ID:NickstaDB,项目名称:BaRMIe,代码行数:41,代码来源:RMIDeserAttack.java

示例15: testStub

import java.rmi.registry.LocateRegistry; //导入方法依赖的package包/类
public String testStub() throws Exception {
try {
    Registry registry = LocateRegistry.getRegistry(port);
    Hello stub = (Hello) registry.lookup("Hello");
    String response = stub.sayHello();
    return response;
    } catch (Exception e) {
        System.err.println("Client exception: " + e.toString());
        throw e;
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:Client.java


注:本文中的java.rmi.registry.LocateRegistry.getRegistry方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。