Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
ioc_sixiang_license
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zengtianlai3
ioc_sixiang_license
Commits
b5fb2362
Commit
b5fb2362
authored
Jun 10, 2022
by
zengtianlai3
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
屏蔽鉴权
parent
775e8ef8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
29 deletions
+26
-29
DeviceServerHandler.java
.../java/iot/sixiang/license/device/DeviceServerHandler.java
+26
-29
No files found.
license/src/main/java/iot/sixiang/license/device/DeviceServerHandler.java
View file @
b5fb2362
...
...
@@ -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
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment