/** * 通过meta获取认证信息 * @param string $pipe_name * @param string $token * @param const $role ( * @return authorization reuslt on success or fasle on failure */ public function authorize($pipe_name, $token, $role) { if (false === $this->_inited) { BigpipeLog::warning("[%s:%u][%s][call uninited object]", __FILE__, __LINE__, __FUNCTION__); return false; } if (empty($this->meta_name)) { // 缺少关键条件 BigpipeLog::warning("[%s:%u][%s][missing meta name]", __FILE__, __LINE__, __FUNCTION__); return false; } // pack reqestion $cmd = new AuthorizeFrame(); $cmd->meta_name = $this->meta_name; $cmd->pipe_name = $pipe_name; $cmd->role = $role; $cmd->token = $token; // send $res_body = $this->_request($cmd); if (null === $res_body) { BigpipeLog::warning("[%s:%u][%s][fail to autorize][meta:%s][pipe_name:%s][token:%d]", __FILE__, __LINE__, __FUNCTION__, $this->meta_name, $pipe_name, $token); return false; } // parse ack $ack = new AuthorizeAckFrame(); if (!$ack->load($res_body)) { BigpipeLog::warning("[%s:%u][%s][ack error]", __FILE__, __LINE__, __FUNCTION__); return false; } // 返回认证状态 $author_result = array(); if (BigpipeErrorCode::OK == $ack->status) { $author_result['authorized'] = true; $author_result['num_pipelet'] = $ack->num_pipelet; } else { // 认证不通过 $author_result['authorized'] = false; $author_result['reason'] = $ack->error_message; } return $author_result; }