File tree 1 file changed +20
-10
lines changed
blade-gateway/src/main/java/org/springblade/gateway/utils
1 file changed +20
-10
lines changed Original file line number Diff line number Diff line change @@ -55,34 +55,44 @@ public static String getBase64Security() {
55
55
}
56
56
57
57
/**
58
- * 判断token类型为crypto
58
+ * 获取请求传递的token串
59
59
*
60
60
* @param auth token
61
61
* @return String
62
62
*/
63
- public static Boolean isCrypto (String auth ) {
63
+ public static String getToken (String auth ) {
64
+ if (isBearer (auth ) || isCrypto (auth )) {
65
+ return auth .substring (AUTH_LENGTH );
66
+ }
67
+ return null ;
68
+ }
69
+
70
+ /**
71
+ * 判断token类型为bearer
72
+ *
73
+ * @param auth token
74
+ * @return String
75
+ */
76
+ public static Boolean isBearer (String auth ) {
64
77
if ((auth != null ) && (auth .length () > AUTH_LENGTH )) {
65
78
String headStr = auth .substring (0 , 6 ).toLowerCase ();
66
- return headStr .compareTo (CRYPTO ) == 0 ;
79
+ return headStr .compareTo (BEARER ) == 0 ;
67
80
}
68
81
return false ;
69
82
}
70
83
71
84
/**
72
- * 获取token串
85
+ * 判断token类型为crypto
73
86
*
74
87
* @param auth token
75
88
* @return String
76
89
*/
77
- public static String getToken (String auth ) {
90
+ public static Boolean isCrypto (String auth ) {
78
91
if ((auth != null ) && (auth .length () > AUTH_LENGTH )) {
79
92
String headStr = auth .substring (0 , 6 ).toLowerCase ();
80
- if (headStr .compareTo (BEARER ) == 0 ) {
81
- auth = auth .substring (7 );
82
- }
83
- return auth ;
93
+ return headStr .compareTo (CRYPTO ) == 0 ;
84
94
}
85
- return null ;
95
+ return false ;
86
96
}
87
97
88
98
/**
You can’t perform that action at this time.
0 commit comments