Пример #1
0
  /**
   * Method description
   *
   * @param p
   * @param serv
   * @param handler
   * @param results
   * @return
   */
  @Override
  public boolean process(
      Packet p, ComponentIOService serv, ComponentProtocolHandler handler, Queue<Packet> results) {
    if (p.isXMLNSStaticStr(Iq.IQ_BIND_PATH, XMLNS)) {
      if ((p.getType() == StanzaType.set) && serv.isAuthenticated()) {
        String hostname = p.getElemCDataStaticStr(IQ_BIND_HOSTNAME_PATH);

        handler.bindHostname(hostname, serv);
        results.offer(Packet.packetInstance(okResult(p.getElement()), null, null));
      } else {
        log.fine("Ok result received: " + p.toString());
      }

      return true;
    }
    if (p.isXMLNSStaticStr(IQ_UNBIND_PATH, XMLNS)) {
      if ((p.getType() == StanzaType.set) && serv.isAuthenticated()) {
        String hostname = p.getElemCDataStaticStr(IQ_BIND_HOSTNAME_PATH);

        handler.unbindHostname(hostname, serv);
        results.offer(Packet.packetInstance(okResult(p.getElement()), null, null));
      } else {
        log.fine("Ok result received: " + p.toString());
      }

      return true;
    }

    return false;
  }
Пример #2
0
  /**
   * Method description
   *
   * @param p
   * @param serv
   * @param handler
   * @param results
   */
  @Override
  public void startProcessing(
      Packet p, ComponentIOService serv, ComponentProtocolHandler handler, Queue<Packet> results) {
    String[] hostnames = (String[]) serv.getSessionData().get(EXTCOMP_BIND_HOSTNAMES_PROP_KEY);

    if (hostnames != null) {
      for (String host : hostnames) {
        if (!host.isEmpty()) {
          Packet bind_p = Packet.packetInstance(newBindElement(host, handler), null, null);

          log.info("Generating hostname bind packet: " + bind_p.toString());
          results.offer(bind_p);
        } else {
          log.warning("Empty hostname set for bind...");
        }
      }
    }
  }