- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试使用以下命令行输入运行我的第一个 Java RMI 客户端-服务器应用程序。
java -cp eclipse-workspace -Djava.rmi.server.codebase=file:/eclipse-workspace -Djava.rmi.server.hostname=localhost -Djava.security.policy=rmidemo.policy -Djava.security.debug=access ct/ExamEngine
rmidemo.policy 文件:
grant codeBase "file:/Users/user/eclipse-workspace/rimdemo/src/ct" {
permission java.security.AllPermission;
};
堆栈跟踪是:
access: access allowed ("java.io.FilePermission" "/Users/user/eclipse-workspace" "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 allowed ("java.util.PropertyPermission" "com.sun.sdp.conf" "read") access: access allowed ("java.lang.RuntimePermission" "loadLibrary.net") access: access allowed ("java.io.FilePermission" "/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre/lib/libnet.dylib" "read") 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" "getProtectionDomain") access: access allowed ("java.util.PropertyPermission" "jdk.internal.lambda.dumpProxyClasses" "read") access: access allowed ("java.lang.reflect.ReflectPermission" "suppressAccessChecks") access: access allowed ("java.util.PropertyPermission" "sun.rmi.transport.dgcFilter" "read") access: access allowed ("java.security.SecurityPermission" "getProperty.sun.rmi.transport.dgcFilter") 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.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.lang.reflect.ReflectPermission" "suppressAccessChecks") access: access allowed ("java.lang.reflect.ReflectPermission" "suppressAccessChecks") access: access denied ("java.net.SocketPermission" "MacBook-Pro.local" "resolve") java.lang.Exception: Stack trace at java.lang.Thread.dumpStack(Thread.java:1336) at java.security.AccessControlContext.checkPermission(AccessControlContext.java:462) at java.security.AccessController.checkPermission(AccessController.java:884) at java.lang.SecurityManager.checkPermission(SecurityManager.java:549) at java.lang.SecurityManager.checkConnect(SecurityManager.java:1048) at java.net.InetAddress.getLocalHost(InetAddress.java:1477) at java.rmi.registry.LocateRegistry.getRegistry(LocateRegistry.java:158) at java.rmi.registry.LocateRegistry.getRegistry(LocateRegistry.java:123) at java.rmi.registry.LocateRegistry.getRegistry(LocateRegistry.java:75) at ct.ExamEngine.main(ExamEngine.java:64) access: access allowed ("java.security.SecurityPermission" "getPolicy") access: access allowed ("java.io.FilePermission" "/Users/user/eclipse-workspace" "read") access: domain that failed ProtectionDomain (file:/Users/user/eclipse-workspace/ ) sun.misc.Launcher$AppClassLoader@2a139a55 java.security.Permissions@27bc2616 ( ("java.net.SocketPermission" "localhost:0" "listen,resolve") ("java.io.FilePermission" "/Users/user/eclipse-workspace/-" "read") ("java.lang.RuntimePermission" "exitVM") ("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") )
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.util.PropertyPermission" "jdk.net.ephemeralPortRange.low" "read") access: access allowed ("java.lang.RuntimePermission" "loadLibrary.net") access: access allowed ("java.io.FilePermission" "/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre/lib/libnet.dylib" "read") access: access allowed ("java.util.PropertyPermission" "os.name" "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(Thread.java:1336) at java.security.AccessControlContext.checkPermission(AccessControlContext.java:462) at java.security.AccessController.checkPermission(AccessController.java:884) at java.lang.SecurityManager.checkPermission(SecurityManager.java:549) at java.lang.SecurityManager.checkConnect(SecurityManager.java:1051) at java.net.Socket.connect(Socket.java:584) at java.net.Socket.connect(Socket.java:538) at java.net.Socket.(Socket.java:434) at java.net.Socket.(Socket.java:211) at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40) at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:148) at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613) at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216) at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202) at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:338) at sun.rmi.registry.RegistryImpl_Stub.rebind(RegistryImpl_Stub.java:147) at ct.ExamEngine.main(ExamEngine.java:65) access: access allowed ("java.security.SecurityPermission" "getPolicy") access: access allowed ("java.io.FilePermission" "/Users/user/eclipse-workspace" "read") access: domain that failed ProtectionDomain (file:/Users/user/eclipse-workspace/ ) sun.misc.Launcher$AppClassLoader@2a139a55 java.security.Permissions@4fca772d ( ("java.net.SocketPermission" "localhost:0" "listen,resolve") ("java.io.FilePermission" "/Users/user/eclipse-workspace/-" "read") ("java.lang.RuntimePermission" "exitVM") ("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") )
ExamEngine exception: java.security.AccessControlException: access denied ("java.net.SocketPermission" "127.0.0.1:1099" "connect,resolve") at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472) at java.security.AccessController.checkPermission(AccessController.java:884) at java.lang.SecurityManager.checkPermission(SecurityManager.java:549) at java.lang.SecurityManager.checkConnect(SecurityManager.java:1051) at java.net.Socket.connect(Socket.java:584) at java.net.Socket.connect(Socket.java:538) at java.net.Socket.(Socket.java:434) at java.net.Socket.(Socket.java:211) at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40) at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:148) at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613) at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216) at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202) at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:338) at sun.rmi.registry.RegistryImpl_Stub.rebind(RegistryImpl_Stub.java:147) at ct.ExamEngine.main(ExamEngine.java:65)
[编辑]如果还不清楚问题出在安全管理器上,当我删除它时,它起作用了,但它对于这个应用程序来说是必要的,所以我需要找到解决这个问题的方法。
最佳答案
试试这个...
启动 RMI 注册表
rmiregistry &
启动服务器(不要忘记末尾的“&”,以便它在后台运行)
注意: 当代码库属性值设置为目录的 URL 时,该值必须以“/”结尾。
-Djava.security.policy=/Users/user/eclipse-workspace/rimdemo/src/ct/rmidemo.policy -Djava.rmi.server.codebase=file:/Users/user/eclipse-workspace/rimdemo/src/ct/
启动客户端
-Djava.security.policy=/Users/user/eclipse-workspace/rimdemo/src/ct/rmidemo.policy
您的服务器策略应该是:
grant {
permission java.security.AllPermission;
};
您的客户策略应该是:
grant {
permission java.security.AllPermission;
};
注意:您可能可以为客户端和服务器使用相同的策略文件。另请注意,您的类路径必须是类文件树的根目录
关于Java RMI : exception: java. security.AccessControlException:访问被拒绝 ("java.net.SocketPermission" "127.0.0.1:1099" "connect,resolve"),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48508636/
我有一个尝试相互通信的客户端和服务器程序。在我的服务器策略文件中,我指定了以下内容: grant signedBy "vivin" { permission java.io.FilePermiss
我正在创建一个 java 小程序来收集和处理来自其他网站的一些数据。该小程序未签名,据我了解,出于安全原因,对其他站点的访问已被阻止。 但是,似乎至少有一个其他站点未被阻止。我试过这段代码: pack
我在连接 Active Directory 时遇到问题。有问题的代码如下: Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTE
我正在尝试制定正确的 Java 安全策略。我的代码需要解析并连接到 login.salesforce.com 和 xx99.salesforce.com,其中 xx99 可以采用大约 100 种不同的
当我在服务器中运行 java 代码时,它会显示以下异常: java.security.AccessControlException: 访问被拒绝 ("java.net.SocketPermission
我有 jApplet,我想将缓冲区发送到服务器并在其上转储,但为什么 AccessControlException 我无法理解。 java.security.AccessControlExcepti
我有一个 RMI 应用程序,我正在努力使策略文件正确。当我将权限设置为: grant codeBase "file:MyJar.jar" { permission java.security.
这个问题已经让我挠头好几天了。对于特定网络上的站点(恰好是 DDOS 缓解提供商),与其他站点相比,安全管理 checkConnect 调用似乎花费了非常非常长的时间。 这个网络上的站点有什么方法可以
我正在开发一个需要在服务器上保存文本文件的小程序。在解决这个问题一段时间后,我在网上偶然发现了 Lynlin.class,它可以使用 ftp 连接发送文件。如果我将以下行添加到我的 C:\Progra
好吧,我有一个小程序,我试图将其嵌入到 HTML 页面中,但它抛出了异常: AccessControlException: access denied (java.net.SocketPermissi
在 Windows 上启动多播 java 套接字时,出现以下错误(防火墙已停用): java.security.AccessControlException:访问被拒绝(java.net.Socket
在远程客户端上下载小程序时,我看到 Sun Java 控制台中显示以下错误消息: java.security.policy: error adding Permission,java.net.Soc
考虑以下代码片段: (在本例中为 OpenJDK 6b24-1.11.5-0ubuntu1~12.10.1,这似乎无关紧要,因为 Oracle 和 OpenJDK 的所有 JVM 6 和 7 都具有相
这个问题在这里已经有了答案: New java.security.AccessControlException in Java 8 (3 个回答) 7年前关闭。 我在一个简单的 HTML 页面上插入了
java.security.AccessControlException: access denied ("java.net.SocketPermission" "127.0.0.1:1099" "c
当我尝试时出现异常 java.security.AccessControlException: access denied (java.net.SocketPermission www.somepag
将 Eclipse Kepler (Windows 7) 用于在 localhost 端口 80 上打开 ServerSocket 的项目。 我使用的安全管理器的策略文件位于: C:\Users\Jo
我们不知道为什么我的客户端在 Safari 中遇到 Java 安全异常。谁能帮忙? 异常在 Windows 上的 Safari 中可靠地发生。这涉及一个Java 小程序。 Windows Vista
我正在从 CF 调用 jar 文件。在CF内部我已经成功创建了一个java类对象。当我当时要调用我的函数时,它会生成以下错误: java.security.AccessControlException
我正在尝试使用小程序读取远程 pdf 文件。当我只从 IDE 运行小程序时它工作正常,但当我将它嵌入到 html 的对象标记中时它会抛出 SocketPermission 异常...以下是访问小程序的
我是一名优秀的程序员,十分优秀!