Commit b5fb2362 authored by zengtianlai3's avatar zengtianlai3

屏蔽鉴权

parent 775e8ef8
......@@ -13,6 +13,7 @@ import iot.sixiang.license.event.DeviceClientInactiveEvent;
import iot.sixiang.license.event.EventPublisher;
import iot.sixiang.license.event.ForwardClientRequestEvent;
import iot.sixiang.license.model.SessionContext;
import iot.sixiang.license.util.CommonUtil;
import iot.sixiang.license.util.HexUtil;
import iot.sixiang.license.util.SpringUtil;
import lombok.extern.slf4j.Slf4j;
......@@ -54,8 +55,8 @@ public class DeviceServerHandler extends SimpleChannelInboundHandler<Object> {
*/
byte cmd = protocol.getCmd();
int cmdInt = cmd & 0xFF;
log.info("real cmd:" + cmdInt);
log.info("收到的消息:" + HexUtil.bytes2hex(protocol.getContent()));
log.debug("real cmd:" + cmdInt);
log.debug("收到的消息:" + HexUtil.bytes2hex(protocol.getContent()));
boolean license = false;
// cmdInt = Consts.CMD_LICENSE;
......@@ -70,9 +71,9 @@ public class DeviceServerHandler extends SimpleChannelInboundHandler<Object> {
}
//TODO 以下为正式代码
// if (license == false) {
// channel.close();
// }
if (license == false) {
channel.close();
}
}
@Override
......@@ -155,23 +156,23 @@ public class DeviceServerHandler extends SimpleChannelInboundHandler<Object> {
}
private boolean handlerLicense(SocketChannel channel, String remoteIp, int remotePort, DeviceProtocol protocol) {
String jsonLicense = new String(protocol.getContent(), 0, protocol.getContent().length);
JSONObject jsonObject = JSON.parseObject(jsonLicense);
String userId = jsonObject.getString("userId");
String password = jsonObject.getString("password");
String appId = jsonObject.getString("appId");
String appKey = jsonObject.getString("appKey");
// String userId = "12345";
// String password = "1234";
// String appId = "12222";
// String appKey = "1234455";
// String jsonLicense = new String(protocol.getContent(), 0, protocol.getContent().length);
// JSONObject jsonObject = JSON.parseObject(jsonLicense);
// String userId = jsonObject.getString("userId");
// String password = jsonObject.getString("password");
// String appId = jsonObject.getString("appId");
// String appKey = jsonObject.getString("appKey");
String userId = "123456";
String password = "123456";
String appId = CommonUtil.getStrUUID();
String appKey = "123456";
String token = "123456";
AuthManager authManager = SpringUtil.getBean(AuthManager.class);
boolean license = authManager.auth(userId, password, appId, appKey);
// boolean license = authManager.auth(userId, password, appId, appKey);
boolean license = true;
String channelId = channel.id().asLongText();
if (license) {
......@@ -193,23 +194,19 @@ public class DeviceServerHandler extends SimpleChannelInboundHandler<Object> {
event.setAppId(appId);
eventPublisher.publishEvent(event);
}
// byte ack = 0x0;
// byte ack2 = 0x01;
// protocol.setAck(ack);
// channel.writeAndFlush(protocol);
return license;
}
private boolean handlerCheckLicense(SocketChannel channel, String remoteIp, int remotePort, DeviceProtocol protocol) {
String channelId = channel.id().asLongText();
// LicenseManager licenseManager = SpringUtil.getBean(LicenseManager.class);
// boolean license = licenseManager.checkLicense(deviceCode,deviceKey);
boolean license = true;
return license;
DeviceManager deviceManager = SpringUtil.getBean(DeviceManager.class);
SessionContext session = deviceManager.getSessionByChannelId(channelId);
if (session != null) {
return true;
} else {
return false;
}
}
private void handlerForward(SocketChannel channel, String remoteIp, int remotePort, DeviceProtocol protocol) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment