Changeset 152


Ignore:
Timestamp:
06/23/11 14:36:55 (12 years ago)
Author:
bowman
Message:

Fixed csp-connect bug where profiles removed from a user were still available to the client proxy as long as the locally cached service state remained (and no removal from that state ever occured, short of a manual reset).

Location:
trunk/src/com/bowman/cardserv
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/com/bowman/cardserv/cws/CspCwsConnector.java

    r11 r152  
    150150  }
    151151
    152   private void handleStatusUpdate(CspNetMessage msg, boolean full) throws IOException {
     152  private void handleStatusUpdate(CspNetMessage msg, boolean full, boolean initial) throws IOException {
    153153    // notify service mappers
    154154    if(!msg.isEmpty()) {
     
    158158        updates = msg.getStatusUpdatesForKey(key);
    159159        if(updates != null) reportRemoteState(key, updates, full);
     160      }
     161      if(initial) { // remove profiles no longer available from the state before saving
     162        for(Iterator iter = receivedState.keySet().iterator(); iter.hasNext(); ) {
     163          key = (CspNetMessage.ProfileKey)iter.next();
     164          if(!keys.contains(key)) {
     165            iter.remove();
     166            logger.warning("Profile no longer available: " + key);
     167            CaProfile profile = config.getProfileById(key.onid, key.caid);
     168            if(profile != null) { // remove local service mappings if removed remote profile had a corresponding local one
     169              connManager.reportMultiStatus(this, profile, new ServiceMapping[0], true, false); // clear candecode
     170              connManager.reportMultiStatus(this, profile, new ServiceMapping[0], false, false); // clear cannotdecode
     171            }
     172          }
     173        }
    160174      }
    161175      saveRemoteState();
     
    272286      } else {
    273287        remoteProxyId = msg.getOriginId();
    274         handleStatusUpdate(msg, true);
     288        handleStatusUpdate(msg, true, true);
    275289
    276290        if(remoteProxyId == config.getProxyOriginId()) {
     
    308322                break;
    309323              case CspNetMessage.TYPE_FULLSTATE:
    310                 handleStatusUpdate(msg, true);
     324                handleStatusUpdate(msg, true, false);
    311325                break;
    312326              case CspNetMessage.TYPE_INCRSTATE:
    313                 handleStatusUpdate(msg, false);
     327                handleStatusUpdate(msg, false, false);
    314328                break;
    315329              case CspNetMessage.TYPE_STATEACK:
  • trunk/src/com/bowman/cardserv/session/AbstractSession.java

    r142 r152  
    2626  boolean userDebug;
    2727
    28   Set allowedConnectors, mappedProfiles;
     28  Set allowedConnectors, mappedProfiles, allowedProfiles = new HashSet();
    2929  Map allowedServices, blockedServices;
    3030  int allowedRate;
     
    141141    allowedConnectors = um.getAllowedConnectors(user);
    142142    allowedRate = um.getAllowedEcmRate(user);
     143    allowedProfiles = um.getAllowedProfiles(user);
    143144    if(allowedRate != -1) allowedRate = allowedRate * 1000;
    144145    if(um.isAdmin(user)) maxPending = 30;
     
    188189
    189190      if(interval < 60000) avgList.addRecord(now, (int)interval); // avoid extreme entries after standby/idletime
     191
     192      if(!allowedProfiles.isEmpty())
     193        if(!allowedProfiles.contains(profileName)) {
     194          msg.setFilteredBy("Profile not allowed: " + profileName);
     195          return false;
     196        }
    190197
    191198      Set services;
Note: See TracChangeset for help on using the changeset viewer.