File tree Expand file tree Collapse file tree 1 file changed +20
-10
lines changed
blade-gateway/src/main/java/org/springblade/gateway/utils Expand file tree Collapse file tree 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() {
5555 }
5656
5757 /**
58- * 判断token类型为crypto
58+ * 获取请求传递的token串
5959 *
6060 * @param auth token
6161 * @return String
6262 */
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 ) {
6477 if ((auth != null ) && (auth .length () > AUTH_LENGTH )) {
6578 String headStr = auth .substring (0 , 6 ).toLowerCase ();
66- return headStr .compareTo (CRYPTO ) == 0 ;
79+ return headStr .compareTo (BEARER ) == 0 ;
6780 }
6881 return false ;
6982 }
7083
7184 /**
72- * 获取token串
85+ * 判断token类型为crypto
7386 *
7487 * @param auth token
7588 * @return String
7689 */
77- public static String getToken (String auth ) {
90+ public static Boolean isCrypto (String auth ) {
7891 if ((auth != null ) && (auth .length () > AUTH_LENGTH )) {
7992 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 ;
8494 }
85- return null ;
95+ return false ;
8696 }
8797
8898 /**
You can’t perform that action at this time.
0 commit comments