Commit b5fb2362 authored by zengtianlai3's avatar zengtianlai3

屏蔽鉴权

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