Returns
true
or
false
, depending on whether a Permission is allowed for the Subject associated with a supplied WikiSession. The access control algorithm works this way:
- The {@link com.ecyrd.jspwiki.auth.acl.Acl} for the page is obtained
- The Subject associated with the current {@link com.ecyrd.jspwiki.WikiSession} is obtained
- If the Subject's Principal set includes the Role Principal that is the administrator group, always allow the Permission
- For all permissions, check to see if the Permission is allowed according to the default security policy. If it isn't, deny the permission and halt further processing.
- If there is an Acl, get the list of Principals assigned this Permission in the Acl: these will be role, group or user Principals, or {@link com.ecyrd.jspwiki.auth.acl.UnresolvedPrincipal}s (see below). Then iterate through the Subject's Principal set and determine whether the user (Subject) posesses any one of these specified Roles or Principals. The matching process delegates to {@link #hasRoleOrPrincipal(WikiSession,Principal)}.
Note that when iterating through the Acl's list of authorized Principals, it is possible that one or more of the Acl's Principal entries are of type UnresolvedPrincipal
. This means that the last time the ACL was read, the Principal (user, built-in Role, authorizer Role, or wiki Group) could not be resolved: the Role was not valid, the user wasn't found in the UserDatabase, or the Group wasn't known to (e.g., cached) in the GroupManager. If an UnresolvedPrincipal
is encountered, this method will attempt to resolve it first before checking to see if the Subject possesses this principal, by calling {@link #resolvePrincipal(String)}. If the (re-)resolution does not succeed, the access check for the principal will fail by definition (the Subject should never contain UnresolvedPrincipals).
If security not set to JAAS, will return true.
@param session the current wiki session
@param permission the Permission being checked
@see #hasRoleOrPrincipal(WikiSession,Principal)
@return the result of the Permission check