當前位置: 首頁>>代碼示例>>Java>>正文


Java SslRMIClientSocketFactory類代碼示例

本文整理匯總了Java中javax.rmi.ssl.SslRMIClientSocketFactory的典型用法代碼示例。如果您正苦於以下問題:Java SslRMIClientSocketFactory類的具體用法?Java SslRMIClientSocketFactory怎麽用?Java SslRMIClientSocketFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SslRMIClientSocketFactory類屬於javax.rmi.ssl包,在下文中一共展示了SslRMIClientSocketFactory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: connect

import javax.rmi.ssl.SslRMIClientSocketFactory; //導入依賴的package包/類
private void connect() throws IOException {
    System.out.println(
            "JMXConnectorThread: Attempting JMX connection on: "
                    + addr + " on port " + jmxPort);
    JMXServiceURL url;
    try {
        url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://"
                + addr + ":" + jmxPort + "/jmxrmi");
    } catch (MalformedURLException e) {
        throw new RuntimeException("Test failed.", e);
    }
    Map<String, Object> env = new HashMap<>();
    if (useSSL) {
        SslRMIClientSocketFactory csf = new SslRMIClientSocketFactory();
        env.put("com.sun.jndi.rmi.factory.socket", csf);
        env.put(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE, csf);
    }
    // connect and immediately close
    JMXConnector c = JMXConnectorFactory.connect(url, env);
    c.close();
    System.out.println("JMXConnectorThread: connection to JMX worked");
    jmxConnectWorked = true;
    checkRmiSocket();
    latch.countDown(); // signal we are done.
}
 
開發者ID:campolake,項目名稱:openjdk9,代碼行數:26,代碼來源:JMXAgentInterfaceBinding.java

示例2: WorldRegistryImpl

import javax.rmi.ssl.SslRMIClientSocketFactory; //導入依賴的package包/類
private WorldRegistryImpl() throws RemoteException {
    super(0, new SslRMIClientSocketFactory(), new SslRMIServerSocketFactory());
    DatabaseConnection.setProps(WorldServer.getInstance().getDbProp());
    final Connection con = DatabaseConnection.getConnection();
    final PreparedStatement ps;
    try {
        ps = con.prepareStatement("SELECT MAX(party)+1 FROM characters");
        final ResultSet rs = ps.executeQuery();
        rs.next();
        runningPartyId.set(rs.getInt(1));
        rs.close();
        ps.close();
    } catch (final SQLException sqle) {
        sqle.printStackTrace();
    }
    runningMessengerId.set(1);
}
 
開發者ID:NoetherEmmy,項目名稱:intransigentms,代碼行數:18,代碼來源:WorldRegistryImpl.java

示例3: main

import javax.rmi.ssl.SslRMIClientSocketFactory; //導入依賴的package包/類
public static void main(String[] args) {
    String host = (args.length < 1) ? null : args[0];

    try {
  	RMIClientSocketFactory rmicsf = new SslRMIClientSocketFactory();

    	Registry registro = LocateRegistry.getRegistry("localhost", 1099, rmicsf);


        Hola stub = (Hola) registro.lookup("ObjetoHola");

        String respuesta = stub.sayHello();
        System.out.println("response: " + respuesta);
    } catch (Exception e) {
        System.err.println("Client exception: " + e.toString());
        e.printStackTrace();
    }
}
 
開發者ID:garciparedes,項目名稱:PracticasSistemasDistribuidos,代碼行數:19,代碼來源:Cliente.java

示例4: main

import javax.rmi.ssl.SslRMIClientSocketFactory; //導入依賴的package包/類
public static void main(String[] args) {
   try {
 RMIClientSocketFactory rmicsf = new SslRMIClientSocketFactory();
 RMIServerSocketFactory rmissf = new SslRMIServerSocketFactory(); 
		
 Registry registro = LocateRegistry.createRegistry(1099, rmicsf, rmissf);

ServidorHola oRemoto = new ServidorHola(1099, rmicsf, rmissf);
		
registro.rebind("ObjetoHola", oRemoto) ;
		
System.err.println("Servidor preparado");
   } catch (Exception e) {
      System.err.println("Excepción del servidor: " + e.toString()); e.printStackTrace();
   }
}
 
開發者ID:garciparedes,項目名稱:PracticasSistemasDistribuidos,代碼行數:17,代碼來源:ServidorHola.java

示例5: createRMIServer

import javax.rmi.ssl.SslRMIClientSocketFactory; //導入依賴的package包/類
/**
 * 創建RMI服務器
 *
 * @return 創建是否成功
 */
private boolean createRMIServer() {
	try {
		logger.info("正在創建 RMI 服務端....");

		_register = LocateRegistry.createRegistry(getServerConfig()
				.getRMIAddress().isValid() ? getServerConfig()
				.getRMIAddress().getPort() : getServerConfig()
				.getMasterPort(), new SslRMIClientSocketFactory(),
				new SslRMIServerSocketFactory());
		_register.rebind(getRemoteObjectName(), _remoteObject);
	} catch (RemoteException ex) {
		logger.error("綁定RMI異常:", ex);
		return false;
	}
	return true;
}
 
開發者ID:316181444,項目名稱:GameServerFramework,代碼行數:22,代碼來源:AbstractRMIServerClient.java

示例6: main

import javax.rmi.ssl.SslRMIClientSocketFactory; //導入依賴的package包/類
public static void main(String[] args) {
	try {
		if (CheckFilePermit()) {
			return;
		}
		System.setProperty("java.rmi.server.hostname", "127.0.0.1");
		Registry registry = LocateRegistry.createRegistry(
				Registry.REGISTRY_PORT, new SslRMIClientSocketFactory(),
				new SslRMIServerSocketFactory());
		registry.rebind("WorldRegistry", WorldRegistryImpl.getInstance());
		log.info("世界服務器 已上線.");
	} catch (RemoteException ex) {
		ServerExceptionHandler.HandlerRemoteException(ex);
		log.error("不能初始化 RMI 係統", ex);
	}
}
 
開發者ID:316181444,項目名稱:Hxms,代碼行數:17,代碼來源:WorldServer.java

示例7: WorldRegistryImpl

import javax.rmi.ssl.SslRMIClientSocketFactory; //導入依賴的package包/類
private WorldRegistryImpl() throws RemoteException {
	super(0, new SslRMIClientSocketFactory(),
			new SslRMIServerSocketFactory());
	try {
		Connection con = DatabaseConnection.getConnection();
		PreparedStatement ps = con
				.prepareStatement("SELECT MAX(party)+1 FROM characters");
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			runningPartyId.set(rs.getInt(1));
		} else {
			log.error("無法設置 組隊編號. Sql [SELECT MAX(party)+1 FROM characters]");
		}
		rs.close();
		ps.close();
		con.close();
	} catch (SQLException e) {
		// TODO Auto-generated catch block
		ServerExceptionHandler.HandlerSqlException(e);
	}
	runningMessengerId.set(1);
}
 
開發者ID:316181444,項目名稱:Hxms,代碼行數:23,代碼來源:WorldRegistryImpl.java

示例8: checkStub

import javax.rmi.ssl.SslRMIClientSocketFactory; //導入依賴的package包/類
private static void checkStub(Remote stub,
                              Class<? extends Remote> stubClass) {
    // Check remote stub is from the expected class.
    //
    if (stub.getClass() != stubClass) {
        if (!Proxy.isProxyClass(stub.getClass())) {
            throw new SecurityException(
                "Expecting a " + stubClass.getName() + " stub!");
        } else {
            InvocationHandler handler = Proxy.getInvocationHandler(stub);
            if (handler.getClass() != RemoteObjectInvocationHandler.class) {
                throw new SecurityException(
                    "Expecting a dynamic proxy instance with a " +
                    RemoteObjectInvocationHandler.class.getName() +
                    " invocation handler!");
            } else {
                stub = (Remote) handler;
            }
        }
    }
    // Check RemoteRef in stub is from the expected class
    // "sun.rmi.server.UnicastRef2".
    //
    RemoteRef ref = ((RemoteObject)stub).getRef();
    if (ref.getClass() != UnicastRef2.class) {
        throw new SecurityException(
            "Expecting a " + UnicastRef2.class.getName() +
            " remote reference in stub!");
    }
    // Check RMIClientSocketFactory in stub is from the expected class
    // "javax.rmi.ssl.SslRMIClientSocketFactory".
    //
    LiveRef liveRef = ((UnicastRef2)ref).getLiveRef();
    RMIClientSocketFactory csf = liveRef.getClientSocketFactory();
    if (csf == null || csf.getClass() != SslRMIClientSocketFactory.class) {
        throw new SecurityException(
            "Expecting a " + SslRMIClientSocketFactory.class.getName() +
            " RMI client socket factory in stub!");
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:41,代碼來源:ProxyClient.java

示例9: connectAndValidateAsJmxClient

import javax.rmi.ssl.SslRMIClientSocketFactory; //導入依賴的package包/類
private void connectAndValidateAsJmxClient(final int jmxPort, final String serverHostName,
    final boolean useSSL, final boolean useMulti) throws Exception {
  // JMX RMI

  Map<String, Object> environment = new HashMap();

  if (useSSL) {
    System.setProperty("javax.net.ssl.keyStore",
        useMulti ? getMultiKeyKeystore() : getSimpleSingleKeyKeystore());
    System.setProperty("javax.net.ssl.keyStoreType", "JKS");
    System.setProperty("javax.net.ssl.keyStorePassword", "password");
    System.setProperty("javax.net.ssl.trustStore",
        useMulti ? getMultiKeyTruststore() : getSimpleSingleKeyKeystore());
    System.setProperty("javax.net.ssl.trustStoreType", "JKS");
    System.setProperty("javax.net.ssl.trustStorePassword", "password");
    environment.put("com.sun.jndi.rmi.factory.socket", new SslRMIClientSocketFactory());
  }

  JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://" + serverHostName + ":" + jmxPort
      + "/jndi/rmi://" + serverHostName + ":" + jmxPort + "/jmxrmi");
  JMXConnector jmxConnector = JMXConnectorFactory.connect(url, environment);


  try {
    MBeanServerConnection mbeanServerConnection = jmxConnector.getMBeanServerConnection();

    ObjectName mbeanName = new ObjectName("GemFire:service=System,type=Distributed");

    // Get MBean proxy instance that will be used to make calls to registered MBean
    DistributedSystemMXBean distributedSystemMXBean =
        JMX.newMBeanProxy(mbeanServerConnection, mbeanName, DistributedSystemMXBean.class, true);

    assertEquals(1, distributedSystemMXBean.getMemberCount());
    assertEquals(1, distributedSystemMXBean.getLocatorCount());

  } finally {
    jmxConnector.close();
  }
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:40,代碼來源:JMXMBeanDUnitTest.java

示例10: connect

import javax.rmi.ssl.SslRMIClientSocketFactory; //導入依賴的package包/類
@Override
public @NotNull JMXConnector connect() throws IOException {
  final Map<String, Object> environment = environment();
  if (ssl) {
    environment.put(Context.SECURITY_PROTOCOL, "ssl");
    final SslRMIClientSocketFactory clientSocketFactory = new SslRMIClientSocketFactory();
    environment.put(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE, clientSocketFactory);
    environment.put("com.sun.jndi.rmi.factory.socket", clientSocketFactory);
  }
  final JMXServiceURL address = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + address() + "/jmxrmi");
  return JMXConnectorFactory.connect(address, environment);
}
 
開發者ID:nolequen,項目名稱:jmx-prometheus-exporter,代碼行數:13,代碼來源:RMIConnector.java

示例11: checkStub

import javax.rmi.ssl.SslRMIClientSocketFactory; //導入依賴的package包/類
private static void checkStub(Remote stub,
        Class<?> stubClass) {

    // Check remote stub is from the expected class.
    //
    if (stub.getClass() != stubClass) {
        if (!Proxy.isProxyClass(stub.getClass())) {
            throw new SecurityException(
                    "Expecting a " + stubClass.getName() + " stub!");
        } else {
            InvocationHandler handler = Proxy.getInvocationHandler(stub);
            if (handler.getClass() != RemoteObjectInvocationHandler.class)
                throw new SecurityException(
                        "Expecting a dynamic proxy instance with a " +
                        RemoteObjectInvocationHandler.class.getName() +
                        " invocation handler!");
            else
                stub = (Remote) handler;
        }
    }

    // Check RemoteRef in stub is from the expected class
    // "sun.rmi.server.UnicastRef2".
    //
    RemoteRef ref = ((RemoteObject)stub).getRef();
    if (ref.getClass() != UnicastRef2.class)
        throw new SecurityException(
                "Expecting a " + UnicastRef2.class.getName() +
                " remote reference in stub!");

    // Check RMIClientSocketFactory in stub is from the expected class
    // "javax.rmi.ssl.SslRMIClientSocketFactory".
    //
    LiveRef liveRef = ((UnicastRef2)ref).getLiveRef();
    RMIClientSocketFactory csf = liveRef.getClientSocketFactory();
    if (csf == null || csf.getClass() != SslRMIClientSocketFactory.class)
        throw new SecurityException(
                "Expecting a " + SslRMIClientSocketFactory.class.getName() +
                " RMI client socket factory in stub!");
}
 
開發者ID:campolake,項目名稱:openjdk9,代碼行數:41,代碼來源:RMIConnector.java

示例12: createJMXConnector

import javax.rmi.ssl.SslRMIClientSocketFactory; //導入依賴的package包/類
private JMXConnector createJMXConnector() throws Exception {
  JMXServiceURL url = new JMXServiceURL(this.urlString);
  RMIServerSocketFactory ssf = new MX4JServerSocketFactory(
      true, true, "any", "any", new LocalLogWriter(LogWriterImpl.FINE_LEVEL), new Properties());
  RMIClientSocketFactory csf = new SslRMIClientSocketFactory();
  
  Map env = new HashMap();
  env.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE, ssf);
  env.put(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE, csf);
    
  return JMXConnectorFactory.connect(url, env);
}
 
開發者ID:gemxd,項目名稱:gemfirexd-oss,代碼行數:13,代碼來源:AdminDUnitTestCase.java

示例13: main

import javax.rmi.ssl.SslRMIClientSocketFactory; //導入依賴的package包/類
public static void main(final String[] args) {
    try {
        final Registry registry = LocateRegistry.createRegistry(Registry.REGISTRY_PORT, new SslRMIClientSocketFactory(), new SslRMIServerSocketFactory());
        registry.rebind("WorldRegistry", WorldRegistryImpl.getInstance());
    } catch (final RemoteException re) {
        System.err.println("Could not initialize RMI system");
        re.printStackTrace();
    }
}
 
開發者ID:NoetherEmmy,項目名稱:intransigentms,代碼行數:10,代碼來源:WorldServer.java

示例14: getRMIClientSocketFactory

import javax.rmi.ssl.SslRMIClientSocketFactory; //導入依賴的package包/類
private RMIClientSocketFactory getRMIClientSocketFactory() throws IOException
{
    if (Boolean.parseBoolean(System.getProperty("ssl.enable")))
        return new SslRMIClientSocketFactory();
    else
        return RMISocketFactory.getDefaultSocketFactory();
}
 
開發者ID:skbkontur,項目名稱:cajrr,代碼行數:8,代碼來源:Node.java

示例15: createSslRMIClientSocketFactory

import javax.rmi.ssl.SslRMIClientSocketFactory; //導入依賴的package包/類
private SslRMIClientSocketFactory createSslRMIClientSocketFactory() {
    return new SslRMIClientSocketFactory() {
        @Override
        public Socket createSocket(String host, int port) throws IOException {
            try {
                final SocketFactory sslSocketFactory = getSslConetext().getSocketFactory();
                return sslSocketFactory.createSocket(host, port);
            } catch (GeneralSecurityException e) {
                throw new IOException("Cannot create socket", e);
            }
        }
    };
}
 
開發者ID:sivasamyk,項目名稱:graylog-plugin-input-jmx,代碼行數:14,代碼來源:Server.java


注:本文中的javax.rmi.ssl.SslRMIClientSocketFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。