If your custom realm extends RealmBase but uses a custom principal, just like mine, you need to duplicate the entire #hasRole(Wrapper, Princpal, String) method. The only interesting part for an implementor is !(principal instanceof GenericPrincipal) and GenericPrincipal gp = (GenericPrincipal) principal; boolean result = gp.hasRole(role); A verbatim copy of the method is need just to adapt three lines. Which basically means to double-check every Tomcat release for changes in this method. I am proposing to introduce a new sub-method: hasRoleInternal(Wrapper, Principal, String) (or alike) which performs just the code above. The entire boilerplate code remains in #hasRole() My custom realm would simply do: public boolean hasRoleInternal(Wrappr wrapper, Principal principal, String role) { if(!(principal instanceof CustomPrincipal)) return false; CustomPrincipal cp = (CustomPrincipal) principal; return cp.hasRole(role); } I can provide a patch for that if you agree with.
I disagree, it's not worth changing the API for it and it's worse than "checking for changes" which actually never happens. BTW, this is an "enhancement", not a "major" bug.
(In reply to Remy Maucherat from comment #1) > I disagree, it's not worth changing the API for it and it's worse than > "checking for changes" which actually never happens. > BTW, this is an "enhancement", not a "major" bug. Why do you close this issue without having a discussion first? No one is changing the API. You can still continue to override #hasRole(), it will have the same effect. The change can happen and are not a part of an API at at all. The code of RealmBase#hasRole() is implementation specific, not to be known to the user at best.
Anyone else care to share an opinion on that?
Feel free to post a patch. I think it's a reasonable change.
(In reply to Christopher Schultz from comment #4) > Feel free to post a patch. I think it's a reasonable change. Thanks, I will prepare one next week.
Fixed in: - trunk for 9.0.0.M18 onwards - 8.5.x for 8.5.12 onwards
(In reply to Mark Thomas from comment #6) > Fixed in: > - trunk for 9.0.0.M18 onwards > - 8.5.x for 8.5.12 onwards Per(In reply to Mark Thomas from comment #6) > Fixed in: > - trunk for 9.0.0.M18 onwards > - 8.5.x for 8.5.12 onwards Perfect, couldn't be better. Thank you!