Пример #1
0
  /**
   * Called by Status implementations to retrieve the pending notifications and send them to the
   * connected client device
   */
  protected void managePendingNotificationMessage() {
    try {

      String username = (String) session.getAttribute(ATTRIBUTE_USERNAME);
      String deviceId = (String) session.getAttribute(ATTRIBUTE_DEVID);
      if (logger.isTraceEnabled()) {
        logger.trace(
            "Retrieving pending notifications for user '"
                + username
                + "', deviceId: '"
                + deviceId
                + "'");
      }

      com.funambol.framework.notification.Message message =
          pendingNotificationManager.getMessageFromPendingNotifications(username, deviceId);

      if (message == null) {
        if (logger.isTraceEnabled()) {
          logger.trace("No pending notification messages present.");
        }
      } else {
        sendSyncMessage(message.getMessageContent());

        pendingNotificationManager.deletePendingNotifications(
            username, deviceId, message.getSyncSources());
        if (logger.isTraceEnabled()) {
          logger.trace("Pending notifications sent to device " + deviceId);
        }
      }
    } catch (PendingNotificationException ex) {
      logger.error("Error while retrieving pending notification messages", ex);
    }
  }
Пример #2
0
 public synchronized void onClose() {
   sessionState.onClose(this);
   setSessionState(new StateDiconnected());
   if (logger.isTraceEnabled()) {
     logger.trace("Connection closed for device '" + getDeviceId() + "'");
   }
 }
Пример #3
0
  /**
   * Forward the authentication request to the Authentication Manager
   *
   * @return
   * @throws com.funambol.ctp.server.authentication.AuthenticationException
   */
  protected AuthorizationResponse forwardAuthenticationRequest() throws AuthenticationException {

    String username = (String) session.getAttribute(ATTRIBUTE_USERNAME);
    String deviceId = (String) session.getAttribute(ATTRIBUTE_DEVID);
    String credential = (String) session.getAttribute(ATTRIBUTE_CRED);
    if (logger.isTraceEnabled()) {
      logger.trace("Authenticating user '" + username + "', deviceId: '" + deviceId + "'");
    }
    AuthorizationResponse result =
        authenticationManager.authenticate(username, deviceId, credential);
    return result;
  }
Пример #4
0
  protected void forwardSubscription() {
    String deviceId = (String) session.getAttribute(ATTRIBUTE_DEVID);
    if (deviceId == null || "".equals(deviceId)) {
      logger.error("Unable to retrieve device id from session attributes");
      closeSession();
      return;
    }

    dispatcher.subscribe(deviceId, this);
    if (logger.isTraceEnabled()) {
      logger.trace("Subscribed notification for device " + deviceId);
    }
  }
Пример #5
0
  private void setSessionState(State sessionState) {

    if (this.sessionState.deepequals(sessionState)) {
      return;
    }
    if (this.sessionState.deepequals(new StateDiconnected())
        && !(sessionState.deepequals(new StateDiconnected()))) {
      logger.error(
          "status transition from "
              + this.sessionState.getName()
              + " to "
              + sessionState.getName()
              + " in not allowed");
      return;
    }
    if (logger.isTraceEnabled()) {
      logger.trace(
          "Changing status from " + this.sessionState.getName() + " to " + sessionState.getName());
    }
    this.sessionState = sessionState;
  }