You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2016/12/12 13:20:19 UTC

[Bug 60469] New: RealmBase#hasRole() imposes too much boilerplate code if principal is not of type GenericPrincipal

https://bz.apache.org/bugzilla/show_bug.cgi?id=60469

            Bug ID: 60469
           Summary: RealmBase#hasRole() imposes too much boilerplate code
                    if principal is not of type GenericPrincipal
           Product: Tomcat 8
           Version: 8.5.x-trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: Catalina
          Assignee: dev@tomcat.apache.org
          Reporter: 1983-01-06@gmx.net
  Target Milestone: ----

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.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 60469] RealmBase#hasRole() imposes too much boilerplate code if principal is not of type GenericPrincipal

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60469

--- Comment #3 from Michael Osipov <19...@gmx.net> ---
Anyone else care to share an opinion on that?

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 60469] RealmBase#hasRole() imposes too much boilerplate code if principal is not of type GenericPrincipal

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60469

--- Comment #5 from Michael Osipov <19...@gmx.net> ---
(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.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 60469] RealmBase#hasRole() imposes too much boilerplate code if principal is not of type GenericPrincipal

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60469

Michael Osipov <19...@gmx.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|WONTFIX                     |---
           Severity|major                       |enhancement
             Status|RESOLVED                    |REOPENED

--- Comment #2 from Michael Osipov <19...@gmx.net> ---
(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.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 60469] RealmBase#hasRole() imposes too much boilerplate code if principal is not of type GenericPrincipal

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60469

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|REOPENED                    |RESOLVED

--- Comment #6 from Mark Thomas <ma...@apache.org> ---
Fixed in:
- trunk for 9.0.0.M18 onwards
- 8.5.x for 8.5.12 onwards

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 60469] RealmBase#hasRole() imposes too much boilerplate code if principal is not of type GenericPrincipal

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60469

Remy Maucherat <re...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |WONTFIX

--- Comment #1 from Remy Maucherat <re...@apache.org> ---
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.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 60469] RealmBase#hasRole() imposes too much boilerplate code if principal is not of type GenericPrincipal

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60469

--- Comment #7 from Michael Osipov <19...@gmx.net> ---
(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!

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 60469] RealmBase#hasRole() imposes too much boilerplate code if principal is not of type GenericPrincipal

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60469

--- Comment #4 from Christopher Schultz <ch...@christopherschultz.net> ---
Feel free to post a patch. I think it's a reasonable change.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org