| | |
| | | if (userSetting.getPushAuthority()) {
|
| | | // 推流鉴权
|
| | | if (param.getParams() == null) {
|
| | | logger.info("推流鉴权失败: 缺少不要参数:sign=md5(user表的pushKey)");
|
| | | logger.info("推流鉴权失败: 缺少必要参数:sign=md5(user表的pushKey)");
|
| | | return new HookResultForOnPublish(401, "Unauthorized");
|
| | | }
|
| | | Map<String, String> paramMap = urlParamToMap(param.getParams());
|
| | | String sign = paramMap.get("sign");
|
| | | if (sign == null) {
|
| | | logger.info("推流鉴权失败: 缺少不要参数:sign=md5(user表的pushKey)");
|
| | | logger.info("推流鉴权失败: 缺少必要参数:sign=md5(user表的pushKey)");
|
| | | return new HookResultForOnPublish(401, "Unauthorized");
|
| | | }
|
| | | // 推流自定义播放鉴权码
|
| | |
| | | import com.github.pagehelper.PageInfo; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.util.DigestUtils; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | |
| | | @Override |
| | | public boolean checkPushAuthority(String callId, String sign) { |
| | | if (ObjectUtils.isEmpty(callId)) { |
| | | return userMapper.checkPushAuthorityByCallId(sign).size() > 0; |
| | | }else { |
| | | return userMapper.checkPushAuthorityByCallIdAndSign(callId, sign).size() > 0; |
| | | |
| | | List<User> users = userMapper.getUsers(); |
| | | if (users.size() == 0) { |
| | | return false; |
| | | } |
| | | for (User user : users) { |
| | | if (user.getPushKey() == null) { |
| | | continue; |
| | | } |
| | | String checkStr = callId == null? user.getPushKey():(callId + "_" + user.getPushKey()) ; |
| | | System.out.println(checkStr); |
| | | String checkSign = DigestUtils.md5DigestAsHex(checkStr.getBytes()); |
| | | if (checkSign.equals(sign)) { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | |
| | | public interface StreamPushMapper { |
| | | |
| | | @Insert("INSERT INTO wvp_stream_push (app, stream, total_reader_count, origin_type, origin_type_str, " + |
| | | "push_time, alive_second, media_server_id, server_id, update_time, create_time, push_ing, self) VALUES" + |
| | | "push_time, alive_second, media_server_id, update_time, create_time, push_ing, self) VALUES" + |
| | | "(#{app}, #{stream}, #{totalReaderCount}, #{originType}, #{originTypeStr}, " + |
| | | "#{pushTime}, #{aliveSecond}, #{mediaServerId} , #{serverId} , #{updateTime} , #{createTime}, " + |
| | | "#{pushTime}, #{aliveSecond}, #{mediaServerId} , #{updateTime} , #{createTime}, " + |
| | | "#{pushIng}, #{self} )") |
| | | int add(StreamPushItem streamPushItem); |
| | | |
| | |
| | | @ResultMap(value="roleMap") |
| | | List<User> selectAll(); |
| | | |
| | | @Select("select * from (select user.*, concat(concat(#{call_id}, '_'), push_key) as str1 from wvp_user) as u where md5(u.str1) = #{sign}") |
| | | List<User> checkPushAuthorityByCallIdAndSign(String callId, String sign); |
| | | |
| | | @Select("select * from wvp_user where md5(push_key) = #{sign}") |
| | | List<User> checkPushAuthorityByCallId(String sign); |
| | | // @Select("select * from (select user.*, concat(concat(#{call_id}, '_'), push_key) as str1 from wvp_user) as u where md5(u.str1) = #{sign}") |
| | | // List<User> checkPushAuthorityByCallIdAndSign(String callId, String sign); |
| | | // |
| | | // @Select("select * from wvp_user where md5(push_key) = #{sign}") |
| | | // List<User> checkPushAuthorityByCallId(String sign); |
| | | |
| | | @Select("select u.id, u.username,u.push_key,u.role_id, r.id as role_id, r.name as role_name, r.authority as role_authority , r.create_time as role_create_time , r.update_time as role_update_time from wvp_user u join wvp_user_role r on u.role_id=r.id") |
| | | @ResultMap(value="roleMap") |