🎉 3.7.0.RELEASE Token加密传输

This commit is contained in:
smallchill 2023-09-12 13:36:26 +08:00
parent 85daa7e425
commit 72b33cd4bb

View File

@ -54,6 +54,33 @@ public class JwtUtil {
return Base64.getEncoder().encodeToString(getJwtProperties().getSignKey().getBytes(StandardCharsets.UTF_8)); return Base64.getEncoder().encodeToString(getJwtProperties().getSignKey().getBytes(StandardCharsets.UTF_8));
} }
/**
* 获取请求传递的token串
*
* @param auth token
* @return String
*/
public static String getToken(String auth) {
if (isBearer(auth) || isCrypto(auth)) {
return auth.substring(AUTH_LENGTH);
}
return null;
}
/**
* 判断token类型为bearer
*
* @param auth token
* @return String
*/
public static Boolean isBearer(String auth) {
if ((auth != null) && (auth.length() > AUTH_LENGTH)) {
String headStr = auth.substring(0, 6).toLowerCase();
return headStr.compareTo(BEARER) == 0;
}
return false;
}
/** /**
* 判断token类型为crypto * 判断token类型为crypto
* *
@ -68,23 +95,6 @@ public class JwtUtil {
return false; return false;
} }
/**
* 获取token串
*
* @param auth token
* @return String
*/
public static String getToken(String auth) {
if ((auth != null) && (auth.length() > AUTH_LENGTH)) {
String headStr = auth.substring(0, 6).toLowerCase();
if (headStr.compareTo(BEARER) == 0) {
auth = auth.substring(7);
}
return auth;
}
return null;
}
/** /**
* 解析jsonWebToken * 解析jsonWebToken
* *