Skip to content

Commit

Permalink
Only print runtime exception at severe, keep auth at fine
Browse files Browse the repository at this point in the history
Signed-off-by: Arjan Tijms <arjan.tijms@gmail.com>
  • Loading branch information
arjantijms committed May 26, 2022
1 parent 28fe14c commit 2d8ef1a
Showing 1 changed file with 2 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import static org.apache.catalina.Globals.WRAPPED_RESPONSE;

import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.ProtocolException;
Expand Down Expand Up @@ -155,7 +154,6 @@ public class RealmAdapter extends RealmBase implements RealmInitializer, PostCon

private static final Logger _logger = LogDomains.getLogger(RealmAdapter.class, WEB_LOGGER);
private static final ResourceBundle resourceBundle = _logger.getResourceBundle();
private static final boolean debug = isDebug();

private static final String SERVER_AUTH_CONTEXT = "__jakarta.security.auth.message.ServerAuthContext";
private static final String MESSAGE_INFO = "__jakarta.security.auth.message.MessageInfo";
Expand Down Expand Up @@ -1348,10 +1346,10 @@ private boolean validate(HttpRequest request, HttpResponse response, LoginConfig
httpServletRequest.setAttribute(MESSAGE_INFO, messageInfo);
}
} catch (AuthException ae) {
_logger.log(debug? SEVERE : FINE, "Jakarta Authentication: http msg authentication fail", ae);
_logger.log(FINE, "Jakarta Authentication: http msg authentication fail", ae);
httpServletResponse.setStatus(SC_INTERNAL_SERVER_ERROR);
} catch (RuntimeException e) {
_logger.log(debug? SEVERE : FINE, "Jakarta Authentication: Exception during validateRequest", e);
_logger.log(SEVERE , "Jakarta Authentication: Exception during validateRequest", e);
httpServletResponse.sendError(SC_INTERNAL_SERVER_ERROR);
}

Expand Down Expand Up @@ -1786,12 +1784,4 @@ private Key findDigestKey(DigestAlgorithmParameter[] digestParameters) {
throw new RuntimeException("No key found in parameters");
}

private static boolean isDebug() {
try {
return ManagementFactory.getRuntimeMXBean().getInputArguments().toString().indexOf("-agentlib:jdwp") > 0;
} catch(Exception e) {
return false;
}
}

}

0 comments on commit 2d8ef1a

Please sign in to comment.