【发布时间】:2012-08-10 08:52:03
【问题描述】:
我在 Webshere 7.0 上使用 JSF 1.2 + Tomahawk 1.1.13
我的 web.xml:
<welcome-file-list>
<welcome-file>/search.faces</welcome-file>
</welcome-file-list>
<security-constraint>
<display-name>Websphere Security Constraint</display-name>
<web-resource-collection>
<web-resource-name>Default</web-resource-name>
<description />
<url-pattern>/*</url-pattern>
</web-resource-collection>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/login.jsp</form-login-page>
<form-error-page>/login.jsp</form-error-page>
</form-login-config>
</login-config>
我的 login.jsp:
<form method="post" action="j_security_check">
<jsp:include page="head.jsp" />
<t:panelGrid columns="2" border="1"
columnClasses="unfixedCol,fixedCol"
style="style=text-align:top; margin-top:20px; margin-bottom:20px;">
<t:panelGroup>
Login
</t:panelGroup>
<t:panelGroup>
<h:inputText id="j_username" autocomplete="off" size="20" />
</t:panelGroup>
<t:panelGroup>
Password
</t:panelGroup>
<t:panelGroup>
<h:inputSecret id="j_password" autocomplete="off" size="20" />
</t:panelGroup>
<f:facet name="footer">
<t:panelGroup colspan="4"
style="text-align:right; background-color:#d9e2f2;">
<h:commandButton type="submit" value="Submit" />
<h:commandButton type="reset" value="Reset" />
</t:panelGroup>
</f:facet>
</t:panelGrid>
<jsp:include page="foot.jsp" />
</form>
当我访问 /localhost:9080/App/ 并输入正确的凭据时,一切似乎都正常,我登录了,但这会出现问题:
我可以访问应用程序 jsp 页面而无需安全检查(我可以访问 /localhost:9080/App/search.jsp 而无需检查,但是当我访问 /localhost:9080/App/ - 有安全性 -查看)。尝试了不同的 url 模式。
当我尝试使用 FacesContext.getCurrentInstance().getExternalContext().getUserPrincipal() 获取 HTTP 会话用户时 - 当我登录 id 时,始终为空。为什么?
检查了所有指南,包括一些 stackowerflow 问题,但没有意识到我的问题出在哪里。
感谢您的帮助
【问题讨论】: