That is the correct way to get it, however it appears that you are
creating it slightly incorrectly. This line:
info = new SimpleAuthenticationInfo(principals,
password.toCharArray(), getName());
is not calling the constructor that you expect. It is calling (Object,
Object, String) - where the first object is "the primary principal".
Instead, change it to:
info = new SimpleAuthenticationInfo(principals,
password.toCharArray());
which should call (PrincipalCollection, Object). You don't need to
specify the realm name again, since you've already specified it when
adding principals to the principal collection.
Hope that helps,
Jared
On Fri 20 Jul 2012 02:30:08 PM CDT, tarka wrote:
> Thanks Kalle,
>
> Could you just clarify for me. My understanding is that a 'principal' is
> the name used to specify a subjects unique identifying attribute such as
> a uuid or a username etc. However when I place a call to
> getPrimaryPrincipal() I get a collection of type
> <SimplePrincipalCollection> containing a linkedHashMap of both the
> username keypair and the uuid keypair. I would have thought that this
> should return only the 'Primary Principal' ie. a single keypair value!
>
> If the above is the correct behaviour and I have misunderstood then
> what's the best way to access the individual principals? When I do this
> for example:
>
> doGetAuthorizationInfo(PrincipalCollection principals) {
> ...
> Object c = principals.getPrimaryPrincipal();
> ...
> }
>
> I can't then access the LinkedHashMap.
>
> Tarka
>
> On 20/07/2012 18:00, kaosko [via Shiro User] wrote:
>> On Fri, Jul 20, 2012 at 8:27 AM, tarka <[hidden email]
>> </user/SendEmail.jtp?type=node&node=7577616&i=0>> wrote:
>>> The above code actually works! The problem is coming from trying to
>> retrieve
>>> the principals! At the moment I am getting a LinkedHashMap inside a
>>> SimplePrincipalCollection object returned.
>>
>> You are getting or "you are trying to get"?
>>
>>> How can I simply access the LinkedHashMap keys directly?
>>
>> The simple answer is you don't. Use the operations of
>> PrincipalCollection to return a principal specific to your needs, for
>> example getPrimaryPrincipal(), oneByType() or fromRealm(...).
>>
>> Kalle
>>
>>
>> ------------------------------------------------------------------------
>> If you reply to this email, your message will be added to the
>> discussion below:
>> http://shiro-user.582556.n2.nabble.com/How-to-set-Principals-tp7490972p7577616.html
>>
>> To unsubscribe from How to set Principals?, click here
>> <http://shiro-user.582556.n2.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=7490972&code=aW5mb0B0YXJrYS50dnw3NDkwOTcyfC0xNjQ5ODA1ODk5>.
>> NAML
>> <http://shiro-user.582556.n2.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>
>
>
>
>
>
>
> --
> View this message in context:
> http://shiro-user.582556.n2.nabble.com/How-to-set-Principals-tp7490972p7577617.html
> Sent from the Shiro User mailing list archive at Nabble.com.