Search in sources :

Example 11 with Visitor

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);
}
Also used : Visitor(com.baidu.disconf.web.service.user.dto.Visitor)

Example 12 with 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;
}
Also used : Visitor(com.baidu.disconf.web.service.user.dto.Visitor) RequestMethod(org.springframework.web.bind.annotation.RequestMethod) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

Visitor (com.baidu.disconf.web.service.user.dto.Visitor)12 User (com.baidu.disconf.web.service.user.bo.User)2 RequestMethod (org.springframework.web.bind.annotation.RequestMethod)2 ConfigHistory (com.baidu.disconf.web.service.config.bo.ConfigHistory)1 VisitorVo (com.baidu.disconf.web.service.user.vo.VisitorVo)1 AccessDeniedException (com.baidu.dsp.common.exception.AccessDeniedException)1 FieldException (com.baidu.dsp.common.exception.FieldException)1 InetAddress (java.net.InetAddress)1 UnknownHostException (java.net.UnknownHostException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 HttpSession (javax.servlet.http.HttpSession)1 Around (org.aspectj.lang.annotation.Around)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1