Exemple #1
0
 /** Check GMail for new mail. */
 @Override
 public void run() {
   if (getTransport().getType().equals(TransportType.gtalk)
       && JiveGlobals.getBooleanProperty("plugin.gateway.gtalk.mailnotifications", true)) {
     GoogleMailNotifyExtension gmne = new GoogleMailNotifyExtension();
     gmne.setNewerThanTime(listener.getLastGMailThreadDate());
     gmne.setNewerThanTid(listener.getLastGMailThreadId());
     conn.sendPacket(
         new IQWithPacketExtension(generateFullJID(getRegistration().getUsername()), gmne));
   }
 }
  private void updateClearspaceClientSettings() {
    String xmppBoshSslPort = "0";
    String xmppBoshPort = "0";
    String xmppPort =
        String.valueOf(XMPPServer.getInstance().getConnectionManager().getClientListenerPort());
    if (JiveGlobals.getBooleanProperty(
        HttpBindManager.HTTP_BIND_ENABLED, HttpBindManager.HTTP_BIND_ENABLED_DEFAULT)) {
      int boshSslPort = HttpBindManager.getInstance().getHttpBindSecurePort();
      int boshPort = HttpBindManager.getInstance().getHttpBindUnsecurePort();
      try {
        if (HttpBindManager.getInstance().isHttpsBindActive()
            && LocalClientSession.getTLSPolicy()
                != org.jivesoftware.openfire.Connection.TLSPolicy.disabled) {
          xmppBoshSslPort = String.valueOf(boshSslPort);
        }
      } catch (Exception e) {
        // Exception while working with certificate
        Log.debug(
            "Error while checking SSL certificate.  Instructing Clearspace not to use SSL port.");
      }
      if (HttpBindManager.getInstance().isHttpBindActive() && boshPort > 0) {
        xmppBoshPort = String.valueOf(boshPort);
      }
    }

    try {
      String path = CHAT_URL_PREFIX + "updateClientSettings/";

      // Creates the XML with the data
      Document groupDoc = DocumentHelper.createDocument();
      Element rootE = groupDoc.addElement("updateClientSettings");
      rootE.addElement("boshSslPort").setText(xmppBoshSslPort);
      rootE.addElement("boshPort").setText(xmppBoshPort);
      rootE.addElement("tcpPort").setText(xmppPort);

      executeRequest(POST, path, groupDoc.asXML());
    } catch (UnauthorizedException ue) {
      Log.error("Error updating the client settings of Clearspace", ue);
    } catch (Exception e) {
      Log.error("Error updating the client settings of Clearspace", e);
    }
  }
 public IQOwnerHandler(LocalMUCRoom chatroom, PacketRouter packetRouter) {
   this.room = chatroom;
   this.router = packetRouter;
   this.skipInvite = JiveGlobals.getBooleanProperty("xmpp.muc.skipInvite", false);
   init();
 }
  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("\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\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('\r');
      out.write('\n');

      webManager.init(request, response, session, application, out);
      boolean save = request.getParameter("save") != null;
      boolean success = request.getParameter("success") != null;
      String persistentRosterParam = request.getParameter("persistentEnabled");
      boolean persistentRoster =
          persistentRosterParam == null ? false : persistentRosterParam.equals("true");

      String ignoreSubdomainsParam = request.getParameter("ignoreSubdomains");
      boolean ignnoreSubdomains =
          ignoreSubdomainsParam == null ? false : ignoreSubdomainsParam.equals("true");
      String blockPresencesParam = request.getParameter("blockPresences");
      boolean blockPresences =
          blockPresencesParam == null ? false : blockPresencesParam.equals("true");

      String sparkdiscoParam = request.getParameter("sparkDiscoInfo");
      boolean sparkDiscoInfo = sparkdiscoParam == null ? false : sparkdiscoParam.equals("true");

      String iqLastFilterPram = request.getParameter("iqLastFilter");
      boolean iqLastFilter = iqLastFilterPram == null ? false : iqLastFilterPram.equals("true");

      String mucFilterParam = request.getParameter("mucFilter");
      boolean mucFilter = mucFilterParam == null ? false : mucFilterParam.equals("true");

      String gajimBroadcastParam = request.getParameter("gajimBroadcast");
      boolean gajimBroadcast =
          gajimBroadcastParam == null ? false : gajimBroadcastParam.equals("true");

      String[] componentsEnabled = request.getParameterValues("enabledComponents[]");
      PermissionManager _pmanager = new PermissionManager();
      DatabaseManager _db;

      Map<String, String> errors = new HashMap<String, String>();
      if (save) {
        for (String property : JiveGlobals.getPropertyNames("plugin.remoteroster.jids")) {
          JiveGlobals.deleteProperty(property);
        }
        if (componentsEnabled != null) {
          for (int i = 0; i < componentsEnabled.length; i++) {
            JiveGlobals.setProperty("plugin.remoteroster.jids." + componentsEnabled[i], "true");
            String group = request.getParameter("input_group." + componentsEnabled[i]);
            if (group != null) {
              _pmanager.setGroupForGateway(componentsEnabled[i], group);
            }
          }
        }
        JiveGlobals.setProperty(
            "plugin.remoteroster.persistent", (persistentRoster ? "true" : "false"));
        JiveGlobals.setProperty(
            "plugin.remoteroster.blockPresences", (blockPresences ? "true" : "false"));
        JiveGlobals.setProperty(
            "plugin.remoteroster.sparkDiscoInfo", (sparkDiscoInfo ? "true" : "false"));
        JiveGlobals.setProperty(
            "plugin.remoteroster.iqLastFilter", (iqLastFilter ? "true" : "false"));
        JiveGlobals.setProperty("plugin.remoteroster.mucFilter", (mucFilter ? "true" : "false"));
        JiveGlobals.setProperty(
            "plugin.remoteroster.gajimBroadcast", (gajimBroadcast ? "true" : "false"));
        JiveGlobals.setProperty(
            "plugin.remoteroster.ignoreSubdomains", (ignnoreSubdomains ? "true" : "false"));
        response.sendRedirect("rr-main.jsp?success=true");
        return;
      }

      // Get the session manager
      SessionManager sessionManager = webManager.getSessionManager();

      Collection<ComponentSession> sessions = sessionManager.getComponentSessions();

      _db = DatabaseManager.getInstance();

      out.write(
          "\r\n\r\n<html>\r\n<head>\r\n<title>Gojara Settings</title>\r\n<link href=\"./css/rr.css\" rel=\"stylesheet\" type=\"text/css\">\r\n<script src=\"./js/http.js\" type=\"text/javascript\"></script>\r\n<script src=\"./js/jquery.js\" type=\"text/javascript\"></script>\r\n<script src=\"./js/rr.js\" type=\"text/javascript\"></script>\r\n<script src=\"./js/jquery.sparkline.js\" type=\"text/javascript\"></script>\r\n<script src=\"./js/jquery.horiz-bar-graph.js\" type=\"text/javascript\"></script>\r\n<!--[if lte IE 8]><script language=\"javascript\" type=\"text/javascript\" src=\"./js/excanvas.min.js\"></script><![endif]-->\r\n<script language=\"javascript\" type=\"text/javascript\" src=\"./js/jquery.flot.js\"></script>\r\n<script language=\"javascript\" type=\"text/javascript\" src=\"./js/jquery.flot.pie.js\"></script>\r\n\r\n<meta name=\"pageID\" content=\"remoteRoster\" />\r\n<meta name=\"helpPage\" content=\"\" />\r\n\r\n</head>\r\n<body>\r\n\r\n\t<p>Any components configured here will allow the external component associated with them full control over their\r\n\t\tdomain within any user's roster. Before enabling Remote Roster Management support for an external component, first\r\n");
      out.write(
          "\t\tconnect it like you would any external component. Once it has connected and registered with Openfire, it's JID should\r\n\t\tshow up below and you can enable Remote Roster support.</p>\r\n\r\n\t");

      if (success) {

        out.write(
            "\r\n\r\n\t<div class=\"jive-success\">\r\n\t\t<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\r\n\t\t\t<tbody>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td class=\"jive-icon\"><img src=\"images/success-16x16.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"\"></td>\r\n\t\t\t\t\t<td class=\"jive-icon-label\">Settings saved!</td>\r\n\t\t\t\t</tr>\r\n\t\t\t</tbody>\r\n\t\t</table>\r\n\t</div>\r\n\t<br>\r\n\r\n\t");

      } else if (errors.size() > 0) {

        out.write(
            "\r\n\r\n\t<div class=\"jive-error\">\r\n\t\t<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\r\n\t\t\t<tbody>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td class=\"jive-icon\"><img src=\"images/error-16x16.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"\"></td>\r\n\t\t\t\t\t<td class=\"jive-icon-label\">Error saving settings!</td>\r\n\t\t\t\t</tr>\r\n\t\t\t</tbody>\r\n\t\t</table>\r\n\t</div>\r\n\t<br>\r\n\r\n\t");
      }

      out.write(
          "\r\n\r\n\t<form action=\"rr-main.jsp?save\" method=\"post\">\r\n\r\n\t\t<div class=\"jive-contentBoxHeader\">Connected Gateway Components</div>\r\n\t\t<div class=\"jive-contentBox\">\r\n\r\n\t\t\t<p>Select which components you want to enable remote roster on:</p>\r\n\t\t\t");

      boolean gatewayFound = false;
      int i = 0;
      for (ComponentSession componentSession : sessions) {
        if (!componentSession.getExternalComponent().getCategory().equals("gateway")) {
          continue;
        }
        gatewayFound = true;

        long incoming = componentSession.getNumClientPackets();
        long outgoing = componentSession.getNumServerPackets();
        long both = incoming + outgoing;
        int incomingPercent = (int) (incoming * 100 / both);
        int outgoingPercent = (int) (outgoing * 100 / both);

        out.write(
            "\r\n\t\t\t<table class=\"gatewayHeader\">\r\n\t\t\t\t<tbody>\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<td class=\"gatewayCheckbox\"><input type=\"checkbox\" name=\"enabledComponents[]\"\r\n\t\t\t\t\t\t\tvalue=\"");
        out.print(componentSession.getExternalComponent().getInitialSubdomain());
        out.write("\"\r\n\t\t\t\t\t\t\t");
        out.print(
            JiveGlobals.getBooleanProperty(
                    "plugin.remoteroster.jids."
                        + componentSession.getExternalComponent().getInitialSubdomain(),
                    false)
                ? "checked=\"checked\""
                : "");
        out.write(" />\r\n\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t<td class=\"gatewayName\">");
        out.print(componentSession.getExternalComponent().getName());
        out.write(
            "</td>\r\n\t\t\t\t\t\t<td class=\"gatewayIcons\"><img src=\"images/log-16x16.png\" onclick=\"slideToggle('#logs");
        out.print(i);
        out.write(
            "')\"><img\r\n\t\t\t\t\t\t\tsrc=\"images/permissions-16x16.png\" id=\"showPermissions\" onclick=\"slideToggle('#permission");
        out.print(i);
        out.write(
            "')\"><img\r\n\t\t\t\t\t\t\tsrc=\"images/info-16x16.png\" id=\"showConfig\" onclick=\"slideToggle('#config");
        out.print(i);
        out.write(
            "')\"></td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t</tbody>\r\n\t\t\t</table>\r\n\t\t\t<div id=\"config");
        out.print(i);
        out.write(
            "\" class=\"slider\">\r\n\t\t\t\t<div class=\"sildeHeader\">Information</div>\r\n\t\t\t\t<table class=\"configTable\">\r\n\t\t\t\t\t<tbody>\r\n\t\t\t\t\t\t<tr id=\"logodd\">\r\n\t\t\t\t\t\t\t<td width=\"200px\">Domain:</td>\r\n\t\t\t\t\t\t\t<td>");
        out.print(componentSession.getExternalComponent().getInitialSubdomain());
        out.write(
            "</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr id=\"logeven\">\r\n\t\t\t\t\t\t\t<td>Status:</td>\r\n\t\t\t\t\t\t\t<td>Online</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr id=\"logodd\">\r\n\t\t\t\t\t\t\t<td>Packages Send/Received:</td>\r\n\t\t\t\t\t\t\t<td><dl class=\"browser-data\" title=\"\">\r\n\t\t\t\t\t\t\t\t\t<dt>Incoming</dt>\r\n\t\t\t\t\t\t\t\t\t<dd>");
        out.print(incomingPercent);
        out.write("</dd>\r\n\t\t\t\t\t\t\t\t\t<dt>Outgoing</dt>\r\n\t\t\t\t\t\t\t\t\t<dd>");
        out.print(outgoingPercent);
        out.write(
            "</dd>\r\n\t\t\t\t\t\t\t\t</dl></td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t</tbody>\r\n\t\t\t\t</table>\r\n\t\t\t</div>\r\n\t\t\t<div id=\"permission");
        out.print(i);
        out.write(
            "\" class=\"slider\">\r\n\t\t\t\t<div class=\"sildeHeader\">Access control</div>\r\n\t\t\t\t<table class=\"groupTable\">\r\n\t\t\t\t\t<tbody>\r\n\t\t\t\t\t\t<tr id=\"loghead\">\r\n\t\t\t\t\t\t\t<td colspan=\"3\">You can limit the access to the external component to an existing group</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td class=\"permissionTableColumn\">Groupname:</td>\r\n\t\t\t\t\t\t\t<td><input class=\"groupInput\" type=\"text\" id=\"groupSearch");
        out.print(i);
        out.write("\"\r\n\t\t\t\t\t\t\t\tname=\"input_group.");
        out.print(componentSession.getExternalComponent().getInitialSubdomain());
        out.write("\" alt=\"Find Groups\"\r\n\t\t\t\t\t\t\t\tonkeyup=\"searchSuggest('");
        out.print(i);
        out.write("');\" autocomplete=\"off\"\r\n\t\t\t\t\t\t\t\tvalue=\"");
        out.print(
            _pmanager.getGroupForGateway(
                componentSession.getExternalComponent().getInitialSubdomain()));
        out.write("\">\r\n\t\t\t\t\t\t\t\t<div id=\"search_suggest");
        out.print(i);
        out.write(
            "\"></div></td>\r\n\t\t\t\t\t\t\t<td style=\"vertical-align: top;\">\r\n\t\t\t\t\t\t\t\t<div class=\"ajaxloading\" id=\"ajaxloading");
        out.print(i);
        out.write(
            "\"></div>\r\n\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t</tbody>\r\n\t\t\t\t</table>\r\n\t\t\t</div>\r\n\t\t\t<div id=\"logs");
        out.print(i);
        out.write("\" class=\"slider\">\r\n\t\t\t\t");

        int iqs =
            _db.getPacketCount(
                componentSession.getExternalComponent().getInitialSubdomain(),
                Class.forName("org.xmpp.packet.IQ"));
        int msgs =
            _db.getPacketCount(
                componentSession.getExternalComponent().getInitialSubdomain(),
                Class.forName("org.xmpp.packet.Message"));
        int rosters =
            _db.getPacketCount(
                componentSession.getExternalComponent().getInitialSubdomain(),
                Class.forName("org.xmpp.packet.Roster"));
        int presences =
            _db.getPacketCount(
                componentSession.getExternalComponent().getInitialSubdomain(),
                Class.forName("org.xmpp.packet.Presence"));

        out.write(
            "\r\n\t\t\t\t<div class=\"sildeHeader\">Logs & Statistics</div>\r\n\r\n\t\t\t\t<table class=\"logtable\">\r\n\t\t\t\t\t<tfoot>\r\n\t\t\t\t\t\t<tr id=\"logfoot\">\r\n\t\t\t\t\t\t\t<td colspan=\"2\">Packages being logged for ");
        out.print(JiveGlobals.getIntProperty("plugin.remoteroster.log.cleaner.minutes", 60));
        out.write(
            "\r\n\t\t\t\t\t\t\t\tminutes\r\n\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t<td><a style=\"float: right;\"\r\n\t\t\t\t\t\t\t\tonClick=\"window.open('liveStats.jsp?component=");
        out.print(componentSession.getExternalComponent().getInitialSubdomain());
        out.write(
            "','mywindow','width=1200,height=700')\">Show\r\n\t\t\t\t\t\t\t\t\trealtime Log</a>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t</tfoot>\r\n\t\t\t\t\t<tbody>\r\n\t\t\t\t\t\t<tr id=\"loghead\">\r\n\t\t\t\t\t\t\t<td width=\"200px\">Paket type</td>\r\n\t\t\t\t\t\t\t<td width=\"100px\">Number</td>\r\n\t\t\t\t\t\t\t<td></td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr id=\"logodd\">\r\n\t\t\t\t\t\t\t<td>IQ</td>\r\n\t\t\t\t\t\t\t<td id=\"logiq");
        out.print(i);
        out.write('"');
        out.write('>');
        out.print(iqs);
        out.write("</td>\r\n\t\t\t\t\t\t\t<td rowspan=\"5\"><div id=\"pie");
        out.print(i);
        out.write(
            "\" class=\"graph\"></div></td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr id=\"logeven\">\r\n\t\t\t\t\t\t\t<td>Messages</td>\r\n\t\t\t\t\t\t\t<td id=\"logmsg");
        out.print(i);
        out.write('"');
        out.write('>');
        out.print(msgs);
        out.write(
            "</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr id=\"logodd\">\r\n\t\t\t\t\t\t\t<td>Roster</td>\r\n\t\t\t\t\t\t\t<td id=\"logroster");
        out.print(i);
        out.write('"');
        out.write('>');
        out.print(rosters);
        out.write(
            "</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr id=\"logeven\">\r\n\t\t\t\t\t\t\t<td>Presence</td>\r\n\t\t\t\t\t\t\t<td id=\"logpresence");
        out.print(i);
        out.write('"');
        out.write('>');
        out.print(presences);
        out.write(
            "</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr id=\"logodd\">\r\n\t\t\t\t\t\t\t<td><span style=\"font-weight: bold;\">Total:</span></td>\r\n\t\t\t\t\t\t\t<td><span style=\"font-weight: bold;\">");
        out.print(iqs + msgs + rosters + presences);
        out.write(
            "</span></td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t</tbody>\r\n\t\t\t\t</table>\r\n\r\n\t\t\t</div>\r\n\r\n\r\n\t\t\t");

        ++i;
      }

      out.write("\r\n\t\t\t");

      if (!gatewayFound) {

        out.write(
            "\r\n\t\t\t<span style=\"font-weight: bold\">No connected external gateway components found.</span>\r\n\t\t\t");
      }

      out.write(
          "\r\n\t\t</div>\r\n\t\t\r\n\t\t\r\n<div class=\"jive-contentBoxHeader\">General Options</div>\r\n<div class=\"jive-contentBox\">\r\n   <table cellpadding=\"3\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n   <tbody>\r\n   <tr valign=\"top\">\r\n       <td width=\"100%\">\r\n           <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\r\n           <tbody>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td><input type=\"checkbox\" name=\"persistentEnabled\" id=\"GO1\" value=\"true\"\r\n\t\t\t\t\t\t");
      out.print(
          JiveGlobals.getBooleanProperty("plugin.remoteroster.persistent", false)
              ? "checked=\"checked\""
              : "");
      out.write(
          " />\r\n\r\n\t\t\t\t\t</td>\r\n\t\t\t\t\t<td><label for=\"GO1\">Enable persistent Roster</label></td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td />\r\n\t\t\t\t\t<td align=\"left\" style=\"font-size: -3; color: grey\">When Persistent-Roster is enabled, contacts will be saved to database and\r\n\t\t\t\t\tno contacts will be deleted\tby GoJara automatically.<br>\t\t\t\t\t\r\n\t\t\t\t\tWhen Persistent-Roster is disabled, contacts will not be saved to database and \r\n\t\t\t\t\tGoJara will automatically delete all Legacy-RosterItems from the OF-Roster of a User upon logout.<br>Enable this if you want to store Gateway contacts in DB. </td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td><input type=\"checkbox\" name=\"mucFilter\" id=\"GO2\" value=\"true\"\r\n\t\t\t\t\t\t");
      out.print(
          JiveGlobals.getBooleanProperty("plugin.remoteroster.mucFilter", false)
              ? "checked=\"checked\""
              : "");
      out.write(
          " />\r\n\t\t\t\t\t</td>\r\n\t\t\t\t\t<td><label for=\"GO2\">Only allow internal Jabber Conferences</label></td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td />\r\n\t\t\t\t\t<td align=\"left\" style=\"font-size: -3; color: grey\">Spectrum might add MUC(Multi User Chat) to supported features\r\n\t\t\t\t\t of some Transports. If this should not be allowed, because only internal Jabber Conferences should be used, GoJara\r\n\t\t\t\t\t can remove these.</td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td><input type=\"checkbox\" name=\"ignoreSubdomains\" id=\"GO3\" value=\"true\"\r\n\t\t\t\t\t\t");
      out.print(
          JiveGlobals.getBooleanProperty("plugin.remoteroster.ignoreSubdomains", true)
              ? "checked=\"checked\""
              : "");
      out.write(
          " />\r\n\t\t\t\t\t</td>\r\n\t\t\t\t\t<td><label for=\"GO2\">Do not add Subdomains to Roster</label></td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td />\r\n\t\t\t\t\t<td align=\"left\" style=\"font-size: -3; color: grey\">If you do not want the gateway itself to show up as a contact on your roster,\r\n\t\t\t\t\tenable this (only happens on registration).\r\n\t\t\t\t\t</td>\r\n\t\t\t\t</tr>\r\n\r\n           </tbody>\r\n           </table>\r\n       </td>\r\n   </tr>\r\n   </tbody>\r\n   </table>\r\n</div>\r\n\r\n\t\t<br /> <br />\r\n\t\t<div class=\"jive-contentBoxHeader\">Client specific options</div>\r\n\t\t<div class=\"jive-contentBox\">\r\n\t\t\t<table cellpadding=\"3\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n\t\t\t\t<tbody>\r\n\t\t\t\t\t<tr valign=\"top\">\r\n\t\t\t\t\t\t<td width=\"1%\" nowrap class=\"c1\">Spark:</td>\r\n\t\t\t\t\t\t<td width=\"99%\">\r\n\t\t\t\t\t\t\t<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\r\n\t\t\t\t\t\t\t\t<tbody>\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td><input type=\"checkbox\" name=\"sparkDiscoInfo\" id=\"SDI\" value=\"true\"\r\n\t\t\t\t\t\t\t\t\t\t\t");
      out.print(
          JiveGlobals.getBooleanProperty("plugin.remoteroster.sparkDiscoInfo", false)
              ? "checked=\"checked\""
              : "");
      out.write(
          " />\r\n\r\n\t\t\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\t\t<td><label for=\"SDI\"> Support jabber:iq:registered feature</label></td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td />\r\n\t\t\t\t\t\t\t\t\t\t<td align=\"left\" style=\"font-size: -3; color: grey\">If you use Spark clients within your network, it\r\n\t\t\t\t\t\t\t\t\t\t\tmight be necessary to modify the service discovery packets between Spark and the external component. If you\r\n\t\t\t\t\t\t\t\t\t\t\tcheck this RemoteRoster will add the feature \"jabber:iq:registered\" to the disco#info to indicate that the\r\n\t\t\t\t\t\t\t\t\t\t\tClient is registered with the external component.</td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td><input type=\"checkbox\" name=\"iqLastFilter\" id=\"SDI2\" value=\"true\"\r\n\t\t\t\t\t\t\t\t\t\t\t");
      out.print(
          JiveGlobals.getBooleanProperty("plugin.remoteroster.iqLastFilter", false)
              ? "checked=\"checked\""
              : "");
      out.write(
          " />\r\n\r\n\t\t\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\t\t<td><label for=\"SDI\">Reply to jabber:iq:last </label></td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td />\r\n\t\t\t\t\t\t\t\t\t\t<td align=\"left\" style=\"font-size: -3; color: grey\">Some clients try to check how long a contact is already offline.\r\n\t\t\t\t\t\t\t\t\t\t This feature is not supported by spectrum so it won't response to this IQ stanza. To prevent the client from waiting\r\n\t\t\t\t\t\t\t\t\t\t for a response we could answer with a service-unavailable message as described in XEP-12.</td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td><input type=\"checkbox\" name=\"blockPresences\" id=\"SDI3\" value=\"true\"\r\n\t\t\t\t\t\t\t\t\t\t\t");
      out.print(
          JiveGlobals.getBooleanProperty("plugin.remoteroster.blockPresences", true)
              ? "checked=\"checked\""
              : "");
      out.write(
          " />\r\n\r\n\t\t\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\t\t<td><label for=\"SDI\">Block presence pushing to rosterItems except gateway</label></td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td />\r\n\t\t\t\t\t\t\t\t\t\t<td align=\"left\" style=\"font-size: -3; color: grey\">Openfire automatically pushes Presences to every Item on your Roster.\r\n\t\t\t\t\t\t\t\t\t\tFor Spark, this means that roster items which are imported through gateway will trigger automatic login, even if you configured\r\n\t\t\t\t\t\t\t\t\t\tSpark to not connect to these gateways on Startup.<br>\r\n\t\t\t\t\t\t\t\t\t\tBlock Presences if you use Spark and do not want to autoconnect.</td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t</tbody>\r\n\t\t\t\t\t\t\t</table>\r\n\t\t\t\t\t\t</td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t\t<tr valign=\"top\">\r\n\t\t\t\t\t\t<td width=\"1%\" nowrap class=\"c1\">Gajim:</td>\r\n\t\t\t\t\t\t<td width=\"99%\">\r\n\t\t\t\t\t\t\t<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\r\n\t\t\t\t\t\t\t\t<tbody>\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td><input type=\"checkbox\" name=\"gajimBroadcast\" id=\"gajimBroadcast\" value=\"true\"\r\n\t\t\t\t\t\t\t\t\t\t\t");
      out.print(
          JiveGlobals.getBooleanProperty("plugin.remoteroster.gajimBroadcast", false)
              ? "checked=\"checked\""
              : "");
      out.write(
          " />\r\n\t\t\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\t\t<td><label for=\"gajimBroadcast\">Push available presence on startup</label></td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td />\r\n\t\t\t\t\t\t\t\t\t\t<td align=\"left\" style=\"font-size: -3; color: grey\">Enable this if Gojara should push available presences to\r\n\t\t\t\t\t\t\t\t\t\ttransports from your roster on startup. If disabled, you may have to manually send an available presence to the specific \r\n\t\t\t\t\t\t\t\t\t\ttransport to connect to it.<br>Not needed if you add Subdomains to roster + disabled presence blocking.</td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t</tbody>\r\n\t\t\t\t\t\t\t</table>\r\n\t\t\t\t\t\t</td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t</tbody>\r\n\t\t\t</table>\r\n\t\t</div>\r\n\r\n\r\n\t\t<input type=\"submit\" name=\"save\" value=\"Save Settings\" />\r\n\t</form>\r\n\r\n</body>\r\n</html>\r\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);
    }
  }
Exemple #5
0
  /** @see net.sf.kraken.session.TransportSession#logIn(net.sf.kraken.type.PresenceType, String) */
  @Override
  public void logIn(PresenceType presenceType, String verboseStatus) {
    final org.jivesoftware.smack.packet.Presence presence =
        new org.jivesoftware.smack.packet.Presence(
            org.jivesoftware.smack.packet.Presence.Type.available);
    if (JiveGlobals.getBooleanProperty(
            "plugin.gateway." + getTransport().getType() + ".avatars", true)
        && getAvatar() != null) {
      Avatar avatar = getAvatar();
      // Same thing in this case, so lets go ahead and set them.
      avatar.setLegacyIdentifier(avatar.getXmppHash());
      VCardUpdateExtension ext = new VCardUpdateExtension();
      ext.setPhotoHash(avatar.getLegacyIdentifier());
      presence.addExtension(ext);
    }
    final Presence.Mode pMode =
        ((XMPPTransport) getTransport()).convertGatewayStatusToXMPP(presenceType);
    if (pMode != null) {
      presence.setMode(pMode);
    }
    if (verboseStatus != null && verboseStatus.trim().length() > 0) {
      presence.setStatus(verboseStatus);
    }
    setPendingPresenceAndStatus(presenceType, verboseStatus);

    if (!this.isLoggedIn()) {
      listener = new XMPPListener(this);
      presenceHandler = new XMPPPresenceHandler(this);
      runThread =
          new Thread() {
            @Override
            public void run() {
              String userName = generateUsername(registration.getUsername());
              conn = new XMPPConnection(config);
              try {
                conn.getSASLAuthentication()
                    .registerSASLMechanism("DIGEST-MD5", MySASLDigestMD5Mechanism.class);
                if (getTransport().getType().equals(TransportType.facebook)
                    && registration.getUsername().equals("{PLATFORM}")) {
                  conn.getSASLAuthentication()
                      .registerSASLMechanism(
                          "X-FACEBOOK-PLATFORM", FacebookConnectSASLMechanism.class);
                  conn.getSASLAuthentication().supportSASLMechanism("X-FACEBOOK-PLATFORM", 0);
                }

                Roster.setDefaultSubscriptionMode(SubscriptionMode.manual);
                conn.connect();
                conn.addConnectionListener(listener);
                try {
                  conn.addPacketListener(
                      presenceHandler,
                      new PacketTypeFilter(org.jivesoftware.smack.packet.Presence.class));
                  // Use this to filter out anything we don't care about
                  conn.addPacketListener(
                      listener,
                      new OrFilter(
                          new PacketTypeFilter(GoogleMailBoxPacket.class),
                          new PacketExtensionFilter(
                              GoogleNewMailExtension.ELEMENT_NAME,
                              GoogleNewMailExtension.NAMESPACE)));
                  conn.login(userName, registration.getPassword(), xmppResource);
                  conn.sendPacket(presence); // send initial presence.
                  conn.getChatManager().addChatListener(listener);
                  conn.getRoster().addRosterListener(listener);

                  if (JiveGlobals.getBooleanProperty(
                          "plugin.gateway." + getTransport().getType() + ".avatars",
                          !TransportType.facebook.equals(getTransport().getType()))
                      && getAvatar() != null) {
                    new Thread() {
                      @Override
                      public void run() {
                        Avatar avatar = getAvatar();

                        VCard vCard = new VCard();
                        try {
                          vCard.load(conn);
                          vCard.setAvatar(
                              Base64.decode(avatar.getImageData()), avatar.getMimeType());
                          vCard.save(conn);
                        } catch (XMPPException e) {
                          Log.debug("XMPP: Error while updating vcard for avatar change.", e);
                        } catch (NotFoundException e) {
                          Log.debug("XMPP: Unable to find avatar while setting initial.", e);
                        }
                      }
                    }.start();
                  }

                  setLoginStatus(TransportLoginStatus.LOGGED_IN);
                  syncUsers();

                  if (getTransport().getType().equals(TransportType.gtalk)
                      && JiveGlobals.getBooleanProperty(
                          "plugin.gateway.gtalk.mailnotifications", true)) {
                    conn.sendPacket(
                        new IQWithPacketExtension(
                            generateFullJID(getRegistration().getUsername()),
                            new GoogleUserSettingExtension(null, true, null),
                            IQ.Type.SET));
                    conn.sendPacket(
                        new IQWithPacketExtension(
                            generateFullJID(getRegistration().getUsername()),
                            new GoogleMailNotifyExtension()));
                    mailCheck = new MailCheck();
                    timer.schedule(mailCheck, timerInterval, timerInterval);
                  }
                } catch (XMPPException e) {
                  Log.debug(
                      getTransport().getType()
                          + " user's login/password does not appear to be correct: "
                          + getRegistration().getUsername(),
                      e);
                  setFailureStatus(ConnectionFailureReason.USERNAME_OR_PASSWORD_INCORRECT);
                  sessionDisconnectedNoReconnect(
                      LocaleUtils.getLocalizedString("gateway.xmpp.passwordincorrect", "kraken"));
                }
              } catch (XMPPException e) {
                Log.debug(
                    getTransport().getType()
                        + " user is not able to connect: "
                        + getRegistration().getUsername(),
                    e);
                setFailureStatus(ConnectionFailureReason.CAN_NOT_CONNECT);
                sessionDisconnected(
                    LocaleUtils.getLocalizedString("gateway.xmpp.connectionfailed", "kraken"));
              }
            }
          };
      runThread.start();
    }
  }
Exemple #6
0
  /**
   * Create an XMPP Session instance.
   *
   * @param registration Registration information used for logging in.
   * @param jid JID associated with this session.
   * @param transport Transport instance associated with this session.
   * @param priority Priority of this session.
   */
  public XMPPSession(
      Registration registration, JID jid, XMPPTransport transport, Integer priority) {
    super(registration, jid, transport, priority);
    setSupportedFeature(SupportedFeature.attention);
    setSupportedFeature(SupportedFeature.chatstates);

    Log.debug(
        "Creating " + getTransport().getType() + " session for " + registration.getUsername());
    String connecthost;
    Integer connectport;
    String domain;

    connecthost =
        JiveGlobals.getProperty(
            "plugin.gateway." + getTransport().getType() + ".connecthost",
            (getTransport().getType().equals(TransportType.gtalk)
                ? "talk.google.com"
                : getTransport().getType().equals(TransportType.facebook)
                    ? "chat.facebook.com"
                    : "jabber.org"));
    connectport =
        JiveGlobals.getIntProperty(
            "plugin.gateway." + getTransport().getType() + ".connectport", 5222);

    if (getTransport().getType().equals(TransportType.gtalk)) {
      domain = "gmail.com";
    } else if (getTransport().getType().equals(TransportType.facebook)) {
      // if (connecthost.equals("www.facebook.com")) {
      connecthost = "chat.facebook.com";
      // }
      // if (connectport.equals(80)) {
      connectport = 5222;
      // }
      domain = "chat.facebook.com";
    } else if (getTransport().getType().equals(TransportType.renren)) {
      connecthost = "talk.renren.com";
      connectport = 5222;
      domain = "renren.com";
    } else {
      domain = connecthost;
    }

    // For different domains other than 'gmail.com', which is given with Google Application services
    if (registration.getUsername().indexOf("@") > -1) {
      domain = registration.getUsername().substring(registration.getUsername().indexOf("@") + 1);
    }

    // If administrator specified "*" for domain, allow user to connect to anything.
    if (connecthost.equals("*")) {
      connecthost = domain;
    }

    config = new ConnectionConfiguration(connecthost, connectport, domain);
    config.setCompressionEnabled(
        JiveGlobals.getBooleanProperty(
            "plugin.gateway." + getTransport().getType() + ".usecompression", false));

    if (getTransport().getType().equals(TransportType.facebook)) {
      // SASLAuthentication.supportSASLMechanism("PLAIN", 0);
      // config.setSASLAuthenticationEnabled(false);
      // config.setSecurityMode(ConnectionConfiguration.SecurityMode.enabled);
    }

    // instead, send the initial presence right after logging in. This
    // allows us to use a different presence mode than the plain old
    // 'available' as initial presence.
    config.setSendPresence(false);

    if (getTransport().getType().equals(TransportType.gtalk)
        && JiveGlobals.getBooleanProperty("plugin.gateway.gtalk.mailnotifications", true)) {
      ProviderManager.getInstance()
          .addIQProvider(
              GoogleMailBoxPacket.MAILBOX_ELEMENT,
              GoogleMailBoxPacket.MAILBOX_NAMESPACE,
              new GoogleMailBoxPacket.Provider());
      ProviderManager.getInstance()
          .addExtensionProvider(
              GoogleNewMailExtension.ELEMENT_NAME,
              GoogleNewMailExtension.NAMESPACE,
              new GoogleNewMailExtension.Provider());
    }
  }
 /**
  * Returns true if the proxy transfer should be matched to an existing file transfer in the
  * system.
  *
  * @return Returns true if the proxy transfer should be matched to an existing file transfer in
  *     the system.
  */
 public boolean isMatchProxyTransfer() {
   return JiveGlobals.getBooleanProperty("xmpp.proxy.transfer.required", true);
 }
 public boolean checkPassword(String username, String testPassword) throws UserNotFoundException {
   Connection con = null;
   PreparedStatement pstmt = null;
   ResultSet rs = null;
   if (username.contains("@")) {
     // Check that the specified domain matches the server's domain
     int index = username.indexOf("@");
     String domain = username.substring(index + 1);
     if (domain.equals(XMPPServer.getInstance().getServerInfo().getXMPPDomain())) {
       username = username.substring(0, index);
     } else {
       // Unknown domain.
       throw new UserNotFoundException();
     }
   }
   try {
     con = DbConnectionManager.getConnection();
     pstmt = con.prepareStatement(TEST_PASSWORD);
     pstmt.setString(1, username);
     rs = pstmt.executeQuery();
     if (!rs.next()) {
       throw new UserNotFoundException(username);
     }
     String plainText = rs.getString(1);
     String encrypted = rs.getString(2);
     int iterations = rs.getInt(3);
     String salt = rs.getString(4);
     String storedKey = rs.getString(5);
     if (encrypted != null) {
       try {
         plainText = AuthFactory.decryptPassword(encrypted);
       } catch (UnsupportedOperationException uoe) {
         // Ignore and return plain password instead.
       }
     }
     if (plainText != null) {
       boolean scramOnly = JiveGlobals.getBooleanProperty("user.scramHashedPasswordOnly");
       if (scramOnly) {
         // If we have a password here, but we're meant to be scramOnly, we should reset it.
         setPassword(username, plainText);
       }
       return testPassword.equals(plainText);
     }
     // Don't have either plain or encrypted, so test SCRAM hash.
     if (salt == null || iterations == 0 || storedKey == null) {
       Log.warn("No available credentials for checkPassword.");
       return false;
     }
     byte[] saltShaker = DatatypeConverter.parseBase64Binary(salt);
     byte[] saltedPassword = null, clientKey = null, testStoredKey = null;
     try {
       saltedPassword = ScramUtils.createSaltedPassword(saltShaker, testPassword, iterations);
       clientKey = ScramUtils.computeHmac(saltedPassword, "Client Key");
       testStoredKey = MessageDigest.getInstance("SHA-1").digest(clientKey);
     } catch (SaslException | NoSuchAlgorithmException | UnsupportedEncodingException e) {
       Log.warn("Unable to check SCRAM values for PLAIN authentication.");
       return false;
     }
     return DatatypeConverter.printBase64Binary(testStoredKey).equals(storedKey);
   } catch (SQLException sqle) {
     Log.error("User SQL failure:", sqle);
     throw new UserNotFoundException(sqle);
   } finally {
     DbConnectionManager.closeConnection(rs, pstmt, con);
   }
 }
  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);
    }
  }
  /**
   * Creates a new session that will receive packets. The new session will be authenticated before
   * being returned. If the authentication process fails then the answer will be <tt>null</tt>.
   *
   * <p>
   *
   * @param serverName hostname of this server.
   * @param reader reader on the new established connection with the remote server.
   * @param connection the new established connection with the remote server.
   * @return a new session that will receive packets or null if a problem occured while
   *     authenticating the remote server or when acting as the Authoritative Server during a Server
   *     Dialback authentication process.
   * @throws org.xmlpull.v1.XmlPullParserException if an error occurs while parsing the XML.
   * @throws java.io.IOException if an input/output error occurs while using the connection.
   */
  public static LocalIncomingServerSession createSession(
      String serverName, XMPPPacketReader reader, SocketConnection connection)
      throws XmlPullParserException, IOException {
    XmlPullParser xpp = reader.getXPPParser();

    String version = xpp.getAttributeValue("", "version");
    int[] serverVersion = version != null ? decodeVersion(version) : new int[] {0, 0};

    try {
      // Get the stream ID for the new session
      StreamID streamID = SessionManager.getInstance().nextStreamID();
      // Create a server Session for the remote server
      LocalIncomingServerSession session =
          SessionManager.getInstance().createIncomingServerSession(connection, streamID);

      // Send the stream header
      StringBuilder openingStream = new StringBuilder();
      openingStream.append("<stream:stream");
      openingStream.append(" xmlns:db=\"jabber:server:dialback\"");
      openingStream.append(" xmlns:stream=\"http://etherx.jabber.org/streams\"");
      openingStream.append(" xmlns=\"jabber:server\"");
      openingStream.append(" from=\"").append(serverName).append("\"");
      openingStream.append(" id=\"").append(streamID).append("\"");
      openingStream.append(" version=\"1.0\">");
      connection.deliverRawText(openingStream.toString());

      if (serverVersion[0] >= 1) {
        // Remote server is XMPP 1.0 compliant so offer TLS and SASL to establish the connection
        // (and server dialback)

        // Indicate the TLS policy to use for this connection
        Connection.TLSPolicy tlsPolicy =
            ServerDialback.isEnabled()
                ? Connection.TLSPolicy.optional
                : Connection.TLSPolicy.required;
        boolean hasCertificates = false;
        try {
          hasCertificates = SSLConfig.getKeyStore().size() > 0;
        } catch (Exception e) {
          Log.error(e.getMessage(), e);
        }
        if (Connection.TLSPolicy.required == tlsPolicy && !hasCertificates) {
          Log.error(
              "Server session rejected. TLS is required but no certificates " + "were created.");
          return null;
        }
        connection.setTlsPolicy(hasCertificates ? tlsPolicy : Connection.TLSPolicy.disabled);
      }

      // Indicate the compression policy to use for this connection
      String policyName =
          JiveGlobals.getProperty(
              "xmpp.server.compression.policy", Connection.CompressionPolicy.disabled.toString());
      Connection.CompressionPolicy compressionPolicy =
          Connection.CompressionPolicy.valueOf(policyName);
      connection.setCompressionPolicy(compressionPolicy);

      StringBuilder sb = new StringBuilder();

      if (serverVersion[0] >= 1) {
        // Remote server is XMPP 1.0 compliant so offer TLS and SASL to establish the connection
        // (and server dialback)
        // Don't offer stream-features to pre-1.0 servers, as it confuses them. Sending features to
        // Openfire < 3.7.1 confuses it too - OF-443)
        sb.append("<stream:features>");

        if (JiveGlobals.getBooleanProperty("xmpp.server.tls.enabled", true)) {
          sb.append("<starttls xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\">");
          if (!ServerDialback.isEnabled()) {
            // Server dialback is disabled so TLS is required
            sb.append("<required/>");
          }
          sb.append("</starttls>");
        }

        // Include available SASL Mechanisms
        sb.append(SASLAuthentication.getSASLMechanisms(session));

        if (ServerDialback.isEnabled()) {
          // Also offer server dialback (when TLS is not required). Server dialback may be offered
          // after TLS has been negotiated and a self-signed certificate is being used
          sb.append("<dialback xmlns=\"urn:xmpp:features:dialback\"/>");
        }

        sb.append("</stream:features>");
      }

      connection.deliverRawText(sb.toString());

      // Set the domain or subdomain of the local server targeted by the remote server
      session.setLocalDomain(serverName);
      return session;
    } catch (Exception e) {
      Log.error("Error establishing connection from remote server:" + connection, e);
      connection.close();
      return null;
    }
  }
  /**
   * Establishes a new outgoing session to a remote server. If the remote server supports TLS and
   * SASL then the new outgoing connection will be secured with TLS and authenticated using SASL.
   * However, if TLS or SASL is not supported by the remote server or if an error occured while
   * securing or authenticating the connection using SASL then server dialback method will be used.
   *
   * @param domain the local domain to authenticate with the remote server.
   * @param hostname the hostname of the remote server.
   * @param port default port to use to establish the connection.
   * @return new outgoing session to a remote server.
   */
  private static LocalOutgoingServerSession createOutgoingSession(
      String domain, String hostname, int port) {

    String localDomainName = XMPPServer.getInstance().getServerInfo().getXMPPDomain();
    boolean useTLS = JiveGlobals.getBooleanProperty(ConnectionSettings.Server.TLS_ENABLED, true);
    RemoteServerConfiguration configuration = RemoteServerManager.getConfiguration(hostname);
    if (configuration != null) {
      // TODO Use the specific TLS configuration for this remote server
      // useTLS = configuration.isTLSEnabled();
    }

    // Connect to remote server using XMPP 1.0 (TLS + SASL EXTERNAL or TLS + server dialback or
    // server dialback)
    String realHostname = null;
    int realPort = port;
    Socket socket = null;
    // Get a list of real hostnames to connect to using DNS lookup of the specified hostname
    List<DNSUtil.HostAddress> hosts = DNSUtil.resolveXMPPDomain(hostname, port);
    for (Iterator<DNSUtil.HostAddress> it = hosts.iterator(); it.hasNext(); ) {
      try {
        socket = new Socket();
        DNSUtil.HostAddress address = it.next();
        realHostname = address.getHost();
        realPort = address.getPort();
        Log.debug(
            "LocalOutgoingServerSession: OS - Trying to connect to "
                + hostname
                + ":"
                + port
                + "(DNS lookup: "
                + realHostname
                + ":"
                + realPort
                + ")");
        // Establish a TCP connection to the Receiving Server
        socket.connect(
            new InetSocketAddress(realHostname, realPort), RemoteServerManager.getSocketTimeout());
        Log.debug(
            "LocalOutgoingServerSession: OS - Plain connection to "
                + hostname
                + ":"
                + port
                + " successful");
        break;
      } catch (Exception e) {
        Log.warn(
            "Error trying to connect to remote server: "
                + hostname
                + "(DNS lookup: "
                + realHostname
                + ":"
                + realPort
                + "): "
                + e.toString());
        try {
          if (socket != null) {
            socket.close();
          }
        } catch (IOException ex) {
          Log.debug(
              "Additional exception while trying to close socket when connection to remote server failed: "
                  + ex.toString());
        }
      }
    }
    if (!socket.isConnected()) {
      return null;
    }

    SocketConnection connection = null;
    try {
      connection =
          new SocketConnection(XMPPServer.getInstance().getPacketDeliverer(), socket, false);

      // Send the stream header
      StringBuilder openingStream = new StringBuilder();
      openingStream.append("<stream:stream");
      openingStream.append(" xmlns:db=\"jabber:server:dialback\"");
      openingStream.append(" xmlns:stream=\"http://etherx.jabber.org/streams\"");
      openingStream.append(" xmlns=\"jabber:server\"");
      openingStream.append(" from=\"").append(localDomainName).append("\""); // OF-673
      openingStream.append(" to=\"").append(hostname).append("\"");
      openingStream.append(" version=\"1.0\">");
      connection.deliverRawText(openingStream.toString());

      // Set a read timeout (of 5 seconds) so we don't keep waiting forever
      int soTimeout = socket.getSoTimeout();
      socket.setSoTimeout(5000);

      XMPPPacketReader reader = new XMPPPacketReader();
      reader
          .getXPPParser()
          .setInput(new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_8));
      // Get the answer from the Receiving Server
      XmlPullParser xpp = reader.getXPPParser();
      for (int eventType = xpp.getEventType(); eventType != XmlPullParser.START_TAG; ) {
        eventType = xpp.next();
      }

      String serverVersion = xpp.getAttributeValue("", "version");
      String id = xpp.getAttributeValue("", "id");

      // Check if the remote server is XMPP 1.0 compliant
      if (serverVersion != null && decodeVersion(serverVersion)[0] >= 1) {
        // Restore default timeout
        socket.setSoTimeout(soTimeout);
        // Get the stream features
        Element features = reader.parseDocument().getRootElement();
        if (features != null) {
          // Check if TLS is enabled
          if (useTLS && features.element("starttls") != null) {
            // Secure the connection with TLS and authenticate using SASL
            LocalOutgoingServerSession answer;
            answer = secureAndAuthenticate(hostname, connection, reader, openingStream, domain);
            if (answer != null) {
              // Everything went fine so return the secured and
              // authenticated connection
              return answer;
            }
          }
          // Check if we are going to try server dialback (XMPP 1.0)
          else if (ServerDialback.isEnabled() && features.element("dialback") != null) {
            Log.debug(
                "LocalOutgoingServerSession: OS - About to try connecting using server dialback XMPP 1.0 with: "
                    + hostname);
            ServerDialback method = new ServerDialback(connection, domain);
            OutgoingServerSocketReader newSocketReader = new OutgoingServerSocketReader(reader);
            if (method.authenticateDomain(newSocketReader, domain, hostname, id)) {
              Log.debug(
                  "LocalOutgoingServerSession: OS - SERVER DIALBACK XMPP 1.0 with "
                      + hostname
                      + " was successful");
              StreamID streamID = new BasicStreamIDFactory().createStreamID(id);
              LocalOutgoingServerSession session =
                  new LocalOutgoingServerSession(domain, connection, newSocketReader, streamID);
              connection.init(session);
              // Set the hostname as the address of the session
              session.setAddress(new JID(null, hostname, null));
              return session;
            } else {
              Log.debug(
                  "LocalOutgoingServerSession: OS - Error, SERVER DIALBACK with "
                      + hostname
                      + " failed");
            }
          }
        } else {
          Log.debug("LocalOutgoingServerSession: OS - Error, <starttls> was not received");
        }
      }
      // Something went wrong so close the connection and try server dialback over
      // a plain connection
      if (connection != null) {
        connection.close();
      }
    } catch (SSLHandshakeException e) {
      Log.debug(
          "LocalOutgoingServerSession: Handshake error while creating secured outgoing session to remote "
              + "server: "
              + hostname
              + "(DNS lookup: "
              + realHostname
              + ":"
              + realPort
              + "):",
          e);
      // Close the connection
      if (connection != null) {
        connection.close();
      }
    } catch (Exception e) {
      Log.error(
          "Error creating secured outgoing session to remote server: "
              + hostname
              + "(DNS lookup: "
              + realHostname
              + ":"
              + realPort
              + ")",
          e);
      // Close the connection
      if (connection != null) {
        connection.close();
      }
    }

    if (ServerDialback.isEnabled()) {
      Log.debug(
          "LocalOutgoingServerSession: OS - Going to try connecting using server dialback with: "
              + hostname);
      // Use server dialback (pre XMPP 1.0) over a plain connection
      return new ServerDialback().createOutgoingSession(domain, hostname, port);
    }
    return null;
  }
 public boolean supportsPasswordRetrieval() {
   boolean scramOnly = JiveGlobals.getBooleanProperty("user.scramHashedPasswordOnly");
   return !scramOnly;
 }
  public void setPassword(String username, String password) throws UserNotFoundException {
    // Determine if the password should be stored as plain text or encrypted.
    boolean usePlainPassword = JiveGlobals.getBooleanProperty("user.usePlainPassword");
    boolean scramOnly = JiveGlobals.getBooleanProperty("user.scramHashedPasswordOnly");
    String encryptedPassword = null;
    if (username.contains("@")) {
      // Check that the specified domain matches the server's domain
      int index = username.indexOf("@");
      String domain = username.substring(index + 1);
      if (domain.equals(XMPPServer.getInstance().getServerInfo().getXMPPDomain())) {
        username = username.substring(0, index);
      } else {
        // Unknown domain.
        throw new UserNotFoundException();
      }
    }

    // Store the salt and salted password so SCRAM-SHA-1 SASL auth can be used later.
    byte[] saltShaker = new byte[32];
    random.nextBytes(saltShaker);
    String salt = DatatypeConverter.printBase64Binary(saltShaker);

    int iterations =
        JiveGlobals.getIntProperty(
            "sasl.scram-sha-1.iteration-count", ScramUtils.DEFAULT_ITERATION_COUNT);
    byte[] saltedPassword = null, clientKey = null, storedKey = null, serverKey = null;
    try {
      saltedPassword = ScramUtils.createSaltedPassword(saltShaker, password, iterations);
      clientKey = ScramUtils.computeHmac(saltedPassword, "Client Key");
      storedKey = MessageDigest.getInstance("SHA-1").digest(clientKey);
      serverKey = ScramUtils.computeHmac(saltedPassword, "Server Key");
    } catch (SaslException | NoSuchAlgorithmException | UnsupportedEncodingException e) {
      Log.warn("Unable to persist values for SCRAM authentication.");
    }

    if (!scramOnly && !usePlainPassword) {
      try {
        encryptedPassword = AuthFactory.encryptPassword(password);
        // Set password to null so that it's inserted that way.
        password = null;
      } catch (UnsupportedOperationException uoe) {
        // Encryption may fail. In that case, ignore the error and
        // the plain password will be stored.
      }
    }
    if (scramOnly) {
      encryptedPassword = null;
      password = null;
    }

    Connection con = null;
    PreparedStatement pstmt = null;
    try {
      con = DbConnectionManager.getConnection();
      pstmt = con.prepareStatement(UPDATE_PASSWORD);
      if (password == null) {
        pstmt.setNull(1, Types.VARCHAR);
      } else {
        pstmt.setString(1, password);
      }
      if (encryptedPassword == null) {
        pstmt.setNull(2, Types.VARCHAR);
      } else {
        pstmt.setString(2, encryptedPassword);
      }
      if (storedKey == null) {
        pstmt.setNull(3, Types.VARCHAR);
      } else {
        pstmt.setString(3, DatatypeConverter.printBase64Binary(storedKey));
      }
      if (serverKey == null) {
        pstmt.setNull(4, Types.VARCHAR);
      } else {
        pstmt.setString(4, DatatypeConverter.printBase64Binary(serverKey));
      }
      pstmt.setString(5, salt);
      pstmt.setInt(6, iterations);
      pstmt.setString(7, username);
      pstmt.executeUpdate();
    } catch (SQLException sqle) {
      throw new UserNotFoundException(sqle);
    } finally {
      DbConnectionManager.closeConnection(pstmt, con);
    }
  }
  public User createUser(String username, String password, String name, String email)
      throws UserAlreadyExistsException {
    if (isReadOnly()) {
      // Reject the operation since the provider is read-only
      throw new UnsupportedOperationException();
    }
    try {
      loadUser(username);
      // The user already exists since no exception, so:
      throw new UserAlreadyExistsException("Username " + username + " already exists");
    } catch (UserNotFoundException unfe) {
      // The user doesn't already exist so we can create a new user

      // Determine if the password should be stored as plain text or encrypted.
      boolean usePlainPassword = JiveGlobals.getBooleanProperty("user.usePlainPassword");
      String encryptedPassword = null;
      if (!usePlainPassword) {
        try {
          encryptedPassword = AuthFactory.encryptPassword(password);
          // Set password to null so that it's inserted that way.
          password = null;
        } catch (UnsupportedOperationException uoe) {
          // Encrypting the password may have failed if in setup mode. Therefore,
          // use the plain password.
        }
      }

      Date now = new Date();
      Connection con = null;
      PreparedStatement pstmt = null;
      try {
        con = DbConnectionManager.getConnection();
        pstmt = con.prepareStatement(INSERT_USER);
        pstmt.setString(1, username);
        if (password == null) {
          pstmt.setNull(2, Types.VARCHAR);
        } else {
          pstmt.setString(2, password);
        }
        if (encryptedPassword == null) {
          pstmt.setNull(3, Types.VARCHAR);
        } else {
          pstmt.setString(3, encryptedPassword);
        }
        if (name == null) {
          pstmt.setNull(4, Types.VARCHAR);
        } else {
          pstmt.setString(4, name);
        }
        if (email == null) {
          pstmt.setNull(5, Types.VARCHAR);
        } else {
          pstmt.setString(5, email);
        }
        pstmt.setString(6, StringUtils.dateToMillis(now));
        pstmt.setString(7, StringUtils.dateToMillis(now));
        pstmt.execute();
      } catch (Exception e) {
        Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
      } finally {
        DbConnectionManager.closeConnection(pstmt, con);
      }
      return new User(username, name, email, now, now);
    }
  }
Exemple #15
0
  public void initializePlugin(PluginManager manager, File pluginDirectory) {
    Log.info("[" + NAME + "] initialize " + NAME + " plugin resources");

    try {
      openfire = new Openfire();
      openfire.start();
      JmxHelper.register(openfire, OBJECTNAME_OPENFIRE);
      Log.info("[" + NAME + "] .. started openfire server detector.");
    } catch (Exception e) {
      Log.debug("cannot start openfire server detector: " + e.getMessage(), e);
    }

    try {
      packetCounter = new PacketCounter();
      packetCounter.start();
      JmxHelper.register(packetCounter, OBJECTNAME_PACKET_COUNTER);

      Log.info("[" + NAME + "] .. started stanza counter.");
    } catch (Exception e) {
      Log.debug("cannot start stanza counter: " + e.getMessage(), e);
    }

    try {
      client =
          new CoreThreadPool(
              ((ConnectionManagerImpl) XMPPServer.getInstance().getConnectionManager())
                  .getSocketAcceptor());
      client.start();
      JmxHelper.register(client, OBJECTNAME_CORE_CLIENT_THREADPOOL);

      Log.info("[" + NAME + "] .. started client thread pool monitor.");
    } catch (Exception e) {
      Log.debug("cannot start client thread pool monitor: " + e.getMessage(), e);
    }

    try {
      database = new DatabasePool();
      database.start();
      JmxHelper.register(database, OBJECTNAME_DATABASEPOOL);

      Log.info("[" + NAME + "] .. started database pool monitor.");
    } catch (Exception e) {
      Log.debug("cannot start database pool monitor: " + e.getMessage(), e);
    }

    try {

      ContextHandlerCollection contexts = HttpBindManager.getInstance().getContexts();

      try {
        Log.info("[" + NAME + "] starting jolokia");
        WebAppContext context = new WebAppContext(contexts, pluginDirectory.getPath(), "/jolokia");

        final List<ContainerInitializer> initializers = new ArrayList<>();
        initializers.add(new ContainerInitializer(new JasperInitializer(), null));
        context.setAttribute("org.eclipse.jetty.containerInitializers", initializers);
        context.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
        context.setWelcomeFiles(new String[] {"index.html"});

        Log.info("[" + NAME + "] starting hawtio");
        WebAppContext context2 =
            new WebAppContext(contexts, pluginDirectory.getPath() + "/hawtio", "/hawtio");
        final List<ContainerInitializer> initializers2 = new ArrayList<>();
        initializers2.add(new ContainerInitializer(new JasperInitializer(), null));
        context2.setAttribute("org.eclipse.jetty.containerInitializers", initializers2);
        context2.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
        context2.setWelcomeFiles(new String[] {"index.html"});

        if (JiveGlobals.getBooleanProperty("xmpp.jmx.secure", true)) {
          SecurityHandler securityHandler = basicAuth("jmxweb");
          if (securityHandler != null) context.setSecurityHandler(securityHandler);

          SecurityHandler securityHandler2 = basicAuth("jmxweb");
          if (securityHandler2 != null) context2.setSecurityHandler(securityHandler2);
        }

      } catch (Exception e) {
        Log.error("An error has occurred", e);
      }
    } catch (Exception e) {
      Log.error("Error initializing JmxWeb Plugin", e);
    }

    if (JiveGlobals.getBooleanProperty("jmxweb.email.monitoring", true)) {
      Log.info("[" + NAME + "] starting email monitoring");
      emailScheduler = new EmailScheduler();
      emailScheduler.startMonitoring();
      Log.info("[" + NAME + "] started monitoring");
    }
  }
 @Override
 boolean validateHost() {
   return JiveGlobals.getBooleanProperty("xmpp.client.validate.host", false);
 }
 public boolean isDigestSupported() {
   boolean scramOnly = JiveGlobals.getBooleanProperty("user.scramHashedPasswordOnly");
   return !scramOnly;
 }