/** * Performs an authentication attempt * * @return \Zend\Authentication\Result * @throws \Zend\Authentication\Adapter\Exception\ExceptionInterface If authentication cannot be performed */ public function authenticate() { if (!$this->userId) { throw new EmptyCredentialsException("C'mon! It's a test things, user ID just cannot be null."); } Logger::getLogger(__CLASS__)->alert("Be sure it's only for testing: user #{$this->userId} was authenticated without credentials."); return new Result(Result::SUCCESS, $this->userId); }
function __construct($login = null, $password = null, $options = array()) { $this->login = $login; $this->password = $password; if ($options) { $this->setOptions($options); } static::$logger = Logger::getLogger(__CLASS__); }
/** * @param array $eventMap * @param null|EventManager $manager */ function __construct($eventMap = array(), $manager = null) { $this->eventMap = $eventMap; $this->manager = $manager; if ($this->manager === null) { $this->manager = new EventManager(); } $this->logger = \Logger\Logger::getLogger(__CLASS__); }
/** * Initialize * * @param $instance * @param ServiceLocatorInterface $serviceLocator * @throws \Acl\Exception\AccessDeniedException * @return mixed */ public function initialize($instance, ServiceLocatorInterface $serviceLocator) { if ($instance instanceof SecureControllerInterface) { /** @var Acl $acl */ $acl = $serviceLocator->get('dao-acl.service.default_factory'); /** @var AuthenticationServiceInterface $auth */ $auth = $serviceLocator->get('dao-auth.service.default_factory'); if ($auth->hasIdentity()) { $acl->setUserId($auth->getIdentity()); } if (!$acl->isAllowed($instance->getPrivileges())) { Logger::getLogger(__CLASS__)->notice("ACL Exception: access denied!"); throw new AccessDeniedException("Access denied!"); } } }
/** * @param null|AdapterOptions $adapterName * @param array $options * @throws Exception\RuntimeException * @return Acl */ public static function getInstance($adapterName = null, $options = array()) { if (static::$instance === null) { static::$logger = Logger::getLogger(__CLASS__); if ($adapterName instanceof AdapterInterface) { $adapter = $adapterName; } else { $adapter = static::getAdapterManager()->get($adapterName); } if ($options) { $adapter->setOptions($options); } static::$instance = new self($adapter); } elseif ($adapterName !== null && static::$instance->getOptions()->getThrowRuntimeExceptions()) { static::$logger->error("Acl cannot be initialized twice."); throw new RuntimeException("Acl cannot be initialized twice."); } return static::$instance; }
public function __construct($options = array()) { static::$logger = Logger::getLogger(get_class($this)); $this->setOptions($options); }