【问题标题】:Prettyfaces and the container based securityPrettyfaces 和基于容器的安全性
【发布时间】:2013-06-24 21:44:08
【问题描述】:

我在使用带有漂亮面孔的基于容器的安全性时遇到问题。至于我禁用漂亮的面孔(在 pom.xml 中删除它的存在),基于容器的安全性工作正常并且页面得到很好的保护。 但是,使用漂亮面孔后,安全性不再起作用,无需身份验证即可访问安全页面(我没有在安全页面上应用漂亮面孔过滤器)。即使我使用的是空的 pretty-config.xml(唯一的)。

我正在使用 Jboss AS

编辑:

使用此设置,无需身份验证即可访问页面 /user/*。从 pom.xml 中删除漂亮的面孔后,它运行良好。

web.xml 的一部分:

   <security-role>
    <description>Users</description>
    <role-name>user</role-name>
   </security-role>

   <security-constraint>
    <web-resource-collection>
        <web-resource-name>General use.</web-resource-name>
        <url-pattern>/user/*</url-pattern>
        <http-method>DELETE</http-method>
        <http-method>GET</http-method>
        <http-method>POST</http-method>
        <http-method>PUT</http-method>
        <http-method>HEAD</http-method>
        <http-method>TRACE</http-method>
        <http-method>OPTIONS</http-method>
    </web-resource-collection>
    <auth-constraint>
        <role-name>user</role-name>
    </auth-constraint>
    <user-data-constraint>
        <transport-guarantee>NONE</transport-guarantee>
    </user-data-constraint>
</security-constraint>

<login-config>
    <auth-method>FORM</auth-method>
    <form-login-config>
        <form-login-page>/login.xhtml</form-login-page>
        <form-error-page>/login-fail.xhtml</form-error-page>
    </form-login-config>
</login-config>

prettyfaces-config.xml(使用空的 pretty-config.xml 时):

<pretty-config xmlns="http://ocpsoft.org/schema/rewrite-config-prettyfaces" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://ocpsoft.org/schema/rewrite-config-prettyfaces
                  http://ocpsoft.org/xml/ns/prettyfaces/rewrite-config-prettyfaces.xsd">


</pretty-config>

【问题讨论】:

  • 你能发布你配置的相关部分吗?
  • 添加了 web.xml 和 prettyfaces-config.xml。我希望它足够
  • 您在使用 PrettyFaces 注释吗?你是如何定义你的页面映射的?
  • 我只使用 xml,没有注释/类。但是,即使 pretty-config 为空,我也会遇到问题(例如,在创建 prettyfaces-config.xml + 向 pom.xml 添加 prettyfaces 后,安全性就会停止工作)。
  • 我更新了答案:)

标签: java prettyfaces


【解决方案1】:

编辑:碰巧,这是 Rewrite 中的一个错误,已在 2.0.4.Final 版本中修复。 (参见相关论坛帖子 - http://ocpsoft.org/support/topic/prettyfaces-with-container-based-security/

【讨论】:

  • 您好,感谢您的关注。我举了一个例子,当时我没有使用任何漂亮的面孔映射,但它仍然失败。我尝试了几个简单的应用程序,我正在按照以下步骤操作: 1.创建应用程序。 2. 创建 web.xml 并添加编辑版本中提到的安全约束。 3. 创建简单的 login.xhtml、login-fail.xhtml 和 user/secured.xhtml 。现在它工作正常......现在只需向 pom.xml 添加漂亮的面孔(2.0.1.Final 完全从“ocpsoft.org/prettyfaces”复制了 JSF2 的 2 个依赖项)......仅此而已。构建/清理后失败(即使在 glassfish 上)。
  • 您能否在 OCPsoft 支持论坛上创建一个主题并上传您的示例项目源代码,包括 POM、.java 和任何配置文件?我想我需要仔细研究一下。
  • 我在 OCPsoft 上创建了一个主题。
  • 好的,谢谢。对不起,我有点忙,我会尽快看看。
  • 您好,谢谢,现在可以使用了。您可以使用固定版本编辑或创建新答案,以便我可以将其标记为其他人接受吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-06-12
  • 2016-08-15
  • 2011-08-07
相关资源
最近更新 更多