Changeset 172
- Timestamp:
- 06/28/11 14:41:38 (12 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/changelog.txt
r142 r172 29 29 - Added: DreamboxPlugin (csp-agent) support for more/older dm500 images. Basic (unsecured) file upload support. 30 30 - 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. 31 32 32 33 - Changes to proxy.xml: -
trunk/config/proxy-reference.html
r165 r172 793 793 794 794 <a name="user-manager/auth-config/user"> 795 <div class='indent'><strong>user-manager/auth-config/user (attributes: *name, *password, display-name, ip-mask, profiles, max-connections, admin, enabled )</strong></div><br />795 <div class='indent'><strong>user-manager/auth-config/user (attributes: *name, *password, display-name, ip-mask, profiles, max-connections, admin, enabled, map-exclude, start-date, expiration-date, debug)</strong></div><br /> 796 796 One user definition for the SimpleUserManager (also used by the XmlUserManager, see <strong>README.XmlUserManager.txt</strong> for more details):<br /><br /> 797 797 - <strong class='bold'>name</strong>: User name, avoid long names, spaces and special characters. There are no particular limitations as far as the proxy is concerned, but the camd clients may have them.<br /> … … 804 804 - <strong class='bold'>enabled</strong>: true/false (default: true). Allows disabling of accounts without deleting them.<br /> 805 805 - <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 user account.<br /> 807 - <strong class='bold'>expiration-date</strong>: (dd-mm-yyyy) Expiration date for the user account.<br /> 806 808 - <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 /> 807 809 <br /> -
trunk/src/com/bowman/cardserv/SimpleUserManager.java
r165 r172 70 70 } catch (ConfigException e) {} 71 71 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 72 82 int maxConnections = xml.getIntValue("max-connections", -1); 73 83 … … 78 88 79 89 UserEntry user = new UserEntry(xml.getStringValue("name"), xml.getStringValue("password"), ipMask, emailAddr, 80 maxConnections, enabled, admin, exclude, debug);90 maxConnections, enabled, admin, exclude, startDate, expirationDate, debug); 81 91 82 92 try { … … 164 174 } 165 175 176 public String getStartDate(String user) { 177 UserEntry entry = getUser(user); 178 if(entry == null) return null; 179 else return entry.startDate; 180 } 181 182 public String getExpirationDate(String user) { 183 UserEntry entry = getUser(user); 184 if(entry == null) return null; 185 else return entry.expirationDate; 186 } 187 166 188 public Set getAllowedProfiles(String user) { 167 189 UserEntry entry = getUser(user); … … 235 257 String ipMask; 236 258 String email, displayName; 259 String startDate, expirationDate; 237 260 int maxConnections; 238 261 boolean enabled, admin, exclude, debug; … … 240 263 241 264 public UserEntry(String name, String password, String ipMask, String email, int maxConnections, boolean enabled, 242 boolean admin, boolean exclude, boolean debug)265 boolean admin, boolean exclude, String startDate, String expirationDate, boolean debug) 243 266 { 244 267 this.name = name; … … 251 274 this.admin = admin; 252 275 this.exclude = exclude; 276 this.startDate = startDate; 277 this.expirationDate = expirationDate; 253 278 this.debug = debug; 254 279 } -
trunk/src/com/bowman/cardserv/interfaces/UserManager.java
r165 r172 34 34 Set getAllowedConnectors(String user); // return Set of String, null for all 35 35 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); 36 38 37 39 } -
trunk/src/com/bowman/cardserv/rmi/RemoteHandler.java
r165 r172 175 175 } else { 176 176 String displayName = session.isTempUser()?session.getLoginName():um.getDisplayName(name); 177 user = new UserStatus(name, displayName, um.get MaxConnections(name), false);177 user = new UserStatus(name, displayName, um.getStartDate(name), um.getExpirationDate(name), um.getMaxConnections(name), false); 178 178 user.addSession(session); 179 179 users.put(name, user); … … 205 205 if(user == null) { 206 206 String displayName = session.isTempUser()?session.getLoginName():um.getDisplayName(userName); 207 user = new UserStatus(userName, displayName, um.get MaxConnections(userName), um.isAdmin(userName));207 user = new UserStatus(userName, displayName, um.getStartDate(userName), um.getExpirationDate(userName), um.getMaxConnections(userName), um.isAdmin(userName)); 208 208 } 209 209 user.addSession(session); -
trunk/src/com/bowman/cardserv/rmi/UserStatus.java
r165 r172 17 17 private static final long serialVersionUID = -4091190186183181716L; 18 18 19 private final String userName, displayName ;19 private final String userName, displayName, startDate, expirationDate; 20 20 private final boolean admin; 21 21 private final int maxSessions; … … 23 23 private final List sessions = new ArrayList(); 24 24 25 public UserStatus(String userName, String displayName, int maxSessions, boolean admin) {25 public UserStatus(String userName, String displayName, String startDate, String expirationDate, int maxSessions, boolean admin) { 26 26 this.userName = userName; 27 27 this.displayName = displayName; 28 28 this.admin = admin; 29 this.startDate = startDate; 30 this.expirationDate = expirationDate; 29 31 this.maxSessions = maxSessions; 30 32 } … … 40 42 public boolean isAdmin() { 41 43 return admin; 44 } 45 46 public String getStartDate() { 47 return startDate; 48 } 49 50 public String getExpirationDate() { 51 return expirationDate; 42 52 } 43 53 -
trunk/src/com/bowman/cardserv/session/NewcamdSession.java
r165 r172 9 9 import java.net.*; 10 10 import java.io.*; 11 import java.text.DateFormat; 12 import java.text.ParseException; 13 import java.text.SimpleDateFormat; 11 14 import java.util.*; 12 15 … … 113 116 } else if(checkProfile && !profiles.contains(getProfileName())) { 114 117 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); 115 120 } else { // successful login 116 121 … … 189 194 checksOk = checksOk && handleMessage(msg); 190 195 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 } 191 200 if(!checksOk) { 192 201 setFlag(msg, 'B'); … … 211 220 protected boolean checkClientId(String id) { 212 221 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; 213 266 } 214 267 -
trunk/src/com/bowman/cardserv/web/XmlHelper.java
r165 r172 872 872 xb.appendElement("user", "name", users[i].getUserName()); 873 873 xb.appendAttr("display-name", users[i].getDisplayName()); 874 xb.appendAttr("start-date", users[i].getStartDate()); 875 xb.appendAttr("expiration-date", users[i].getExpirationDate()); 874 876 if(users[i].isAdmin()) xb.appendAttr("admin", users[i].isAdmin()); 875 877
Note:
See TracChangeset
for help on using the changeset viewer.