Feature/remove hard requirements for mdc (#1811)
* Remove hard requirements for MDCHandler dependencies Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com> --------- Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -38,9 +38,9 @@ public class MDCHandler {
|
|||||||
|
|
||||||
@Value("${hawkbit.logging.mdchandler.enabled:true}")
|
@Value("${hawkbit.logging.mdchandler.enabled:true}")
|
||||||
private boolean mdcEnabled;
|
private boolean mdcEnabled;
|
||||||
@Autowired
|
@Autowired(required = false)
|
||||||
private SpringSecurityAuditorAware springSecurityAuditorAware;
|
private SpringSecurityAuditorAware springSecurityAuditorAware = new SpringSecurityAuditorAware();
|
||||||
@Autowired
|
@Autowired(required = false)
|
||||||
private SystemSecurityContext securityContext;
|
private SystemSecurityContext securityContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -110,7 +110,7 @@ public class MDCHandler {
|
|||||||
final String user = springSecurityAuditorAware
|
final String user = springSecurityAuditorAware
|
||||||
.getCurrentAuditor()
|
.getCurrentAuditor()
|
||||||
.filter(username -> !username.equals("system")) // null and system are the same - system user
|
.filter(username -> !username.equals("system")) // null and system are the same - system user
|
||||||
.map(username -> (securityContext.isCurrentThreadSystemCode() ? "as " : "") + username)
|
.map(username -> (securityContext != null && securityContext.isCurrentThreadSystemCode() ? "as " : "") + username)
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
|
|
||||||
final String currentUser = MDC.get(MDC_KEY_USER);
|
final String currentUser = MDC.get(MDC_KEY_USER);
|
||||||
|
|||||||
Reference in New Issue
Block a user