@@ -63,9 +63,9 @@ public boolean handleLogin(HttpServletRequest request, HttpServletResponse respo
6363 try {
6464 claims = jwt .decodeAccessToken (tokenStr );
6565 } catch (TokenExpiredException e ) {
66- throw new io .github .talelin .autoconfigure .exception .TokenExpiredException (e . getMessage (), 10051 );
66+ throw new io .github .talelin .autoconfigure .exception .TokenExpiredException (10051 );
6767 } catch (AlgorithmMismatchException | SignatureVerificationException | JWTDecodeException | InvalidClaimException e ) {
68- throw new TokenInvalidException (e . getMessage (), 10041 );
68+ throw new TokenInvalidException (10041 );
6969 }
7070 return getClaim (claims );
7171 }
@@ -83,7 +83,7 @@ public boolean handleGroup(HttpServletRequest request, HttpServletResponse respo
8383 List <PermissionDO > permissions = userService .getUserPermissions (userId );
8484 boolean matched = permissions .stream ().anyMatch (it -> it .getModule ().equals (module ) && it .getName ().equals (permission ));
8585 if (!matched ) {
86- throw new AuthenticationException ("you don't have the permission to access" , 10001 );
86+ throw new AuthenticationException (10001 );
8787 }
8888 return true ;
8989 }
@@ -93,7 +93,7 @@ public boolean handleAdmin(HttpServletRequest request, HttpServletResponse respo
9393 handleLogin (request , response , meta );
9494 UserDO user = LocalUser .getLocalUser ();
9595 if (!verifyAdmin (user )) {
96- throw new AuthenticationException ("you don't have the permission to access" , 10001 );
96+ throw new AuthenticationException (10001 );
9797 }
9898 return true ;
9999 }
@@ -106,9 +106,9 @@ public boolean handleRefresh(HttpServletRequest request, HttpServletResponse res
106106 try {
107107 claims = jwt .decodeRefreshToken (tokenStr );
108108 } catch (TokenExpiredException e ) {
109- throw new io .github .talelin .autoconfigure .exception .TokenExpiredException (e . getMessage (), 10051 );
109+ throw new io .github .talelin .autoconfigure .exception .TokenExpiredException (10051 );
110110 } catch (AlgorithmMismatchException | SignatureVerificationException | JWTDecodeException | InvalidClaimException e ) {
111- throw new TokenInvalidException (e . getMessage (), 10041 );
111+ throw new TokenInvalidException (10041 );
112112 }
113113 return getClaim (claims );
114114 }
@@ -126,12 +126,12 @@ public void handleAfterCompletion(HttpServletRequest request, HttpServletRespons
126126
127127 private boolean getClaim (Map <String , Claim > claims ) {
128128 if (claims == null ) {
129- throw new TokenInvalidException ("token is invalid, can't be decode" , 10041 );
129+ throw new TokenInvalidException (10041 );
130130 }
131131 int identity = claims .get ("identity" ).asInt ();
132132 UserDO user = userService .getById (identity );
133133 if (user == null ) {
134- throw new NotFoundException ("user is not found" , 10021 );
134+ throw new NotFoundException (10021 );
135135 }
136136 String avatarUrl ;
137137 if (user .getAvatar () == null ) {
@@ -159,18 +159,18 @@ private String verifyHeader(HttpServletRequest request, HttpServletResponse resp
159159 // 处理头部header,带有access_token的可以访问
160160 String authorization = request .getHeader (AUTHORIZATION_HEADER );
161161 if (authorization == null || Strings .isBlank (authorization )) {
162- throw new AuthorizationException ("authorization field is required" , 10012 );
162+ throw new AuthorizationException (10012 );
163163 }
164164 String [] splits = authorization .split (" " );
165165 if (splits .length != 2 ) {
166- throw new AuthorizationException ("authorization field is invalid" , 10013 );
166+ throw new AuthorizationException (10013 );
167167 }
168168 // Bearer 字段
169169 String scheme = splits [0 ];
170170 // token 字段
171171 String tokenStr = splits [1 ];
172172 if (!Pattern .matches (BEARER_PATTERN , scheme )) {
173- throw new AuthorizationException ("authorization field is invalid" , 10013 );
173+ throw new AuthorizationException (10013 );
174174 }
175175 return tokenStr ;
176176 }
0 commit comments