Skip to content

Commit

Permalink
Changing AclBase into AclInterface as it is now an interface.
Browse files Browse the repository at this point in the history
Splitting the test case into separate test cases for each class.
  • Loading branch information
markstory committed Apr 24, 2010
1 parent 523eda0 commit e111735
Show file tree
Hide file tree
Showing 2 changed files with 219 additions and 100 deletions.
89 changes: 77 additions & 12 deletions cake/libs/controller/components/acl.php
Expand Up @@ -76,8 +76,8 @@ public function adapter($adapter = null) {
if (is_string($adapter)) {
$adapter = new $adapter();
}
if (!$adapter instanceof AclBase) {
throw new Exception(__('AclComponent adapters must extend AclBase'));
if (!$adapter instanceof AclInterface) {
throw new Exception(__('AclComponent adapters must implement AclInterface'));
}
$this->_Instance = $adapter;
$this->_Instance->initialize($this);
Expand Down Expand Up @@ -176,14 +176,13 @@ public function revoke($aro, $aco, $action = "*") {
}

/**
* Access Control List abstract class. Not to be instantiated.
* Subclasses of this class are used by AclComponent to perform ACL checks in Cake.
* Access Control List interface.
* Implementing classes are used by AclComponent to perform ACL checks in Cake.
*
* @package cake
* @subpackage cake.cake.libs.controller.components
* @abstract
*/
abstract class AclBase extends Object {
interface AclInterface {

/**
* Empty method to be overridden in subclasses
Expand All @@ -192,14 +191,44 @@ abstract class AclBase extends Object {
* @param string $aco ACO The controlled object identifier.
* @param string $action Action (defaults to *)
*/
public abstract function check($aro, $aco, $action = "*");
public function check($aro, $aco, $action = "*");

/**
* Empty method to be overridden in subclasses
* Allow methods are used to grant an ARO access to an ACO.
*
* @param string $aro ARO The requesting object identifier.
* @param string $aco ACO The controlled object identifier.
* @param string $action Action (defaults to *)
* @return boolean Success
*/
public function allow($aro, $aco, $action = "*");

/**
* Deny methods are used to remove permission from an ARO to access an ACO.
*
* @param string $aro ARO The requesting object identifier.
* @param string $aco ACO The controlled object identifier.
* @param string $action Action (defaults to *)
* @return boolean Success
*/
public function deny($aro, $aco, $action = "*");

/**
* Inherit methods modify the permission for an ARO to be that of its parent object.
*
* @param object $component Component
* @param string $aro ARO The requesting object identifier.
* @param string $aco ACO The controlled object identifier.
* @param string $action Action (defaults to *)
* @return boolean Success
*/
public abstract function initialize($component);
public function inherit($aro, $aco, $action = "*");

/**
* Initialization method for the Acl implementation
*
* @param AclComponent $component
*/
public function initialize($component);
}

/**
Expand All @@ -222,7 +251,7 @@ public abstract function initialize($component);
* @package cake
* @subpackage cake.cake.libs.model
*/
class DbAcl extends AclBase {
class DbAcl extends Object implements AclInterface {

/**
* Constructor
Expand Down Expand Up @@ -492,7 +521,7 @@ protected function _getAcoKeys($keys) {
* @package cake
* @subpackage cake.cake.libs.model.iniacl
*/
class IniAcl extends AclBase {
class IniAcl extends Object implements AclInterface {

/**
* Array with configuration, parsed from ini file
Expand All @@ -512,6 +541,42 @@ public function initialize($component) {

}

/**
* No op method, allow cannot be done with IniAcl
*
* @param string $aro ARO The requesting object identifier.
* @param string $aco ACO The controlled object identifier.
* @param string $action Action (defaults to *)
* @return boolean Success
*/
public function allow($aro, $aco, $action = "*") {

}

/**
* No op method, deny cannot be done with IniAcl
*
* @param string $aro ARO The requesting object identifier.
* @param string $aco ACO The controlled object identifier.
* @param string $action Action (defaults to *)
* @return boolean Success
*/
public function deny($aro, $aco, $action = "*") {

}

/**
* No op method, inherit cannot be done with IniAcl
*
* @param string $aro ARO The requesting object identifier.
* @param string $aco ACO The controlled object identifier.
* @param string $action Action (defaults to *)
* @return boolean Success
*/
public function inherit($aro, $aco, $action = "*") {

}

/**
* Main ACL check function. Checks to see if the ARO (access request object) has access to the
* ACO (access control object).Looks at the acl.ini.php file for permissions
Expand Down

0 comments on commit e111735

Please sign in to comment.