public String view() throws Exception {
String moduleName = getModuleName();
if (FrameworkUtil.convertToNull(moduleName) != null) {// 不允许直接访问action,必须加上moduleName参数,
FunctionDetails functionDetails = getSecurityCacheManager()
.getFunctionFromCache(moduleName);
if (functionDetails != null) {// moduleName对应的菜单必须存在
log.debug("getRequestURI() is : "
+ getRequest().getRequestURI());
log.debug("getRequestURL() is : "
+ getRequest().getRequestURL());
log.debug("getServletPath() is : "
+ getRequest().getServletPath());
log.debug("getQueryString() is : "
+ getRequest().getQueryString());
// moduleName必须与菜单路径对应,保持一致,防止(用户只要拿一个可以通过的菜单,就可以访问所有的页面)
if (functionDetails.getUrl().indexOf(
getRequest().getRequestURI()) >= 0) {
List bizModuleNames = SecurityContextService
.getBizModuleViewAuthorities();
if ("admin".equals(getLoginUser().getLoginname())
|| HelpUtil.containsString(bizModuleNames,
functionDetails.getId())) {// 当前用户必须要有对该菜单访问的权限
return SUCCESS;
}
}
}
}
log.debug("has permission : false");
getRequest().setAttribute("_exception_title_", "错误窗口");
String errorMsg = "当前用户没有页面浏览权限!";
getRequest().setAttribute("_exception_message_", errorMsg);
try {
getRequest().getRequestDispatcher("/common/exception.jsp").forward(
getRequest(), getResponse());
} catch (IOException ioe) {
log.error("/common/exception.jsp页面出错");
}
return null;
}
判断一个用户对一个页面有没有权限(根据moduleName)
最新推荐文章于 2022-04-07 17:21:49 发布