Tlssigapiv2.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. <?php
  2. namespace app\common\library;
  3. class Tlssigapiv2 {
  4. private $key = false;
  5. private $sdkappid = 0;
  6. /**
  7. *【功能说明】用于签发 TRTC 和 IM 服务中必须要使用的 UserSig 鉴权票据
  8. *
  9. *【参数说明】
  10. * @param string userid - 用户id,限制长度为32字节,只允许包含大小写英文字母(a-zA-Z)、数字(0-9)及下划线和连词符。
  11. * @param string expire - UserSig 票据的过期时间,单位是秒,比如 86400 代表生成的 UserSig 票据在一天后就无法再使用了。
  12. * @return string 签名字符串
  13. * @throws \Exception
  14. */
  15. /**
  16. * Function: Used to issue UserSig that is required by the TRTC and IM services.
  17. *
  18. * Parameter description:
  19. * @param userid - User ID. The value can be up to 32 bytes in length and contain letters (a-z and A-Z), digits (0-9), underscores (_), and hyphens (-).
  20. * @param expire - UserSig expiration time, in seconds. For example, 86400 indicates that the generated UserSig will expire one day after being generated.
  21. * @return string signature string
  22. * @throws \Exception
  23. */
  24. public function genUserSig( $userid, $expire = 86400*180 ) {
  25. return $this->__genSig( $userid, $expire, '', false );
  26. }
  27. /**
  28. *【功能说明】
  29. * 用于签发 TRTC 进房参数中可选的 PrivateMapKey 权限票据。
  30. * PrivateMapKey 需要跟 UserSig 一起使用,但 PrivateMapKey 比 UserSig 有更强的权限控制能力:
  31. * - UserSig 只能控制某个 UserID 有无使用 TRTC 服务的权限,只要 UserSig 正确,其对应的 UserID 可以进出任意房间。
  32. * - PrivateMapKey 则是将 UserID 的权限控制的更加严格,包括能不能进入某个房间,能不能在该房间里上行音视频等等。
  33. * 如果要开启 PrivateMapKey 严格权限位校验,需要在【实时音视频控制台】=>【应用管理】=>【应用信息】中打开“启动权限密钥”开关。
  34. *
  35. *【参数说明】
  36. * @param userid - 用户id,限制长度为32字节,只允许包含大小写英文字母(a-zA-Z)、数字(0-9)及下划线和连词符。
  37. * @param expire - PrivateMapKey 票据的过期时间,单位是秒,比如 86400 生成的 PrivateMapKey 票据在一天后就无法再使用了。
  38. * @param roomid - 房间号,用于指定该 userid 可以进入的房间号
  39. * @param privilegeMap - 权限位,使用了一个字节中的 8 个比特位,分别代表八个具体的功能权限开关:
  40. * - 第 1 位:0000 0001 = 1,创建房间的权限
  41. * - 第 2 位:0000 0010 = 2,加入房间的权限
  42. * - 第 3 位:0000 0100 = 4,发送语音的权限
  43. * - 第 4 位:0000 1000 = 8,接收语音的权限
  44. * - 第 5 位:0001 0000 = 16,发送视频的权限
  45. * - 第 6 位:0010 0000 = 32,接收视频的权限
  46. * - 第 7 位:0100 0000 = 64,发送辅路(也就是屏幕分享)视频的权限
  47. * - 第 8 位:1000 0000 = 200,接收辅路(也就是屏幕分享)视频的权限
  48. * - privilegeMap == 1111 1111 == 255 代表该 userid 在该 roomid 房间内的所有功能权限。
  49. * - privilegeMap == 0010 1010 == 42 代表该 userid 拥有加入房间和接收音视频数据的权限,但不具备其他权限。
  50. */
  51. /**
  52. * Function:
  53. * Used to issue PrivateMapKey that is optional for room entry.
  54. * PrivateMapKey must be used together with UserSig but with more powerful permission control capabilities.
  55. * - UserSig can only control whether a UserID has permission to use the TRTC service. As long as the UserSig is correct, the user with the corresponding UserID can enter or leave any room.
  56. * - PrivateMapKey specifies more stringent permissions for a UserID, including whether the UserID can be used to enter a specific room and perform audio/video upstreaming in the room.
  57. * To enable stringent PrivateMapKey permission bit verification, you need to enable permission key in TRTC console > Application Management > Application Info.
  58. *
  59. * Parameter description:
  60. * userid - User ID. The value can be up to 32 bytes in length and contain letters (a-z and A-Z), digits (0-9), underscores (_), and hyphens (-).
  61. * roomid - ID of the room to which the specified UserID can enter.
  62. * expire - PrivateMapKey expiration time, in seconds. For example, 86400 indicates that the generated PrivateMapKey will expire one day after being generated.
  63. * privilegeMap - Permission bits. Eight bits in the same byte are used as the permission switches of eight specific features:
  64. * - Bit 1: 0000 0001 = 1, permission for room creation
  65. * - Bit 2: 0000 0010 = 2, permission for room entry
  66. * - Bit 3: 0000 0100 = 4, permission for audio sending
  67. * - Bit 4: 0000 1000 = 8, permission for audio receiving
  68. * - Bit 5: 0001 0000 = 16, permission for video sending
  69. * - Bit 6: 0010 0000 = 32, permission for video receiving
  70. * - Bit 7: 0100 0000 = 64, permission for substream video sending (screen sharing)
  71. * - Bit 8: 1000 0000 = 200, permission for substream video receiving (screen sharing)
  72. * - privilegeMap == 1111 1111 == 255: Indicates that the UserID has all feature permissions of the room specified by roomid.
  73. * - privilegeMap == 0010 1010 == 42: Indicates that the UserID has only the permissions to enter the room and receive audio/video data.
  74. */
  75. public function genPrivateMapKey( $userid, $expire, $roomid, $privilegeMap ) {
  76. $userbuf = $this->__genUserBuf( $userid, $roomid, $expire, $privilegeMap, 0, '' );
  77. return $this->__genSig( $userid, $expire, $userbuf, true );
  78. }
  79. /**
  80. *【功能说明】
  81. * 用于签发 TRTC 进房参数中可选的 PrivateMapKey 权限票据。
  82. * PrivateMapKey 需要跟 UserSig 一起使用,但 PrivateMapKey 比 UserSig 有更强的权限控制能力:
  83. * - UserSig 只能控制某个 UserID 有无使用 TRTC 服务的权限,只要 UserSig 正确,其对应的 UserID 可以进出任意房间。
  84. * - PrivateMapKey 则是将 UserID 的权限控制的更加严格,包括能不能进入某个房间,能不能在该房间里上行音视频等等。
  85. * 如果要开启 PrivateMapKey 严格权限位校验,需要在【实时音视频控制台】=>【应用管理】=>【应用信息】中打开“启动权限密钥”开关。
  86. *
  87. *【参数说明】
  88. * @param userid - 用户id,限制长度为32字节,只允许包含大小写英文字母(a-zA-Z)、数字(0-9)及下划线和连词符。
  89. * @param expire - PrivateMapKey 票据的过期时间,单位是秒,比如 86400 生成的 PrivateMapKey 票据在一天后就无法再使用了。
  90. * @param roomstr - 房间号,用于指定该 userid 可以进入的房间号
  91. * @param privilegeMap - 权限位,使用了一个字节中的 8 个比特位,分别代表八个具体的功能权限开关:
  92. * - 第 1 位:0000 0001 = 1,创建房间的权限
  93. * - 第 2 位:0000 0010 = 2,加入房间的权限
  94. * - 第 3 位:0000 0100 = 4,发送语音的权限
  95. * - 第 4 位:0000 1000 = 8,接收语音的权限
  96. * - 第 5 位:0001 0000 = 16,发送视频的权限
  97. * - 第 6 位:0010 0000 = 32,接收视频的权限
  98. * - 第 7 位:0100 0000 = 64,发送辅路(也就是屏幕分享)视频的权限
  99. * - 第 8 位:1000 0000 = 200,接收辅路(也就是屏幕分享)视频的权限
  100. * - privilegeMap == 1111 1111 == 255 代表该 userid 在该 roomid 房间内的所有功能权限。
  101. * - privilegeMap == 0010 1010 == 42 代表该 userid 拥有加入房间和接收音视频数据的权限,但不具备其他权限。
  102. */
  103. /**
  104. * Function:
  105. * Used to issue PrivateMapKey that is optional for room entry.
  106. * PrivateMapKey must be used together with UserSig but with more powerful permission control capabilities.
  107. * - UserSig can only control whether a UserID has permission to use the TRTC service. As long as the UserSig is correct, the user with the corresponding UserID can enter or leave any room.
  108. * - PrivateMapKey specifies more stringent permissions for a UserID, including whether the UserID can be used to enter a specific room and perform audio/video upstreaming in the room.
  109. * To enable stringent PrivateMapKey permission bit verification, you need to enable permission key in TRTC console > Application Management > Application Info.
  110. *
  111. * Parameter description:
  112. * @param userid - User ID. The value can be up to 32 bytes in length and contain letters (a-z and A-Z), digits (0-9), underscores (_), and hyphens (-).
  113. * @param roomstr - ID of the room to which the specified UserID can enter.
  114. * @param expire - PrivateMapKey expiration time, in seconds. For example, 86400 indicates that the generated PrivateMapKey will expire one day after being generated.
  115. * @param privilegeMap - Permission bits. Eight bits in the same byte are used as the permission switches of eight specific features:
  116. * - Bit 1: 0000 0001 = 1, permission for room creation
  117. * - Bit 2: 0000 0010 = 2, permission for room entry
  118. * - Bit 3: 0000 0100 = 4, permission for audio sending
  119. * - Bit 4: 0000 1000 = 8, permission for audio receiving
  120. * - Bit 5: 0001 0000 = 16, permission for video sending
  121. * - Bit 6: 0010 0000 = 32, permission for video receiving
  122. * - Bit 7: 0100 0000 = 64, permission for substream video sending (screen sharing)
  123. * - Bit 8: 1000 0000 = 200, permission for substream video receiving (screen sharing)
  124. * - privilegeMap == 1111 1111 == 255: Indicates that the UserID has all feature permissions of the room specified by roomid.
  125. * - privilegeMap == 0010 1010 == 42: Indicates that the UserID has only the permissions to enter the room and receive audio/video data.
  126. */
  127. public function genPrivateMapKeyWithStringRoomID( $userid, $expire, $roomstr, $privilegeMap ) {
  128. $userbuf = $this->__genUserBuf( $userid, 0, $expire, $privilegeMap, 0, $roomstr );
  129. return $this->__genSig( $userid, $expire, $userbuf, true );
  130. }
  131. public function __construct( $sdkappid, $key ) {
  132. $this->sdkappid = $sdkappid;
  133. $this->key = $key;
  134. }
  135. /**
  136. * 用于 url 的 base64 encode
  137. * '+' => '*', '/' => '-', '=' => '_'
  138. * @param string $string 需要编码的数据
  139. * @return string 编码后的base64串,失败返回false
  140. * @throws \Exception
  141. */
  142. /**
  143. * base64 encode for url
  144. * '+' => '*', '/' => '-', '=' => '_'
  145. * @param string $string data to be encoded
  146. * @return string The encoded base64 string, returns false on failure
  147. * @throws \Exception
  148. */
  149. private function base64_url_encode( $string ) {
  150. static $replace = Array( '+' => '*', '/' => '-', '=' => '_' );
  151. $base64 = base64_encode( $string );
  152. if ( $base64 === false ) {
  153. throw new \Exception( 'base64_encode error' );
  154. }
  155. return str_replace( array_keys( $replace ), array_values( $replace ), $base64 );
  156. }
  157. /**
  158. * 用于 url 的 base64 decode
  159. * '+' => '*', '/' => '-', '=' => '_'
  160. * @param string $base64 需要解码的base64串
  161. * @return string 解码后的数据,失败返回false
  162. * @throws \Exception
  163. */
  164. /**
  165. * base64 decode for url
  166. * '+' => '*', '/' => '-', '=' => '_'
  167. * @param string $base64 base64 string to be decoded
  168. * @return string Decoded data, return false on failure
  169. * @throws \Exception
  170. */
  171. private function base64_url_decode( $base64 ) {
  172. static $replace = Array( '+' => '*', '/' => '-', '=' => '_' );
  173. $string = str_replace( array_values( $replace ), array_keys( $replace ), $base64 );
  174. $result = base64_decode( $string );
  175. if ( $result == false ) {
  176. throw new \Exception( 'base64_url_decode error' );
  177. }
  178. return $result;
  179. }
  180. /**
  181. * TRTC业务进房权限加密串使用用户定义的userbuf
  182. * @brief 生成 userbuf
  183. * @param account 用户名
  184. * @param dwSdkappid sdkappid
  185. * @param dwAuthID 数字房间号
  186. * @param dwExpTime 过期时间:该权限加密串的过期时间. 过期时间 = now+dwExpTime
  187. * @param dwPrivilegeMap 用户权限,255表示所有权限
  188. * @param dwAccountType 用户类型, 默认为0
  189. * @param roomStr 字符串房间号
  190. * @return userbuf string 返回的userbuf
  191. */
  192. /**
  193. * User-defined userbuf is used for the encrypted string of TRTC service entry permission
  194. * @brief generate userbuf
  195. * @param account username
  196. * @param dwSdkappid sdkappid
  197. * @param dwAuthID digital room number
  198. * @param dwExpTime Expiration time: The expiration time of the encrypted string of this permission. Expiration time = now+dwExpTime
  199. * @param dwPrivilegeMap User permissions, 255 means all permissions
  200. * @param dwAccountType User type, default is 0
  201. * @param roomStr String room number
  202. * @return userbuf string returned userbuf
  203. */
  204. private function __genUserBuf( $account, $dwAuthID, $dwExpTime, $dwPrivilegeMap, $dwAccountType,$roomStr ) {
  205. //cVer unsigned char/1 版本号,填0
  206. if($roomStr == '')
  207. $userbuf = pack( 'C1', '0' );
  208. else
  209. $userbuf = pack( 'C1', '1' );
  210. $userbuf .= pack( 'n', strlen( $account ) );
  211. //wAccountLen unsigned short /2 第三方自己的帐号长度
  212. $userbuf .= pack( 'a'.strlen( $account ), $account );
  213. //buffAccount wAccountLen 第三方自己的帐号字符
  214. $userbuf .= pack( 'N', $this->sdkappid );
  215. //dwSdkAppid unsigned int/4 sdkappid
  216. $userbuf .= pack( 'N', $dwAuthID );
  217. //dwAuthId unsigned int/4 群组号码/音视频房间号
  218. $expire = $dwExpTime + time();
  219. $userbuf .= pack( 'N', $expire );
  220. //dwExpTime unsigned int/4 过期时间 (当前时间 + 有效期(单位:秒,建议300秒))
  221. $userbuf .= pack( 'N', $dwPrivilegeMap );
  222. //dwPrivilegeMap unsigned int/4 权限位
  223. $userbuf .= pack( 'N', $dwAccountType );
  224. //dwAccountType unsigned int/4
  225. if($roomStr != '')
  226. {
  227. $userbuf .= pack( 'n', strlen( $roomStr ) );
  228. //roomStrLen unsigned short /2 字符串房间号长度
  229. $userbuf .= pack( 'a'.strlen( $roomStr ), $roomStr );
  230. //roomStr roomStrLen 字符串房间号
  231. }
  232. return $userbuf;
  233. }
  234. /**
  235. * 使用 hmac sha256 生成 sig 字段内容,经过 base64 编码
  236. * @param $identifier 用户名,utf-8 编码
  237. * @param $curr_time 当前生成 sig 的 unix 时间戳
  238. * @param $expire 有效期,单位秒
  239. * @param $base64_userbuf base64 编码后的 userbuf
  240. * @param $userbuf_enabled 是否开启 userbuf
  241. * @return string base64 后的 sig
  242. */
  243. /**
  244. * Use hmac sha256 to generate sig field content, base64 encoded
  245. * @param $identifier Username, utf-8 encoded
  246. * @param $curr_time The unix timestamp of the current generated sig
  247. * @param $expire Validity period, in seconds
  248. * @param $base64_userbuf base64 encoded userbuf
  249. * @param $userbuf_enabled 是No enable userbuf
  250. * @return string sig after base64
  251. */
  252. private function hmacsha256( $identifier, $curr_time, $expire, $base64_userbuf, $userbuf_enabled ) {
  253. $content_to_be_signed = 'TLS.identifier:' . $identifier . "\n"
  254. . 'TLS.sdkappid:' . $this->sdkappid . "\n"
  255. . 'TLS.time:' . $curr_time . "\n"
  256. . 'TLS.expire:' . $expire . "\n";
  257. if ( true == $userbuf_enabled ) {
  258. $content_to_be_signed .= 'TLS.userbuf:' . $base64_userbuf . "\n";
  259. }
  260. return base64_encode( hash_hmac( 'sha256', $content_to_be_signed, $this->key, true ) );
  261. }
  262. /**
  263. * 生成签名。
  264. *
  265. * @param $identifier 用户账号
  266. * @param int $expire 过期时间,单位秒,默认 180 天
  267. * @param $userbuf base64 编码后的 userbuf
  268. * @param $userbuf_enabled 是否开启 userbuf
  269. * @return string 签名字符串
  270. * @throws \Exception
  271. */
  272. /**
  273. * Generate signature.
  274. *
  275. * @param $identifier user account
  276. * @param int $expire Expiration time, in seconds, default 180 days
  277. * @param $userbuf base64 encoded userbuf
  278. * @param $userbuf_enabled Whether to enable userbuf
  279. * @return string signature string
  280. * @throws \Exception
  281. */
  282. private function __genSig( $identifier, $expire, $userbuf, $userbuf_enabled ) {
  283. $curr_time = time();
  284. $sig_array = Array(
  285. 'TLS.ver' => '2.0',
  286. 'TLS.identifier' => strval( $identifier ),
  287. 'TLS.sdkappid' => intval( $this->sdkappid ),
  288. 'TLS.expire' => intval( $expire ),
  289. 'TLS.time' => intval( $curr_time )
  290. );
  291. $base64_userbuf = '';
  292. if ( true == $userbuf_enabled ) {
  293. $base64_userbuf = base64_encode( $userbuf );
  294. $sig_array['TLS.userbuf'] = strval( $base64_userbuf );
  295. }
  296. $sig_array['TLS.sig'] = $this->hmacsha256( $identifier, $curr_time, $expire, $base64_userbuf, $userbuf_enabled );
  297. if ( $sig_array['TLS.sig'] === false ) {
  298. throw new \Exception( 'base64_encode error' );
  299. }
  300. $json_str_sig = json_encode( $sig_array );
  301. if ( $json_str_sig === false ) {
  302. throw new \Exception( 'json_encode error' );
  303. }
  304. $compressed = gzcompress( $json_str_sig );
  305. if ( $compressed === false ) {
  306. throw new \Exception( 'gzcompress error' );
  307. }
  308. return $this->base64_url_encode( $compressed );
  309. }
  310. /**
  311. * 验证签名。
  312. *
  313. * @param string $sig 签名内容
  314. * @param string $identifier 需要验证用户名,utf-8 编码
  315. * @param int $init_time 返回的生成时间,unix 时间戳
  316. * @param int $expire_time 返回的有效期,单位秒
  317. * @param string $userbuf 返回的用户数据
  318. * @param string $error_msg 失败时的错误信息
  319. * @return boolean 验证是否成功
  320. * @throws \Exception
  321. */
  322. /**
  323. * Verify signature.
  324. *
  325. * @param string $sig Signature content
  326. * @param string $identifier Need to authenticate user name, utf-8 encoding
  327. * @param int $init_time Returned generation time, unix timestamp
  328. * @param int $expire_time Return the validity period, in seconds
  329. * @param string $userbuf returned user data
  330. * @param string $error_msg error message on failure
  331. * @return boolean Verify success
  332. * @throws \Exception
  333. */
  334. private function __verifySig( $sig, $identifier, &$init_time, &$expire_time, &$userbuf, &$error_msg ) {
  335. try {
  336. $error_msg = '';
  337. $compressed_sig = $this->base64_url_decode( $sig );
  338. $pre_level = error_reporting( E_ERROR );
  339. $uncompressed_sig = gzuncompress( $compressed_sig );
  340. error_reporting( $pre_level );
  341. if ( $uncompressed_sig === false ) {
  342. throw new \Exception( 'gzuncompress error' );
  343. }
  344. $sig_doc = json_decode( $uncompressed_sig );
  345. if ( $sig_doc == false ) {
  346. throw new \Exception( 'json_decode error' );
  347. }
  348. $sig_doc = ( array )$sig_doc;
  349. if ( $sig_doc['TLS.identifier'] !== $identifier ) {
  350. throw new \Exception( "identifier dosen't match" );
  351. }
  352. if ( $sig_doc['TLS.sdkappid'] != $this->sdkappid ) {
  353. throw new \Exception( "sdkappid dosen't match" );
  354. }
  355. $sig = $sig_doc['TLS.sig'];
  356. if ( $sig == false ) {
  357. throw new \Exception( 'sig field is missing' );
  358. }
  359. $init_time = $sig_doc['TLS.time'];
  360. $expire_time = $sig_doc['TLS.expire'];
  361. $curr_time = time();
  362. if ( $curr_time > $init_time+$expire_time ) {
  363. throw new \Exception( 'sig expired' );
  364. }
  365. $userbuf_enabled = false;
  366. $base64_userbuf = '';
  367. if ( isset( $sig_doc['TLS.userbuf'] ) ) {
  368. $base64_userbuf = $sig_doc['TLS.userbuf'];
  369. $userbuf = base64_decode( $base64_userbuf );
  370. $userbuf_enabled = true;
  371. }
  372. $sigCalculated = $this->hmacsha256( $identifier, $init_time, $expire_time, $base64_userbuf, $userbuf_enabled );
  373. if ( $sig != $sigCalculated ) {
  374. throw new \Exception( 'verify failed' );
  375. }
  376. return true;
  377. } catch ( \Exception $ex ) {
  378. $error_msg = $ex->getMessage();
  379. return false;
  380. }
  381. }
  382. /**
  383. * 带 userbuf 验证签名。
  384. *
  385. * @param string $sig 签名内容
  386. * @param string $identifier 需要验证用户名,utf-8 编码
  387. * @param int $init_time 返回的生成时间,unix 时间戳
  388. * @param int $expire_time 返回的有效期,单位秒
  389. * @param string $error_msg 失败时的错误信息
  390. * @return boolean 验证是否成功
  391. * @throws \Exception
  392. */
  393. /**
  394. * Verify signature with userbuf.
  395. *
  396. * @param string $sig Signature content
  397. * @param string $identifier Need to authenticate user name, utf-8 encoding
  398. * @param int $init_time Returned generation time, unix timestamp
  399. * @param int $expire_time Return the validity period, in seconds
  400. * @param string $error_msg error message on failure
  401. * @return boolean Verify success
  402. * @throws \Exception
  403. */
  404. public function verifySig( $sig, $identifier, &$init_time, &$expire_time, &$error_msg ) {
  405. $userbuf = '';
  406. return $this->__verifySig( $sig, $identifier, $init_time, $expire_time, $userbuf, $error_msg );
  407. }
  408. /**
  409. * 验证签名
  410. * @param string $sig 签名内容
  411. * @param string $identifier 需要验证用户名,utf-8 编码
  412. * @param int $init_time 返回的生成时间,unix 时间戳
  413. * @param int $expire_time 返回的有效期,单位秒
  414. * @param string $userbuf 返回的用户数据
  415. * @param string $error_msg 失败时的错误信息
  416. * @return boolean 验证是否成功
  417. * @throws \Exception
  418. */
  419. /**
  420. * Verify signature
  421. * @param string $sig Signature content
  422. * @param string $identifier Need to authenticate user name, utf-8 encoding
  423. * @param int $init_time Returned generation time, unix timestamp
  424. * @param int $expire_time Return the validity period, in seconds
  425. * @param string $userbuf returned user data
  426. * @param string $error_msg error message on failure
  427. * @return boolean Verify success
  428. * @throws \Exception
  429. */
  430. public function verifySigWithUserBuf( $sig, $identifier, &$init_time, &$expire_time, &$userbuf, &$error_msg ) {
  431. return $this->__verifySig( $sig, $identifier, $init_time, $expire_time, $userbuf, $error_msg );
  432. }
  433. }