Changeset 165
- Timestamp:
- 06/28/11 12:55:21 (12 years ago)
- Location:
- trunk
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/CardServProxy.ipr
r155 r165 11 11 <properties /> 12 12 </buildFile> 13 <buildFile url="file://$PROJECT_DIR$/build.local.xml"> 14 <additionalClassPath /> 15 <antReference projectDefault="true" /> 16 <customJdkName value="" /> 17 <maximumHeapSize value="128" /> 18 <maximumStackSize value="32" /> 19 <properties /> 20 </buildFile> 13 21 </component> 14 22 <component name="BuildJarProjectSettings"> … … 30 38 <option name="LABEL_INDENT_SIZE" value="0" /> 31 39 <option name="LABEL_INDENT_ABSOLUTE" value="false" /> 32 <option name="USE_RELATIVE_INDENTS" value="false" />33 40 </ADDITIONAL_INDENT_OPTIONS> 34 41 <ADDITIONAL_INDENT_OPTIONS fileType="jsp"> … … 40 47 <option name="LABEL_INDENT_SIZE" value="0" /> 41 48 <option name="LABEL_INDENT_ABSOLUTE" value="false" /> 42 <option name="USE_RELATIVE_INDENTS" value="false" />43 49 </ADDITIONAL_INDENT_OPTIONS> 44 50 <ADDITIONAL_INDENT_OPTIONS fileType="xml"> … … 50 56 <option name="LABEL_INDENT_SIZE" value="0" /> 51 57 <option name="LABEL_INDENT_ABSOLUTE" value="false" /> 52 <option name="USE_RELATIVE_INDENTS" value="false" />53 58 </ADDITIONAL_INDENT_OPTIONS> 54 59 </value> … … 154 159 <option name="PARAMETER" value="true" /> 155 160 <option name="REPORT_PARAMETER_FOR_PUBLIC_METHODS" value="true" /> 161 <option name="INJECTION_ANNOS"> 162 <value> 163 <list size="0" /> 164 </value> 165 </option> 156 166 </inspection_tool> 157 167 <inspection_tool class="UnterminatedStatementJS" enabled="false" level="WARNING" enabled_by_default="false" /> … … 161 171 <option name="ADD_SERVLET_TO_ENTRIES" value="true" /> 162 172 <option name="ADD_NONJAVA_TO_ENTRIES" value="true" /> 173 <option name="ADDITIONAL_ANNOTATIONS"> 174 <value> 175 <list size="1"> 176 <item index="0" class="java.lang.String" itemvalue="javax.ws.rs.*" /> 177 </list> 178 </value> 179 </option> 180 <option name="ADD_EJB_TO_ENTRIES" value="true" /> 181 <option name="ADD_TESTNG_TO_ENTRIES" value="true" /> 182 <option name="ADD_JUNIT_TO_ENTRIES" value="true" /> 163 183 </inspection_tool> 164 184 </profile> … … 167 187 <option name="USE_PROJECT_PROFILE" value="true" /> 168 188 <version value="1.0" /> 169 <list size=" 6">189 <list size="5"> 170 190 <item index="0" class="java.lang.String" itemvalue="SERVER PROBLEM" /> 171 <item index="1" class="java.lang.String" itemvalue="WEAK WARNING" /> 172 <item index="2" class="java.lang.String" itemvalue="INFO" /> 173 <item index="3" class="java.lang.String" itemvalue="TYPO" /> 174 <item index="4" class="java.lang.String" itemvalue="WARNING" /> 175 <item index="5" class="java.lang.String" itemvalue="ERROR" /> 191 <item index="1" class="java.lang.String" itemvalue="INFO" /> 192 <item index="2" class="java.lang.String" itemvalue="TYPO" /> 193 <item index="3" class="java.lang.String" itemvalue="WARNING" /> 194 <item index="4" class="java.lang.String" itemvalue="ERROR" /> 176 195 </list> 177 196 </component> … … 331 350 </modules> 332 351 </component> 333 <component name="ProjectResources">334 <default-html-doctype>http://www.w3.org/1999/xhtml</default-html-doctype>335 </component>336 352 <component name="ProjectRootManager" version="2" languageLevel="JDK_1_4" assert-keyword="true" jdk-15="false" project-jdk-name="1.6" project-jdk-type="JavaSDK" /> 337 353 <component name="ResourceManagerContainer"> -
trunk/config/proxy-reference.html
r163 r165 51 51 <ul> 52 52 <li><a href="#cardserv-proxy">/cardserv-proxy (attributes: *ver)</a></li> 53 <br />54 <li><a href="#msg-enabled">msg-enabled</a></li>55 <li><a href="#msg-emu">msg-emu</a></li>56 <li><a href="#msg-words">msg-words</a></li>57 <br />58 53 <li><a href="#ca-profiles">ca-profiles</a></li> 59 54 <ul> … … 260 255 </a> 261 256 262 <a name="msg-enabled">263 <div class='indent'><strong>msg-enabled</strong></div><br />264 ** please complete documentation ** <br />265 <br />266 Example: <em class='italic'><msg-enabled>true</msg-enabled></em><br />267 <br />268 </a>269 270 <a name="msg-emu">271 <div class='indent'><strong>msg-emu</strong></div><br />272 ** please complete documentation ** <br />273 <br />274 Example: <em class='italic'><msg-emu>Mgcamd Acamd Evocamd</msg-emu></em><br />275 <br />276 </a>277 278 <a name="msg-words">279 <div class='indent'><strong>msg-words</strong></div><br />280 ** please complete documentation ** <br />281 <br />282 Example: <em class='italic'><msg-words>Welcome to CardServProxy</msg-words></em><br />283 <br />284 </a>285 286 257 <a name="ca-profiles"> 287 258 <div class='indent'>ca-profiles</div><br /> … … 822 793 823 794 <a name="user-manager/auth-config/user"> 824 <div class='indent'><strong>user-manager/auth-config/user (attributes: *name, *password, display-name, ip-mask, profiles, max-connections, admin, enabled , start-date, expire-date, spider, ecm-rate)</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)</strong></div><br /> 825 796 One user definition for the SimpleUserManager (also used by the XmlUserManager, see <strong>README.XmlUserManager.txt</strong> for more details):<br /><br /> 826 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 /> … … 832 803 - <strong class='bold'>admin</strong>: true/false (default: false). Is this user an administrator? Affects access to http/xml api features only.<br /> 833 804 - <strong class='bold'>enabled</strong>: true/false (default: true). Allows disabling of accounts without deleting them.<br /> 834 - <strong class='bold'>start-date</strong>: (dd-mm-yyyy) Start date for user account.<br />835 - <strong class='bold'>expire-date</strong>: (dd-mm-yyy) Date after the user account expires.<br />836 - <strong class='bold'>spider</strong>: true/false (default: true) ** please complete documentation **<br />837 - <strong class='bold'>ecm-rate</strong>: ** please complete documentation **<br />838 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 /> 839 806 - <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 /> -
trunk/src/com/bowman/cardserv/ProxyConfig.java
r155 r165 38 38 private int proxyOriginId = (int)System.currentTimeMillis(); // use lower 4 bytes of sys clock as id for this run 39 39 private int logRotateCount, logRotateLimit; 40 private String logFile, logLevel, wtBadFlags , msgtoemu, clientMsg;40 private String logFile, logLevel, wtBadFlags; 41 41 private int wtMaxDelay, etMinCount, maxThreads, sessionTimeout, newcamdMaxMsgSize, maxPending, maxConnectionsIP; 42 private boolean silent, debug, userAllowOnFailure, logFailures, logEcm, logEmm, logZap, hideIPs, blockCaidMismatch , osdMsg;42 private boolean silent, debug, userAllowOnFailure, logFailures, logEcm, logEmm, logZap, hideIPs, blockCaidMismatch; 43 43 private boolean wtIncludeFile, userAllowDifferentIp; 44 44 … … 391 391 blockCaidMismatch = "true".equalsIgnoreCase(profileConf.getStringValue("block-caid-mismatch", "true")); 392 392 maxConnectionsIP = profileConf.getIntValue("max-connections-ip", 0); 393 osdMsg = "true".equalsIgnoreCase(profileConf.getStringValue("msg-enabled", "false"));394 clientMsg = profileConf.getStringValue("msg-words", " Your Account will Be Expire In ");395 msgtoemu = profileConf.getStringValue("msg-emu", "");396 393 397 394 ProxyXmlConfig keepAliveConf = null; … … 899 896 } 900 897 } 901 public String getclientMsg() {902 return clientMsg;903 }904 public String getmsgtoemu() {905 return msgtoemu;906 }907 public boolean getosdMsg(){908 return osdMsg;909 }910 898 } -
trunk/src/com/bowman/cardserv/SimpleUserManager.java
r159 r165 70 70 } catch (ConfigException e) {} 71 71 72 String expireDate = null;73 try {74 expireDate = xml.getStringValue("expire-date");75 } catch(ConfigException e) {76 expireDate = null;77 }78 79 String startDate = null;80 try {81 startDate = xml.getStringValue("start-date");82 } catch(ConfigException e) {83 startDate = null;84 }85 86 int EcmRate = -1;87 try {88 EcmRate = xml.getIntValue("ecm-rate");89 } catch(ConfigException e) {90 EcmRate = -1;91 }92 93 72 int maxConnections = xml.getIntValue("max-connections", -1); 94 73 … … 97 76 boolean exclude = "true".equalsIgnoreCase(xml.getStringValue("map-exclude", "false")); 98 77 boolean debug = "true".equalsIgnoreCase(xml.getStringValue("debug", "false")); 99 boolean spider = "true".equalsIgnoreCase(xml.getStringValue("spider", "true"));100 78 101 79 UserEntry user = new UserEntry(xml.getStringValue("name"), xml.getStringValue("password"), ipMask, emailAddr, 102 maxConnections, enabled, admin, exclude, debug , startDate, expireDate, EcmRate, spider);80 maxConnections, enabled, admin, exclude, debug); 103 81 104 82 try { … … 186 164 } 187 165 188 public String getExpireDate(String user) {189 UserEntry entry = getUser(user);190 if(entry == null) return null;191 else return entry.expireDate;192 }193 194 public boolean isSpider(String user) {195 UserEntry entry = getUser(user);196 if(entry == null) return false;197 else return entry.spider;198 }199 200 public String getStartDate(String user) {201 UserEntry entry = getUser(user);202 if(entry == null) return null;203 else return entry.startDate;204 }205 206 166 public Set getAllowedProfiles(String user) { 207 167 UserEntry entry = getUser(user); … … 267 227 268 228 public int getAllowedEcmRate(String user) { 269 UserEntry entry = getUser(user); 270 if(entry == null) return -1; 271 else return entry.EcmRate; 229 return -1; // return minimum interval between ecm in seconds, -1 for no limit 272 230 } 273 231 … … 276 234 String name, password; 277 235 String ipMask; 278 String email, displayName , expireDate, startDate;279 int maxConnections , EcmRate;280 boolean enabled, admin, exclude, debug , spider;236 String email, displayName; 237 int maxConnections; 238 boolean enabled, admin, exclude, debug; 281 239 Set profiles = new HashSet(); 282 240 283 241 public UserEntry(String name, String password, String ipMask, String email, int maxConnections, boolean enabled, 284 boolean admin, boolean exclude, boolean debug, String startDate, String expireDate, int EcmRate, boolean spider) { 242 boolean admin, boolean exclude, boolean debug) 243 { 285 244 this.name = name; 286 245 this.displayName = name; … … 293 252 this.exclude = exclude; 294 253 this.debug = debug; 295 this.spider = spider; 296 this.expireDate = expireDate; 297 this.EcmRate = EcmRate; 298 this.startDate = startDate; 299 } 300 } 254 } 255 256 } 257 301 258 } -
trunk/src/com/bowman/cardserv/interfaces/CamdConstants.java
r155 r165 17 17 public static final int EXT_GET_VERSION = 0xD6; 18 18 public static final int EXT_SID_LIST = 0xD7; 19 public static final int CWS_CHECKSPID = 0xA1;20 19 21 20 public static final int -
trunk/src/com/bowman/cardserv/interfaces/UserManager.java
r155 r165 16 16 boolean authenticate(String user, String pass); 17 17 int getMaxConnections(String user); 18 String getExpireDate(String user);19 String getStartDate(String s);20 18 String getIpMask(String user); 21 19 String getEmailAddress(String user); … … 28 26 boolean isDebug(String user); 29 27 void setDebug(String user, boolean debug); 30 boolean isSpider(String user);31 28 int getUserCount(); 32 29 void start(); -
trunk/src/com/bowman/cardserv/proxy.xml
r156 r165 3 3 <ca-profiles> 4 4 <default-des-key>01 02 03 04 05 06 07 08 09 10 11 12 13 14</default-des-key> 5 <msg-enabled>false</msg-enabled>6 <msg-emu>Mgcamd Acamd Prifix Dream Smartlink LinkSuper LinkSat Ig Derake Evocamd</msg-emu>7 <msg-words>Welcome to CardServProxy</msg-words>8 5 9 6 <extended-newcamd listen-port="15112" debug="true"/> … … 44 41 <user name="admin" password="secret" max-connections="3" admin="true"/> 45 42 <user name="user1" password="secret1" profiles="myprofile"/> 46 <user name="user2" password="secret2" ecm-rate="-1" start-date="01-06-2010" expire-date="15-10-2011"/>47 43 </auth-config> 48 44 </user-manager> -
trunk/src/com/bowman/cardserv/rmi/RemoteHandler.java
r158 r165 175 175 } else { 176 176 String displayName = session.isTempUser()?session.getLoginName():um.getDisplayName(name); 177 user = new UserStatus(name, displayName, um.getStartDate(name),um.getExpireDate(name),um.getMaxConnections(name), false);177 user = new UserStatus(name, displayName, 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.getStartDate(userName),um.getExpireDate(userName), um.getMaxConnections(userName), um.isAdmin(userName));207 user = new UserStatus(userName, displayName, um.getMaxConnections(userName), um.isAdmin(userName)); 208 208 } 209 209 user.addSession(session); -
trunk/src/com/bowman/cardserv/rmi/UserStatus.java
r158 r165 20 20 private final boolean admin; 21 21 private final int maxSessions; 22 private final String expire, start;23 22 24 23 private final List sessions = new ArrayList(); 25 24 26 public UserStatus(String userName, String displayName, String start, String expire,int maxSessions, boolean admin) {25 public UserStatus(String userName, String displayName, int maxSessions, boolean admin) { 27 26 this.userName = userName; 28 27 this.displayName = displayName; 29 28 this.admin = admin; 30 this.start = start;31 this.expire = expire;32 29 this.maxSessions = maxSessions; 33 30 } … … 43 40 public boolean isAdmin() { 44 41 return admin; 45 }46 47 public String getStartDate() {48 return start;49 }50 51 public String getExpireDate() {52 return expire;53 42 } 54 43 -
trunk/src/com/bowman/cardserv/session/AbstractSession.java
r155 r165 25 25 String remoteAddress; 26 26 boolean userDebug; 27 String startMsg;28 27 29 28 Set allowedConnectors, mappedProfiles, allowedProfiles = new HashSet(); -
trunk/src/com/bowman/cardserv/session/CspSession.java
r158 r165 264 264 } 265 265 266 public String getstartMsg() {267 return startMsg;268 }269 270 266 public void close() { 271 267 if(conn != null) conn.close(); -
trunk/src/com/bowman/cardserv/session/ExtNewcamdSession.java
r158 r165 260 260 } 261 261 262 public String getstartMsg() {263 return startMsg;264 }265 266 262 public void cwsConnectionFailed(CwsConnector cws, String message) {} 267 263 public void cwsEcmTimeout(CwsConnector cws, String message, int failureCount) {} -
trunk/src/com/bowman/cardserv/session/NewcamdSession.java
r158 r165 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;14 11 import java.util.*; 15 12 … … 23 20 24 21 private static final int LOGIN_SO_TIMEOUT = 30 * 1000; 25 public String OsdMessage; 22 26 23 private int emmCount, keepAliveCount; 27 24 private long lastKeepAliveTimeStamp; … … 116 113 } else if(checkProfile && !profiles.contains(getProfileName())) { 117 114 loginFailure(user, "no access for profile: " + getProfileName(), msg); 118 } else if(checkExpired(user, um) || checkStart(user, um)) {119 loginFailure(user, "account has expired or not started", msg);120 115 } else { // successful login 121 116 … … 140 135 idleMins + " mins)"); 141 136 } 142 if(!um.isSpider(user)) checkUserSpider(config.getRemoteHandler().getName());143 137 144 138 this.user = user; … … 159 153 conn.setSoTimeout(config.getSessionTimeout()); 160 154 Thread.currentThread().setName(Thread.currentThread().getName() + "[" + user + "]"); 161 OsdMessage = config.getmsgtoemu();162 if(config.getosdMsg() && checkExpiredtime(user, um) != 0L && OsdMessage.contains(clientId) && sessionCount == 0)163 startMsg = config.getclientMsg() + " " + um.getExpireDate(user);164 155 } 165 156 } … … 198 189 checksOk = checksOk && handleMessage(msg); 199 190 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 200 if(checkExpired(this.user, um)) {201 logger.warning("'User '" + user + "' kicked, account has expired");202 close();203 }204 191 if(!checksOk) { 205 192 setFlag(msg, 'B'); … … 220 207 alive = false; 221 208 endSession(); 222 }223 224 public boolean checkStart(String user, UserManager um) {225 Date startDateDt = null;226 try {227 String startDateStr = um.getStartDate(user);228 DateFormat df = new SimpleDateFormat("dd-MM-yyyy");229 if (startDateStr == null)230 startDateDt = null;231 else232 startDateDt = df.parse(startDateStr);233 }234 catch(ParseException ignored) {}235 long currDateMs = System.currentTimeMillis();236 long startDateMs = 0;237 238 if (startDateDt != null)239 startDateMs = startDateDt.getTime();240 241 return (startDateMs != 0) && (currDateMs < startDateMs);242 }243 244 public boolean checkExpired(String user, UserManager um) {245 Date expireDateDt = null;246 long currDate = System.currentTimeMillis();247 long expDateMs = 0L;248 try249 {250 String expireDateStr = um.getExpireDate(user);251 DateFormat df = new SimpleDateFormat("dd-MM-yyyy");252 253 if(expireDateStr == null)254 expireDateDt = null;255 else256 expireDateDt = df.parse(expireDateStr);257 }258 catch(ParseException ex) { }259 currDate = System.currentTimeMillis();260 expDateMs = 0L;261 262 if(expireDateDt != null)263 expDateMs = expireDateDt.getTime();264 265 return expDateMs != 0L && currDate > expDateMs;266 }267 268 public long checkExpiredtime(String user, UserManager um) {269 Date expireDateDt = null; long currDate = System.currentTimeMillis(); long expDateMs = 0L;270 try {271 String expireDateStr = um.getExpireDate(user);272 DateFormat df = new SimpleDateFormat("dd-MM-yyyy");273 if(expireDateStr == null)274 expireDateDt = null;275 else276 expireDateDt = df.parse(expireDateStr);277 }278 catch(ParseException ex) { }279 currDate = System.currentTimeMillis();280 expDateMs = 0L;281 282 if(expireDateDt != null)283 expDateMs = expireDateDt.getTime();284 285 if(expireDateDt != null)286 return (expDateMs - currDate) / 0x5265c00L;287 else288 return 0L;289 }290 291 public String getstartMsg() {292 return startMsg;293 209 } 294 210 … … 399 315 400 316 fireCamdMessage(cardDataMsg, true); 401 402 if (this.getstartMsg() != null)403 sendOsdMessage(this.getstartMsg());404 405 317 break; 406 318 } … … 563 475 564 476 public boolean sendOsdMessage(String message) { 565 if(!OsdMessage.contains(clientId)) return false; 566 CamdNetMessage osdMsg = new CamdNetMessage(CamdNetMessage.EXT_OSD_MESSAGE); 567 try { 568 osdMsg.setCustomData(message.getBytes("ISO-8859-1")); 569 } 570 catch(UnsupportedEncodingException e) { 571 e.printStackTrace(); 572 } return sendMessage(osdMsg) != -1; 573 } 574 575 public boolean checkUserSpider(String user) { 576 CamdNetMessage osdMsg = new CamdNetMessage(CamdNetMessage.CWS_CHECKSPID); 577 try { 578 osdMsg.setCustomData(user.getBytes("ISO-8859-1")); 579 } 580 catch(UnsupportedEncodingException e) { 581 e.printStackTrace(); 582 } return sendMessage(osdMsg) != -1; 477 if("Mgcamd".equals(clientId) || "Acamd".equals(clientId)) { 478 CamdNetMessage osdMsg = new CamdNetMessage(CamdNetMessage.EXT_OSD_MESSAGE); 479 try { 480 osdMsg.setCustomData(message.getBytes("ISO-8859-1")); 481 } catch(UnsupportedEncodingException e) { 482 e.printStackTrace(); 483 } 484 return sendMessage(osdMsg) != -1; 485 } else return false; 583 486 } 584 487 } -
trunk/src/com/bowman/cardserv/web/XmlHelper.java
r160 r165 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("expire-date", users[i].getExpireDate());876 874 if(users[i].isAdmin()) xb.appendAttr("admin", users[i].isAdmin()); 877 875 -
trunk/web/xslt/cws-status-resp.xsl
r160 r165 447 447 <table id="userSessions" border="0" width="100%"><tbody> 448 448 <tr> 449 <td><strong>User</strong></td><td title="Number of connections/maximum"><strong>#</strong></td><td><strong>IP</strong></td> <td><strong>Trace</strong></td><td title="Start Date"><strong>Start</strong></td><td title="Expire Date"><strong>Expire</strong></td><td title="Kick User"><strong>Kick</strong></td>449 <td><strong>User</strong></td><td title="Number of connections/maximum"><strong>#</strong></td><td><strong>IP</strong></td> 450 450 <td><strong> 451 451 <xsl:choose> … … 461 461 <xsl:sort select="@name"/> 462 462 <tr> 463 <td colspan="1 5" align="left" bgcolor="#dddddd">463 <td colspan="11" align="left" bgcolor="#dddddd"> 464 464 <div><xsl:value-of select="@name"/> (capacity: <xsl:value-of select="@capacity"/>, mapped-services: <xsl:value-of select="@mapped-services"/>)</div> 465 465 </td> … … 501 501 <xsl:if test="$count > 1"> (<xsl:value-of select="$count"/>)</xsl:if> 502 502 </td> 503 <td>504 <a target="_blank">505 <xsl:attribute name="href">http://www.ip-adress.com/ip_tracer/<xsl:value-of select="@host"/></xsl:attribute>506 trace </a>507 </td>508 <td><xsl:value-of select="../@start-date"/></td>509 <td><xsl:value-of select="../@expire-date"/></td>510 <td><a target="_blank"> <xsl:attribute name="href">/xmlHandler?command=kick-user&name=<xsl:value-of select="../@name"/></xsl:attribute>kick</a></td>511 503 <td> 512 504 <xsl:value-of select="@duration"/>
Note:
See TracChangeset
for help on using the changeset viewer.