Small JPA improvements & test code style (#2122)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2024-12-06 13:03:48 +02:00
committed by GitHub
parent efc6d051f7
commit 2a476d1268
17 changed files with 243 additions and 324 deletions

View File

@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.security;
import java.util.Optional;
import org.eclipse.hawkbit.tenancy.TenantAwareAuthenticationDetails;
import org.springframework.data.domain.AuditorAware;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
@@ -58,6 +59,9 @@ public class SpringSecurityAuditorAware implements AuditorAware<String> {
}
protected String getCurrentAuditor(final Authentication authentication) {
if (authentication.getDetails() instanceof TenantAwareAuthenticationDetails tenantAwareDetails && tenantAwareDetails.isController()) {
return "CONTROLLER_PLUG_AND_PLAY";
}
if (authentication.getPrincipal() instanceof UserDetails) {
return ((UserDetails) authentication.getPrincipal()).getUsername();
}