Package com.github.zhangkaitao.shiro.chapter15.dao

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


    @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


     * 修改密码
     * @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

    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.chapter15.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.