Skip to content

Commit

Permalink
Open readPrincipal method
Browse files Browse the repository at this point in the history
  • Loading branch information
DamnClin committed Jun 27, 2022
1 parent c4449fa commit ede76e7
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,18 @@ public final class AuthenticatedUser {
return authentication().map(AuthenticatedUser::readPrincipal).flatMap(Username::of);
}

private static String readPrincipal(Authentication authentication) {
/**
* Read user principal from authentication
*
* @param authentication
* authentication to read the principal from
* @return The user principal
* @throws UnknownAuthenticationException
* if the authentication can't be read
*/
public static String readPrincipal(Authentication authentication) {
Assert.notNull("authentication", authentication);
if (authentication.getPrincipal() instanceof UserDetails details) {
return details.getUsername();
}
Expand Down

0 comments on commit ede76e7

Please sign in to comment.