我正在努力获得rmi连接.我遇到了很多安全问题,但一直无法找到解决这一问题的方法.我执行我的jar文件:
java -Djava.security.policy=java.security.AllPermission -jar "myjarfile"
Run Code Online (Sandbox Code Playgroud)
我用来创建它的代码是:
public class server
{
public static void main(String args[])throws Exception
{
if (System.getSecurityManager() == null)
System.setSecurityManager ( new RMISecurityManager() {
public void checkConnect (String host, int port) {}
public void checkConnect (String host, int port, Object context) {}
});
try
{
sampleserverimpl server = new sampleserverimpl();
System.out.println("SERVER IS WAITING");
LocateRegistry.createRegistry(2020);
//Runtime.getRuntime().exec("rmiregistry 2020");
Naming.rebind("//localhost:2020/SERVER", server);
}
catch(Exception e)
{
System.out.println(e);
}
}
};
Run Code Online (Sandbox Code Playgroud)
我收到的错误跟踪是:
Exception in thread "RMI TCP Connection(idle)" java.security.AccessControlExcept
ion: access denied (java.net.SocketPermission …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建自己的实现javax.net.ssl.SSLSocketFactory,以便捕获所有HTTP/SSL请求,由第三方库发送,并记录它们.这就是在该库中调用工厂的方式(它是commons-httpclient):
import javax.net.ssl.SSLSocketFactory;
// ...
return SSLSocketFactory.getDefault().createSocket(host, port);
Run Code Online (Sandbox Code Playgroud)
目前使用的实现是com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl.如何将其更改为我自己的自定义类?