Search in sources :

Example 6 with User

use of com.luoxiao.model.User in project ssm_shiro_blog by Mandelo.

the class MainController method userManage.

/**
 * 角色管理界面
 *
 * @return
 */
@RequestMapping(value = "/cms/userManage")
public ModelAndView userManage() {
    ModelAndView mv = new ModelAndView();
    List<User> userList = userService.selectAll();
    List<UserRoleTemp> userRoleList = new ArrayList<UserRoleTemp>();
    for (User user : userList) {
        List<String> roleList = userExtendService.getRoles(user.getUsername());
        UserRoleTemp u = new UserRoleTemp();
        u.setId(user.getId());
        u.setUsername(user.getUsername());
        u.setRoles(roleList);
        // System.out.println(u);
        userRoleList.add(u);
    }
    mv.addObject("urList", userRoleList);
    mv.setViewName("cms/userManage");
    return mv;
}
Also used : User(com.luoxiao.model.User) UserRoleTemp(com.luoxiao.model.UserRoleTemp) ModelAndView(org.springframework.web.servlet.ModelAndView) ArrayList(java.util.ArrayList) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with User

use of com.luoxiao.model.User in project ssm_shiro_blog by Mandelo.

the class MyRealm method doGetAuthenticationInfo.

/**
 * 用于验证身份
 */
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
    String username = (String) token.getPrincipal();
    User user = userExtendDao.selectByUsername(username);
    if (null != user) {
        AuthenticationInfo info = new SimpleAuthenticationInfo(user.getUsername(), user.getPassword(), "xx");
        return info;
    }
    return null;
}
Also used : User(com.luoxiao.model.User) SimpleAuthenticationInfo(org.apache.shiro.authc.SimpleAuthenticationInfo) AuthenticationInfo(org.apache.shiro.authc.AuthenticationInfo) SimpleAuthenticationInfo(org.apache.shiro.authc.SimpleAuthenticationInfo)

Aggregations

User (com.luoxiao.model.User)7 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 UserRoleTemp (com.luoxiao.model.UserRoleTemp)3 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)3 ModelAndView (org.springframework.web.servlet.ModelAndView)2 UserRole (com.luoxiao.model.UserRole)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 AuthenticationInfo (org.apache.shiro.authc.AuthenticationInfo)1 SimpleAuthenticationInfo (org.apache.shiro.authc.SimpleAuthenticationInfo)1 UsernamePasswordToken (org.apache.shiro.authc.UsernamePasswordToken)1 Subject (org.apache.shiro.subject.Subject)1