@Test public void testGetMDCValueNullAuthentication() { UserIdMDCPutFilter mdcPutFilter = new UserIdMDCPutFilter(); String mdcValueStr = mdcPutFilter.getMDCValue(request, response); assertThat(mdcValueStr, is(nullValue())); }
@Override protected String getMDCValue(HttpServletRequest request, HttpServletResponse response) { Authentication authentication = SecurityContextHolder.getContext() .getAuthentication(); if (authentication != null) { Object principal = authentication.getPrincipal(); if (principal instanceof UserDetails) { return ((UserDetails) principal).getUsername(); } return principal.toString(); } return null; }
UserIdMDCPutFilter extends AbstractMDCPutFilter { @Override protected String getMDCValue(HttpServletRequest request, HttpServletResponse response) { Authentication authentication = SecurityContextHolder.getContext() .getAuthentication(); if (authentication != null) { Object principal = authentication.getPrincipal(); if (principal instanceof UserDetails) { return ((UserDetails) principal).getUsername(); } return principal.toString(); } return null; } }
UserIdMDCPutFilter extends AbstractMDCPutFilter { @Override protected String getMDCValue(HttpServletRequest request, HttpServletResponse response) { Authentication authentication = SecurityContextHolder.getContext() .getAuthentication(); if (authentication != null) { Object principal = authentication.getPrincipal(); if (principal instanceof UserDetails) { return ((UserDetails) principal).getUsername(); } return principal.toString(); } return null; }  }
UserIdMDCPutFilter extends AbstractMDCPutFilter { @Override protected String getMDCValue(HttpServletRequest request, HttpServletResponse response) { Authentication authentication = SecurityContextHolder.getContext() .getAuthentication(); if (authentication != null) { Object principal = authentication.getPrincipal(); if (principal instanceof UserDetails) { return ((UserDetails) principal).getUsername(); } return principal.toString(); } return null; }  void setAttributeName(String attibuteName); }
UserIdMDCPutFilter extends AbstractMDCPutFilter { @Override protected String getMDCValue(HttpServletRequest request, HttpServletResponse response) { Authentication authentication = SecurityContextHolder.getContext() .getAuthentication(); if (authentication != null) { Object principal = authentication.getPrincipal(); if (principal instanceof UserDetails) { return ((UserDetails) principal).getUsername(); } return principal.toString(); } return null; }  void setAttributeName(String attibuteName);  }