Skip to content

Commit

Permalink
spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
mathew-jose committed Aug 26, 2024
1 parent e5deec1 commit 63c4c63
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
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 @@ -142,9 +143,10 @@ private String getJwtSecret(JWSHeader header) throws JOSEException {
* @return validate token expire and true boolean
*/
public boolean validateJwtToken(String authToken) {
JWT jwt = null;
try {
if (JWTParser.parse(authToken) instanceof PlainJWT) return true;
SignedJWT signedJWT = SignedJWT.parse(authToken);
jwt = JWTParser.parse(authToken);
SignedJWT signedJWT = (SignedJWT) jwt;
JWSHeader header = signedJWT.getHeader();
Algorithm alg = header.getAlgorithm();

Expand All @@ -171,6 +173,7 @@ public boolean validateJwtToken(String authToken) {
}

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

0 comments on commit 63c4c63

Please sign in to comment.