rendered paste body<?php/** * AgaviRbacFilter checks security by calling the getPermissions() * method of the action. Once the permission has been acquired, * AgaviRbacFilter verifies the user has the same permissions * by calling the hasPermissions() method of AgaviRbacUser. * * @package agavi * @subpackage filter * * @copyright (c) Authors * @since 0.9.0 * * @version $Id: AgaviSecurityFilter.class.php 657 2006-07-03 14:53:53Z david $ */class AgaviRbacFilter extends AgaviSecurityFilter implements AgaviIActionFilter, AgaviISecurityFilter{ /** * Execute this filter. * * @param AgaviFilterChain A FilterChain instance. * @param AgaviResponse A Response instance. * * @since 0.11.0 */ public function execute(AgaviFilterChain $filterChain, AgaviResponse $response) { parent::execute($filterChain, $response); // get the cool stuff $context = $this->getContext(); $controller = $context->getController(); $request = $context->getRequest(); $user = $context->getUser(); // get the current action instance $actionEntry = $controller->getActionStack()->getLastEntry(); $actionInstance = $actionEntry->getActionInstance(); // get the credential required for this action $permissions = $actionInstance->getPermissions(); if($user->isAuthenticated()) { if($permissions === null || $user->hasPermissions($permissions) ) { $filterChain->execute(); } else { $request->setAttributes(array( 'requested_module' => $actionEntry->getModuleName(), 'requested_action' => $actionEntry->getActionName() ), 'org.agavi.controller.forwards.secure'); $controller->forward(AgaviConfig::get('actions.secure_module'), AgaviConfig::get('actions.secure_action')); } } else { $request->setAttributes(array( 'requested_module' => $actionEntry->getModuleName(), 'requested_action' => $actionEntry->getActionName() ), 'org.agavi.controller.forwards.login'); $controller->forward(AgaviConfig::get('actions.login_module'), AgaviConfig::get('actions.login_action')); } }}?>