Spring Security
  1. Spring Security
  2. SEC-1347

GrantedAuthority should extends Comparable<GrantedAuthority>

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Won't Fix
    • Affects Version/s: 3.0.0
    • Fix Version/s: 3.0.1
    • Component/s: Core
    • Labels:
      None

      Description

      GrantedAuthorityImpl has a compareTo() method which I guess is supposed to be the implementation of Comparable<GrantedAuthority>, however this interface is nowhere to be found in the class hierarchy.

      We found out because UserDetails.getAuthorities() : Collection<GrantedAuthority> is supposed to return elements "sorted by natural key" and we thought about using a TreeSet in our implementation, but of course this would only work if the GrantedAuthorityImpl objects we put in it implement Comparable, which they don't. We use a LinkedHashSet instead as a workaround, pre-sorting elements before insertion.

      BTW, what's the reasoning behind the "sorted by natural key" requirement for iterating through authorities?

        Activity

        Hide
        Luke Taylor added a comment - - edited

        Please see SEC-1304 and SEC-717. The compareTo() method has been left in by mistake and should be removed.

        Show
        Luke Taylor added a comment - - edited Please see SEC-1304 and SEC-717 . The compareTo() method has been left in by mistake and should be removed.
        Hide
        Luke Taylor added a comment -

        Removed the compareTo method as part of the original issue.

        Show
        Luke Taylor added a comment - Removed the compareTo method as part of the original issue.

          People

          • Assignee:
            Luke Taylor
            Reporter:
            Manuel Dominguez Sarmiento
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: