Hi, Can you please provide reproducer code? While the explanation you provided is nice, it’s not really actionable. The best way to get a resolution to a specific problem is to provide a reproducer. The best ones use a failing test. Make it easy for us to help you :)
> On Nov 1, 2024, at 9:47 AM, [email protected] wrote: > > Ok, swinging back around for my PrincipalCollection question. > > In one of my realms in the doGetAuthenticationInfo method I am creating a > SimplePrincipalCollection and adding 2 items to it. Then I create a > SimpleAuthentication info passing that SPC as the first parameter, the > credentials and the realm name. > > My question is later on if I do SecurityUtils.getSubject().getPrincipals() I > get a PrincipalCollection which seems like it should be the SPC that I > created above. So if I call getPrimaryPrincipal() I would expect the first > principal (one of the Objects I toss in like username or userid). But what I > get back is a....PrincipalCollection. So I need to cast the result of the > getPrimaryPrincipal to a PrincipalCollection...then I can getPrimary or I've > been using oneByType to pick out the object I want. > > Since the getPrimaryPrincipal javadoc mentioned the AuthenticationStrategy > and we were using the "at least one", I tried with "first successful" but got > the same wrapping. > > Am I doing something wrong or is this PrincipalCollection inception expected? > > All of my realms only support one token type, so there shouldn't be info from > multiple realms in the top-level principal collection. > > Thanks! > >
