|
|
@@ -16,8 +16,8 @@ import java.util.Date;
|
|
|
public class JwtUtil {
|
|
|
public static final String SHIRO_USER_NAME = "username";
|
|
|
public static final String SHIRO_USER_ID = "userId";
|
|
|
- public static final String SHIRO_FTY_ID = "ftyId";
|
|
|
- public static final String SHIRO_FTY_CODE = "ftyCode";
|
|
|
+ public static final String SHIRO_CP_ID = "cpId";
|
|
|
+ public static final String SHIRO_CP_CODE = "cpCode";
|
|
|
public static final String SHIRO_CLIENT_ID = "clientId";
|
|
|
public static final String SHIRO_APP_CODE = "appCode";
|
|
|
public static final String SHIRO_USER_SALT = "salt";
|
|
|
@@ -105,14 +105,14 @@ public class JwtUtil {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @desc : 获取token中FtyId
|
|
|
+ * @desc : 获取token中CpId
|
|
|
* @author : 周兴
|
|
|
* @date : 2023/2/26 16:32
|
|
|
*/
|
|
|
- public static String getFtyId(String token) {
|
|
|
+ public static String getCPId(String token) {
|
|
|
try {
|
|
|
DecodedJWT jwt = JWT.decode(token);
|
|
|
- return jwt.getClaim(SHIRO_FTY_ID).asString();
|
|
|
+ return jwt.getClaim(SHIRO_CP_ID).asString();
|
|
|
} catch (JWTDecodeException e) {
|
|
|
log.error("error:{}", e.getMessage());
|
|
|
return null;
|
|
|
@@ -120,14 +120,14 @@ public class JwtUtil {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @desc : 获取token中FtyCode
|
|
|
+ * @desc : 获取token中CpCode
|
|
|
* @author : 周兴
|
|
|
* @date : 2023/2/26 16:32
|
|
|
*/
|
|
|
- public static String getFtyCode(String token) {
|
|
|
+ public static String getCpCode(String token) {
|
|
|
try {
|
|
|
DecodedJWT jwt = JWT.decode(token);
|
|
|
- return jwt.getClaim(SHIRO_FTY_CODE).asString();
|
|
|
+ return jwt.getClaim(SHIRO_CP_CODE).asString();
|
|
|
} catch (JWTDecodeException e) {
|
|
|
log.error("error:{}", e.getMessage());
|
|
|
return null;
|
|
|
@@ -176,7 +176,7 @@ public class JwtUtil {
|
|
|
* @param salt 盐值
|
|
|
* @return 加密的token
|
|
|
*/
|
|
|
- public static String sign(String username, String userId, String appCode, String clientId, String salt, String ftyId, String ftyCode, String lang) {
|
|
|
+ public static String sign(String username, String userId, String appCode, String clientId, String salt, String cpId, String cpCode, String lang) {
|
|
|
Date expireDate = new Date(System.currentTimeMillis() + OauthConstants.EXPIRES_IN);
|
|
|
//加盐值
|
|
|
Algorithm algorithm = Algorithm.HMAC256(salt);
|
|
|
@@ -184,8 +184,8 @@ public class JwtUtil {
|
|
|
return JWT.create()
|
|
|
.withClaim(SHIRO_USER_NAME, username)
|
|
|
.withClaim(SHIRO_USER_ID, userId)
|
|
|
- .withClaim(SHIRO_FTY_ID, ftyId)
|
|
|
- .withClaim(SHIRO_FTY_CODE, ftyCode)
|
|
|
+ .withClaim(SHIRO_CP_ID, cpId)
|
|
|
+ .withClaim(SHIRO_CP_CODE, cpCode)
|
|
|
.withClaim(SHIRO_APP_CODE, appCode)
|
|
|
.withClaim(SHIRO_CLIENT_ID, clientId)
|
|
|
.withClaim(SHIRO_USER_SALT, salt)
|
|
|
@@ -206,7 +206,7 @@ public class JwtUtil {
|
|
|
.sign(algorithm);
|
|
|
}
|
|
|
|
|
|
- public static String sign(String username, String userId, String appCode, String clientId, String salt, String grantType, String ftyId, String ftyCode, String lang) {
|
|
|
+ public static String sign(String username, String userId, String appCode, String clientId, String salt, String grantType, String cpId, String cpCode, String lang) {
|
|
|
Date expireDate = new Date(System.currentTimeMillis() + OauthConstants.EXPIRES_IN);
|
|
|
//加盐值
|
|
|
Algorithm algorithm = Algorithm.HMAC256(salt);
|
|
|
@@ -214,8 +214,8 @@ public class JwtUtil {
|
|
|
return JWT.create()
|
|
|
.withClaim(SHIRO_USER_NAME, username)
|
|
|
.withClaim(SHIRO_USER_ID, userId)
|
|
|
- .withClaim(SHIRO_FTY_ID, ftyId)
|
|
|
- .withClaim(SHIRO_FTY_CODE, ftyCode)
|
|
|
+ .withClaim(SHIRO_CP_ID, cpId)
|
|
|
+ .withClaim(SHIRO_CP_CODE, cpCode)
|
|
|
.withClaim(SHIRO_APP_CODE, appCode)
|
|
|
.withClaim(SHIRO_CLIENT_ID, clientId)
|
|
|
.withClaim(SHIRO_USER_SALT, salt)
|
|
|
@@ -237,15 +237,15 @@ public class JwtUtil {
|
|
|
.sign(algorithm);
|
|
|
}
|
|
|
|
|
|
- public static String sign(String username, String clientId, String salt, String ftyId, String ftyCode, String lang) {
|
|
|
+ public static String sign(String username, String clientId, String salt, String cpId, String cpCode, String lang) {
|
|
|
Date expireDate = new Date(System.currentTimeMillis() + OauthConstants.EXPIRES_IN);
|
|
|
//加盐值
|
|
|
Algorithm algorithm = Algorithm.HMAC256(salt);
|
|
|
// 附带username信息
|
|
|
return JWT.create()
|
|
|
.withClaim(SHIRO_USER_NAME, username)
|
|
|
- .withClaim(SHIRO_FTY_ID, ftyId)
|
|
|
- .withClaim(SHIRO_FTY_CODE, ftyCode)
|
|
|
+ .withClaim(SHIRO_CP_ID, cpId)
|
|
|
+ .withClaim(SHIRO_CP_CODE, cpCode)
|
|
|
.withClaim(SHIRO_CLIENT_ID, clientId)
|
|
|
.withClaim(SHIRO_USER_SALT, salt)
|
|
|
.withClaim(SHIRO_APP_LANG, lang)
|