Exemplo n.º 1
0
  public String getOnThePhoneMessage(String sipUserName) throws UserNotFoundException {

    String userName = this.sipIdToXmppIdMap.get(sipUserName);
    if (userName == null) {
      throw new UserNotFoundException("User not found - no xmpp ID exists " + sipUserName);
    }
    User user = userManager.getUser(userName);
    return user.getProperties().get(ON_THE_PHONE_MESSAGE);
  }
Exemplo n.º 2
0
  public void setConferenceExtension(String sipUserName, String conferenceExtension)
      throws UserNotFoundException {
    String userName = this.sipIdToXmppIdMap.get(sipUserName);
    if (userName == null) {
      throw new UserNotFoundException("SIP User " + sipUserName + " not found");
    }
    User user = userManager.getUser(userName);

    user.getProperties().put(CONFERENCE_EXTENSION, conferenceExtension);
  }
Exemplo n.º 3
0
 public HashSet<UserAccount> getUserAccounts() {
   HashSet<UserAccount> userAccounts = new HashSet<UserAccount>();
   for (User user : this.userManager.getUsers()) {
     UserAccount userAccount = new UserAccount();
     String sipUserId = user.getProperties().get(SIP_UID);
     userAccount.setXmppUserName(user.getUsername());
     userAccount.setSipUserName(sipUserId);
     userAccounts.add(userAccount);
   }
   return userAccounts;
 }
Exemplo n.º 4
0
 public void setOnThePhoneMessage(String sipUserName, String onThePhoneMessage)
     throws UserNotFoundException {
   String userName = this.sipIdToXmppIdMap.get(sipUserName);
   if (userName == null) {
     throw new UserNotFoundException("SIP User " + sipUserName + " not found");
   }
   User user = userManager.getUser(userName);
   if (!onThePhoneMessage.equals("")) {
     user.getProperties().put(ON_THE_PHONE_MESSAGE, onThePhoneMessage);
   } else {
     user.getProperties().remove(ON_THE_PHONE_MESSAGE);
   }
 }
Exemplo n.º 5
0
  // Experimental - to be debugged and tested
  public Presence getForeignUserPresence(String sender, String jid) throws UserNotFoundException {

    log.debug("getPresence : sender = " + sender + " jid = " + jid);

    if (jid == null) {
      throw new UserNotFoundException("Target JID not found in request");
    }

    JID targetJID = new JID(jid);
    // Check that the sender is not requesting information of a remote server entity
    if (targetJID.getDomain() == null || XMPPServer.getInstance().isRemote(targetJID)) {
      throw new UserNotFoundException("Domain does not matches local server domain");
    }
    if (!hostname.equals(targetJID.getDomain())) {
      // Sender is requesting information about component presence, so we send a
      // presence probe to the component.
      presenceManager.probePresence(componentJID, targetJID);

      // Wait 30 seconds until we get the probe presence result
      int count = 0;
      Presence presence = probedPresence.get(jid);
      while (presence == null) {
        if (count > 300) {
          // After 30 seconds, timeout
          throw new UserNotFoundException("Request for component presence has timed-out.");
        }
        try {
          Thread.sleep(100);
        } catch (InterruptedException e) {
          // don't care!
        }
        presence = probedPresence.get(jid);

        count++;
      }
      // Clean-up probe presence result
      probedPresence.remove(jid);
      // Return component presence
      return presence;
    }
    if (targetJID.getNode() == null
        || !UserManager.getInstance().isRegisteredUser(targetJID.getNode())) {
      // Sender is requesting presence information of an anonymous user
      throw new UserNotFoundException("Username is null");
    }
    User user = userManager.getUser(targetJID.getNode());
    log.debug("user = "******"isNameVisible " + user.isNameVisible());
    return ((PresenceManagerImpl) presenceManager).getPresence(user);
  }
Exemplo n.º 6
0
  public void createUserAccount(
      String userName, String password, String displayName, String email) {

    try {
      User user = userManager.getUser(userName);
      user.setPassword(password);
      user.setName(displayName);
      user.setEmail(email);
    } catch (UserNotFoundException e) {
      try {
        userManager.createUser(userName, password, displayName, email);
      } catch (UserAlreadyExistsException ex) {
        throw new SipXOpenfirePluginException(ex);
      }
    }
  }
 /**
  * Delete user.
  *
  * @param oldUser the old user
  */
 private static void deleteUser(User oldUser) {
   UserManager.getInstance().deleteUser(oldUser);
   final StreamError error = new StreamError(StreamError.Condition.not_authorized);
   for (ClientSession sess : SessionManager.getInstance().getSessions(oldUser.getUsername())) {
     sess.deliverRawText(error.toXML());
     sess.close();
   }
 }
  /**
   * Adds the new user to others roster.
   *
   * @param newUser the new user
   * @param otherItem the other item
   * @param currentUser the current user
   * @throws ServiceException the service exception
   */
  private static void addNewUserToOthersRoster(
      User newUser, RosterItem otherItem, String currentUser) throws ServiceException {
    otherItem.getJid();
    UserManager userManager = UserManager.getInstance();

    // Is this user registered with our OF server?
    String username = otherItem.getJid().getNode();
    if (username != null
        && username.length() > 0
        && userManager.isRegisteredUser(username)
        && XMPPServer.getInstance()
            .isLocal(XMPPServer.getInstance().createJID(currentUser, null))) {
      try {
        User otherUser = userManager.getUser(username);
        Roster otherRoster = otherUser.getRoster();
        RosterItem oldUserOnOthersRoster =
            otherRoster.getRosterItem(XMPPServer.getInstance().createJID(currentUser, null));

        try {
          if (!oldUserOnOthersRoster.isOnlyShared()) {

            RosterItem justCreated =
                otherRoster.createRosterItem(
                    XMPPServer.getInstance().createJID(newUser.getUsername(), null),
                    oldUserOnOthersRoster.getNickname(),
                    oldUserOnOthersRoster.getGroups(),
                    true,
                    true);
            justCreated.setAskStatus(oldUserOnOthersRoster.getAskStatus());
            justCreated.setRecvStatus(oldUserOnOthersRoster.getRecvStatus());
            justCreated.setSubStatus(oldUserOnOthersRoster.getSubStatus());
            otherRoster.updateRosterItem(justCreated);
          }
        } catch (UserAlreadyExistsException e) {
          throw new ServiceException(
              "Could not create roster item for user ",
              newUser.getUsername(),
              ExceptionType.USER_ALREADY_EXISTS_EXCEPTION,
              Response.Status.CONFLICT,
              e);
        } catch (SharedGroupException e) {
          throw new ServiceException(
              "Could not create roster item, because it is a contact from a shared group",
              newUser.getUsername(),
              ExceptionType.USER_ALREADY_EXISTS_EXCEPTION,
              Response.Status.BAD_REQUEST,
              e);
        }
      } catch (UserNotFoundException e) {
        throw new ServiceException(
            "Could not create roster item for user "
                + newUser.getUsername()
                + "  because it is a contact from a shared group.",
            newUser.getUsername(),
            ExceptionType.USER_NOT_FOUND_EXCEPTION,
            Response.Status.NOT_FOUND,
            e);
      }
    }
  }
Exemplo n.º 9
0
  public void setPresenceState(String jid, UnifiedPresence.XmppPresence xmppPresence)
      throws UserNotFoundException {
    log.debug("setPresenceState : " + jid + " XmppPresence = " + xmppPresence);
    if (jid == null) {
      throw new UserNotFoundException("Target JID not found in request");
    }
    JID targetJID = new JID(jid);
    // Check that the sender is not requesting information of a remote server entity
    if (targetJID.getDomain() == null || XMPPServer.getInstance().isRemote(targetJID)) {
      throw new UserNotFoundException("Domain does not matches local server domain");
    }
    User user = userManager.getUser(targetJID.getNode());
    Presence presence = presenceManager.getPresence(user);
    if (presence == null) {
      log.debug("User is OFFLINE  -- cannot set presence state");
      return;
    }

    presence.setShow(xmppPresence.asPresenceShowEnum());
    user.getRoster().broadcastPresence(presence);
  }
  /**
   * Copy roster.
   *
   * @param currentUser the current user
   * @param newUser the new user
   * @param currentUserName the current user name
   * @throws ServiceException the service exception
   */
  private static void copyRoster(User currentUser, User newUser, String currentUserName)
      throws ServiceException {
    Roster newRoster = newUser.getRoster();
    Roster currentRoster = currentUser.getRoster();
    for (RosterItem item : currentRoster.getRosterItems()) {
      try {
        List<String> groups = item.getGroups();

        RosterItem justCreated =
            newRoster.createRosterItem(item.getJid(), item.getNickname(), groups, true, true);
        justCreated.setAskStatus(item.getAskStatus());
        justCreated.setRecvStatus(item.getRecvStatus());
        justCreated.setSubStatus(item.getSubStatus());

        for (Group gr : item.getSharedGroups()) {
          justCreated.addSharedGroup(gr);
        }

        for (Group gr : item.getInvisibleSharedGroups()) {
          justCreated.addInvisibleSharedGroup(gr);
        }
        newRoster.updateRosterItem(justCreated);
        addNewUserToOthersRoster(newUser, item, currentUserName);

      } catch (UserAlreadyExistsException e) {
        throw new ServiceException(
            "Could not create roster item for user ",
            newUser.getUsername(),
            ExceptionType.USER_ALREADY_EXISTS_EXCEPTION,
            Response.Status.CONFLICT,
            e);
      } catch (SharedGroupException e) {
        throw new ServiceException(
            "Could not create roster item, because it is a contact from a shared group",
            newUser.getUsername(),
            ExceptionType.USER_ALREADY_EXISTS_EXCEPTION,
            Response.Status.BAD_REQUEST,
            e);
      } catch (UserNotFoundException e) {
        throw new ServiceException(
            "Could not update roster item for user "
                + newUser.getUsername()
                + " because it was not properly created.",
            newUser.getUsername(),
            ExceptionType.USER_NOT_FOUND_EXCEPTION,
            Response.Status.NOT_FOUND,
            e);
      }
    }
  }
 /**
  * Copy properties.
  *
  * @param currentUser the current user
  * @param newUser the new user
  */
 private static void copyProperties(User currentUser, User newUser) {
   for (String key : currentUser.getProperties().keySet()) {
     newUser.getProperties().put(key, User.getPropertyValue(currentUser.getUsername(), key));
   }
 }
Exemplo n.º 12
0
  public void _jspService(HttpServletRequest request, HttpServletResponse response)
      throws java.io.IOException, ServletException {

    JspFactory _jspxFactory = null;
    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;

    try {
      _jspxFactory = JspFactory.getDefaultFactory();
      response.setContentType("text/html");
      pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("\n\n\n\n\n\n\n\n\n\n\n");
      org.jivesoftware.util.WebManager webManager = null;
      synchronized (_jspx_page_context) {
        webManager =
            (org.jivesoftware.util.WebManager)
                _jspx_page_context.getAttribute("webManager", PageContext.PAGE_SCOPE);
        if (webManager == null) {
          webManager = new org.jivesoftware.util.WebManager();
          _jspx_page_context.setAttribute("webManager", webManager, PageContext.PAGE_SCOPE);
        }
      }
      out.write('\n');

      webManager.init(request, response, session, application, out);
      DBManager dbManager = DBManager.getInstance();
      Iterator<User> users = webManager.getUserManager().getUsers().iterator();

      Msn msn = null;
      // Get Action
      boolean create = request.getParameter("create") != null;
      boolean cancel = request.getParameter("cancel") != null;

      // Get data

      Map<String, String> errors = new HashMap<String, String>();

      if (cancel) {
        String user = request.getParameter("user");
        if (user != null & !"".equals(user)) {
          response.sendRedirect("pf-main.jsp?user="******"pf-main.jsp");
        }
        return;
      }
      if (create) {
        String input_jid = null;
        try {
          input_jid = request.getParameter("jid");
          String input_msn = request.getParameter("msn");
          String input_enable = request.getParameter("enable");
          if (input_jid == null || "".equals(input_jid)) {
            errors.put("add_msn_error", "jid can not be null");
          }

          if (input_msn == null || "".equals(input_msn)) {
            errors.put("add_msn_error", "msn can not be null");
          }

          int enable = 0;
          if (input_enable == null) {
            enable = 0;
          } else {
            enable = 1;
          }

          dbManager.addMsn(input_jid, input_msn, enable);
        } catch (Exception e) {
          Log.error(e);
          errors.put("add_msn_error", e.getLocalizedMessage());
        }
        if (errors.isEmpty()) {
          response.sendRedirect("pf-main.jsp?user="******"\n<html>\n<head>\n    <title>\n        ");
      if (_jspx_meth_fmt_message_0(_jspx_page_context)) return;
      out.write(
          "\n\n    </title>\n    <meta name=\"pageID\" content=\"addMsn\"/>\n    <script language=\"JavaScript\" type=\"text/javascript\" src=\"scripts/packetfilter.js\"></script>\n</head>\n<body>\n\n");
      if (!errors.isEmpty()) {
        out.write(
            "\n\n<div class=\"jive-error\">\n    <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n        <tbody>\n        <tr>\n            <td class=\"jive-icon\"><img src=\"/images/error-16x16.gif\" width=\"16\" height=\"16\" border=\"0\"/></td>\n            <td class=\"jive-icon-label\">\n\n                ");
        if (errors.get("add_msn_error") != null) {
          out.write("\n                ");
          out.print(errors.get("add_msn_error"));
          out.write("\n                ");
        }
        out.write(
            "\n            </td>\n        </tr>\n        </tbody>\n    </table>\n</div>\n<br>\n\n");
      }
      out.write(
          "\n\n<form action=\"msn-form.jsp\" method=\"get\">\n    <div class=\"jive-table\">\n        <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\n            <tbody>\n            <tr class=\"jive-even\">\n                <td>JID</td>\n                <td>\n                    <select name=\"jid\" id=\"jid\">\n                        ");

      if (users != null) {
        while (users.hasNext()) {
          User user = users.next();
          out.write("\n                            <option value=\"");
          out.print(user.getUsername());
          out.write('"');
          out.write('>');
          out.print(user.getUsername());
          out.write("</option>\n                        ");
        }
      }

      out.write("\n                    </select>\n\n\n                   ");
      // <input type="text" name="jid" value="" size="40"/>
      out.write(
          "\n                </td>\n            </tr>\n            <tr class=\"jive-odd\">\n                <td>Msn</td>\n                <td>\n                    <input type=\"text\" name=\"msn\" value=\"\" size=\"40\"/>\n                </td>\n\n            </tr>\n            <tr class=\"jive-even\">\n                <td>Enable</td>\n                <td>\n                    <input type=\"checkbox\" name=\"enable\" value=\"true\" checked>\n                </td>\n\n            </tr>\n\n\n            <tr>\n                <td>\n                    <input type=\"submit\" name=\"create\" value=\"");
      if (_jspx_meth_fmt_message_1(_jspx_page_context)) return;
      out.write("\">\n                    <input type=\"submit\" name=\"cancel\" value=\"");
      if (_jspx_meth_fmt_message_2(_jspx_page_context)) return;
      out.write(
          "\">\n                </td>\n                <td>&nbsp;</td>\n            </tr>\n            </tbody>\n        </table>\n\n    </div>\n</form>\n\n</body>\n</html>\n\n");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)) {
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0) out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
Exemplo n.º 13
0
  public void _jspService(HttpServletRequest request, HttpServletResponse response)
      throws java.io.IOException, ServletException {

    JspFactory _jspxFactory = null;
    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;

    try {
      _jspxFactory = JspFactory.getDefaultFactory();
      response.setContentType("text/html");
      pageContext =
          _jspxFactory.getPageContext(this, request, response, "error.jsp", true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("\n\n\n\n\n\n\n\n\n");
      out.write('\n');
      org.jivesoftware.util.WebManager webManager = null;
      synchronized (_jspx_page_context) {
        webManager =
            (org.jivesoftware.util.WebManager)
                _jspx_page_context.getAttribute("webManager", PageContext.PAGE_SCOPE);
        if (webManager == null) {
          webManager = new org.jivesoftware.util.WebManager();
          _jspx_page_context.setAttribute("webManager", webManager, PageContext.PAGE_SCOPE);
        }
      }
      out.write('\n');
      webManager.init(request, response, session, application, out);
      out.write('\n');
      out.write('\n');
      // Get paramters
      boolean doTest = request.getParameter("test") != null;
      boolean cancel = request.getParameter("cancel") != null;
      boolean sent = ParamUtils.getBooleanParameter(request, "sent");
      boolean success = ParamUtils.getBooleanParameter(request, "success");
      String from = ParamUtils.getParameter(request, "from");
      String to = ParamUtils.getParameter(request, "to");
      String subject = ParamUtils.getParameter(request, "subject");
      String body = ParamUtils.getParameter(request, "body");

      // Cancel if requested
      if (cancel) {
        response.sendRedirect("system-email.jsp");
        return;
      }

      // Variable to hold messaging exception, if one occurs
      Exception mex = null;

      // Validate input
      Map<String, String> errors = new HashMap<String, String>();
      if (doTest) {
        if (from == null) {
          errors.put("from", "");
        }
        if (to == null) {
          errors.put("to", "");
        }
        if (subject == null) {
          errors.put("subject", "");
        }
        if (body == null) {
          errors.put("body", "");
        }

        EmailService service = EmailService.getInstance();

        // Validate host - at a minimum, it needs to be set:
        String host = service.getHost();
        if (host == null) {
          errors.put("host", "");
        }

        // if no errors, continue
        if (errors.size() == 0) {
          // Create a message
          MimeMessage message = service.createMimeMessage();
          // Set the date of the message to be the current date
          SimpleDateFormat format =
              new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", java.util.Locale.US);
          format.setTimeZone(JiveGlobals.getTimeZone());
          message.setHeader("Date", format.format(new Date()));

          // Set to and from.
          message.setRecipient(Message.RecipientType.TO, new InternetAddress(to, null));
          message.setFrom(new InternetAddress(from, null));
          message.setSubject(subject);
          message.setText(body);
          // Send the message, wrap in a try/catch:
          try {
            service.sendMessagesImmediately(Collections.singletonList(message));
            // success, so indicate this:
            response.sendRedirect("system-emailtest.jsp?sent=true&success=true");
            return;
          } catch (MessagingException me) {
            me.printStackTrace();
            mex = me;
          }
        }
      }

      // Set var defaults
      Collection<JID> jids = webManager.getXMPPServer().getAdmins();
      User user = null;
      if (!jids.isEmpty()) {
        for (JID jid : jids) {
          if (webManager.getXMPPServer().isLocal(jid)) {
            user = webManager.getUserManager().getUser(jid.getNode());
            if (user.getEmail() != null) {
              break;
            }
          }
        }
      }
      if (from == null) {
        from = user.getEmail();
      }
      if (to == null) {
        to = user.getEmail();
      }
      if (subject == null) {
        subject = "Test email sent via Openfire";
      }
      if (body == null) {
        body = "This is a test message.";
      }

      out.write("\n\n<html>\n    <head>\n        <title>");
      if (_jspx_meth_fmt_message_0(_jspx_page_context)) return;
      out.write(
          "</title>\n        <meta name=\"pageID\" content=\"system-email\"/>\n    </head>\n    <body>\n\n<script language=\"JavaScript\" type=\"text/javascript\">\nvar clicked = false;\nfunction checkClick(el) {\n    if (!clicked) {\n        clicked = true;\n        return true;\n    }\n    return false;\n}\n</script>\n\n<p>\n");
      if (_jspx_meth_fmt_message_1(_jspx_page_context)) return;
      out.write("\n</p>\n\n");
      if (JiveGlobals.getProperty("mail.smtp.host") == null) {
        out.write(
            "\n\n    <div class=\"jive-error\">\n    <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n    <tbody>\n        <tr>\n        \t<td class=\"jive-icon\"><img src=\"images/error-16x16.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"\"></td>\n\t        <td class=\"jive-icon-label\">\n\t\t        ");
        if (_jspx_meth_fmt_message_2(_jspx_page_context)) return;
        out.write("\n\t        </td>\n        </tr>\n    </tbody>\n    </table>\n    </div>\n\n");
      }
      out.write('\n');
      out.write('\n');
      if (doTest || sent) {
        out.write("\n\n    ");
        if (success) {
          out.write(
              "\n\n        <div class=\"jive-success\">\n        <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n        <tbody>\n            <tr>\n            \t<td class=\"jive-icon\"><img src=\"images/success-16x16.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"\"></td>\n            \t<td class=\"jive-icon-label\">");
          if (_jspx_meth_fmt_message_3(_jspx_page_context)) return;
          out.write(
              "</td>\n            </tr>\n        </tbody>\n        </table>\n        </div>\n\n    ");
        } else {
          out.write(
              "\n\n        <div class=\"jive-error\">\n        <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n        <tbody>\n            <tr><td class=\"jive-icon\"><img src=\"images/error-16x16.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"\"></td>\n            <td class=\"jive-icon-label\">\n                ");
          if (_jspx_meth_fmt_message_4(_jspx_page_context)) return;
          out.write("\n                ");
          if (mex != null) {
            out.write("\n                    ");
            if (mex instanceof AuthenticationFailedException) {
              out.write("\n                    \t");
              if (_jspx_meth_fmt_message_5(_jspx_page_context)) return;
              out.write("                        \n                    ");
            } else {
              out.write("\n                        (Message: ");
              out.print(mex.getMessage());
              out.write(")\n                    ");
            }
            out.write("\n                ");
          }
          out.write(
              "\n            </td></tr>\n        </tbody>\n        </table>\n        </div>\n\n    ");
        }
        out.write("\n\n    <br>\n\n");
      }
      out.write(
          "\n\n<form action=\"system-emailtest.jsp\" method=\"post\" name=\"f\" onsubmit=\"return checkClick(this);\">\n\n<table cellpadding=\"3\" cellspacing=\"0\" border=\"0\">\n<tbody>\n    <tr>\n        <td>\n            ");
      if (_jspx_meth_fmt_message_6(_jspx_page_context)) return;
      out.write(":\n        </td>\n        <td>\n            ");
      String host = JiveGlobals.getProperty("mail.smtp.host");
      if (host == null) {

        out.write("\n                <i>");
        if (_jspx_meth_fmt_message_7(_jspx_page_context)) return;
        out.write("</i>\n            ");

      } else {

        out.write("\n                ");
        out.print(host);
        out.write(':');
        out.print(JiveGlobals.getIntProperty("mail.smtp.port", 25));
        out.write("\n\n                ");
        if (JiveGlobals.getBooleanProperty("mail.smtp.ssl", false)) {
          out.write("\n\n                    (");
          if (_jspx_meth_fmt_message_8(_jspx_page_context)) return;
          out.write(")\n\n                ");
        }
        out.write("\n            ");
      }
      out.write("\n        </td>\n    </tr>\n    <tr>\n        <td>\n            ");
      if (_jspx_meth_fmt_message_9(_jspx_page_context)) return;
      out.write(
          ":\n        </td>\n        <td>\n            <input type=\"hidden\" name=\"from\" value=\"");
      out.print(from);
      out.write("\">\n            ");
      out.print(StringUtils.escapeHTMLTags(from));
      out.write(
          "\n            <span class=\"jive-description\">\n            (<a href=\"user-edit-form.jsp?username="******"\">Update Address</a>)\n            </span>\n        </td>\n    </tr>\n    <tr>\n        <td>\n            ");
      if (_jspx_meth_fmt_message_10(_jspx_page_context)) return;
      out.write(
          ":\n        </td>\n        <td>\n            <input type=\"text\" name=\"to\" value=\"");
      out.print(((to != null) ? to : ""));
      out.write(
          "\"\n             size=\"40\" maxlength=\"100\">\n        </td>\n    </tr>\n    <tr>\n        <td>\n            ");
      if (_jspx_meth_fmt_message_11(_jspx_page_context)) return;
      out.write(
          ":\n        </td>\n        <td>\n            <input type=\"text\" name=\"subject\" value=\"");
      out.print(((subject != null) ? subject : ""));
      out.write(
          "\"\n             size=\"40\" maxlength=\"100\">\n        </td>\n    </tr>\n    <tr valign=\"top\">\n        <td>\n            ");
      if (_jspx_meth_fmt_message_12(_jspx_page_context)) return;
      out.write(
          ":\n        </td>\n        <td>\n            <textarea name=\"body\" cols=\"45\" rows=\"5\" wrap=\"virtual\">");
      out.print(body);
      out.write(
          "</textarea>\n        </td>\n    </tr>\n    <tr>\n        <td colspan=\"2\">\n            <br>\n            <input type=\"submit\" name=\"test\" value=\"");
      if (_jspx_meth_fmt_message_13(_jspx_page_context)) return;
      out.write("\">\n            <input type=\"submit\" name=\"cancel\" value=\"");
      if (_jspx_meth_fmt_message_14(_jspx_page_context)) return;
      out.write(
          "\">\n        </td>\n    </tr>\n</tbody>\n</table>\n\n</form>\n\n    </body>\n</html>");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)) {
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0) out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
  /**
   * Change name.
   *
   * @param currentUserName the current user name
   * @param newUserName the new user name
   * @param deleteOldUser the delete old user
   * @param newEmail the new email
   * @param newRealName the new real name
   * @return true, if successful
   * @throws ServiceException the service exception
   */
  public static boolean changeName(
      String currentUserName,
      String newUserName,
      boolean deleteOldUser,
      String newEmail,
      String newRealName)
      throws ServiceException {
    UserManager userManager = UserManager.getInstance();

    try {
      User currentUser = userManager.getUser(currentUserName);
      // Old user found, create new one
      String password = AuthFactory.getPassword(currentUserName);
      String newName =
          (newRealName == null || newRealName.length() == 0) ? currentUser.getName() : newRealName;
      String newMail =
          (newEmail == null || newEmail.length() == 0) ? currentUser.getEmail() : newEmail;
      User newUser = userManager.createUser(newUserName, password, currentUser.getName(), newMail);
      newUser.setName(newName);
      newUser.setNameVisible(currentUser.isNameVisible());
      newUser.setEmailVisible(currentUser.isEmailVisible());
      newUser.setCreationDate(currentUser.getCreationDate());

      copyRoster(currentUser, newUser, currentUserName);
      copyProperties(currentUser, newUser);
      copyToGroups(currentUserName, newUserName);
      copyVCard(currentUserName, newUserName);
      if (deleteOldUser) {
        deleteUser(currentUser);
      }

    } catch (UserNotFoundException e) {
      throw new ServiceException(
          "Could not find user",
          currentUserName,
          ExceptionType.USER_NOT_FOUND_EXCEPTION,
          Response.Status.NOT_FOUND,
          e);
    } catch (UserAlreadyExistsException e) {
      throw new ServiceException(
          "Could not create new user",
          newUserName,
          ExceptionType.USER_ALREADY_EXISTS_EXCEPTION,
          Response.Status.CONFLICT,
          e);
    }
    return true;
  }
Exemplo n.º 15
0
 public void setSipPassword(String userName, String sipPassword) throws UserNotFoundException {
   User user = userManager.getUser(userName);
   user.getProperties().put(SIP_PWD, sipPassword);
 }
Exemplo n.º 16
0
 public String getSipPassword(String userName) throws UserNotFoundException {
   User user = userManager.getUser(userName);
   return user.getProperties().get(SIP_PWD);
 }
Exemplo n.º 17
0
 public void setSipId(String userName, String sipUserName) throws UserNotFoundException {
   User user = userManager.getUser(userName);
   user.getProperties().put(SIP_UID, sipUserName);
   user.getProperties().put(ON_THE_PHONE_MESSAGE, "I am on the phone");
   this.sipIdToXmppIdMap.put(sipUserName, userName);
 }
Exemplo n.º 18
0
  public void chatSupportFinished(Workgroup workgroup, String sessionID) {
    Log.debug("Chat Support Finished, sending transcripts");

    final EmailService emailService = EmailService.getInstance();

    String property = JiveGlobals.getProperty("mail.configured");
    if (!ModelUtil.hasLength(property)) {
      Log.debug("Mail settings are not configured, transcripts will not be sent.");
      return;
    }

    final ChatSession chatSession = ChatTranscriptManager.getChatSession(sessionID);
    if (chatSession == null || chatSession.getFirstSession() == null) {
      return;
    }

    final StringBuilder builder = new StringBuilder();

    SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyy hh:mm a");

    // Get duration of conversation
    Date date = new Date(chatSession.getFirstSession().getStartTime());
    int duration = getChatDuration(date, chatSession);

    TreeMap<String, List<String>> map =
        new TreeMap<String, List<String>>(chatSession.getMetadata());

    String body = JiveGlobals.getProperty("chat.transcript.body");

    if (ModelUtil.hasLength(body)) {
      builder.append(body).append("\n\n");
    }

    builder.append("formname=chat transcript\n");
    extractAndDisplay(builder, "question", map);
    display(builder, "fullname", chatSession.getCustomerName());
    extractAndDisplay(builder, "email", map);
    extractAndDisplay(builder, "Location", map);
    extractAndDisplay(builder, "userID", map);
    extractAndDisplay(builder, "username", map);
    extractAndDisplay(builder, "workgroup", map);
    display(builder, "chatduration", String.valueOf(duration));
    display(builder, "chatdate", formatter.format(date));
    if (chatSession.getFirstSession() != null
        && chatSession.getFirstSession().getAgentJID() != null) {
      try {
        display(builder, "agent", new JID(chatSession.getFirstSession().getAgentJID()).toBareJID());
      } catch (Exception e) {
        Log.debug("Could not display agent in transcript.", e);
      }
    }
    for (Iterator<Map.Entry<String, List<String>>> iterator = map.entrySet().iterator();
        iterator.hasNext(); ) {
      Map.Entry<String, List<String>> entry = iterator.next();
      display(builder, entry.getKey(), getListItem(entry.getValue()));
    }
    builder.append("ctranscript=\n");
    builder.append(ChatTranscriptManager.getTextTranscriptFromSessionID(sessionID));

    String subject = JiveGlobals.getProperty("chat.transcript.subject");
    String from = JiveGlobals.getProperty("chat.transcript.from");
    String to = JiveGlobals.getProperty("chat.transcript.to");

    if (!ModelUtil.hasLength(subject) || !ModelUtil.hasLength(from)) {
      Log.debug(
          "Transcript settings (chat.transcript.subject, chat.transcript.from) are not configured, "
              + "transcripts will not be sent.");
      return;
    }

    if (ModelUtil.hasLength(to)) {
      emailService.sendMessage(
          "Chat Transcript", to, "Chat Transcript", from, subject, builder.toString(), null);
      Log.debug("Transcript sent to " + to);
    }

    // NOTE: Do not sent to the customer. They will receive a prompt for a seperate chat transcript
    // that does not contain agent information.

    // Send to Agents
    UserManager um = UserManager.getInstance();
    for (Iterator<AgentChatSession> iterator = chatSession.getAgents(); iterator.hasNext(); ) {
      AgentChatSession agentSession = iterator.next();
      try {
        User user = um.getUser(new JID(agentSession.getAgentJID()).getNode());
        emailService.sendMessage(
            "Chat Transcript",
            user.getEmail(),
            "Chat Transcript",
            from,
            subject,
            builder.toString(),
            null);
        Log.debug("Transcript sent to agent " + agentSession.getAgentJID());
      } catch (UserNotFoundException e) {
        Log.error(
            "Email Transcript Not Sent:"
                + "Could not load agent user object for jid "
                + agentSession.getAgentJID());
      }
    }
  }
Exemplo n.º 19
0
 @Override
 public void userDeleting(User user, Map params) {
   // Delete all offline messages of the user
   deleteMessages(user.getUsername());
 }