2026-06-26 20b96473f2520590a0dca6b775b81e3ea06a77a0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream;
 
import lombok.extern.slf4j.Slf4j;
import org.eclipse.californium.core.CoapResource;
import org.eclipse.californium.core.server.resources.CoapExchange;
 
/**
 * IoT 网关 CoAP 协议的认证资源(/auth)
 *
 * 设备通过此资源进行认证,获取 Token
 *
 * @author 芋道源码
 */
@Slf4j
public class IotCoapAuthResource extends CoapResource {
 
    public static final String PATH = "auth";
 
    private final IotCoapAuthHandler authHandler;
 
    public IotCoapAuthResource(IotCoapAuthHandler authHandler) {
        super(PATH);
        this.authHandler = authHandler;
        log.info("[IotCoapAuthResource][创建 CoAP 认证资源: /{}]", PATH);
    }
 
    @Override
    public void handlePOST(CoapExchange exchange) {
        log.debug("[handlePOST][收到 /auth POST 请求]");
        authHandler.handle(exchange);
    }
 
}