Skip to content
This repository was archived by the owner on Dec 12, 2018. It is now read-only.
This repository was archived by the owner on Dec 12, 2018. It is now read-only.

NoSuchElementException when reading principals where multiple Realms in use #2

Description

@zgrose

I have an application that uses multiple Realms (in this particular case an IniRealm and the ApplicationRealm). ApplicationRealm.getAccountHref() assumes that the subject was authenticated against the ApplicationRealm

protected String getAccountHref(PrincipalCollection principals) {
    Collection c = principals.fromRealm(getName());
    //Based on the createPrincipals implementation above, the first one is the Account href:
    return (String) c.iterator().next();
}

When a PrincipalCollection is passed to doGetAuthorizationInfo, the c.size() == 0 so there is no next().

java.util.NoSuchElementException
at java.util.Collections$EmptyIterator.next(Collections.java:3006)

Trapping an empty collection and returning a default/empty SimpleAuthorizationInfo seems the most appropriate solution but that's just a guess.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions