【发布时间】:2012-05-30 04:33:32
【问题描述】:
是否有“j_security_check”的标准位置以便我查看?
搜索我的计算机没有找到该文件,只是对其进行了引用。那么它是出于安全原因隐藏还是不是文件?
我已被锁定在应用程序之外,这是我寻找解决方案的第一个地方。
【问题讨论】:
-
检查 META-INF/context.xml,
标签
是否有“j_security_check”的标准位置以便我查看?
搜索我的计算机没有找到该文件,只是对其进行了引用。那么它是出于安全原因隐藏还是不是文件?
我已被锁定在应用程序之外,这是我寻找解决方案的第一个地方。
【问题讨论】:
它是Servlet API 的一部分,由servletcontainer 实现。在您的情况下,它是由 Tomcat 实现的。更具体地说,org.apache.catalina.authenticator.FormAuthenticator 类。
227 // Is this the action request from the login page?
228 boolean loginAction =
229 requestURI.startsWith(contextPath) &&
230 requestURI.endsWith(Constants.FORM_ACTION);
231
232 // No -- Save this request and redirect to the form login page
233 if (!loginAction) {
234 session = request.getSessionInternal(true);
235 if (log.isDebugEnabled())
236 log.debug("Save request in session '" + session.getIdInternal() + "'");
237 try {
238 saveRequest(request, session);
239 } catch (IOException ioe) {
240 log.debug("Request body too big to save during authentication");
241 response.sendError(HttpServletResponse.SC_FORBIDDEN,
242 sm.getString("authenticator.requestBodyTooBig"));
243 return (false);
244 }
245 forwardToLoginPage(request, response, config);
246 return (false);
247 }
248
249 // Yes -- Validate the specified credentials and redirect
250 // to the error page if they are not correct
251 Realm realm = context.getRealm();
252 if (characterEncoding != null) {
253 request.setCharacterEncoding(characterEncoding);
254 }
255 String username = request.getParameter(Constants.FORM_USERNAME);
256 String password = request.getParameter(Constants.FORM_PASSWORD);
257 if (log.isDebugEnabled())
258 log.debug("Authenticating username '" + username + "'");
259 principal = realm.authenticate(username, password);
260 if (principal == null) {
261 forwardToErrorPage(request, response, config);
262 return (false);
263 }
Constants.FORM_ACTION 是 /j_security_check。
至于您被锁定的具体问题,请确保您提供正确的用户名和密码。用户数据库通常由realm 配置。
【讨论】:
这不是文件,这是基于容器的身份验证的别名:
http://docs.oracle.com/javaee/1.4/tutorial/doc/Security5.html
【讨论】:
您无需对 j_security_check 执行任何操作。问题出在其他地方:
例如:
连接到数据库(或者如果您使用的是 Tomcat,则为 tomcat-users.xml 文件)、密码加密、web.xml 中的某些内容、 context.xml 中的某些内容。对于 Glassfish,它也可以是 pool 和 realm 或者 glassfish-web.xml 中的东西。
仔细检查日志。对于 GF,您需要像这样启用 Finest: (a) 转到此页面:http://localhost:4848/common/monitor/serverInstMonitoringServerPage.jsf。 (b) 将此属性设置为 Finest: javax.enterprise.system.core.security
【讨论】: