Creating a custom ACL driver involves a few steps that should feel like a relatively easy task for a PHP programmer. Basically, your new driver needs to implement the only abstract class defined in the ACL.php file, that is org_geoprisma_acl_ACL and its abstract public function isAuthorized. Once defined, you then set GeoPrisma to use your new driver.
See the BorealisACL or NoACL driver for an example.
Create a new PHP class which extends org_geoprisma_acl_ACL
<?php
class your_custom_acl_driver extends org_geoprisma_acl_ACL
{
....
}
?>
Implement the com_borealis_foundation_util_Singleton abstract function in the constructor of your new class.
<?php
class your_custom_acl_driver extends org_geoprisma_acl_ACL
{
private static $s_objInstance = null;
private function __construct()
{
// Singleton DP
}
public static function getInstance()
{
if (is_null(self::$s_objInstance))
{
self::$s_objInstance = new your_custom_acl_driver();
}
return self::$s_objInstance;
}
}
?>
Implement the isAuthorized function in your class. This function receives two parameters : Ressource Name and Action Name. Your function checks if the action in this resource is authorized and returns true or false.
<?php
class your_custom_acl_driver extends org_geoprisma_acl_ACL
{
public function isAuthorized($pstrRessource, $pstrAction)
{
....
return true;
....
return false;
}
}
?>
Set Geoprisma to use your driver [1]
<?php
org_geoprisma_SettingImpl::setACLClass('your_custom_acl_driver');
?>
P.S: Your driver class needs to be loaded before, or loaded in an autoload function like com_borealis_Autoload.php
<?php
require 'your_custom_acl_driver.php'
?>
Final result of your_custom_acl_driver.php
<?php
class your_custom_acl_driver extends org_geoprisma_acl_ACL
{
private static $s_objInstance = null;
private function __construct()
{
// Singleton DP
}
public static function getInstance()
{
if (is_null(self::$s_objInstance))
{
self::$s_objInstance = new your_custom_acl_driver();
}
return self::$s_objInstance;
}
public function isAuthorized($pstrRessource, $pstrAction)
{
....
return true;
....
return false;
}
}
?>
[1] | The default acl driver used is defined in the Setting.php file. It defaults to org_geoprisma_acl_NoACL. The implementation resides in the SettingImpl.php class. That class defines getters and setters, amongst which the setter for the locale driver : setACLClass. This is usually done in the common.php file. |