mirror of
https://github.com/chillzhuang/SpringBlade.git
synced 2024-11-23 10:59:25 +08:00
🎉 3.7.0.RELEASE Token加密传输
This commit is contained in:
parent
85daa7e425
commit
72b33cd4bb
@ -54,6 +54,33 @@ public class JwtUtil {
|
||||
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
|
||||
*
|
||||
@ -68,23 +95,6 @@ public class JwtUtil {
|
||||
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
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user