protected AuthenticationToken createToken(ServletRequest request, ServletResponse response) {
   String username = "";
   // 验证是否是邮箱登陆
   String email = getUsername(request);
   String reg = "[\\w]+@[\\w]+.[\\w]+";
   // 告知此字符串是否匹配给定的正则表达式。
   if (email.matches(reg)) { // 匹配的是邮箱,那么进行邮箱登陆验证
     Member mem = memberService.retrieveEmail(email); // 通过该邮箱,看是否存在
     if (mem != null) { // 说明数据库存在
       // 是否禁用了该会员
       if (mem.getStatus().equals("disable")) {
         username = "******"; // 不让它登陆
       } else {
         username = mem.getMemberName(); // 取出用户名称,交给shiro去验证密码
       }
     } else { // 否则的话,把他当成用户名登陆验证
       username = email;
     }
   } else { // 否则按照用户名登陆验证
     Member member = memberService.retrieveName(email);
     if (member != null) {
       // 是否禁用了该会员
       if (member.getStatus().equals("disable")) {
         username = "******"; // 不让它登陆
       } else {
         username = email; // 取出用户名称,交给shiro去验证密码
       }
     }
   }
   String password = getPassword(request);
   String captcha = getCaptcha(request);
   boolean rememberMe = isRememberMe(request);
   String ip = IpUtil.getIpAddr((HttpServletRequest) request);
   String host = ip + IpUtil.getIpInfo(ip);
   char[] charPassword = null;
   if (StringUtils.isNotBlank(password)) {
     charPassword = password.toCharArray();
   }
   return new CaptchaUsernamePasswordToken(username, charPassword, rememberMe, host, captcha);
 }
 /** 登录认证,失败会捕获相关异常信息 */
 protected boolean executeLogin(ServletRequest request, ServletResponse response)
     throws Exception {
   CaptchaUsernamePasswordToken token =
       (CaptchaUsernamePasswordToken) createToken(request, response);
   try {
     doCaptchaValidate((HttpServletRequest) request, token);
     if (token.getUsername().equals("NO")) {
       throw new DisabledAccountException("该用户被禁用,请联系客服!");
     }
     Subject subject = getSubject(request, response);
     subject.login(token);
     HttpSession session = ((HttpServletRequest) request).getSession(false);
     Member member = (Member) subject.getPrincipal();
     session.setAttribute("currentMember", member);
     session.setAttribute("currentMemberWork", memberService.getMemberWork(member.getMemberId()));
     int messageNoticCount = loginTotalMessageNotic(member.getMemberId());
     session.setAttribute("messageNoticCount", messageNoticCount);
     memberService.updateIntegra(member.getMemberId());
     return onLoginSuccess(token, subject, request, response);
   } catch (AuthenticationException e) {
     return onLoginFailure(token, e, request, response);
   }
 }
  @Transactional(readOnly = false)
  public Object sendMessage(String[] array, MessageNote messageNote) {
    Subject pricipalSubject = SecurityUtils.getSubject();
    User pricipalUser = (User) pricipalSubject.getPrincipal();
    JqReturnJson returnResult = new JqReturnJson(); // 构建返回结果,默认结果为false
    List<String> noteList = new ArrayList<String>(); // 构建接收邮箱List
    messageNote.setNoteId(RandomGUID.getRandomGUID());
    int count = 0;
    if (messageNote.getNoteType().equals("candidate")) { // 部分群发
      for (int i = 0; i < array.length; i++) {
        Member member = memberService.getMemberMsg(array[i]);
        noteList.add(member.getMobileNumber());
      }
      // 对MessageEmail赋值
      messageNote.setCreater(pricipalUser.getUserId());
      messageNote.setCreaterTime(new Date());
      messageNote.setNoteTime(new Date());
      count = messageNoteMapper.insertSelective(messageNote);
      if (count == 1) {
        for (int i = 0; i < array.length; i++) {
          Member member = memberService.getMemberMsg(array[i]);
          MessageInfo messageInfo = new MessageInfo(); // 构建邮箱记录
          messageInfo.setInfoId(RandomGUID.getRandomGUID()); // 随即产生32位ID
          messageInfo.setInfoTitle(messageNote.getNoteTitle()); // 设置标题
          messageInfo.setInfoSend(pricipalUser.getUserId()); // 管理员
          messageInfo.setInfoMemberid(member.getMemberId()); // 会员ID
          messageInfo.setCreaterTime(new Date()); // 设置当前时间
          messageInfo.setNoteId(messageNote.getNoteId()); // 设置活动邮件ID
          messageInfoMapper.insertSelective(messageInfo); // 执行添加
        }
      }

      for (int i = 0; i < noteList.size(); i++) {
        noteSend(messageNote.getNoteText(), noteList.get(i));
      }

      returnResult.setMsg("发送成功");
      returnResult.setSuccess(true);

    } else if (messageNote.getNoteType().equals("mass")) { // 群发会员
      List<Member> memberList = memberService.getMemberList();
      for (Member member : memberList) {
        noteList.add(member.getMobileNumber());
      }
      // 对MessageEmail赋值
      messageNote.setCreater(pricipalUser.getUserId());
      messageNote.setCreaterTime(new Date());
      messageNote.setNoteTime(new Date());
      count = messageNoteMapper.insertSelective(messageNote);
      if (count == 1) {
        for (Member member : memberList) {
          MessageInfo messageInfo = new MessageInfo(); // 构建邮箱记录
          messageInfo.setInfoId(RandomGUID.getRandomGUID()); // 随即产生32位ID
          messageInfo.setInfoTitle(messageNote.getNoteTitle()); // 设置标题
          messageInfo.setInfoSend(pricipalUser.getUserId()); // 管理员
          messageInfo.setInfoMemberid(member.getMemberId()); // 会员ID
          messageInfo.setCreaterTime(new Date()); // 设置当前时间
          messageInfo.setNoteId(messageNote.getNoteId()); // 设置活动邮件ID
          messageInfoMapper.insertSelective(messageInfo); // 执行添加
        }
      }

      for (int i = 0; i < noteList.size(); i++) {
        noteSend(messageNote.getNoteText(), noteList.get(i));
      }

      returnResult.setMsg("发送成功");
      returnResult.setSuccess(true);

    } else if (messageNote.getNoteType().equals("Vip")) {
      MemberExample memberExample = new MemberExample();
      memberExample.createCriteria().andTypeEqualTo("vip");
      List<Member> memberList = memberMapper.selectByExample(memberExample);
      for (Member member : memberList) {
        noteList.add(member.getMobileNumber());
      }
      // 对MessageEmail赋值
      messageNote.setCreater(pricipalUser.getUserId());
      messageNote.setCreaterTime(new Date());
      messageNote.setNoteTime(new Date());
      count = messageNoteMapper.insertSelective(messageNote);
      if (count == 1) {
        for (Member member : memberList) {
          MessageInfo messageInfo = new MessageInfo(); // 构建邮箱记录
          messageInfo.setInfoId(RandomGUID.getRandomGUID()); // 随即产生32位ID
          messageInfo.setInfoTitle(messageNote.getNoteTitle()); // 设置标题
          messageInfo.setInfoSend(pricipalUser.getUserId()); // 管理员
          messageInfo.setInfoMemberid(member.getMemberId()); // 会员ID
          messageInfo.setCreaterTime(new Date()); // 设置当前时间
          messageInfo.setNoteId(messageNote.getNoteId()); // 设置活动邮件ID
          messageInfoMapper.insertSelective(messageInfo); // 执行添加
        }
      }

      for (int i = 0; i < noteList.size(); i++) {
        noteSend(messageNote.getNoteText(), noteList.get(i));
      }

      returnResult.setMsg("发送成功");
      returnResult.setSuccess(true);

    } else if (messageNote.getNoteType().equals("general")) {
      MemberExample memberExample = new MemberExample();
      memberExample.createCriteria().andTypeEqualTo("vip");
      List<Member> memberList = memberMapper.selectByExample(memberExample);
      for (Member member : memberList) {
        noteList.add(member.getMobileNumber());
      }
      // 对MessageEmail赋值
      messageNote.setCreater(pricipalUser.getUserId());
      messageNote.setCreaterTime(new Date());
      messageNote.setNoteTime(new Date());
      count = messageNoteMapper.insertSelective(messageNote);
      if (count == 1) {
        for (Member member : memberList) {
          MessageInfo messageInfo = new MessageInfo(); // 构建邮箱记录
          messageInfo.setInfoId(RandomGUID.getRandomGUID()); // 随即产生32位ID
          messageInfo.setInfoTitle(messageNote.getNoteTitle()); // 设置标题
          messageInfo.setInfoSend(pricipalUser.getUserId()); // 管理员
          messageInfo.setInfoMemberid(member.getMemberId()); // 会员ID
          messageInfo.setCreaterTime(new Date()); // 设置当前时间
          messageInfo.setNoteId(messageNote.getNoteId()); // 设置活动邮件ID
          messageInfoMapper.insertSelective(messageInfo); // 执行添加
        }
      }

      for (int i = 0; i < noteList.size(); i++) {
        noteSend(messageNote.getNoteText(), noteList.get(i));
      }

      returnResult.setMsg("发送成功");
      returnResult.setSuccess(true);
    }
    return returnResult;
  }