Exemplo n.º 1
0
  public String offline(String message) {
    RequestReader reader = new RequestReader(message);
    String ticket = reader.getString("Request/Ticket", false);
    Integer kickFlag = reader.getInteger("Request/KickFlag", true);

    OnlineReal onlineReal = onlineManager.getOnlineReal(ticket);
    if (null != onlineReal) {
      if (logger.isDebugEnabled()) {
        logger.debug("Offline Ticket[" + ticket + "]");
      }
      onlineManager.offline(onlineReal, kickFlag);
    }

    Document doc = XmlUtil.generateResponse("Offline", ErrorCode.SUCCESS, "");
    return XmlUtil.xmlToString(doc);
  }
Exemplo n.º 2
0
  public String csLogin(String message) {
    RequestReader reader = new RequestReader(message);
    String loginName = reader.getString("Request/LoginName", false);
    String passwd = reader.getString("Request/Password", false);
    String type = reader.getString("Request/ClientType", false);
    String ip = reader.getString("Request/IP", false);

    List<User> user = userManager.getUserByName(loginName);
    if (user.size() <= 0) {
      throw new BusinessException(
          ErrorCode.USER_NOT_FOUND, "login_name [" + loginName + "] not found!");
    }
    if (!passwd.equals(MD5Util.MD5(user.get(0).getPassword()))) {
      throw new BusinessException(ErrorCode.PASSWORD_ERROR, "password error!");
    }
    // 判断OMC登录权限
    if (type.equals(TypeDefinition.CLIENT_TYPE_OMC)) {
      if (user.get(0).getAdminPriv() == 0) {
        throw new BusinessException(
            ErrorCode.USER_ROLE_INVALID, "user [" + user.get(0).getLogonName() + "] is not admin");
      }
    }
    // 生成ticket
    String ticket = onlineManager.csLogin(user.get(0), type, ip).getTicket();

    Element root = DocumentHelper.createElement("Response");
    root.addAttribute("Method", "UserLogin");
    root.addAttribute("Code", "200");
    root.addAttribute("Message", "");
    Document doc = DocumentHelper.createDocument(root);
    Element ticketE = DocumentHelper.createElement("Ticket");
    Element userId = DocumentHelper.createElement("UseId");
    root.add(ticketE);
    root.add(userId);
    ticketE.setText(ticket);
    userId.setText(user.get(0).getId().toString());
    return XmlUtil.xmlToString(doc);
  }