@Test public void testConvertNoAuth() { ILoggingEvent event = mock(ILoggingEvent.class); String res = converter.convert(event); assertEquals("NO ORIGIN", res); }
@Override public String convert(ILoggingEvent event) { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); if (auth == null) { return NO_ORIGIN; } Object principal = auth.getPrincipal(); if (principal instanceof WebCertUser) { WebCertUser user = (WebCertUser) auth.getPrincipal(); return user.getOrigin(); } return NO_ORIGIN; }
OriginConverter extends ClassicConverter { @Override public String convert(ILoggingEvent event) { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); if (auth == null) { return NO_ORIGIN; } Object principal = auth.getPrincipal(); if (principal instanceof WebCertUser) { WebCertUser user = (WebCertUser) auth.getPrincipal(); return user.getOrigin(); } return NO_ORIGIN; } }
OriginConverter extends ClassicConverter { @Override public String convert(ILoggingEvent event) { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); if (auth == null) { return NO_ORIGIN; } Object principal = auth.getPrincipal(); if (principal instanceof WebCertUser) { WebCertUser user = (WebCertUser) auth.getPrincipal(); return user.getOrigin(); } return NO_ORIGIN; }  }
OriginConverter extends ClassicConverter { @Override public String convert(ILoggingEvent event) { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); if (auth == null) { return NO_ORIGIN; } Object principal = auth.getPrincipal(); if (principal instanceof WebCertUser) { WebCertUser user = (WebCertUser) auth.getPrincipal(); return user.getOrigin(); } return NO_ORIGIN; }  @Override String convert(ILoggingEvent event); }
OriginConverter extends ClassicConverter { @Override public String convert(ILoggingEvent event) { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); if (auth == null) { return NO_ORIGIN; } Object principal = auth.getPrincipal(); if (principal instanceof WebCertUser) { WebCertUser user = (WebCertUser) auth.getPrincipal(); return user.getOrigin(); } return NO_ORIGIN; }  @Override String convert(ILoggingEvent event);  }