Changeset 2518 for sandbox/workflow


Ignore:
Timestamp:
04/14/10 10:59:04 (14 years ago)
Author:
pedroerp
Message:

Ticket #993 - Implementada política de segurança para a classe Settings.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/workflow/branches/993/lib/settings/Settings.php

    r2492 r2518  
    1818 * @author Pedro Eugênio Rocha - pedro.eugenio.rocha@gmail.com 
    1919 */ 
    20 class Settings { 
     20final class Settings { 
    2121 
    2222        /** 
     
    110110 
    111111        /** 
     112         * Implements security policy. Throw an exception if not allowed; 
     113         * do nothing otherwise. Advanced security policies for this class 
     114         * could be implemeted here. 
     115         * 
     116         * @access private 
     117         * @return void 
     118         * @static 
     119         */ 
     120        private static function _isAllowed() { 
     121 
     122                /* if we are an process mode */ 
     123                if (Security::isEnabled()) { 
     124 
     125                        /** 
     126                         * even in process mode, if we are dealing with a module class, not process code, 
     127                         * we should grant access. 
     128                         */ 
     129                        if (!Security::isSafeDir(2)) 
     130                                throw new Exception("You are not allowed to access settings."); 
     131 
     132                } 
     133 
     134        } 
     135 
     136 
     137        /** 
    112138         * Returns settings. If the hole path has not be setted, return the hole 
    113139         * hierarchy under it. 
     
    121147        public static function get() { 
    122148 
     149                /* checking permission to access */ 
     150                self::_isAllowed(); 
     151 
    123152                /* getting the variable number of parameters */ 
    124153                $args = func_get_args(); 
     
    139168 
    140169        public static function set() { 
     170 
     171                /* checking permission to access */ 
     172                self::_isAllowed(); 
    141173 
    142174                /* getting the variable number of parameters */ 
Note: See TracChangeset for help on using the changeset viewer.