rmisslserversocketfactory.java

来自「java安全」· Java 代码 · 共 54 行

JAVA
54
字号
/* * @(#)RMISSLServerSocketFactory.java	1.3 00/06/21 * * Copyright 1995-1998 by Sun Microsystems, Inc., * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. * All rights reserved. * * This software is the confidential and proprietary information * of Sun Microsystems, Inc. ("Confidential Information").  You * shall not disclose such Confidential Information and shall use * it only in accordance with the terms of the license agreement * you entered into with Sun. */import java.io.*;import java.net.*;import java.rmi.server.*;import javax.net.ssl.*;import java.security.KeyStore;import javax.net.*;import javax.net.ssl.*;import javax.security.cert.X509Certificate;import com.sun.net.ssl.*;public class RMISSLServerSocketFactory	implements RMIServerSocketFactory, Serializable {    public ServerSocket createServerSocket(int port)	throws IOException	{ 	    SSLServerSocketFactory ssf = null;	    try {		// set up key manager to do server authentication		SSLContext ctx;		KeyManagerFactory kmf;		KeyStore ks;		char[] passphrase = "passphrase".toCharArray();		ctx = SSLContext.getInstance("TLS");		kmf = KeyManagerFactory.getInstance("SunX509");		ks = KeyStore.getInstance("JKS");		ks.load(new FileInputStream("testkeys"), passphrase);		kmf.init(ks, passphrase);		ctx.init(kmf.getKeyManagers(), null, null);		ssf = ctx.getServerSocketFactory();	    } catch (Exception e) {		e.printStackTrace();	    }	    return ssf.createServerSocket(port);	}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?