新增加解密方法
This commit is contained in:
parent
21627cd878
commit
9204b7cfb9
@ -14,13 +14,19 @@
|
|||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.cm</groupId>
|
<groupId>com.cm</groupId>
|
||||||
<artifactId>cloud-common</artifactId>
|
<artifactId>cloud-common-plugin</artifactId>
|
||||||
<version>1.0.1-SNAPSHOT</version>
|
<version>1.0.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.cm</groupId>
|
||||||
|
<artifactId>cloud-security</artifactId>
|
||||||
|
<version>1.0.1-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.netty</groupId>
|
<groupId>io.netty</groupId>
|
||||||
<artifactId>netty-all</artifactId>
|
<artifactId>netty-all</artifactId>
|
||||||
<version>4.1.50.Final</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package com.cm.socket.service;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.cm.common.base.AbstractService;
|
import com.cm.common.base.AbstractService;
|
||||||
|
import com.cm.common.utils.AesUtil;
|
||||||
import com.cm.socket.enums.SocketCodeEnum;
|
import com.cm.socket.enums.SocketCodeEnum;
|
||||||
import com.cm.socket.enums.SocketTypeMessageEnum;
|
import com.cm.socket.enums.SocketTypeMessageEnum;
|
||||||
import com.cm.socket.pojo.Message;
|
import com.cm.socket.pojo.Message;
|
||||||
@ -22,13 +23,15 @@ import java.util.List;
|
|||||||
**/
|
**/
|
||||||
public abstract class AbstractSocketService extends AbstractService implements ISocketService {
|
public abstract class AbstractSocketService extends AbstractService implements ISocketService {
|
||||||
|
|
||||||
|
private static final String CONTENT_ENCODE_KEY = "Ts_Socket_Key_W_";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 读取信息业务
|
* 读取信息业务
|
||||||
*
|
*
|
||||||
* @param channelHandlerContext
|
* @param channelHandlerContext
|
||||||
* @param readMessage
|
* @param readMessage
|
||||||
*/
|
*/
|
||||||
protected abstract void readMessageService(ChannelHandlerContext channelHandlerContext, Message readMessage);
|
protected abstract void readMessageService(ChannelHandlerContext channelHandlerContext, Message readMessage) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 输出信息
|
* 输出信息
|
||||||
@ -120,4 +123,26 @@ public abstract class AbstractSocketService extends AbstractService implements I
|
|||||||
return socketResult;
|
return socketResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取加密结果
|
||||||
|
*
|
||||||
|
* @param content
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
protected String getEncodeContent(String content) throws Exception {
|
||||||
|
return AesUtil.aesCommonEncoder(CONTENT_ENCODE_KEY, content);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取解密结果
|
||||||
|
*
|
||||||
|
* @param content
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
protected String getDecodeContent(String content) throws Exception {
|
||||||
|
return AesUtil.aesCommonDecoder(CONTENT_ENCODE_KEY, content);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,13 +21,13 @@ public interface ISocketService {
|
|||||||
* @param channelHandlerContext
|
* @param channelHandlerContext
|
||||||
* @param readMessage
|
* @param readMessage
|
||||||
*/
|
*/
|
||||||
void readMessage(ChannelHandlerContext channelHandlerContext, Message readMessage);
|
void readMessage(ChannelHandlerContext channelHandlerContext, Message readMessage) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自动回复数据
|
* 自动回复数据
|
||||||
*
|
*
|
||||||
* @param channelHandlerContext
|
* @param channelHandlerContext
|
||||||
*/
|
*/
|
||||||
void autoReply(ChannelHandlerContext channelHandlerContext);
|
void autoReply(ChannelHandlerContext channelHandlerContext) throws Exception;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user