除非刷新JSF,否则目录不安全

时间:2013-10-27 16:57:48

标签: jsf jaas

我已经为我的网站实现了基于JAAS表单的安全性,并且假设保护名为“secure”的文件夹中的所有.xhtml文件,但直到该页面被刷新才会保留。

在第一次访问时,url没有为文件命名,只显示“faces / catalog.xhtml”,这是以前未受保护的页面,然后如果我点击刷新它就可以了。

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<context-param>
    <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
    <param-value>/WEB-INF/bookstore.taglib.xml</param-value>
</context-param>
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<session-config>
    <session-timeout>
        30
    </session-timeout>
</session-config>
<welcome-file-list>
    <welcome-file>faces/catalog.xhtml</welcome-file>
</welcome-file-list>
<security-constraint>
    <web-resource-collection>
        <web-resource-name>customer</web-resource-name>
        <description/>
        <url-pattern>/faces/secured/checkout.xhtml</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>customer</role-name>
    </auth-constraint>
</security-constraint>
<login-config>
    <auth-method>FORM</auth-method>
    <realm-name>myjdbc</realm-name>
    <form-login-config>
        <form-login-page>/login.xhtml</form-login-page>
        <form-error-page>/login_error.xhtml</form-error-page>
    </form-login-config>
</login-config>
<security-role>
    <role-name>customer</role-name>
</security-role>

哦也像这样调用安全页面:

public String buy() {

    if (getNumberOfItems() < 1) {
        message(null, "CartEmpty");

        return (null);
    } else {
        return ("/secured/checkout");
    }
}

现在试着解决这个问题,谢谢你的帮助。

0 个答案:

没有答案