Spring Security
  1. Spring Security
  2. SEC-1304

Remove Comparable from GrantedAuthority to allow Enum impl

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: 3.0.0 RC1
    • Fix Version/s: 3.0.0.RC2
    • Component/s: Core
    • Labels:
      None

      Description

      it would be great to have my enum implement the GrantedAuthority interface. currently this is not possible because of the typed Comparable. a more generic approach works:

      interface GrantedAuthority<T extends GrantedAuthority<?>> extends Serializable, Comparable<T> {

        Activity

        Hide
        Luke Taylor added a comment - - edited

        This appears to cause compiler errors and warnings (requiring parameterization of GrantedAuthority) if substituted for the existing code.

        Could you be more specific about how you get it to work?

        Show
        Luke Taylor added a comment - - edited This appears to cause compiler errors and warnings (requiring parameterization of GrantedAuthority) if substituted for the existing code. Could you be more specific about how you get it to work?
        Hide
        Luke Taylor added a comment -

        Actually, I'm not sure we need the Comparable on GrantedAuthority. It was introduced for SEC-717. Since we now use a Collection for getAuthorities() methods, I don't really see that a specific ordering should be required. The current places where the authorities are loaded could achieve the same result using a Comparator.

        Show
        Luke Taylor added a comment - Actually, I'm not sure we need the Comparable on GrantedAuthority. It was introduced for SEC-717 . Since we now use a Collection for getAuthorities() methods, I don't really see that a specific ordering should be required. The current places where the authorities are loaded could achieve the same result using a Comparator.
        Hide
        Alex Peters added a comment -

        i attachted a sample impl

        Show
        Alex Peters added a comment - i attachted a sample impl
        Hide
        Luke Taylor added a comment -

        Having to implement GrantedAuthority<GrantedAuthority<?>>, rather than just GrantedAuthority seems to me like it would be confusing for people (it is for me ).

        I would prefer just to roll back the addition of Comparable from SEC-717.

        Show
        Luke Taylor added a comment - Having to implement GrantedAuthority<GrantedAuthority<?>>, rather than just GrantedAuthority seems to me like it would be confusing for people (it is for me ). I would prefer just to roll back the addition of Comparable from SEC-717 .
        Hide
        Luke Taylor added a comment -

        I've removed the Comparable interface. I don't think this should cause any problems.

        Show
        Luke Taylor added a comment - I've removed the Comparable interface. I don't think this should cause any problems.
        Hide
        Alex Peters added a comment -

        thank you!

        Show
        Alex Peters added a comment - thank you!

          People

          • Assignee:
            Luke Taylor
            Reporter:
            Alex Peters
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: