Commit f7aa86cf authored by 龚小红's avatar 龚小红

Merge branch 'Feature/20220305-gxh' into 'master'

增加生成otoCookie的方法

See merge request test-group/kejiji!237
parents 14871378 d6c46741
package com.kjj.bean.jmterbean;
import lombok.Data;
/**
* OTO-销售工作台token
*
* @author ZhangJun
* @date 2022/1/8 5:00 下午
*/
@Data
public class OtoTokenCookie {
/**
* 登录用户id
*/
private String loginId;
/**
* 登录手机号
*/
private String phoneNumber;
/**
* 过期时间
*/
private Long expiredTime;
}
package com.kjj.utils;
import java.util.HashMap;
import java.util.Map;
/**
* @author lizhi
* @date 2020/4/9 11:36 AM
*/
public enum IdConvertBase64Enum {
/**
* 注意,code只能是两位
*/
DEF("j2", "默认类型"),
TRANS("t3", "短链接服务"),
;
private String code;
private String desc;
IdConvertBase64Enum(String code, String desc) {
this.code = code;
this.desc = desc;
}
public String getCode() {
return "K"+ code;
}
private static final Map<String, IdConvertBase64Enum> ENUM_MAP = new HashMap<>();
static{
for(IdConvertBase64Enum lengthEnum : values()){
ENUM_MAP.put(lengthEnum.getCode(), lengthEnum);
}
}
public static IdConvertBase64Enum getByCode(String code) {
if (code == null) {
return null;
}
return ENUM_MAP.get(code);
}
}
\ No newline at end of file
...@@ -78,5 +78,14 @@ public class IdMakeUtil implements Authorization { ...@@ -78,5 +78,14 @@ public class IdMakeUtil implements Authorization {
return decodeId; return decodeId;
} }
public static String encodingId(Long id, IdConvertBase64Enum base64Enum) {
if (id == null || base64Enum == null || base64Enum.getCode().length() != 3) {
return null;
}
id = (id << 3) ^ 7;
String encode = encoder.encodeToString(Long.toString(id).getBytes());
String replace = encode.replace("=", "");
return base64Enum.getCode() + (encode.length() - replace.length()) + replace;
}
} }
package com.kjj.utils; package com.kjj.utils;
import com.alibaba.fastjson.JSON;
import com.kjj.bean.jmterbean.OtoTokenCookie;
import com.kjj.config.BasicConfig; import com.kjj.config.BasicConfig;
import com.kjj.sql.KjyUserDB; import com.kjj.sql.KjyUserDB;
import com.kjj.sql.UserSqlFactory; import com.kjj.sql.UserSqlFactory;
...@@ -19,9 +21,27 @@ public class JmeterAccountFile { ...@@ -19,9 +21,27 @@ public class JmeterAccountFile {
private static final NetworkUtils network = NetworkUtils.getInstance(); private static final NetworkUtils network = NetworkUtils.getInstance();
public static void main(String[] args) { public static void main(String[] args) {
String path = String.valueOf(JmeterAccountFile.class.getResource("/")); // String path = String.valueOf(JmeterAccountFile.class.getResource("/"));
accountFile(path); // accountFile(path);
otoCookieMaker();
} }
/**
* 生成otoCookie,仅用于压力测试文件
*/
public static void otoCookieMaker() {
OtoTokenCookie otoTokenCookie = new OtoTokenCookie();
otoTokenCookie.setExpiredTime(System.currentTimeMillis() + 86400*1000*150L);
otoTokenCookie.setPhoneNumber("18909890978");
otoTokenCookie.setLoginId(IdMakeUtil.encodingId(21L, IdConvertBase64Enum.DEF));
String json = JSON.toJSONString(otoTokenCookie);
String otoToken = BlowfishUtils.encryptBlowfish(json,"02a16fs1b6a3");
System.out.println(otoToken);
}
//仅用于生成直播账号Authkey文件
public static void accountFile(String path) { public static void accountFile(String path) {
BaseUtils.ssoLogin(); BaseUtils.ssoLogin();
// 保存路径 // 保存路径
......
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