//
// If the page or ACL is null, it's allowed.
//
String pageName = ((PagePermission)permission).getPage();
WikiPage page = m_engine.getPage( pageName );
Acl acl = ( page == null) ? null : m_engine.getAclManager().getPermissions( page );
if ( page == null || acl == null || acl.isEmpty() )
{
fireEvent( WikiSecurityEvent.ACCESS_ALLOWED, user, permission );
return true;
}
//
// Next, iterate through the Principal objects assigned
// this permission. If the context's subject possesses
// any of these, the action is allowed.
Principal[] aclPrincipals = acl.findPrincipals( permission );
log.debug( "Checking ACL entries..." );
log.debug( "Acl for this page is: " + acl );
log.debug( "Checking for principal: " + Arrays.toString( aclPrincipals ) );
log.debug( "Permission: " + permission );
for( Principal aclPrincipal : aclPrincipals )
{
// If the ACL principal we're looking at is unresolved,
// try to resolve it here & correct the Acl
if ( aclPrincipal instanceof UnresolvedPrincipal )
{
AclEntry aclEntry = acl.getEntry( aclPrincipal );
aclPrincipal = resolvePrincipal( aclPrincipal.getName() );
if ( aclEntry != null && !( aclPrincipal instanceof UnresolvedPrincipal ) )
{
aclEntry.setPrincipal( aclPrincipal );
}