if (acls[i] instanceof AbstractBasicAclEntry) { AbstractBasicAclEntry processableAcl = (AbstractBasicAclEntry) acls[i];
if (acls[i] instanceof BasicAclEntry) { BasicAclEntry processableAcl = (BasicAclEntry) acls[i];
    public Object decide(Authentication authentication, Object object,        ConfigAttributeDefinition config, Object returnedObject)        throws AccessDeniedException {        Iterator iter = config.getConfigAttributes();        while (iter.hasNext()) {            ConfigAttribute attr = (ConfigAttribute) iter.next();            if (this.supports(attr)) {                // Need to process the Collection for this invocation                if (returnedObject == null) {                    if (logger.isDebugEnabled()) {                        logger.debug("Return object is null, skipping");                    }                    return null;                }                Filterer filterer = null;                if (returnedObject instanceof Collection) {                    Collection collection = (Collection) returnedObject;                    filterer = new CollectionFilterer(collection);                } else if (returnedObject.getClass().isArray()) {                    Object[] array = (Object[]) returnedObject;                    filterer = new ArrayFilterer(array);                } else {                    throw new AuthorizationServiceException(                        "A Collection or an array (or null) was required as the returnedObject, but the returnedObject was: "                        + returnedObject);                }                // Locate unauthorised Collection elements                Iterator collectionIter = filterer.iterator();                while (collectionIter.hasNext()) {                    Object domainObject = collectionIter.next();                    boolean hasPermission = false;                    AclEntry[] acls = null;                    if (domainObject == null) {                        hasPermission = true;                    } else {                        acls = aclManager.getAcls(domainObject, authentication);                    }                    if ((acls != null) && (acls.length != 0)) {                        for (int i = 0; i < acls.length; i++) {                            // Locate processable AclEntrys                            if (acls[i] instanceof AbstractBasicAclEntry) {                                AbstractBasicAclEntry processableAcl = (AbstractBasicAclEntry) acls[i];                                // See if principal has any of the required permissions                                for (int y = 0; y < requirePermission.length;                                    y++) {                                    if (processableAcl.isPermitted(                                            requirePermission[y])) {                                        hasPermission = true;                                        if (logger.isDebugEnabled()) {                                            logger.debug(                                                "Principal is authorised for element: "                                                + domainObject                                                + " due to ACL: "                                                + processableAcl.toString());                                        }                                    }                                }                            }                        }                    }                    if (!hasPermission) {                        filterer.remove(domainObject);                        if (logger.isDebugEnabled()) {                            logger.debug(                                "Principal is NOT authorised for element: "                                + domainObject);                        }                    }                }                return filterer.getFilteredObject();            }        }        return returnedObject;    }