gpt4 book ai didi

security - 在 JBoss 7.1.1 上的standalone.xml 之外声明安全域

转载 作者:行者123 更新时间:2023-12-04 04:30:56 25 4
gpt4 key购买 nike

我在 JBoss 7 上通过注释使用安全域来实现 EJB-Security。例如。

@RolesAllowed({"User", "Admin"})

目前我在standalone.xml 中声明了安全域。这适用于小事情,但我想在同一个 JBoss 服务器上的不同项目中使用这个安全小子。因此,我正在寻找一种在standalone.xml 之外声明安全域的方法。我想在 war-Deployment 中使用部署描述符。

根据 this documentation这应该是可能的。但这是针对 JBoss 5 的,似乎不适用于 JBoss 7.1.1。由于解析器错误,启动 JBoss 会引发异常。我也看过 this question但我不确定这是否是我需要的东西。我需要在standalone.xml 之外的某个地方使用登录模块声明新的安全域。

有没有 简单 在 war 部署中存储安全域声明和配置的解决方案?

谢谢

最佳答案

我认为目前以简单的方式( related JIRA issue )是不可能的。但是,您可以使用 jboss-as-maven-plugin作为一种解决方法:

<profiles>
<profile>
<id>deploy-security-domain</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<version>7.4.Final</version>
<executions>
<execution>
<id>add-security-domain</id>
<phase>install</phase>
<goals>
<!-- This should work in both "standalone" and "domain" mode -->
<goal>execute-commands</goal>
</goals>
<configuration>
<execute-commands>
<batch>true</batch>
<commands>
<command>/subsystem=security/security-domain=MyDomain:add(cache-type=default)</command>
<command>/subsystem=security/security-domain=MyDomain/authentication=classic:add(login-modules=[{"code"=>"Database","flag"=>"required","module-options"=>[("dsJndiName"=>"java:jboss/datasources/UserDB"),("principalsQuery"=>"select password from users where user_name=?"),("rolesQuery"=>"select role, 'Roles' from user_roles where user_name=?"),("hashAlgorithm"=>"SHA-256"),("hashEncoding"=>"base64")]}]</command>
</commands>
</execute-commands>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
</profiles>

执行:
mvn install -P deploy-security-domain

另一种选择是 CLI脚本,或多或少做同样的事情。查看 this以快速启动项目为例。

关于security - 在 JBoss 7.1.1 上的standalone.xml 之外声明安全域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17364524/

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