Package com.github.zhangkaitao.shiro.chapter11.dao

Examples of com.github.zhangkaitao.shiro.chapter11.dao.UserDao


        JdbcTemplateUtils.jdbcTemplate().update("delete from sys_users_roles");
        JdbcTemplateUtils.jdbcTemplate().update("delete from sys_roles_permissions");


        //1、新增权限
        p1 = new Permission("user:create", "用户模块新增", Boolean.TRUE);
        p2 = new Permission("user:update", "用户模块修改", Boolean.TRUE);
        p3 = new Permission("menu:create", "菜单模块新增", Boolean.TRUE);
        permissionService.createPermission(p1);
        permissionService.createPermission(p2);
        permissionService.createPermission(p3);
        //2、新增角色
        r1 = new Role("admin", "管理员", Boolean.TRUE);
View Full Code Here


        p3 = new Permission("menu:create", "菜单模块新增", Boolean.TRUE);
        permissionService.createPermission(p1);
        permissionService.createPermission(p2);
        permissionService.createPermission(p3);
        //2、新增角色
        r1 = new Role("admin", "管理员", Boolean.TRUE);
        r2 = new Role("user", "用户管理员", Boolean.TRUE);
        roleService.createRole(r1);
        roleService.createRole(r2);
        //3、关联角色-权限
        roleService.correlationPermissions(r1.getId(), p1.getId());
        roleService.correlationPermissions(r1.getId(), p2.getId());
View Full Code Here

     * 修改密码
     * @param userId
     * @param newPassword
     */
    public void changePassword(Long userId, String newPassword) {
        User user =userDao.findOne(userId);
        user.setPassword(newPassword);
        passwordHelper.encryptPassword(user);
        userDao.updateUser(user);
    }
View Full Code Here

        roleService.correlationPermissions(r2.getId(), p1.getId());
        roleService.correlationPermissions(r2.getId(), p2.getId());

        //4、新增用户
        u1 = new User("zhang", password);
        userService.createUser(u1);
        //5、关联用户-角色
        userService.correlationRoles(u1.getId(), r1.getId());

        //1、获取SecurityManager工厂,此处使用Ini配置文件初始化SecurityManager
View Full Code Here

    @Override
    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {

        String username = (String)token.getPrincipal();

        User user = userService.findByUsername(username);
        if(user == null) {
            throw new UnknownAccountException();//没找到帐号
        }

        if(Boolean.TRUE.equals(user.getLocked())) {
            throw new LockedAccountException(); //帐号锁定
        }

        //交给AuthenticatingRealm使用CredentialsMatcher进行密码匹配,如果觉得人家的不好可以自定义实现
        SimpleAuthenticationInfo authenticationInfo = new SimpleAuthenticationInfo(
                user.getUsername(), //用户名
                user.getPassword(), //密码
                ByteSource.Util.bytes(user.getCredentialsSalt()),//salt=username+salt
                getName()  //realm name
        );
        return authenticationInfo;
    }
View Full Code Here

    prepareData(model, request);
    String page = "login";
    if (request.getParameter("Login") != null) {
      String taikhoan = request.getParameter("taikhoan");
      String matkhau = request.getParameter("matkhau");
      UserDAO khDAO = new UserDAOImpl();
      User kh = khDAO.getUserInfo(taikhoan);
      if (kh != null && matkhau.equals(kh.getPassword())) {

        request.setAttribute("TaiKhoan", taikhoan,
            WebRequest.SCOPE_SESSION);
        request.setAttribute("HoTen", kh.getName(),
View Full Code Here

      String diachi = request.getParameter("diachi");
      String matkhau = request.getParameter("matkhau");
      String dienthoai = request.getParameter("dienthoai");
      String email = request.getParameter("email");
      String zipCode = request.getParameter("zipcode");
      UserDAO khDAO = new UserDAOImpl();
      User khTest = khDAO.getUserInfo(taikhoan);
      if (khTest != null) {
        model.addAttribute("info", "account is available!");
      } else {

        User kh = new User(taikhoan, hoten, diachi, email, dienthoai,
            matkhau, zipCode, null);
        boolean result = khDAO.addUser(kh);
        if (result == true) {
          request.setAttribute("TaiKhoan", taikhoan,
              WebRequest.SCOPE_SESSION);
          request.setAttribute("HoTen", kh.getName(),
              WebRequest.SCOPE_SESSION);
View Full Code Here

        if (request.getParameter("Checkout") != null) {
          String idKhachHang = (String) request.getAttribute(
              "TaiKhoan", WebRequest.SCOPE_SESSION);

          UserDAO khDAO = new UserDAOImpl();
          User kh = khDAO.getUserInfo(idKhachHang);

          if (hoten.equals("") || diachi.equals("")
              || dienthoai.equals("")) {
            model.addAttribute("notice",
                "Please enter all information");
View Full Code Here

  // add a user to database
  public boolean addUser(User u) {
    logger.debug("addUser start");
    Session session = HibernateUtil.getSessionFactory().openSession();
    UserDAO khDAO = new UserDAOImpl();
    if (khDAO.getUserInfo(u.getIduser()) != null) {
      return false;
    }

    Transaction transaction = null;
    try {
View Full Code Here

TOP

Related Classes of com.github.zhangkaitao.shiro.chapter11.dao.UserDao

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.