Changeset 178


Ignore:
Timestamp:
07/01/11 00:13:31 (12 years ago)
Author:
bowman
Message:

Moved recent changes to SimpleUserManager and core to a separate TestUserManager to better illustrate how such extensions are meant to be implemented. This fixes any independently maintained managers that were broken by the additions to the UserManager interface and SimpleUserManager.

Location:
trunk
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/README.txt

    r50 r178  
    6060The proxy prefers a sun JRE (1.4.2 or later) but others like JamVM _may_ work. If you're interested in getting the
    6161proxy to run properly under gcj/gij or any other non-sun jre, contact me on efnet (be prepared to make source changes).
    62 As of 0.9.0 the proxy will not start with non-sun jvms, unless you explicit force it to by adding the cmd line argument:
     62As of 0.9.0 the proxy will not start with non-sun jvms, unless you explicitly force it to by adding the cmd line argument:
    6363-Dcom.bowman.cardserv.allowanyjvm=true
    6464
  • trunk/changelog.txt

    r175 r178  
    1616- Fixed: Closing of old sessions (on new login) wasn't working for ExtNewcamd.
    1717- Fixed: Debug mode for the "*" pseudo profile (Csp, ExtNewcamd) couldn't be turned off via config (attribute ignored).
     18- Fixed: Removing a profile from a user that had used csp-connect had no effect, as it remained locally cached at the
     19  client proxy, and no mechanism existed for removing it or blocking the now disallowed requests.
    1820- Changed: Two ecms (or dcw replies) with the same payload data but different dvb table ids (even/0x80 vs odd/0x81) are
    1921  now considered identical by the proxy. Implications unknown.
     
    2931- Added: DreamboxPlugin (csp-agent) support for more/older dm500 images. Basic (unsecured) file upload support.
    3032- Added: proxy-reference.html updated with highlighting for important elements and additional examples.
    31 - Added: Ability to set start and expiration date for user accounts (only Simple and XmlUsermanager).
    32 - Added: Ability to set minimum interval between ecm's in seconds (only Simple and XmlUsermanager).
     33- Added: New TestUserManager to show how to add um-specific functionality without changing the core or existing um's.
    3334
    3435- Changes to proxy.xml:
  • trunk/config/proxy-reference.html

    r174 r178  
    804804- <strong class='bold'>enabled</strong>: true/false (default: true). Allows disabling of accounts without deleting them.<br />
    805805- <strong class='bold'>map-exclude</strong>: true/false (default: false). Set to true to prevent the user from causing changes to the service maps. If a particular user is sending bad ecms or is otherwise misbehaving, this will protect the service mappings and ensure no other users are affected. Only use this if you are sure a particular client is misbehaving, the service mapping can't work if no clients are allowed to update the map.<br />
    806 - <strong class='bold'>start-date</strong>: (dd-mm-yyyy) Start date for the user account.<br />
    807 - <strong class='bold'>expiration-date</strong>: (dd-mm-yyyy) Expiration date for the user account.<br />
    808 - <strong class='bold'>ecm-rate</strong>: Minimum interval between ecm's in seconds (disabled by default).<br />
    809806- <strong class='bold'>debug</strong>: true/false (default: false). Set to true to enable ecm/emm/zap logging for this user only (has no effect if these are already enabled globally).<br />
    810807<br />
  • trunk/src/com/bowman/cardserv/SimpleUserManager.java

    r173 r178  
    7070    } catch (ConfigException e) {}
    7171
    72     String startDate = null;
    73     try {
    74       startDate = xml.getStringValue("start-date");
    75     } catch (ConfigException e) {}
    76 
    77     String expirationDate = null;
    78     try {
    79       expirationDate = xml.getStringValue("expiration-date");
    80     } catch (ConfigException e) {}
    81 
    82     int EcmRate = -1;
    83     try {
    84       EcmRate = xml.getIntValue("ecm-rate");
    85     } catch (ConfigException e) {}
    86 
    8772    int maxConnections = xml.getIntValue("max-connections", -1);
    8873
     
    9378
    9479    UserEntry user = new UserEntry(xml.getStringValue("name"), xml.getStringValue("password"), ipMask, emailAddr,
    95         maxConnections, enabled, admin, exclude, startDate, expirationDate, EcmRate, debug);
     80        maxConnections, enabled, admin, exclude, debug);
    9681
    9782    try {
     
    179164  }
    180165
    181   public String getStartDate(String user) {
    182     UserEntry entry = getUser(user);
    183     if(entry == null) return null;
    184     else return entry.startDate;
    185   }
    186 
    187   public String getExpirationDate(String user) {
    188     UserEntry entry = getUser(user);
    189     if(entry == null) return null;
    190     else return entry.expirationDate;
    191   }
    192 
    193166  public Set getAllowedProfiles(String user) {
    194167    UserEntry entry = getUser(user);
     
    254227
    255228  public int getAllowedEcmRate(String user) {
    256     UserEntry entry = getUser(user);
    257     if(entry == null) return -1; // return minimum interval between ecm in seconds, -1 for no limit
    258     else return entry.EcmRate;
     229    return -1; // return minimum interval between ecm in seconds, -1 for no limit
    259230  }
    260231
     
    264235    String ipMask;
    265236    String email, displayName;
    266     String startDate, expirationDate;
    267     int maxConnections, EcmRate;
     237    int maxConnections;
    268238    boolean enabled, admin, exclude, debug;
    269239    Set profiles = new HashSet();
    270240
    271241    public UserEntry(String name, String password, String ipMask, String email, int maxConnections, boolean enabled,
    272                      boolean admin, boolean exclude, String startDate, String expirationDate, int EcmRate, boolean debug)
     242                     boolean admin, boolean exclude, boolean debug)
    273243    {
    274244      this.name = name;
     
    281251      this.admin = admin;
    282252      this.exclude = exclude;
    283       this.startDate = startDate;
    284       this.expirationDate = expirationDate;
    285       this.EcmRate = EcmRate;
    286253      this.debug = debug;
    287254    }
  • trunk/src/com/bowman/cardserv/interfaces/UserManager.java

    r172 r178  
    3434  Set getAllowedConnectors(String user); // return Set of String, null for all
    3535  int getAllowedEcmRate(String user); // return minimum interval between ecm in seconds, -1 for no limit
    36   String getStartDate(String user);
    37   String getExpirationDate(String user);
    3836
    3937}
  • trunk/src/com/bowman/cardserv/rmi/RemoteHandler.java

    r172 r178  
    175175      } else {
    176176        String displayName = session.isTempUser()?session.getLoginName():um.getDisplayName(name);
    177         user = new UserStatus(name, displayName, um.getStartDate(name), um.getExpirationDate(name), um.getMaxConnections(name), false);
     177        user = new UserStatus(name, displayName, um.getMaxConnections(name), false);
    178178        user.addSession(session);
    179179        users.put(name, user);
     
    205205        if(user == null) {
    206206          String displayName = session.isTempUser()?session.getLoginName():um.getDisplayName(userName);
    207           user = new UserStatus(userName, displayName, um.getStartDate(userName), um.getExpirationDate(userName), um.getMaxConnections(userName), um.isAdmin(userName));
     207          user = new UserStatus(userName, displayName,um.getMaxConnections(userName), um.isAdmin(userName));
    208208        }
    209209        user.addSession(session);
  • trunk/src/com/bowman/cardserv/rmi/UserStatus.java

    r172 r178  
    1717  private static final long serialVersionUID = -4091190186183181716L;
    1818
    19   private final String userName, displayName, startDate, expirationDate;
     19  private final String userName, displayName;
    2020  private final boolean admin;
    2121  private final int maxSessions;
     
    2323  private final List sessions = new ArrayList();
    2424
    25   public UserStatus(String userName, String displayName, String startDate, String expirationDate, int maxSessions, boolean admin) {
     25  public UserStatus(String userName, String displayName, int maxSessions, boolean admin) {
    2626    this.userName = userName;
    2727    this.displayName = displayName;
    2828    this.admin = admin;
    29     this.startDate = startDate;
    30     this.expirationDate = expirationDate;
    3129    this.maxSessions = maxSessions;
    3230  }
     
    4240  public boolean isAdmin() {
    4341    return admin;
    44   }
    45 
    46   public String getStartDate() {
    47     return startDate;
    48   }
    49 
    50   public String getExpirationDate() {
    51     return expirationDate;
    5242  }
    5343
  • trunk/src/com/bowman/cardserv/session/NewcamdSession.java

    r172 r178  
    11package com.bowman.cardserv.session;
    22
     3import com.bowman.cardserv.*;
    34import com.bowman.cardserv.crypto.DESUtil;
     5import com.bowman.cardserv.cws.CwsConnectorManager;
    46import com.bowman.cardserv.interfaces.*;
    5 import com.bowman.cardserv.*;
    6 import com.bowman.cardserv.cws.CwsConnectorManager;
    77import com.bowman.util.Globber;
    88
     9import java.io.*;
    910import java.net.*;
    10 import java.io.*;
    11 import java.text.DateFormat;
    12 import java.text.ParseException;
    13 import java.text.SimpleDateFormat;
    1411import java.util.*;
    1512
     
    116113          } else if(checkProfile && !profiles.contains(getProfileName())) {
    117114            loginFailure(user, "no access for profile: " + getProfileName(), msg);
    118           } else if(checkAccountExpired(user, um) || checkAccountStarted(user, um)) {
    119             loginFailure(user, "account has expired or has not reached start date yet", msg);
    120115          } else { // successful login
    121116
     
    194189            checksOk = checksOk && handleMessage(msg);
    195190            fireCamdMessage(msg, false); // still need to notify the rest of the proxy about the bad message to give plugins and logging a chance to see it
    196             if(checkAccountExpired(this.user, um)) {
    197               logger.warning("'User '" + user + "' kicked, account has expired");
    198               close();
    199             }
    200191            if(!checksOk) {
    201192              setFlag(msg, 'B');
     
    220211  protected boolean checkClientId(String id) {
    221212    return true;
    222   }
    223 
    224   public boolean checkAccountStarted(String user, UserManager um) {
    225     Date startedDateDt = null;
    226     try {
    227       String startedDateStr = um.getStartDate(user);
    228       DateFormat df = new SimpleDateFormat("dd-MM-yyyy");
    229       if (startedDateStr == null)
    230         startedDateDt = null;
    231       else
    232         startedDateDt = df.parse(startedDateStr);
    233     }
    234     catch(ParseException ignored) {}
    235     long currDateMs = System.currentTimeMillis();
    236     long startedDateMs = 0;
    237 
    238     if (startedDateDt != null)
    239       startedDateMs = startedDateDt.getTime();
    240 
    241     return (startedDateMs != 0) && (currDateMs < startedDateMs);
    242   }
    243 
    244   public boolean checkAccountExpired(String user, UserManager um) {
    245     Date expirationDateDt = null;
    246     long currDate = System.currentTimeMillis();
    247     long expirationDateMs = 0L;
    248     try
    249     {
    250       String expirationDateStr = um.getExpirationDate(user);
    251       DateFormat df = new SimpleDateFormat("dd-MM-yyyy");
    252 
    253       if(expirationDateStr == null)
    254         expirationDateDt = null;
    255       else
    256         expirationDateDt = df.parse(expirationDateStr);
    257     }
    258     catch(ParseException ex) { }
    259     currDate = System.currentTimeMillis();
    260     expirationDateMs = 0L;
    261 
    262     if(expirationDateDt != null)
    263       expirationDateMs = expirationDateDt.getTime();
    264 
    265     return expirationDateMs != 0L && currDate > expirationDateMs;
    266213  }
    267214
  • trunk/src/com/bowman/cardserv/web/XmlHelper.java

    r172 r178  
    872872      xb.appendElement("user", "name", users[i].getUserName());
    873873      xb.appendAttr("display-name", users[i].getDisplayName());
    874       xb.appendAttr("start-date", users[i].getStartDate());
    875       xb.appendAttr("expiration-date", users[i].getExpirationDate());
    876874      if(users[i].isAdmin()) xb.appendAttr("admin", users[i].isAdmin());
    877875
Note: See TracChangeset for help on using the changeset viewer.