shikeying
2024-01-11 3b67e947e36133e2a40eb2737b15ea375e157ea0
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
package com.walker.tcp.websocket;
 
import com.walker.infrastructure.utils.StringUtils;
import com.walker.tcp.Authenticate;
import com.walker.tcp.AuthenticateException;
import com.walker.tcp.Request;
 
/**
 * WebSocket中默认认证实现。</p>
 * 因为在网页中,并不存在需要认证的情况,一般系统已经登录,因此直接从请求数据中获取固定uid标识。
 * @author Administrator
 *
 */
@Deprecated
public class DefaultAuthentication implements Authenticate {
 
    @Override
    public String authenticate(Request<?> request) throws AuthenticateException {
        String clientId = request.getName();
        if(StringUtils.isEmpty(clientId)){
            throw new AuthenticateException("请求信息中不存在设备ID号,无法认证");
        }
        return clientId;
    }
 
}