0

我已经在 J​​Boss 6.x EAP 上部署了我的应用程序。启用安全管理器后,部署失败并出现以下异常。

Caused by: java.security.AccessControlException: access denied ("org.jboss.vfs.VirtualFilePermission" "/E:/Servers/jboss-eap-6.4.0/jboss-eap-6.4/standalone/deployments/eQubeMI.war/WEB-INF/lib/spring-web-4.1.9.RELEASE.jar/org/springframework/web/context/ContextLoader.properties" "read")
        at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472) [rt.jar:1.8.0_101]
        at java.security.AccessController.checkPermission(AccessController.java:884) [rt.jar:1.8.0_101]
        at java.lang.SecurityManager.checkPermission(SecurityManager.java:549) [rt.jar:1.8.0_101]
        at org.jboss.vfs.VirtualFile.openStream(VirtualFile.java:248) [jboss-vfs-3.2.9.Final-redhat-1.jar:3.2.9.Final-redhat-1]
        at org.jboss.as.server.deployment.module.VFSResourceLoader$VFSEntryResource.openStream(VFSResourceLoader.java:329)
        at org.jboss.modules.Module.getResourceAsStream(Module.java:637) [jboss-modules.jar:1.3.6.Final-redhat-1]
        at org.jboss.modules.ModuleClassLoader.findResourceAsStream(ModuleClassLoader.java:587) [jboss-modules.jar:1.3.6.Final-redhat-1]
        at org.jboss.modules.ConcurrentClassLoader.getResourceAsStream(ConcurrentClassLoader.java:362) [jboss-modules.jar:1.3.6.Final-redhat-1]
        at java.lang.Class.getResourceAsStream(Class.java:2223) [rt.jar:1.8.0_101]
        at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:163) [spring-core-4.1.9.RELEASE.jar:4.1.9.RELEASE]
        at org.springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:132) [spring-core-4.1.9.RELEASE.jar:4.1.9.RELEASE]
        at org.springframework.core.io.support.PropertiesLoaderUtils.loadProperties(PropertiesLoaderUtils.java:121) [spring-core-4.1.9.RELEASE.jar:4.1.9.RELEASE]
        at org.springframework.web.context.ContextLoader.<clinit>(ContextLoader.java:176) [spring-web-4.1.9.RELEASE.jar:4.1.9.RELEASE]

我已按照安全指南中提到的步骤操作: https ://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.4/html/Security_Guide/Run_JBoss_Enterprise_Application_Platform_Within_the_Java_Security_Manager.html

我附上了standalone.conf.bat 和server.policy 文件以供参考。

Standalone.conf.bat

if not "x%JAVA_OPTS%" == "x" (
  echo "JAVA_OPTS already set in environment; overriding default settings with values: %JAVA_OPTS%"
  goto JAVA_OPTS_SET
)


rem # JVM memory allocation pool parameters - modify as appropriate.
set "JAVA_OPTS=%JAVA_OPTS% -Xms1G -Xmx3G -XX:MaxPermSize=512M"



rem # Prefer IPv4
set "JAVA_OPTS=%JAVA_OPTS% -Djava.net.preferIPv4Stack=true"

rem # Set the jboss.modules.policy-permissions property to true by default.
set "JAVA_OPTS=%JAVA_OPTS%  -Djboss.modules.policy-permissions=true "

rem # Make Byteman classes visible in all module loaders
rem # This is necessary to inject Byteman rules into AS7 deployments
set "JAVA_OPTS=%JAVA_OPTS% -Djboss.modules.system.pkgs=org.jboss.byteman"

rem # Sample JPDA settings for remote socket debugging
set "JAVA_OPTS=%JAVA_OPTS% -agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n"

rem # Sample JPDA settings for shared memory debugging
rem set "JAVA_OPTS=%JAVA_OPTS% -agentlib:jdwp=transport=dt_shmem,address=jboss,server=y,suspend=n"

rem # Use JBoss Modules lockless mode
rem set "JAVA_OPTS=%JAVA_OPTS% -Djboss.modules.lockless=true"

rem # Uncomment this to run with a security manager enabled
set "SECMGR=true"
set "JAVA_OPTS=%JAVA_OPTS% -Djboss.home.dir=%JBOSS_HOME% -Djava.security.policy==%JBOSS_HOME%/bin/server.policy -Djava.security.debug=failure"
echo %JAVA_OPTS%
:JAVA_OPTS_SET

服务器策略

/* AUTOMATICALLY GENERATED ON Mon Jul 17 18:54:06 IST 2017*/
/* DO NOT EDIT */

grant codeBase "file:E:/Servers/jboss-eap-6.4.0/jboss-eap-6.4/standalone/deployments/eQubeMI.war/lib/-" {
  permission java.security.AllPermission;
  permission java.io.FilePermission "<<ALL FILES>>", "read";
  permission java.io.FilePermission "<<ALL FILES>>", "write";
  permission org.jboss.vfs.VirtualFilePermission "*", "read";
  permission org.jboss.vfs.VirtualFilePermission "*", "write";
};

grant codeBase "file:E:/Servers/jboss-eap-6.4.0/jboss-eap-6.4/standalone/deployments/eQubeMI.war/-" {
  permission java.security.AllPermission;
  permission java.io.FilePermission "<<ALL FILES>>", "read";
  permission java.io.FilePermission "<<ALL FILES>>", "write";
  permission org.jboss.vfs.VirtualFilePermission "*", "read";
  permission org.jboss.vfs.VirtualFilePermission "*", "write";
};

如果我错过了任何步骤或者是服务器问题,请告诉我。

提前致谢..

4

1 回答 1

0

您需要在 server.policy 中授予除这两个之外的 codeBase,使用“-Djava.security.debug=access,failure,policy”查找其他 codeBase,在日志文件中搜索“Active CodeSource”。参见例如https://developer.jboss.org/wiki/JBossAS7SecurityRunningUnderAJavaSecurityManager

于 2017-08-11T04:14:42.327 回答