package com.fs.app.socket.configurator;

import com.fs.app.exception.FSException;

import javax.websocket.HandshakeResponse;
import javax.websocket.server.HandshakeRequest;
import javax.websocket.server.ServerEndpointConfig;
import java.util.List;
import java.util.Map;
import java.util.Objects;

public class QwImConfigurator extends ServerEndpointConfig.Configurator {

    @Override
    public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) {
        Map<String, List<String>> parameterMap = request.getParameterMap();
        List<String> token = parameterMap.get("token");
        if (Objects.isNull(token)) {
            throw new FSException("Unauthorized access to WebSocket endpoint.");
        }
    }
}
