Я пишу клиент-серверную программу на основе JAVA RMI, я отделил код клиента от кода сервера, и я все еще получаю исключение java .security.AccessControlException на стороне клиента, в противном случае я ' Мы устанавливаем server.policy для allPermission и client.policy таким же образом, вот коды файлов моей политики: server.policy
grant {
permission java.security.SecurityPermission "putProviderProperty.BC";
permission java.lang.RuntimePermission "*";
permission java.security.AllPermision;
permission java.net.SocketPermission "localhost:1099", "connect";
};
grant codeBase "file:/home/e20190014044/workspace/TP1_NTiers/bin/"{
permission java.security.AllPermision;
};
client.policy:
grant codeBase "file:/home/e20190014044/workspace/Client_Ntiers/src/"{
permission java.security.SecurityPermission "putProviderProperty.BC";
permission java.security.AllPermision;
};
Я добавил эти командные строки в аргументы JVM сервера:
-Djava.rmi.server.codebase=file:/home/e20190014044/workspace/TP1_NTiers/bin/ -Djava.security.policy=/home/e20190014044/workspace/TP1_NTiers/server.policy -Djava.security.manager -Djava.security.debug=access,failure
и эти командные строки в аргументы JVM клиента:
-Djava.rmi.server.codebase=file:/home/e20190014044/workspace/Client_Ntiers/bin/ -Djava.security.policy=/home/e20190014044/workspace/Client_Ntiers/client.policy -Djava.security.manager -Djava.security.debug=access,failure
Я получил эти результаты после отладки:
("java.util.PropertyPermission" "os.name" "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" "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" "read")
("java.util.PropertyPermission" "java.vm.version" "read")
("java.util.PropertyPermission" "java.class.version" "read")
("java.io.FilePermission" "/home/e20190014044/workspace/Client_Ntiers/bin/-#plus" "read")
("java.io.FilePermission" "/home/e20190014044/workspace/Client_Ntiers/bin/-" "read")
("java.lang.RuntimePermission" "accessClassInPackage.com.sun.beans.*")
("java.lang.RuntimePermission" "accessClassInPackage.com.apple.*")
("java.lang.RuntimePermission" "accessClassInPackage.com.sun.java.swing.plaf.*")
("java.lang.RuntimePermission" "exitVM")
("java.lang.RuntimePermission" "accessClassInPackage.com.sun.beans")
("java.net.SocketPermission" "localhost:0" "listen,resolve")
)
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.security.SecurityPermission" "getProperty.security.provider.12")
access: access allowed ("java.security.SecurityPermission" "getProperty.security.provider.13")
access: access allowed ("java.security.SecurityPermission" "getProperty.jdk.security.provider.preferred")
access: access allowed ("java.util.PropertyPermission" "jdk.security.legacyDSAKeyPairGenerator" "read")
access: access allowed ("java.util.PropertyPermission" "java.security.egd" "read")
access: access allowed ("java.security.SecurityPermission" "getProperty.securerandom.source")
access: access allowed ("java.io.FilePermission" "/dev/random" "read")
access: access allowed ("java.io.FilePermission" "/dev/random" "read")
access: access allowed ("java.io.FilePermission" "/dev/urandom" "read")
access: access allowed ("java.io.FilePermission" "/dev/random" "read")
access: access allowed ("java.io.FilePermission" "/dev/urandom" "read")
access: access allowed ("java.io.FilePermission" "/dev/random" "read")
access: access allowed ("java.io.FilePermission" "/dev/random" "read")
access: access allowed ("java.io.FilePermission" "/dev/urandom" "read")
access: access allowed ("java.io.FilePermission" "/dev/urandom" "read")
access: access allowed ("java.security.SecurityPermission" "putProviderProperty.SUN")
access: access allowed ("java.lang.reflect.ReflectPermission" "suppressAccessChecks")
access: access allowed ("java.util.PropertyPermission" "java.rmi.server.hostname" "read")
access: access denied ("java.net.SocketPermission" "prodpeda-x2go-bionic1" "resolve")
java.lang.Exception: Stack trace
at java.base/java.lang.Thread.dumpStack(Thread.java:1387)
at java.base/java.security.AccessControlContext.checkPermission(AccessControlContext.java:462)
at java.base/java.security.AccessController.checkPermission(AccessController.java:897)
at java.base/java.lang.SecurityManager.checkPermission(SecurityManager.java:322)
at java.base/java.lang.SecurityManager.checkConnect(SecurityManager.java:821)
at java.base/java.net.InetAddress.getLocalHost(InetAddress.java:1626)
at java.rmi/sun.rmi.transport.tcp.TCPEndpoint.<clinit>(TCPEndpoint.java:114)
at java.rmi/java.rmi.registry.LocateRegistry.getRegistry(LocateRegistry.java:175)
at java.rmi/java.rmi.registry.LocateRegistry.getRegistry(LocateRegistry.java:123)
at java.rmi/java.rmi.registry.LocateRegistry.getRegistry(LocateRegistry.java:90)
at Client.Client.main(Client.java:23)
access: access allowed ("java.security.SecurityPermission" "getPolicy")
access: access allowed ("java.io.FilePermission" "/home/e20190014044/workspace/Client_Ntiers/bin" "read")
access: domain that failed ProtectionDomain (file:/home/e20190014044/workspace/Client_Ntiers/bin/ <no signer certificates>)
jdk.internal.loader.ClassLoaders$AppClassLoader@55054057
<no principals>
java.security.Permissions@14514713 (
("java.util.PropertyPermission" "java.specification.version" "read")
("java.util.PropertyPermission" "java.vm.vendor" "read")
("java.util.PropertyPermission" "path.separator" "read")
("java.util.PropertyPermission" "os.version" "read")
("java.util.PropertyPermission" "java.vendor.url" "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.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" "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" "read")
("java.util.PropertyPermission" "java.vm.version" "read")
("java.util.PropertyPermission" "java.class.version" "read")
("java.io.FilePermission" "/home/e20190014044/workspace/Client_Ntiers/bin/-#plus" "read")
("java.io.FilePermission" "/home/e20190014044/workspace/Client_Ntiers/bin/-" "read")
("java.lang.RuntimePermission" "accessClassInPackage.com.sun.beans.*")
("java.lang.RuntimePermission" "accessClassInPackage.com.apple.*")
("java.lang.RuntimePermission" "accessClassInPackage.com.sun.java.swing.plaf.*")
("java.lang.RuntimePermission" "exitVM")
("java.lang.RuntimePermission" "accessClassInPackage.com.sun.beans")
("java.net.SocketPermission" "localhost:0" "listen,resolve")
)
access: access allowed ("java.util.PropertyPermission" "java.rmi.server.useLocalHostName" "read")
access: access allowed ("java.lang.reflect.ReflectPermission" "suppressAccessChecks")
access: access allowed ("java.util.PropertyPermission" "sun.rmi.transport.logLevel" "read")
access: access allowed ("java.lang.reflect.ReflectPermission" "suppressAccessChecks")
access: access allowed ("java.util.PropertyPermission" "sun.rmi.log.useOld" "read")
access: access allowed ("java.util.PropertyPermission" "java.util.logging.manager" "read")
access: access allowed ("java.lang.RuntimePermission" "shutdownHooks")
access: access allowed ("java.lang.RuntimePermission" "setContextClassLoader")
access: access allowed ("java.lang.RuntimePermission" "setContextClassLoader")
access: access allowed ("java.lang.RuntimePermission" "shutdownHooks")
access: access allowed ("java.lang.RuntimePermission" "getProtectionDomain")
access: access allowed ("java.util.logging.LoggingPermission" "control")
access: access allowed ("java.util.logging.LoggingPermission" "control")
access: access allowed ("java.util.PropertyPermission" "java.util.logging.config.class" "read")
access: access allowed ("java.util.PropertyPermission" "java.util.logging.config.file" "read")
access: access allowed ("java.util.PropertyPermission" "java.home" "read")
access: access allowed ("java.io.FilePermission" "/usr/lib/jvm/java-11-openjdk-amd64/conf/logging.properties" "read")
access: access allowed ("java.util.logging.LoggingPermission" "control")
access: access allowed ("java.util.logging.LoggingPermission" "control")
access: access allowed ("java.util.PropertyPermission" "*" "read,write")
access: access allowed ("java.util.logging.LoggingPermission" "control")
access: access allowed ("java.util.logging.LoggingPermission" "control")
access: access allowed ("java.util.logging.LoggingPermission" "control")
access: access allowed ("java.util.logging.LoggingPermission" "control")
access: access allowed ("java.util.logging.LoggingPermission" "control")
access: access allowed ("java.util.logging.LoggingPermission" "control")
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 allowed ("java.lang.reflect.ReflectPermission" "suppressAccessChecks")
access: access allowed ("java.lang.reflect.ReflectPermission" "suppressAccessChecks")
access: access allowed ("java.util.logging.LoggingPermission" "control")
access: access allowed ("java.util.logging.LoggingPermission" "control")
access: access allowed ("java.lang.reflect.ReflectPermission" "suppressAccessChecks")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.lang.RuntimePermission" "accessSystemModules")
access: access allowed ("java.util.PropertyPermission" "java.protocol.handler.pkgs" "read")
access: access allowed ("java.lang.reflect.ReflectPermission" "suppressAccessChecks")
access: access allowed ("java.io.FilePermission" "/usr/share/java/java-atk-wrapper.jar" "read")
access: access allowed ("java.lang.reflect.ReflectPermission" "suppressAccessChecks")
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.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" "loadLibrary.rmi")
access: access allowed ("java.io.FilePermission" "/usr/lib/jvm/java-11-openjdk-amd64/lib/librmi.so" "read")
access: access allowed ("java.lang.RuntimePermission" "enableContextClassLoaderOverride")
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.io.FilePermission" "/home/e20190014044/workspace/TP1_NTiers/bin/EspeceImpl.class" "read")
access: access allowed ("java.io.FilePermission" "/home/e20190014044/workspace/TP1_NTiers/bin/EspeceImpl.class" "read")
access: access allowed ("java.io.FilePermission" "/home/e20190014044/workspace/TP1_NTiers/bin/EspeceImpl.class" "read")
access: access allowed ("java.io.FilePermission" "/home/e20190014044/workspace/TP1_NTiers/bin/AnimalImpl.class" "read")
access: access allowed ("java.io.FilePermission" "/home/e20190014044/workspace/TP1_NTiers/bin/AnimalImpl.class" "read")
access: access allowed ("java.io.FilePermission" "/home/e20190014044/workspace/TP1_NTiers/bin/AnimalImpl.class" "read")
access: access allowed ("java.io.FilePermission" "/home/e20190014044/workspace/TP1_NTiers/bin/CabinetVetImpl.class" "read")
access: access allowed ("java.io.FilePermission" "/home/e20190014044/workspace/TP1_NTiers/bin/CabinetVetImpl.class" "read")
access: access allowed ("java.io.FilePermission" "/home/e20190014044/workspace/TP1_NTiers/bin/CabinetVetImpl.class" "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.io.FilePermission" "/home/e20190014044/workspace/TP1_NTiers/bin/CabinetVetImpl_Stub.class" "read")
access: access allowed ("java.lang.RuntimePermission" "getClassLoader")
access: access allowed ("java.lang.reflect.ReflectPermission" "suppressAccessChecks")
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" "/usr/lib/jvm/java-11-openjdk-amd64/lib/libnet.so" "read")
access: access allowed ("java.util.PropertyPermission" "os.name" "read")
access: access allowed ("java.util.PropertyPermission" "jdk.net.ephemeralPortRange.high" "read")
access: access allowed ("java.net.SocketPermission" "localhost:33793" "listen,resolve")
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 allowed ("java.util.PropertyPermission" "sun.rmi.registry.registryFilter" "read")
access: access allowed ("java.security.SecurityPermission" "getProperty.sun.rmi.registry.registryFilter")
access: access allowed ("java.lang.RuntimePermission" "getProtectionDomain")
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.net.SocketPermission" "localhost:1099" "listen,resolve")
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.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 allowed ("java.lang.reflect.ReflectPermission" "suppressAccessChecks")
Server ready