Search in sources :

Example 1 with KeySegmentationWebSocketHandler

use of com.itrus.portal.mobile.controller.websocket.handler.KeySegmentationWebSocketHandler in project portal by ixinportal.

the class KeySegmentationTask method buildTask.

public static void buildTask(final WebSocketSession session, final WebSocketMessage<?> message) throws UnsupportedEncodingException, NoSuchAlgorithmException, URISyntaxException {
    // header 获取云盾秘钥连接 // TODO: 2017/11/29
    final WebSocketHttpHeaders headers = new WebSocketHttpHeaders();
    MobileSecretKeyConfigExample configExample = new MobileSecretKeyConfigExample();
    MobileSecretKeyConfig keyConfig = accesskeyLiensConfigService.selectByConfig(configExample);
    // keyConfig.getPasswordNumber()
    headers.add("appId", keyConfig.getPasswordNumber());
    headers.add("Content-Signature", Base64.encode(HMACSHA1.getHmacSHA1(/*keyConfig.getPasswordNumber(),keyConfig.getPassword()*/
    "1", "123"), false));
    final URI uri = new URI(/*keyConfig.getConnectAddress()*/
    "ws://192.168.102.237:8080/km/webSocketServer");
    Runnable task = new Runnable() {

        @Override
        public void run() {
            WebSocketClient webSocketClient = new StandardWebSocketClient();
            webSocketClient.doHandshake(new KeySegmentationWebSocketHandler(session, message), headers, uri);
        }
    };
    threadPool.execute(task);
}
Also used : MobileSecretKeyConfig(com.itrus.portal.db.MobileSecretKeyConfig) WebSocketHttpHeaders(org.springframework.web.socket.WebSocketHttpHeaders) KeySegmentationWebSocketHandler(com.itrus.portal.mobile.controller.websocket.handler.KeySegmentationWebSocketHandler) MobileSecretKeyConfigExample(com.itrus.portal.db.MobileSecretKeyConfigExample) StandardWebSocketClient(org.springframework.web.socket.client.standard.StandardWebSocketClient) WebSocketClient(org.springframework.web.socket.client.WebSocketClient) StandardWebSocketClient(org.springframework.web.socket.client.standard.StandardWebSocketClient) URI(java.net.URI)

Aggregations

MobileSecretKeyConfig (com.itrus.portal.db.MobileSecretKeyConfig)1 MobileSecretKeyConfigExample (com.itrus.portal.db.MobileSecretKeyConfigExample)1 KeySegmentationWebSocketHandler (com.itrus.portal.mobile.controller.websocket.handler.KeySegmentationWebSocketHandler)1 URI (java.net.URI)1 WebSocketHttpHeaders (org.springframework.web.socket.WebSocketHttpHeaders)1 WebSocketClient (org.springframework.web.socket.client.WebSocketClient)1 StandardWebSocketClient (org.springframework.web.socket.client.standard.StandardWebSocketClient)1