@Test void getCurrentUsernameSystemPrincipal() { try { SecurityContextHolder.getContext().setAuthentication(SystemSecurityToken.getInstance()); assertNull(SecurityUtils.getCurrentUsername()); } finally { SecurityContextHolder.getContext().setAuthentication(authentication); } }
public static @Nullable @CheckForNull String getCurrentUsername() { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (authentication == null) { return null; } return getUsername(authentication); }
SecurityUtils { public static @Nullable @CheckForNull String getCurrentUsername() { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (authentication == null) { return null; } return getUsername(authentication); } }
SecurityUtils { public static @Nullable @CheckForNull String getCurrentUsername() { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (authentication == null) { return null; } return getUsername(authentication); } private  SecurityUtils(); }
SecurityUtils { public static @Nullable @CheckForNull String getCurrentUsername() { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (authentication == null) { return null; } return getUsername(authentication); } private  SecurityUtils(); static @Nullable @CheckForNull String getCurrentUsername(); static boolean currentUserHasRole(String... roles); static boolean currentUserIsSuOrSystem(); static boolean currentUserIsSu(); static boolean currentUserIsSystem(); static boolean currentUserIsAuthenticated(); static boolean currentUserIsAnonymous(); }
SecurityUtils { public static @Nullable @CheckForNull String getCurrentUsername() { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (authentication == null) { return null; } return getUsername(authentication); } private  SecurityUtils(); static @Nullable @CheckForNull String getCurrentUsername(); static boolean currentUserHasRole(String... roles); static boolean currentUserIsSuOrSystem(); static boolean currentUserIsSu(); static boolean currentUserIsSystem(); static boolean currentUserIsAuthenticated(); static boolean currentUserIsAnonymous(); static final String ANONYMOUS_USERNAME; static final String AUTHORITY_SU; static final String AUTHORITY_ANONYMOUS; static final String AUTHORITY_USER; static final String ROLE_SYSTEM; static final String ROLE_ACL_TAKE_OWNERSHIP; static final String ROLE_ACL_MODIFY_AUDITING; static final String ROLE_ACL_GENERAL_CHANGES; }