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

SimpleAuthenticationInfo.merge does not merge principals if its internal principal collection is not mutable

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.9
    • 1.0.0
    • None

    Description

      In SimpleAuthenticationInfo.merge(AuthenticationInfo), there is the following code:

              if (this.principals == null) {
                  this.principals = info.getPrincipals();
              } else {
                  if (this.principals instanceof MutablePrincipalCollection) {
                      ((MutablePrincipalCollection) this.principals).addAll(info.getPrincipals());
                  } else {
                      this.principals = new SimplePrincipalCollection(this.principals);
                  }
              }
      

      The logic in the nested else block appears incorrect. If the current "principals" collection is not MutablePrincipalCollection, a new SimplePrincipalCollection, which is mutable, is constructed from it. However, it does not copy the principals from other.getPrincipals(), which by that point in the method is known to be non-null and non-empty, after it makes a mutable principal collection.

      Attachments

        Activity

          People

            kaosko Kalle Korhonen
            bturner Bryan Turner
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: