Skip to content

Commit

Permalink
Exception handling in RequestFilter
Browse files Browse the repository at this point in the history
  • Loading branch information
Odd Einar Hoel committed Sep 3, 2019
1 parent 83bc787 commit 2b2b08f
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha

HttpServletResponse res = HttpServletResponse.class.cast(response);

String fnr = HttpServletRequest.class.cast(request).getHeader(FNR_HEADER_VALUE);
if (fnr != null && tokenHelper.getSubject() != null && !fnr.equals(tokenHelper.getSubject())) {
LOG.warn("FNR {} i header matcher ikke subject {} i token", fnr, tokenHelper.getSubject());
res.sendError(CONFLICT.value());
} else {
try {
String fnr = HttpServletRequest.class.cast(request).getHeader(FNR_HEADER_VALUE);
if ((fnr != null) && (tokenHelper.getSubject() != null) && !fnr.equals(tokenHelper.getSubject())) {
LOG.warn("FNR {} i header matcher ikke subject {} i token", fnr, tokenHelper.getSubject());
res.sendError(CONFLICT.value());
} else {
chain.doFilter(request, response);
}
} catch (Exception e) {
chain.doFilter(request, response);
}
}
Expand Down

0 comments on commit 2b2b08f

Please sign in to comment.