设备和token
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
package com.sunyard.chsm.constant;
|
||||
|
||||
/**
|
||||
* @author Exrickx
|
||||
*/
|
||||
public interface SecurityConstant {
|
||||
|
||||
/**
|
||||
* token分割
|
||||
*/
|
||||
String TOKEN_SPLIT = "Bearer ";
|
||||
|
||||
/**
|
||||
* JWT签名加密key
|
||||
*/
|
||||
String JWT_SIGN_KEY = "keeper";
|
||||
|
||||
/**
|
||||
* token参数头
|
||||
*/
|
||||
String HEADER = "accessToken";
|
||||
|
||||
/**
|
||||
* 权限参数头
|
||||
*/
|
||||
String AUTHORITIES = "authorities";
|
||||
|
||||
/**
|
||||
* 用户选择JWT保存时间参数头
|
||||
*/
|
||||
String SAVE_LOGIN = "saveLogin";
|
||||
|
||||
/**
|
||||
* github保存state前缀key
|
||||
*/
|
||||
String GITHUB_STATE = "KEEPER_GITHUB:";
|
||||
|
||||
/**
|
||||
* qq保存state前缀key
|
||||
*/
|
||||
String QQ_STATE = "KEEPER_QQ:";
|
||||
|
||||
/**
|
||||
* qq保存state前缀key
|
||||
*/
|
||||
String WEIBO_STATE = "KEEPER_WEIBO:";
|
||||
|
||||
/**
|
||||
* 交互token前缀key
|
||||
*/
|
||||
String TOKEN_PRE = "KEEPER_TOKEN_PRE:";
|
||||
|
||||
/**
|
||||
* 用户token前缀key 单点登录使用
|
||||
*/
|
||||
String USER_TOKEN = "KEEPER_USER_TOKEN:";
|
||||
|
||||
/**
|
||||
* 用户登陆之后的租户识别id
|
||||
* @auther: ZS
|
||||
* @description:
|
||||
* @param:
|
||||
* @return:
|
||||
* @date: 2019/3/20 16:21
|
||||
*/
|
||||
String TENANT_ID = "KEEPER_TENANT_ID";
|
||||
|
||||
/**
|
||||
* 更新用户接口url
|
||||
* @auther: ZS
|
||||
* @description:
|
||||
* @param:
|
||||
* @return:
|
||||
* @date: 2019/7/31 14:54
|
||||
*/
|
||||
String USER_UPDATE_URL = "/keeper/user/admin/edit";
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@ import java.util.Objects;
|
||||
@AllArgsConstructor
|
||||
public enum ManufacturerModelEnum {
|
||||
|
||||
enc001(ManufacturerEnum.SUNYARD, "enc001", "服务器密码机enc001"),
|
||||
enc001(ManufacturerEnum.SUNYARD, "SYD-001", "服务器密码机"),
|
||||
;
|
||||
|
||||
private final ManufacturerEnum manufacturer;
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
package com.sunyard.chsm.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sunyard.chsm.model.entity.Application;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liulu
|
||||
@@ -10,4 +15,15 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
*/
|
||||
@Mapper
|
||||
public interface ApplicationMapper extends BaseMapper<Application> {
|
||||
|
||||
|
||||
default Application selectByAppKey(String appKey) {
|
||||
List<Application> apps = selectList(new QueryWrapper<Application>().eq("app_key", appKey));
|
||||
if (CollectionUtils.isEmpty(apps)) {
|
||||
return null;
|
||||
}
|
||||
Assert.isTrue(apps.size() == 1, "app 数据异常");
|
||||
return apps.iterator().next();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class R<T> {
|
||||
R<T> r = new R<>();
|
||||
r.setSuccess(false);
|
||||
r.setMessage(msg);
|
||||
r.setCode(500);
|
||||
r.setCode(400);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,16 +21,20 @@ public class Device {
|
||||
private Integer managePort;
|
||||
private String manufacturer;
|
||||
private String manufacturerModel;
|
||||
private Integer encKeyIdx;
|
||||
private String accessCredentials;
|
||||
|
||||
private Boolean connected;
|
||||
private LocalDateTime lastCheckTime;
|
||||
private LocalDateTime lastConnectedTime;
|
||||
|
||||
private Long groupId;
|
||||
private String groupName;
|
||||
private Integer weight;
|
||||
|
||||
private String tmkStatus;
|
||||
private String deviceSerial;
|
||||
private String pubKey;
|
||||
private String encTmk;
|
||||
private Boolean connected;
|
||||
private LocalDateTime lastCheckTime;
|
||||
private LocalDateTime lastConnectedTime;
|
||||
|
||||
private String remark;
|
||||
private LocalDateTime createTime;
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.sunyard.chsm.utils;
|
||||
|
||||
import org.bouncycastle.util.encoders.Hex;
|
||||
|
||||
import java.util.Base64;
|
||||
|
||||
/**
|
||||
* @author liulu
|
||||
* @since 2024/12/6
|
||||
*/
|
||||
public abstract class CodecUtils {
|
||||
|
||||
public static String encodeBase64(byte[] data) {
|
||||
return Base64.getEncoder().encodeToString(data);
|
||||
}
|
||||
|
||||
public static byte[] decodeBase64(String str) {
|
||||
try {
|
||||
return Base64.getDecoder().decode(str);
|
||||
} catch (Exception var3) {
|
||||
if (str.length() > 32) {
|
||||
str = str.substring(0, 32) + "...";
|
||||
}
|
||||
|
||||
String format = String.format("参数[%s]不是正确的base64格式", str);
|
||||
throw new IllegalArgumentException(format);
|
||||
}
|
||||
}
|
||||
|
||||
public static String encodeHex(byte[] data) {
|
||||
return Hex.toHexString(data);
|
||||
}
|
||||
|
||||
public static byte[] decodeHex(String str) {
|
||||
try {
|
||||
return Hex.decode(str);
|
||||
} catch (Exception var3) {
|
||||
if (str.length() > 32) {
|
||||
str = str.substring(0, 32) + "...";
|
||||
}
|
||||
String format = String.format("参数[%s]不是正确的hex格式", str);
|
||||
throw new IllegalArgumentException(format);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user