Changeset 154 for trunk/src/com/bowman/cardserv/SimpleUserManager.java
- Timestamp:
- 06/27/11 15:07:42 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/com/bowman/cardserv/SimpleUserManager.java
r153 r154 70 70 } catch (ConfigException e) {} 71 71 72 String expireDate = null; try { expireDate = xml.getStringValue("endDate"); } catch(ConfigException e) { expireDate = null; }73 String startDate = null; try { startDate = xml.getStringValue("startDate"); } catch(ConfigException e) { startDate = null; }74 int EcmRate = -1; try { EcmRate = xml.getIntValue("ecm-rate"); } catch(ConfigException e) { EcmRate = -1; }75 72 int maxConnections = xml.getIntValue("max-connections", -1); 76 73 … … 78 75 boolean admin = "true".equalsIgnoreCase(xml.getStringValue("admin", "false")); 79 76 boolean exclude = "true".equalsIgnoreCase(xml.getStringValue("map-exclude", "false")); 80 boolean debug = "true".equalsIgnoreCase(xml.getStringValue("debug", "true")); 81 boolean spider = "true".equalsIgnoreCase(xml.getStringValue("spider", "true")); 77 boolean debug = "true".equalsIgnoreCase(xml.getStringValue("debug", "false")); 82 78 83 79 UserEntry user = new UserEntry(xml.getStringValue("name"), xml.getStringValue("password"), ipMask, emailAddr, 84 maxConnections, enabled, admin, exclude, debug , startDate, expireDate, EcmRate, spider);80 maxConnections, enabled, admin, exclude, debug); 85 81 86 82 try { … … 92 88 for(StringTokenizer st = new StringTokenizer(profiles); st.hasMoreTokens(); ) user.profiles.add(st.nextToken()); 93 89 } catch (ConfigException e) {} 94 try { 95 String allowServ = xml.getStringValue("allowedServices"); 96 for(StringTokenizer st = new StringTokenizer(allowServ); st.hasMoreTokens(); ) user.allowedServices.add(st.nextToken()); 97 } catch (ConfigException e) {} 98 try { 99 String blockServ = xml.getStringValue("blockedServices"); 100 for(StringTokenizer st = new StringTokenizer(blockServ); st.hasMoreTokens(); ) user.blockedServices.add(st.nextToken()); 101 } catch (ConfigException e) {} 102 try { 103 String allowConn = xml.getStringValue("allowedConnectors"); 104 for(StringTokenizer st = new StringTokenizer(allowConn); st.hasMoreTokens(); ) user.allowedConnectors.add(st.nextToken()); 105 } catch (ConfigException e) {} 90 106 91 return user; 107 92 } … … 135 120 } else return entry.password; 136 121 } 137 public String getExpireDate(String user) { UserEntry _la = getUser(user); if(_la == null) return null; else return _la.expireDate; }138 public boolean isSpider(String user) { UserEntry entry = getUser(user); if(entry == null) return false; else return entry.spider; }139 public String getStartDate(String user) { UserEntry entry = getUser(user); if(entry == null) return null; else return entry.startDate; }140 122 141 123 public String getUserName(String user) { … … 232 214 233 215 // access control/limits 234 public Set getAllowedServices(String user, String profile) {216 public Set getAllowedServices(String user, String profile) { 235 217 return null; // return Set of Integer, null for all 236 } /* 237 { 238 HashSet hashset = new HashSet(); 239 if((user = getUser(user)) != null && !((g) (user)).r.isEmpty()) 240 { 241 user = ((g) (user)).r.iterator(); 242 do 243 { 244 if(!user.hasNext()) 245 break; 246 String s2; 247 if((s2 = (String)user.next()).matches("^" + profile + ":[a-zA-Z0-9]*")) 248 hashset.add(new Integer(Integer.parseInt(s2.replace(profile + ":", ""), 16))); 249 } while(true); 250 } else 251 { 252 hashset = null; 253 } 254 return hashset; 255 } */ 256 257 public Set getBlockedServices(String user, String profile) 258 { 259 return null; // return Set of Integer, null for all 260 } /* 261 { 262 UserEntry entry = getUser(user); 263 if((user = a(user)) != null && !((g) (user)).s.isEmpty()) 264 { 265 user = ((g) (user)).s.iterator(); 266 do 267 { 268 if(!user.hasNext()) 269 break; 270 String s2; 271 if((s2 = (String)user.next()).matches("^" + profile + ":[a-zA-Z0-9]*")) 272 hashset.add(new Integer(Integer.parseInt(s2.replace(profile + ":", ""), 16))); 273 } while(true); 274 } else 275 { 276 hashset = null; 277 } 278 return hashset; 279 } */ 280 281 public Set getAllowedConnectors(String user) { 282 UserEntry entry = getUser(user); 283 if(entry == null) { 284 return Collections.EMPTY_SET; 285 } 286 else return entry.allowedConnectors; 287 } 288 289 public int getAllowedEcmRate(String user) { 290 UserEntry entry = getUser(user); 291 if(entry == null) return -1; 292 else return entry.EcmRate; 293 } 294 295 static class UserEntry { 296 297 String name, password; 298 String ipMask; 299 String email, displayName, expireDate, startDate; 300 int maxConnections, EcmRate; 301 boolean enabled, admin, exclude, debug, spider; 302 Set profiles = new HashSet(); 303 Set blockedServices = new HashSet(); 304 Set allowedServices = new HashSet(); 305 Set allowedConnectors = new HashSet(); 306 public UserEntry(String name, String password, String ipMask, String email, int maxConnections, boolean enabled, 307 boolean admin, boolean exclude, boolean debug, String startDate, String expireDate, int EcmRate, boolean spider) 308 { 309 this.name = name; 310 this.displayName = name; 311 this.password = password; 312 this.ipMask = ipMask; 313 this.email = email; 314 this.maxConnections = maxConnections; 315 this.enabled = enabled; 316 this.admin = admin; 317 this.exclude = exclude; 318 this.debug = debug; 319 this.spider = spider; 320 this.expireDate = expireDate; 321 this.EcmRate = EcmRate; 322 this.startDate = startDate; 323 } 218 } 219 220 public Set getBlockedServices(String user, String profile) { 221 return null; // return Set of Integer, null for all 222 } 223 224 public Set getAllowedConnectors(String user) { 225 return null; // return Set of String, null for all 226 } 227 228 public int getAllowedEcmRate(String user) { 229 return -1; // return minimum interval between ecm in seconds, -1 for no limit 230 } 231 232 static class UserEntry { 233 234 String name, password; 235 String ipMask; 236 String email, displayName; 237 int maxConnections; 238 boolean enabled, admin, exclude, debug; 239 Set profiles = new HashSet(); 240 241 public UserEntry(String name, String password, String ipMask, String email, int maxConnections, boolean enabled, 242 boolean admin, boolean exclude, boolean debug) 243 { 244 this.name = name; 245 this.displayName = name; 246 this.password = password; 247 this.ipMask = ipMask; 248 this.email = email; 249 this.maxConnections = maxConnections; 250 this.enabled = enabled; 251 this.admin = admin; 252 this.exclude = exclude; 253 this.debug = debug; 254 } 324 255 325 256 }
Note:
See TracChangeset
for help on using the changeset viewer.