use of com.baidu.disconf.web.service.user.dto.Visitor in project disconf by knightliao.
the class RedisLoginImplMock method login.
@Override
public void login(HttpServletRequest request, User user, int expireTime) {
Visitor visitor = new Visitor();
visitor.setId(user.getId());
visitor.setLoginUserId(user.getId());
visitor.setLoginUserName(user.getName());
//
// 更新session
//
updateSessionVisitor(request.getSession(), visitor);
}
use of com.baidu.disconf.web.service.user.dto.Visitor in project disconf by knightliao.
the class RoleResourceMgrImpl method checkUserPermission.
/**
* @param pattern
* @param method
*
* @return
*/
@Override
public boolean checkUserPermission(String pattern, RequestMethod method) {
// 获取用户角色
Visitor visitor = ThreadContext.getSessionVisitor();
if (visitor == null) {
return false;
}
String urlPattarn = pattern;
if (!urlPattarn.endsWith(RoleResourceConstant.URL_SPLITOR)) {
urlPattarn += RoleResourceConstant.URL_SPLITOR;
}
Integer roleId = visitor.getRoleId();
Map<String, Map<RequestMethod, List<Integer>>> roleResMap = getAllAsMap();
Map<RequestMethod, List<Integer>> methodMap = roleResMap.get(urlPattarn);
if (methodMap == null) {
return false;
}
List<Integer> roleIdList = methodMap.get(method);
if (roleIdList == null) {
return false;
}
if (!roleIdList.contains(roleId)) {
return false;
}
return true;
}
Aggregations