private static Principal getPrimaryPrincipal ( final PrincipalElectionStrategy principalElectionStrategy , final Set < Authentication > authentications , final Map < String , List < Object > > principalAttributes ) { return principalElectionStrategy . nominate ( new LinkedHashSet <> ( authentications ) , principalAttributes ) ; }
Principal id is and must be enforced to be the same for all authentications . Based on that restriction it s safe to simply grab the first principal id in the chain when composing the authentication chain for the caller .