mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-18 17:05:55 +08:00
认证匹配加密认证和简单认证
This commit is contained in:
@@ -37,6 +37,16 @@ public class ProductAuthenticateModel {
|
|||||||
/** 产品秘钥 */
|
/** 产品秘钥 */
|
||||||
private String mqttSecret;
|
private String mqttSecret;
|
||||||
|
|
||||||
|
private int vertificateMethod;
|
||||||
|
|
||||||
|
public int getVertificateMethod() {
|
||||||
|
return vertificateMethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVertificateMethod(int vertificateMethod) {
|
||||||
|
this.vertificateMethod = vertificateMethod;
|
||||||
|
}
|
||||||
|
|
||||||
public Integer getIsAuthorize() {
|
public Integer getIsAuthorize() {
|
||||||
return isAuthorize;
|
return isAuthorize;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -200,6 +200,10 @@ public class ToolServiceImpl implements IToolService
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity simpleMqttAuthentication(MqttAuthenticationModel mqttModel, ProductAuthenticateModel productModel) {
|
public ResponseEntity simpleMqttAuthentication(MqttAuthenticationModel mqttModel, ProductAuthenticateModel productModel) {
|
||||||
|
// 1=简单认证,2=加密认证,3=简单+加密认证
|
||||||
|
if(productModel.getVertificateMethod()!=1 && productModel.getVertificateMethod()!=3){
|
||||||
|
return returnUnauthorized(mqttModel, "设备简单认证,设备对应产品不支持简单认证");
|
||||||
|
}
|
||||||
String[] passwordArray = mqttModel.getPassword().split("&");
|
String[] passwordArray = mqttModel.getPassword().split("&");
|
||||||
if (productModel.getIsAuthorize() == 1 && passwordArray.length != 2) {
|
if (productModel.getIsAuthorize() == 1 && passwordArray.length != 2) {
|
||||||
return returnUnauthorized(mqttModel, "设备简单认证,产品启用授权码后,密码格式为:密码 & 授权码");
|
return returnUnauthorized(mqttModel, "设备简单认证,产品启用授权码后,密码格式为:密码 & 授权码");
|
||||||
@@ -242,6 +246,10 @@ public class ToolServiceImpl implements IToolService
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity encryptAuthentication(MqttAuthenticationModel mqttModel, ProductAuthenticateModel productModel) throws Exception {
|
public ResponseEntity encryptAuthentication(MqttAuthenticationModel mqttModel, ProductAuthenticateModel productModel) throws Exception {
|
||||||
|
// 1=简单认证,2=加密认证,3=简单+加密认证
|
||||||
|
if(productModel.getVertificateMethod()!=2 && productModel.getVertificateMethod()!=3){
|
||||||
|
return returnUnauthorized(mqttModel, "设备加密认证,设备对应产品不支持加密认证");
|
||||||
|
}
|
||||||
String decryptPassword = AESUtils.decrypt(mqttModel.getPassword(), productModel.getMqttSecret());
|
String decryptPassword = AESUtils.decrypt(mqttModel.getPassword(), productModel.getMqttSecret());
|
||||||
if (decryptPassword == null || decryptPassword.equals("")) {
|
if (decryptPassword == null || decryptPassword.equals("")) {
|
||||||
return returnUnauthorized(mqttModel, "设备加密认证,mqtt密码解密失败");
|
return returnUnauthorized(mqttModel, "设备加密认证,mqtt密码解密失败");
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="mqttAccount" column="mqtt_account" />
|
<result property="mqttAccount" column="mqtt_account" />
|
||||||
<result property="mqttPassword" column="mqtt_password" />
|
<result property="mqttPassword" column="mqtt_password" />
|
||||||
<result property="mqttSecret" column="mqtt_secret" />
|
<result property="mqttSecret" column="mqtt_secret" />
|
||||||
|
<result property="vertificateMethod" column="vertificate_method" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<resultMap type="com.ruoyi.iot.model.ThingsModels.ThingsModelValuesOutput" id="DeviceThingsValueResult">
|
<resultMap type="com.ruoyi.iot.model.ThingsModels.ThingsModelValuesOutput" id="DeviceThingsValueResult">
|
||||||
@@ -171,7 +172,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectProductAuthenticate" parameterType="com.ruoyi.iot.model.AuthenticateInputModel" resultMap="DeviceAuthenticateResult">
|
<select id="selectProductAuthenticate" parameterType="com.ruoyi.iot.model.AuthenticateInputModel" resultMap="DeviceAuthenticateResult">
|
||||||
SELECT p.mqtt_password,p.mqtt_account, p.mqtt_secret,p.is_authorize,p.product_id,p.product_name,p.STATUS as product_status,d.device_id,d.device_name,d.STATUS,d.serial_number
|
SELECT p.mqtt_password,p.mqtt_account, p.mqtt_secret,p.is_authorize,p.product_id,p.product_name,p.vertificate_method,p.STATUS as product_status,d.device_id,d.device_name,d.STATUS,d.serial_number
|
||||||
FROM iot_product p
|
FROM iot_product p
|
||||||
LEFT JOIN ( SELECT device_id, device_name, STATUS, product_id, product_name, serial_number
|
LEFT JOIN ( SELECT device_id, device_name, STATUS, product_id, product_name, serial_number
|
||||||
FROM iot_device
|
FROM iot_device
|
||||||
|
|||||||
Reference in New Issue
Block a user