1414import io .jsonwebtoken .JwtParserBuilder ;
1515import io .jsonwebtoken .Jwts ;
1616import org .apache .logging .log4j .Logger ;
17+ import org .opensearch .OpenSearchSecurityException ;
1718import org .opensearch .SpecialPermission ;
1819import org .opensearch .core .common .Strings ;
1920
@@ -51,13 +52,13 @@ public JwtParserBuilder run() {
5152
5253 try {
5354 key = getPublicKey (decoded , "RSA" );
54- } catch (Exception e ) {
55+ } catch (NoSuchAlgorithmException | InvalidKeySpecException e ) {
5556 log .debug ("No public RSA key, try other algos ({})" , e .toString ());
5657 }
5758
5859 try {
5960 key = getPublicKey (decoded , "EC" );
60- } catch (final Exception e ) {
61+ } catch (NoSuchAlgorithmException | InvalidKeySpecException e ) {
6162 log .debug ("No public ECDSA key, try other algos ({})" , e .toString ());
6263 }
6364
@@ -68,7 +69,7 @@ public JwtParserBuilder run() {
6869 return Jwts .parserBuilder ().setSigningKey (decoded );
6970 } catch (Throwable e ) {
7071 log .error ("Error while creating JWT authenticator" , e );
71- throw new RuntimeException ( e );
72+ throw new OpenSearchSecurityException ( e . toString (), e );
7273 }
7374 }
7475 }
0 commit comments