@@ -77,19 +77,12 @@ public FirebasePnvToken verifyToken(String token) throws FirebasePnvException {
7777 checkArgument (!Strings .isNullOrEmpty (token ), "FPNV token must not be null or empty" );
7878
7979 try {
80- // Parse the token first to inspect header
8180 SignedJWT signedJwt = SignedJWT .parse (token );
82-
83- // Explicitly verify the header (alg & kid)
8481 verifyHeader (signedJwt .getHeader ());
8582
86- // Verify Signature and Structure
8783 JWTClaimsSet claims = jwtProcessor .process (signedJwt , null );
88-
89- // Verify Claims (Issuer, Audience, Expiration)
9084 verifyClaims (claims );
9185
92- // Construct Token Object
9386 return new FirebasePnvToken (claims .getClaims ());
9487 } catch (ParseException e ) {
9588 throw new FirebasePnvException (
@@ -122,7 +115,7 @@ public FirebasePnvToken verifyToken(String token) throws FirebasePnvException {
122115
123116 private void verifyHeader (JWSHeader header ) throws FirebasePnvException {
124117 // Check Algorithm (alg)
125- if (!JWSAlgorithm . ES256 . equals ( header .getAlgorithm ())) {
118+ if (!header .getAlgorithm (). equals ( JWSAlgorithm . ES256 )) {
126119 throw new FirebasePnvException (
127120 FirebasePnvErrorCode .INVALID_ARGUMENT ,
128121 "FPNV has incorrect 'algorithm'. Expected " + JWSAlgorithm .ES256 .getName ()
@@ -135,8 +128,8 @@ private void verifyHeader(JWSHeader header) throws FirebasePnvException {
135128 "FPNV has no 'kid' claim."
136129 );
137130 }
138- // Check Typ (typ)
139- if (Objects .isNull (header .getType ()) || !HEADER_TYP . equals ( header .getType ().getType () )) {
131+ // Check Type (typ)
132+ if (Objects .isNull (header .getType ()) || !header .getType ().toString (). equals ( HEADER_TYP )) {
140133 throw new FirebasePnvException (
141134 FirebasePnvErrorCode .INVALID_ARGUMENT ,
142135 "FPNV has incorrect 'typ'. Expected " + HEADER_TYP
0 commit comments