package com.koobietech.eas.security.utils;
import org.springframework.security.core.context.SecurityContextHolder;
public class SecurityUtils {

    public static String getLoginUserName(){
        Object principal = getPrincipal();
        return principal.toString().equals("anonymousUser") ? "" : principal.toString();
    }

    public static boolean isLogged(){
        Object principal = getPrincipal();
        return principal.toString().equals("anonymousUser");
    }

    private static Object getPrincipal(){
        return SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    }

}
