gpt4 book ai didi

java rmi - 访问被拒绝 ("java.net.SocketPermission" "127.0.0.1:1099" "connect,resolve")

转载 作者:行者123 更新时间:2023-12-02 04:20:53 24 4
gpt4 key购买 nike

我在网上寻找答案,但没有任何帮助。我正在尝试运行我创建的 RMI 服务器。在服务器主体中我有这部分:

System.setSecurityManager(new RMISecurityManager());
...
...
...
Naming.rebind("//localhost/ForumSite", obj);

我的策略文件:server,policy(...指向该文件夹)-

grant codeBase "file:C:/.../workspace//ForunServer/bin/" {
permission java.security.AllPermission;
permission java.net.SocketPermission "localhost:1099-", "listen, connect, resolve";

};

grant {
permission java.lang.RuntimePermission "setSecurityManager";
permission java.lang.RuntimePermission "createSecurityManager";
permission java.lang.RuntimePermission "usePolicy";
};

我正在尝试运行 Windows 操作系统,我在另一个控制台中写道:javaw rmiregistry在另一个(来自 bin 文件夹)中:

java -Djava.security.manager -Djava.security.policy=server.policy ServerSideImp

我不断收到错误:

access denied ("java.net.SocketPermission" "127.0.0.1:1099" "connect,resolve")

我确保策略文件位于同一位置,

这是我在运行中添加 -Djava.security.debug=access,failure 时的运行结果-

access: access allowed ("java.io.FilePermission" "C:\Users...\ForumServer\bin" "read") access: access allowed ("java.lang.RuntimePermission" "setSecurityManager") access: access allowed ("java.security.SecurityPermission" "getProperty.security.provider.1") access: access allowed ("java.security.SecurityPermission" "getProperty.security.provider.2") access: access allowed ("java.security.SecurityPermission" "getProperty.security.provider.3") access: access allowed ("java.security.SecurityPermission" "getProperty.security.provider.4") access: access allowed ("java.security.SecurityPermission" "getProperty.security.provider.5") access: access allowed ("java.security.SecurityPermission" "getProperty.security.provider.6") access: access allowed ("java.security.SecurityPermission" "getProperty.security.provider.7") access: access allowed ("java.security.SecurityPermission" "getProperty.security.provider.8") access: access allowed ("java.security.SecurityPermission" "getProperty.security.provider.9") access: access allowed ("java.security.SecurityPermission" "getProperty.security.provider.10") access: access allowed ("java.security.SecurityPermission" "getProperty.security.provider.11") access: access allowed ("java.lang.RuntimePermission" "accessClassInPackage.sun.security.provider") access: access allowed ("java.lang.reflect.ReflectPermission" "suppressAccessChecks") access: access allowed ("java.util.PropertyPermission" "java.security.egd" "read") access: access allowed ("java.security.SecurityPermission" "getProperty.securerandom.source") access: access allowed ("java.security.SecurityPermission" "putProviderProperty.SUN") access: access allowed ("java.util.PropertyPermission" "*" "read,write") access: access allowed ("java.util.PropertyPermission" "os.arch" "read") access: access allowed ("java.lang.RuntimePermission" "loadLibrary.net") access: access allowed ("java.io.FilePermission" "C:\Program Files\Java\jre1.8.0_45\bin\net.dll" "read") access: access allowed ("java.util.PropertyPermission" "java.net.preferIPv4Stack" "read") access: access allowed ("java.util.PropertyPermission" "java.net.preferIPv6Addresses" "read") access: access allowed ("java.lang.RuntimePermission" "loadLibrary.net") access: access allowed ("java.io.FilePermission" "C:\Program Files\Java\jre1.8.0_45\bin\net.dll" "read") access: access allowed ("java.util.PropertyPermission" "impl.prefix" "read") access: access allowed ("java.lang.reflect.ReflectPermission" "suppressAccessChecks") access: access allowed ("java.util.PropertyPermission" "sun.net.spi.nameservice.provider.1" "read") access: access allowed ("java.net.NetPermission" "getNetworkInformation") access: access allowed ("java.net.NetPermission" "getNetworkInformation") access: access allowed ("java.net.NetPermission" "getNetworkInformation") access: access allowed ("java.net.NetPermission" "getNetworkInformation") access: access allowed ("java.net.NetPermission" "getNetworkInformation") access: access allowed ("java.net.NetPermission" "getNetworkInformation") access: access allowed ("java.net.NetPermission" "getNetworkInformation") access: access allowed ("java.net.NetPermission" "getNetworkInformation") access: access allowed ("java.net.NetPermission" "getNetworkInformation") access: access allowed ("java.net.NetPermission" "getNetworkInformation") access: access allowed ("java.net.NetPermission" "getNetworkInformation") access: access allowed ("java.lang.RuntimePermission" "fileSystemProvider") access: access allowed ("java.util.PropertyPermission" "user.dir" "read") access: access allowed ("java.util.PropertyPermission" "os.version" "read") access: access allowed ("java.util.PropertyPermission" "sun.jnu.encoding" "read") access: access allowed ("java.util.PropertyPermission" "java.nio.file.spi.DefaultFileSystemProvider" "read") access: access allowed ("java.io.FilePermission" "C:\Users\URI\AppData\Local\Temp" "read") access: access allowed ("java.io.FilePermission" "C:\Users\URI\AppData\Local\Temp" "read") access: access allowed ("java.io.FilePermission" "C:\Users\URI\AppData\Local\Temp" "read") access: access allowed ("java.lang.RuntimePermission" "loadLibrary.net") access: access allowed ("java.io.FilePermission" "C:\Program Files\Java\jre1.8.0_45\bin\net.dll" "read") access: access allowed ("java.lang.RuntimePermission" "loadLibrary.nio") access: access allowed ("java.io.FilePermission" "C:\Program Files\Java\jre1.8.0_45\bin\nio.dll" "read") access: access allowed ("java.util.PropertyPermission" "sun.nio.fs.ensureAccurateMetadata" "read") access: access allowed ("java.util.PropertyPermission" "java.rmi.server.randomIDs" "read") access: access allowed ("java.util.PropertyPermission" "java.rmi.server.hostname" "read") access: access allowed ("java.security.SecurityPermission" "getProperty.networkaddress.cache.ttl") access: access allowed ("java.util.PropertyPermission" "sun.net.inetaddr.ttl" "read") access: access allowed ("java.security.SecurityPermission" "getProperty.networkaddress.cache.negative.ttl") access: access denied ("java.net.SocketPermission" "URI-PC" "resolve") java.lang.Exception: Stack trace at java.lang.Thread.dumpStack(Unknown Source) at java.security.AccessControlContext.checkPermission(Unknown Source) at java.security.AccessController.checkPermission(Unknown Source) at java.lang.SecurityManager.checkPermission(Unknown Source) at java.lang.SecurityManager.checkConnect(Unknown Source) at java.net.InetAddress.getLocalHost(Unknown Source) at sun.rmi.transport.tcp.TCPEndpoint.(Unknown Source) at sun.rmi.transport.LiveRef.(Unknown Source) at sun.rmi.transport.LiveRef.(Unknown Source) at sun.rmi.server.UnicastServerRef.(Unknown Source) at java.rmi.server.UnicastRemoteObject.exportObject(Unknown Source) at java.rmi.server.UnicastRemoteObject.(Unknown Source) at java.rmi.server.UnicastRemoteObject.(Unknown Source) at ServerSideImp.(ServerSideImp.java:18) at ServerSideImp.main(ServerSideImp.java:62) access: access allowed ("java.security.SecurityPermission" "getPolicy") access: access allowed ("java.io.FilePermission" "C:\Users...\ForumServer\bin" "read") access: domain that failed ProtectionDomain (file:/C:/Users/.../ForumServer/bin/ ) sun.misc.Launcher$AppClassLoader@73d16e93 java.security.Permissions@6f94fa3e ( ("java.lang.RuntimePermission" "setSecurityManager") ("java.lang.RuntimePermission" "createSecurityManager") ("java.lang.RuntimePermission" "exitVM") ("java.lang.RuntimePermission" "usePolicy") ("java.lang.RuntimePermission" "stopThread") ("java.util.PropertyPermission" "java.specification.version" "read") ("java.util.PropertyPermission" "java.version" "read") ("java.util.PropertyPermission" "os.arch" "read") ("java.util.PropertyPermission" "java.specification.vendor" "read") ("java.util.PropertyPermission" "java.vm.specification.name" "read") ("java.util.PropertyPermission" "java.vm.vendor" "read") ("java.util.PropertyPermission" "path.separator" "read") ("java.util.PropertyPermission" "os.version" "read") ("java.util.PropertyPermission" "file.separator" "read") ("java.util.PropertyPermission" "line.separator" "read") ("java.util.PropertyPermission" "java.vm.specification.vendor" "read") ("java.util.PropertyPermission" "java.specification.name" "read") ("java.util.PropertyPermission" "java.vendor.url" "read") ("java.util.PropertyPermission" "java.vendor" "read") ("java.util.PropertyPermission" "java.vm.version" "read") ("java.util.PropertyPermission" "java.vm.name" "read") ("java.util.PropertyPermission" "java.vm.specification.version" "read") ("java.util.PropertyPermission" "os.name" "read") ("java.util.PropertyPermission" "java.class.version" "read") ("java.net.SocketPermission" "localhost:0" "listen,resolve") ("java.io.FilePermission" "\C:\Users...\ForumServer\bin-" "read") )

access: access allowed ("java.util.PropertyPermission" "java.rmi.server.useLocalHostName" "read") access: access allowed ("java.util.PropertyPermission" "sun.rmi.transport.logLevel" "read") access: access allowed ("java.util.logging.LoggingPermission" "control") access: access allowed ("java.util.logging.LoggingPermission" "control") access: access allowed ("java.util.PropertyPermission" "sun.rmi.transport.tcp.logLevel" "read") access: access allowed ("java.util.logging.LoggingPermission" "control") access: access allowed ("java.util.logging.LoggingPermission" "control") access: access allowed ("java.util.PropertyPermission" "sun.rmi.transport.tcp.maxConnectionThreads" "read") access: access allowed ("java.util.PropertyPermission" "sun.rmi.transport.tcp.threadKeepAliveTime" "read") access: access allowed ("java.util.PropertyPermission" "sun.rmi.transport.proxy.logLevel" "read") access: access allowed ("java.util.logging.LoggingPermission" "control") access: access allowed ("java.util.logging.LoggingPermission" "control") access: access allowed ("java.util.PropertyPermission" "sun.rmi.transport.proxy.connectTimeout" "read") access: access allowed ("java.util.PropertyPermission" "sun.rmi.transport.proxy.eagerHttpFallback" "read") access: access allowed ("java.util.PropertyPermission" "http.proxyHost" "read") access: access allowed ("java.util.PropertyPermission" "proxyHost" "read") access: access allowed ("java.util.PropertyPermission" "java.rmi.server.disableHttp" "read") access: access allowed ("java.util.PropertyPermission" "sun.rmi.transport.tcp.readTimeout" "read") access: access allowed ("java.util.PropertyPermission" "java.rmi.server.hostname" "read") access: access allowed ("java.util.PropertyPermission" "sun.misc.ProxyGenerator.saveGeneratedFiles" "read") access: access allowed ("java.util.PropertyPermission" "sun.rmi.dgc.server.gcInterval" "read") access: access allowed ("java.lang.RuntimePermission" "loadLibrary.net") access: access allowed ("java.io.FilePermission" "C:\Program Files\Java\jre1.8.0_45\bin\net.dll" "read") access: access allowed ("java.util.PropertyPermission" "" "read,write") access: access allowed ("java.util.PropertyPermission" "" "read,write") access: access allowed ("java.util.PropertyPermission" "sun.net.useExclusiveBind" "read") access: access allowed ("java.net.SocketPermission" "localhost:0" "listen,resolve") access: access allowed ("java.lang.RuntimePermission" "modifyThreadGroup") access: access allowed ("java.lang.RuntimePermission" "modifyThreadGroup") access: access allowed ("java.lang.RuntimePermission" "getClassLoader") access: access allowed ("java.lang.RuntimePermission" "modifyThreadGroup") access: access allowed ("java.lang.RuntimePermission" "modifyThread") access: access allowed ("java.lang.RuntimePermission" "setContextClassLoader") access: access allowed ("java.lang.RuntimePermission" "modifyThread") access: access allowed ("java.util.PropertyPermission" "sun.rmi.dgc.logLevel" "read") access: access allowed ("java.util.logging.LoggingPermission" "control") access: access allowed ("java.util.logging.LoggingPermission" "control") access: access allowed ("java.util.PropertyPermission" "java.rmi.dgc.leaseValue" "read") access: access allowed ("java.util.PropertyPermission" "sun.rmi.dgc.checkInterval" "read") access: access allowed ("java.util.logging.LoggingPermission" "control") access: access allowed ("java.util.logging.LoggingPermission" "control") access: access allowed ("java.util.PropertyPermission" "sun.rmi.runtime.schedulerThreads" "read") access: access allowed ("java.lang.RuntimePermission" "sun.rmi.runtime.RuntimeUtil.getInstance") access: access allowed ("java.lang.RuntimePermission" "setContextClassLoader") access: access allowed ("java.util.PropertyPermission" "java.rmi.server.hostname" "read") access: access allowed ("java.lang.reflect.ReflectPermission" "suppressAccessChecks") access: access allowed ("java.lang.RuntimePermission" "setContextClassLoader") access: access allowed ("java.lang.RuntimePermission" "getClassLoader") access: access allowed ("java.lang.RuntimePermission" "modifyThreadGroup") access: access allowed ("java.lang.RuntimePermission" "modifyThread") access: access allowed ("java.lang.RuntimePermission" "setContextClassLoader") access: access allowed ("java.lang.RuntimePermission" "modifyThread") access: access allowed ("java.lang.RuntimePermission" "modifyThreadGroup") access: access allowed ("java.lang.RuntimePermission" "modifyThreadGroup") access: access allowed ("java.lang.RuntimePermission" "modifyThread") access: access allowed ("java.lang.RuntimePermission" "modifyThread") access: access allowed ("java.lang.RuntimePermission" "modifyThread") access: access allowed ("java.lang.reflect.ReflectPermission" "suppressAccessChecks") access: access allowed ("java.lang.reflect.ReflectPermission" "suppressAccessChecks") access: access allowed ("java.util.PropertyPermission" "java.rmi.server.hostname" "read") access: access allowed ("java.util.PropertyPermission" "sun.rmi.transport.connectionTimeout" "read") access: access allowed ("java.util.PropertyPermission" "sun.rmi.transport.tcp.handshakeTimeout" "read") access: access allowed ("java.util.PropertyPermission" "sun.rmi.transport.tcp.responseTimeout" "read") access: access allowed ("java.lang.RuntimePermission" "sun.rmi.runtime.RuntimeUtil.getInstance") access: access allowed ("java.net.SocketPermission" "localhost" "resolve") access: access allowed ("java.util.PropertyPermission" "jdk.net.ephemeralPortRange.low" "read") access: access allowed ("java.lang.RuntimePermission" "loadLibrary.net") access: access allowed ("java.io.FilePermission" "C:\Program Files\Java\jre1.8.0_45\bin\net.dll" "read") access: access allowed ("java.util.PropertyPermission" "jdk.net.ephemeralPortRange.high" "read") access: access denied ("java.net.SocketPermission" "127.0.0.1:1099" "connect,resolve") java.lang.Exception: Stack trace at java.lang.Thread.dumpStack(Unknown Source) at java.security.AccessControlContext.checkPermission(Unknown Source) at java.security.AccessController.checkPermission(Unknown Source) at java.lang.SecurityManager.checkPermission(Unknown Source) at java.lang.SecurityManager.checkConnect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.(Unknown Source) at java.net.Socket.(Unknown Source) at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown Source) at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown Source) at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source) at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source) at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source) at sun.rmi.server.UnicastRef.newCall(Unknown Source) at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source) at java.rmi.Naming.rebind(Unknown Source) at ServerSideImp.main(ServerSideImp.java:63) access: access allowed ("java.security.SecurityPermission" "getPolicy") access: access allowed ("java.io.FilePermission" "C:\Users...\ForumServer\bin" "read") access: domain that failed ProtectionDomain (file:/C:/Users/.../ForumServer/bin/ ) sun.misc.Launcher$AppClassLoader@73d16e93 java.security.Permissions@2c7b84de ( ("java.lang.RuntimePermission" "setSecurityManager") ("java.lang.RuntimePermission" "createSecurityManager") ("java.lang.RuntimePermission" "exitVM") ("java.lang.RuntimePermission" "usePolicy") ("java.lang.RuntimePermission" "stopThread") ("java.util.PropertyPermission" "java.specification.version" "read") ("java.util.PropertyPermission" "java.version" "read") ("java.util.PropertyPermission" "os.arch" "read") ("java.util.PropertyPermission" "java.specification.vendor" "read") ("java.util.PropertyPermission" "java.vm.specification.name" "read") ("java.util.PropertyPermission" "java.vm.vendor" "read") ("java.util.PropertyPermission" "path.separator" "read") ("java.util.PropertyPermission" "os.version" "read") ("java.util.PropertyPermission" "file.separator" "read") ("java.util.PropertyPermission" "line.separator" "read") ("java.util.PropertyPermission" "java.vm.specification.vendor" "read") ("java.util.PropertyPermission" "java.specification.name" "read") ("java.util.PropertyPermission" "java.vendor.url" "read") ("java.util.PropertyPermission" "java.vendor" "read") ("java.util.PropertyPermission" "java.vm.version" "read") ("java.util.PropertyPermission" "java.vm.name" "read") ("java.util.PropertyPermission" "java.vm.specification.version" "read") ("java.util.PropertyPermission" "os.name" "read") ("java.util.PropertyPermission" "java.class.version" "read") ("java.net.SocketPermission" "localhost:0" "listen,resolve") ("java.io.FilePermission" "\C:\Users...\ForumServer\bin-" "read") )

access: access allowed ("java.lang.RuntimePermission" "exitVM.1")

但我不太明白这里发生了什么,任何帮助将不胜感激。

最佳答案

删除安全管理器。除非您使用 RMI 代码库功能,否则 RMI 不需要它,但您并不使用它。

关于java rmi - 访问被拒绝 ("java.net.SocketPermission" "127.0.0.1:1099" "connect,resolve"),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30542778/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com