Skip to content

Commit

Permalink
Cleans up changes around the HTTPJwtAuthenticator constructor
Browse files Browse the repository at this point in the history
Signed-off-by: Darshit Chanpura <[email protected]>
  • Loading branch information
DarshitChanpura committed Oct 25, 2023
1 parent bc22e40 commit 2215fa2
Showing 1 changed file with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,29 +69,23 @@ public HTTPJwtAuthenticator(final Settings settings, final Path configPath) {
requireAudience = settings.get("required_audience");
requireIssuer = settings.get("required_issuer");

JwtParserBuilder jwtParserBuilder = KeyUtils.createJwtParserBuilderFromSigningKey(signingKey, log);
final JwtParserBuilder jwtParserBuilder = KeyUtils.createJwtParserBuilderFromSigningKey(signingKey, log);
if (jwtParserBuilder == null) {
jwtParser = null;
} else {
if (requireAudience != null) {
jwtParserBuilder = jwtParserBuilder.require("aud", requireAudience);
jwtParserBuilder.requireAudience(requireAudience);
}

if (requireIssuer != null) {
jwtParserBuilder = jwtParserBuilder.require("iss", requireIssuer);
jwtParserBuilder.requireIssuer(requireIssuer);
}

final SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(new SpecialPermission());
}
JwtParserBuilder finalJwtParserBuilder = jwtParserBuilder;
jwtParser = AccessController.doPrivileged(new PrivilegedAction<JwtParser>() {
@Override
public JwtParser run() {
return finalJwtParserBuilder.build();
}
});
jwtParser = AccessController.doPrivileged((PrivilegedAction<JwtParser>) jwtParserBuilder::build);
}
}

Expand Down

0 comments on commit 2215fa2

Please sign in to comment.