Example #1
0
  /**
   * Method description
   *
   * @param packet
   * @param session
   * @param repo
   * @param results
   * @param settings
   */
  @Override
  public boolean preProcess(
      Packet packet,
      XMPPResourceConnection session,
      NonAuthUserRepository repo,
      Queue<Packet> results,
      Map<String, Object> settings) {
    boolean stop = false;

    if ((session == null) || session.isServerSession()) {
      return stop;
    }

    VHostItem vhost = session.getDomain();

    if (log.isLoggable(Level.FINEST)) {
      log.log(Level.FINEST, "VHost: {0}", new Object[] {vhost});
    }

    // Check whether the TLS has been completed
    // and the packet is allowed to be processed.
    if ((vhost != null)
        && session.isTlsRequired()
        && (session.getSessionData(ID) == null)
        && !packet.isElement(EL_NAME, XMLNS)) {
      stop = true;
    }

    return stop;
  }
Example #2
0
  /**
   * Method description
   *
   * @param session
   */
  @Override
  public Element[] supStreamFeatures(final XMPPResourceConnection session) {

    // If session does not exist, just return null, we don't provide features
    // for non-existen stream, the second condition means that the TLS
    // has not been yet completed for the user connection.
    if ((session != null) && (session.getSessionData(ID) == null)) {
      VHostItem vhost = session.getDomain();

      if ((vhost != null) && session.isTlsRequired()) {
        return F_REQUIRED;
      } else {
        return F_NOT_REQUIRED;
      }
    } else {
      return null;
    } // end of if (session.isAuthorized()) else
  }