onenethelper.ie.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. function onenet_guid()
  2. {
  3. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
  4. var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
  5. return v.toString(16);
  6. });
  7. }
  8. function InitCmdMsg(action, data)
  9. {
  10. var msg = {};
  11. msg['logid'] = onenet_guid();
  12. msg['action'] = action;
  13. msg['data'] = data;
  14. return msg;
  15. }
  16. var oneNetHelper_activex=new Object();
  17. oneNetHelper_activex.isAvailable = false;
  18. oneNetHelper_activex.IsAddonAvailable = function ()
  19. {
  20. if(!oneNetHelper_activex.isAvailable)
  21. {
  22. oneNetHelper_activex.isAvailable = (AuthClientCtrl)? true : false;
  23. if(oneNetHelper_activex.isAvailable)
  24. {
  25. try
  26. {
  27. AuthClientCtrl.Test();
  28. }
  29. catch(e)
  30. {
  31. oneNetHelper_activex.isAvailable = false;
  32. alert("AuthClientCtrl.Test失败!");
  33. }
  34. }
  35. else
  36. {
  37. alert("加载AuthClientCtrl 对象失败!");
  38. }
  39. }
  40. return oneNetHelper_activex.isAvailable;
  41. }
  42. oneNetHelper_activex.AddonAvailableNotify = function (notify_web)
  43. {
  44. setTimeout(function (){
  45. var resp = {};
  46. resp['addon']=oneNetHelper_activex.isAvailable;
  47. notify_web(resp);
  48. }, 0);
  49. }
  50. oneNetHelper_activex.GetUASToken = function (notify_web)
  51. {
  52. setTimeout(function (){
  53. var resp = {};
  54. AuthClientCtrl.GetUASToken();
  55. resp['ret'] = AuthClientCtrl.lResult == 0 ? 1 : 0;
  56. resp['errinfo'] = AuthClientCtrl.bstrError;
  57. resp['token'] = AuthClientCtrl.bstrUASToken;
  58. resp['expiredate'] = AuthClientCtrl.bstrUASExpireDate;
  59. notify_web(resp);
  60. }, 0);
  61. }
  62. oneNetHelper_activex.GetUserInfo = function (notify_web)
  63. {
  64. setTimeout(function (){
  65. var resp = {};
  66. AuthClientCtrl.GetUserInfo();
  67. resp['ret'] = AuthClientCtrl.lResult == 0 ? 1 : 0;
  68. resp['errinfo'] = AuthClientCtrl.bstrError;
  69. resp['userid'] = AuthClientCtrl.bstrUserID;
  70. resp['username'] = AuthClientCtrl.bstrUserName;
  71. resp['certuserid'] = AuthClientCtrl.bstrCertUserID;
  72. resp['certusername'] = AuthClientCtrl.bstrCertUserName;
  73. resp['authresult'] = AuthClientCtrl.lAuthResult;
  74. notify_web(resp);
  75. }, 0);
  76. }
  77. oneNetHelper_activex.GetSignAndToken = function (randomnum, notify_web)
  78. {
  79. setTimeout(function (){
  80. var hostname = location.hostname;
  81. var msg = InitCmdMsg("GetSignAndToken", randomnum);
  82. msg['appServerAddr'] = hostname;
  83. var resp = {};
  84. AuthClientCtrl.JsonActionCmdDeal(JSON.stringify(msg));
  85. var obj = JSON.parse(AuthClientCtrl.bstrResponse);
  86. resp = obj.info;
  87. /*说明:1.针对老版本客户端底层未处理GetSignAndToken action方式,再次调用原接口获取令牌;
  88. 2.若提示AuthClientCtrl未定义JsonActionCmdDeal方法,则直接使用GetSignAndToken方法*/
  89. if(resp['ret'] == -2003)
  90. {
  91. AuthClientCtrl.GetSignAndToken(randomnum);
  92. resp['ret'] = AuthClientCtrl.lResult == 0 ? 1 : 0;
  93. resp['errinfo'] = AuthClientCtrl.bstrError;
  94. resp['signandtoken'] = AuthClientCtrl.bstrSignValAndToken;
  95. }
  96. notify_web(resp);
  97. }, 0);
  98. }
  99. oneNetHelper_activex.GetUserCertInfo = function (notify_web)
  100. {
  101. setTimeout(function (){
  102. var resp = {};
  103. AuthClientCtrl.GetUserCertInfo();
  104. resp['ret'] = AuthClientCtrl.lResult == 0 ? 1 : 0;
  105. resp['errinfo'] = AuthClientCtrl.bstrError;
  106. resp['DNStringAll'] = AuthClientCtrl.bstrUserCertInfoValue('DNStringAll');
  107. resp['UserName'] = AuthClientCtrl.bstrUserCertInfoValue('UserName');
  108. resp['UserID'] = AuthClientCtrl.bstrUserCertInfoValue('UserID');
  109. resp['DNCode'] = AuthClientCtrl.bstrUserCertInfoValue('DNCode');
  110. resp['DisName'] = AuthClientCtrl.bstrUserCertInfoValue('DisName');
  111. resp['UniqueId'] = AuthClientCtrl.bstrUserCertInfoValue('UniqueId');
  112. resp['IssuerDisName'] = AuthClientCtrl.bstrUserCertInfoValue('IssuerDisName');
  113. resp['CertSerial'] = AuthClientCtrl.bstrUserCertInfoValue('CertSerial');
  114. resp['EMail'] = AuthClientCtrl.bstrUserCertInfoValue('EMail');
  115. resp['Org'] = AuthClientCtrl.bstrUserCertInfoValue('Org');
  116. resp['OrgUnit'] = AuthClientCtrl.bstrUserCertInfoValue('OrgUnit');
  117. resp['City'] = AuthClientCtrl.bstrUserCertInfoValue('City');
  118. resp['State'] = AuthClientCtrl.bstrUserCertInfoValue('State');
  119. resp['Descption'] = AuthClientCtrl.bstrUserCertInfoValue('Descption');
  120. resp['Version'] = AuthClientCtrl.bstrUserCertInfoValue('Version');
  121. resp['BeginTime'] = AuthClientCtrl.bstrUserCertInfoValue('BeginTime');
  122. resp['EndTime'] = AuthClientCtrl.bstrUserCertInfoValue('EndTime');
  123. //resp['authresult'] = AuthClientCtrl.lAuthResult;
  124. notify_web(resp);
  125. }, 0);
  126. }
  127. oneNetHelper_activex.Login = function (appToken,username,userpwd,authtype,svctype, gw_id, notify_web)
  128. {
  129. alert("Login IE插件未实现");
  130. }
  131. oneNetHelper_activex.ChangeUKeyPin = function (old_key_pin,new_key_pin,notify_web)
  132. {
  133. alert("ChangeUKeyPin IE插件未实现");
  134. }
  135. oneNetHelper_activex.SSLUsbKeyLogin = function (appToken,gw_id,key_pin,notify_web)
  136. {
  137. alert("SSLUsbKeyLogin IE插件未实现");
  138. }
  139. oneNetHelper_activex.SSLUserPwdLogin = function (appToken,gw_id,username,userpwd,notify_web)
  140. {
  141. alert("SSLUserPwdLogin IE插件未实现");
  142. }
  143. oneNetHelper_activex.IPSecUsbKeyLogin = function (appToken,gw_id,key_pin,notify_web)
  144. {
  145. alert("IPSecUsbKeyLogin IE插件未实现");
  146. }
  147. oneNetHelper_activex.Logout = function (appToken,notify_web)
  148. {
  149. alert("Logout IE插件未实现");
  150. }
  151. oneNetHelper_activex.QuerySecPortalStatus = function (appToken,notify_web)
  152. {
  153. alert("QuerySecPortalStatus IE插件未实现");
  154. }
  155. oneNetHelper_activex.HeartBeat = function (appToken,notify_web)
  156. {
  157. alert("HeartBeat IE插件未实现");
  158. }
  159. oneNetHelper_activex.GetGateWayAddrList = function (notify_web)
  160. {
  161. setTimeout(function (){
  162. var msg = InitCmdMsg("GetGateWayAddrList", "");
  163. var resp = {};
  164. AuthClientCtrl.JsonActionCmdDeal(JSON.stringify(msg));
  165. var obj = JSON.parse(AuthClientCtrl.bstrResponse);
  166. resp = obj.info;
  167. notify_web(resp);
  168. }, 0);
  169. }
  170. oneNetHelper_activex.JsonActionTestCmdDeal = function (notify_web)
  171. {
  172. setTimeout(function (){
  173. var msg = InitCmdMsg("testAction", "");
  174. var resp = {};
  175. AuthClientCtrl.JsonActionCmdDeal(JSON.stringify(msg));
  176. var obj = JSON.parse(AuthClientCtrl.bstrResponse);
  177. resp = obj.info;
  178. notify_web(resp);
  179. }, 0);
  180. }