Uploaded image for project: 'Shiro'
  1. Shiro
  2. SHIRO-101

Comma in role in the properties file is not read correctly by the PropertyRealm

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Not A Problem
    • Affects Version/s: 0.9-RC1, 0.9
    • Fix Version/s: 1.0.0
    • Component/s: Configuration
    • Labels:
      None
    • Environment:
      Ubuntu 8.10, eclipse Galileo

      Description

      I had the following the property file.
      user.luke=luke,Pilot
      role.Pilot=xWing:fly:xxx,yyy
      Now supposdly subject.isPermitted("xWing:fly:xxx") and Subject.isPermitted("xWing:fly:yyy") should both return true. this is not the case, since the first returns true and the second false. Now lets exchange the last term as follows: role.Pilot=xWing:fly:yyy,xxx. and make the same calls again. Now we see the forst returns false and the second returns true. So now we know that only the first token before the comma is read.
      Looking into shiro code in org.apache.shiro.util.PermissionUtils.toPermissionStrings() which calls in turn StringUtils.split(permissionString). This function splits the string around the comma. So from role.Pilot=xWing:fly:xxx,yyy we get two string: xWing:fly:xxx and yyy. To prove this theory I called Subject.isPermitted("yyy") which returned true.

      My suggestion would be not to call PermissionUtils at all, since its being called from WildcardPermission which in turn splits the String using * then the comma afterwards. So it makes no sense splitting the string with the comma two times, since the second time there would be nothing to split anyway.

      Best regards and thanks for your efforts

        Attachments

        1. shirobug.zip
          443 kB
          Moataz Elmasry

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              zaza1851983 Moataz Elmasry
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: