Skip to content

Commit

Permalink
resolved comment
Browse files Browse the repository at this point in the history
  • Loading branch information
mathew-jose committed Aug 26, 2024
1 parent 2b47188 commit cfb2695
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.nimbusds.jose.jwk.JWK;
import com.nimbusds.jose.jwk.JWKSet;
import com.nimbusds.jose.jwk.RSAKey;
import com.nimbusds.jwt.JWT;
import com.nimbusds.jwt.JWTParser;
import com.nimbusds.jwt.PlainJWT;
import com.nimbusds.jwt.SignedJWT;
Expand Down Expand Up @@ -169,10 +168,8 @@ private String getJwtSecret(JWSHeader header) throws JOSEException {
* @return validate token expire and true boolean
*/
public boolean validateJwtToken(String authToken) {
JWT jwt = null;
try {
jwt = JWTParser.parse(authToken);
SignedJWT signedJWT = (SignedJWT) jwt;
SignedJWT signedJWT = SignedJWT.parse(authToken);
JWSHeader header = signedJWT.getHeader();
Algorithm alg = header.getAlgorithm();
boolean valid = false;
Expand All @@ -198,8 +195,12 @@ public boolean validateJwtToken(String authToken) {
}

} catch (ParseException e) {
if (jwt instanceof PlainJWT) return true;
logger.error("Could not parse JWT Token -> Message: %d", e);
try {
PlainJWT jwt = PlainJWT.parse(authToken);
return true;
} catch (ParseException parseException) {
log.error("Could not parse JWT Token -> Message: %d", parseException);
}
} catch (JOSEException e) {
log.error("RSA JWK Extraction failed -> Message: %d", e);
}
Expand Down

0 comments on commit cfb2695

Please sign in to comment.