本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《 阿里云开发者社区用户服务协议 》和 《 阿里云开发者社区知识产权保护指引 》。如果您发现本社区中有涉嫌抄袭的内容,填写 侵权投诉表单 进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
auth.http.auth_req.url = http://127.0.0.1:8002/emqapi/auth【修改接口地址】
auth.http.super_req.url = http://127.0.0.1:8003/emqapi/superuser【放开注释并修改接口地址】
auth.http.super_req.method = post【放开注释】
auth.http.super_req.headers.content-type = application/x-www-form-urlencoded【放开注释】
auth.http.super_req.params = clientid=%c,username=%u【放开注释】【修改接口地址】
auth.http.acl_req.url = http://127.0.0.1:8003/emqapi/acl【修改接口地址】
@RequestMapping("/emqapi")
@Api(value="EMQAPI接口",tags={"EMQAPI接口"})
public class EmqApiController{
  private static Logger logger = LoggerFactory.getLogger(EmqApiController.class);
  @Autowired
  AuthService authService;
  @ApiOperation(value = "客户端连接授权" ,notes = "客户端连接授权" )
  @ApiImplicitParams({
      @ApiImplicitParam(name = "clientid" ,value = "客户端clientId" , required = false, dataType = "String"),
      @ApiImplicitParam(name = "username" ,value = "客户端username" , required = false, dataType = "String"),
      @ApiImplicitParam(name = "password" ,value = "客户端password" , required = false, dataType = "String")
  @PostMapping(value = "/auth")
  public void checkUser(String clientid, String username, String password, HttpServletResponse response) throws Exception {
    //这里添加业务逻辑 200 允许登录,其他Stuatus不允许登录
        System.out.println("普通用户;clientid:" + clientid + ";username:" + username);
    response.setStatus(200);
  @PostMapping("/superuser")
  public void mqttSuperuser(String clientid, String username, HttpServletResponse response) {
    logger.info("超级用户;clientid:" + clientid + ";username:" + username);
    System.out.println("超级用户;clientid:" + clientid + ";username:" + username);
    response.setStatus(200);
  @PostMapping("/acl")
  public void mqttAcl(String access, String username, String clientid, String ipaddr, String topic, HttpServletResponse response) {
    //auth.http.acl_req.params = access=%A,username=%u,clientid=%c,ipaddr=%a,topic=%t
    logger.info("access: " + access + ";username: " + username + ";clientid: " + clientid + "; ipaddr: " + ipaddr + ";topic: " + topic);
    System.out.println("access: " + access + ";username: " + username + ";clientid: " + clientid + "; ipaddr: " + ipaddr + ";topic: " + topic);
    response.setStatus(200);