updates on batch logic

This commit is contained in:
Prince
2026-06-17 01:11:48 +02:00
parent 5d3c9a46a3
commit 0eda74414e
16 changed files with 288 additions and 254 deletions

View File

@@ -0,0 +1,21 @@
package zw.qantra.tm.utils;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
public class SecurityUtils {
public static String getCurrentUsername() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication != null && authentication.isAuthenticated()) {
Object principal = authentication.getPrincipal();
if (principal instanceof UserDetails) {
return ((UserDetails) principal).getUsername();
} else {
return principal.toString(); // For cases where principal might be a String
}
}
return null; // Or throw an exception if the user is expected to be logged in
}
}