File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
java/app/src/main/java/org/vss/auth Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,8 @@ public class JwtAuthorizer implements Authorizer {
1919 private final PublicKey publicKey ;
2020 private final JWTVerifier verifier ;
2121
22+ public static final String BEARER_PREFIX = "Bearer " ;
23+
2224 public JwtAuthorizer (String pemFormatPublicKey ) throws Exception {
2325 this .publicKey = loadPublicKey (pemFormatPublicKey );
2426
@@ -31,12 +33,12 @@ public AuthResponse verify(HttpHeaders headers) throws AuthException {
3133
3234 try {
3335 String authorizationHeader = headers .getHeaderString (HttpHeaders .AUTHORIZATION );
34- if (authorizationHeader == null || !authorizationHeader .startsWith ("Bearer " )) {
36+ if (authorizationHeader == null || !authorizationHeader .startsWith (BEARER_PREFIX )) {
3537 throw new AuthException ("Missing or invalid Authorization header." );
3638 }
3739
38- // Extract token by excluding 'Bearer ' .
39- String token = authorizationHeader .substring (7 );
40+ // Extract token by excluding BEARER_PREFIX .
41+ String token = authorizationHeader .substring (BEARER_PREFIX . length () );
4042
4143 DecodedJWT jwt = verifier .verify (token );
4244
You can’t perform that action at this time.
0 commit comments