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 int vertificateMethod;
|
||||
|
||||
public int getVertificateMethod() {
|
||||
return vertificateMethod;
|
||||
}
|
||||
|
||||
public void setVertificateMethod(int vertificateMethod) {
|
||||
this.vertificateMethod = vertificateMethod;
|
||||
}
|
||||
|
||||
public Integer getIsAuthorize() {
|
||||
return isAuthorize;
|
||||
}
|
||||
|
||||
@@ -200,6 +200,10 @@ public class ToolServiceImpl implements IToolService
|
||||
*/
|
||||
@Override
|
||||
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("&");
|
||||
if (productModel.getIsAuthorize() == 1 && passwordArray.length != 2) {
|
||||
return returnUnauthorized(mqttModel, "设备简单认证,产品启用授权码后,密码格式为:密码 & 授权码");
|
||||
@@ -242,6 +246,10 @@ public class ToolServiceImpl implements IToolService
|
||||
*/
|
||||
@Override
|
||||
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());
|
||||
if (decryptPassword == null || decryptPassword.equals("")) {
|
||||
return returnUnauthorized(mqttModel, "设备加密认证,mqtt密码解密失败");
|
||||
|
||||
Reference in New Issue
Block a user