【问题标题】:JSF and Container Managed SecurityJSF 和容器管理的安全性
【发布时间】:2012-06-12 01:58:23
【问题描述】:

我有一个 JSF 登录页面,当用户直接导航到它时效果很好。

但是,如果用户在没有先登录的情况下尝试访问受保护的页面,容器会正确拦截此操作并将他们扔到登录页面。但是,因为登录页面是 JSF,所以存在问题。发送给用户的是原始的 JSF 页面,完全没有被 FacesServlet 处理。

片段示例 - 在未登录的情况下访问受保护页面后发送到浏览器:

<ui:define name="body">
    <p:growl id="growl" showDetail="true" sticky="true"  /> 
    <div class="mytext">Please login to the application...</div>

    <form method="POST" action="j_security_check">
        <table cellpadding="0" cellspacing="0" border="0">
            <tr>
                <td align="right">Username:&nbsp;</td>
                <td>
                    <input type="text" name="j_username"/>
                </td>
            </tr>
            <tr>
                <td align="right">Password:&nbsp;</td>
                <td>
                    <input type="password" name="j_password"/>
                </td>
            </tr>
            <tr>
                <td></td>
                <td>
                    <input type="submit" value="Login"/>
                 </td>
             </tr>
            </table>
     </form>
 </ui:define>

有没有办法强制容器通过 FacesServlet 处理器呈现响应,而不是简单地返回原始 JSF 文件?

【问题讨论】:

    标签: jsf authentication jakarta-ee


    【解决方案1】:

    要么更改&lt;form-login-page&gt; 的URL 以匹配FacesServlet 的URL 模式,或者更好地将FacesServlet 的URL 模式更改为*.xhtml,以便最终用户永远看不到原始JSF 源通过有目的地更改浏览器地址栏中的 URL 来生成任何页面的代码。

    【讨论】:

      猜你喜欢
      • 2012-09-22
      • 2016-08-15
      • 1970-01-01
      • 2011-04-25
      • 1970-01-01
      • 1970-01-01
      • 2013-01-21
      • 2012-05-29
      相关资源
      最近更新 更多