/**
  * Returns true if and only if the assertion conditions are met
  *
  * This method is passed the ACL, Role, Resource, and privilege to which
  * the authorization query applies. If the $role, $resource, or $privilege
  * parameters are null, it means that the query applies to all Roles,
  * Resources, or privileges, respectively.
  *
  * @param  Zend_Acl                    $acl
  * @param  Zend_Acl_Role_Interface     $role
  * @param  Zend_Acl_Resource_Interface $resource
  * @param  string                      $privilege
  * @return boolean
  */
 public function assert(Zend_Acl $acl, Zend_Acl_Role_Interface $role = null, Zend_Acl_Resource_Interface $resource = null, $privilege = null)
 {
     // We need specific objects to check against each other
     if (NULL === $role) {
         return false;
     }
     // Ensure we're handled User models
     if (!$role instanceof UserModel) {
         throw new Exception('Role must be an instance of UserModel');
     }
     // Get the organization
     $orgService = \Application\Service\OrgService::getInstance();
     $org = $orgService->load($role->getOrganizationId());
     if ($org->getType() != OrgCustomerModel::ORG_TYPE) {
         $org = $orgService->getParentByType($org, OrgCustomerModel::ORG_TYPE);
     }
     if ($org && !is_null($org->getSupplementaryServicesId())) {
         // Check if the customer has supplementary services configured
         // with application originated SMS option activated
         $supplSrv = \Application\Service\SupplServicesService::getInstance();
         $services = $supplSrv->load($org->getSupplementaryServicesId());
         if ($services && $services->getApplicationOriginatedSms() == SupplServicesModel::ST_ACTIVATED) {
             return true;
         }
     }
     throw new Exception('Role must have applicationOriginatedSms activated');
 }
 public function getSupplementaryService($context)
 {
     $service = SupplServicesService::getInstance();
     if (isset($context[$this->_supplServiceIdVarInContext])) {
         $item = $service->load($context[$this->_supplServiceIdVarInContext]);
         return $item;
     }
 }
Ejemplo n.º 3
0
 public function getSupplementaryService($context)
 {
     $user = \App::getUserLogged();
     $org = $user->getOrganization();
     if (!$org->supplementaryServicesId) {
         $orgService = OrgService::getInstance();
         $org = $orgService->getParentByType($org, OrgCustomerModel::ORG_TYPE);
     }
     if ($org) {
         $item = SupplServicesService::getInstance()->load($org->supplementaryServicesId);
         return $item;
     }
 }
 public function __construct($options = null)
 {
     $this->_spec = array('validators' => array('sms' => array('NotEmpty' => array('breakChainOnFailure' => true, 'type' => \Zend_Validate_NotEmpty::NULL), 'isBoolean' => array('breakChainOnFailure' => true)), 'msisdnList' => array('NotEmptyIfField' => array('breakChainOnFailure' => true, 'field' => 'sms', 'value' => true), 'Array' => array('breakChainOnFailure' => true, 'distinct' => true, 'validators' => array('NotEmpty' => array('breakChainOnFailure' => true), 'StringLength' => array('max' => 15, 'encoding' => "UTF-8", 'breakChainOnFailure' => true)))), 'email' => array('NotEmpty' => array('breakChainOnFailure' => true, 'type' => \Zend_Validate_NotEmpty::NULL), 'isBoolean' => array('breakChainOnFailure' => true)), 'emailList' => array('NotEmptyIfField' => array('breakChainOnFailure' => true, 'field' => 'email', 'value' => true, 'type' => \Zend_Validate_NotEmpty::EMPTY_ARRAY), 'Array' => array('breakChainOnFailure' => true, 'distinct' => true, 'validators' => array('EmailAddress' => array('mx' => false, 'breakChainOnFailure' => true)))), 'snmp' => array('NotEmpty' => array('breakChainOnFailure' => true, 'type' => \Zend_Validate_NotEmpty::NULL), 'isBoolean' => array('breakChainOnFailure' => true))));
     $org = \App::getOrgUserLogged();
     if ($org->getType() != OrgCustomerModel::ORG_TYPE) {
         $org = OrgService::getInstance()->getParentByType($org, OrgCustomerModel::ORG_TYPE);
     }
     if ($org && !is_null($org->getSupplementaryServicesId())) {
         $services = SupplServicesService::getInstance()->load($org->getSupplementaryServicesId());
         if (!$services || $services->getApplicationOriginatedSms() != SupplServicesModel::ST_ACTIVATED) {
             $this->_spec['validators']['sms']['Identical'] = array('token' => false, 'messageTemplates' => array(\Zend_Validate_Identical::NOT_SAME => "Application originated sms service not activated"));
         }
     }
     parent::__construct($options);
 }
 /**
  * Returns true if and only if the assertion conditions are met
  *
  * This method is passed the ACL, Role, Resource, and privilege to which
  * the authorization query applies. If the $role, $resource, or $privilege
  * parameters are null, it means that the query applies to all Roles,
  * Resources, or privileges, respectively.
  *
  * @param  Zend_Acl                    $acl
  * @param  Zend_Acl_Role_Interface     $role
  * @param  Zend_Acl_Resource_Interface $resource
  * @param  string                      $privilege
  * @return boolean
  */
 public function assert(Zend_Acl $acl, Zend_Acl_Role_Interface $role = null, Zend_Acl_Resource_Interface $resource = null, $privilege = null)
 {
     // We need specific objects to check against each other
     if (NULL === $role) {
         return false;
     }
     // Ensure we're handled User models
     if (!$role instanceof UserModel) {
         throw new Exception('Role must be an instance of UserModel');
     }
     if (!$resource instanceof SimModel) {
         throw new Exception('Resource must be an instance of SimModel');
     }
     // Get the organization
     $orgService = \Application\Service\OrgService::getInstance();
     if ($orgService->getTypeById($role->getOrganizationId()) == OrgServiceProviderModel::ORG_TYPE) {
         $org = $orgService->load($resource->customerId);
     } else {
         $org = $orgService->load($role->getOrganizationId());
     }
     if ($org->getType() != OrgCustomerModel::ORG_TYPE) {
         $org = $orgService->getParentByType($org, OrgCustomerModel::ORG_TYPE);
     }
     if ($org && !is_null($org->getSupplementaryServicesId())) {
         // Check if the customer has supplementary services configured
         // with application originated SMS option activated
         $supplSrv = \Application\Service\SupplServicesService::getInstance();
         try {
             if ($orgService->getTypeById($role->getOrganizationId()) == OrgAggregatorModel::ORG_TYPE) {
                 $services = $supplSrv->load($org->getSupplementaryServicesId(), $org);
             } else {
                 $services = $supplSrv->load($org->getSupplementaryServicesId());
             }
         } catch (\Exception $e) {
             \App::log()->warn($e);
             return False;
         }
         if ($services && $services->advancedSupervision == SupplServicesModel::ST_ACTIVATED) {
             return true;
         }
     }
     return false;
 }
 public function isValid($value, $content = null)
 {
     $this->_messages = array();
     $service = SupplServicesService::getInstance();
     try {
         $item = $service->load($value);
     } catch (\Application\Exceptions\NotFoundException $e) {
         $item = null;
     } catch (\Application\Exceptions\GlobalServiceException $e) {
         $message = $this->_createMessage(self::ERROR_ON_CONNECTION, $value);
         $this->_messages[self::ERROR_ON_CONNECTION] = $message;
         return false;
     }
     if (!isset($item)) {
         $message = $this->_createMessage(self::NO_SUPPL_SERVICE, $value);
         $this->_messages[self::NO_SUPPL_SERVICE] = $message;
         return false;
     }
     return true;
 }
 public function isValid($value, $context = null)
 {
     $this->_messages = array();
     $service = SupplServicesService::getInstance();
     $item = $service->load($value);
     if ($item->applicationOriginatedSms != SupplServicesModel::ST_ACTIVATED) {
         $message = $this->_createMessage(self::NO_ACTIVATED_SUPPL_SERVICE, $value);
         $this->_messages[self::NO_ACTIVATED_SUPPL_SERVICE] = $message;
         return false;
     }
     if ($item->readyForMultipleSmsOa === false) {
         $message = $this->_createMessage(self::INACTIVE_OCS, $context['msisdn']);
         $this->_messages[self::INACTIVE_OCS] = $message;
         return false;
     }
     if (!$item->customerId) {
         $message = $this->_createMessage(self::NO_CUSTOMER_SUPPL_SERVICE, $context['msisdn']);
         $this->_messages[self::NO_CUSTOMER_SUPPL_SERVICE] = $message;
         return false;
     }
     if (!$item->applicationOriginatedSmsMsisdn) {
         $message = $this->_createMessage(self::NOT_DEFAULT_CONFIGURED);
         $this->_messages[self::NOT_DEFAULT_CONFIGURED] = $message;
         return false;
     }
     if ($item->published != SupplServicesModel::STATUS_PUBLISHED) {
         $message = $this->_createMessage(self::NOT_PUBLISHED, $value);
         $this->_messages[self::NOT_PUBLISHED] = $message;
         return false;
     }
     if ($item->additionalMsisdn && count($item->additionalMsisdn) >= $this->_maxMsisdns - 1) {
         $message = $this->_createMessage(self::MAX_ADDITIONAL_MSISDNS);
         $this->_messages[self::MAX_ADDITIONAL_MSISDNS] = $message;
         return false;
     }
     return true;
 }
Ejemplo n.º 8
0
 public function meAction()
 {
     $this->view->user = \App::getUserLogged();
     $this->_helper->filterNotAllowedFields('read_field', $this->view->user);
     if ($this->getRequest()->getParam('organization', false)) {
         $this->view->organization = $this->view->user->getOrganization();
         $this->_helper->filterNotAllowedFields('read_field', $this->view->organization);
         $orgService = OrgService::getInstance();
         $orgService->getOrgConfig($this->view->organization);
         $sp = $orgService->getParentByType($this->view->organization, OrgServiceProviderModel::ORG_TYPE);
         if ($sp && isset($sp->isEnabler)) {
             $this->view->organization->alwaysOnRoaming = !$sp->isEnabler;
         }
         if ($this->view->organization instanceof OrgCustomerModel && isset($this->view->organization->supplementaryServicesId)) {
             try {
                 $supplService = SupplServicesService::getInstance()->load($this->view->organization->supplementaryServicesId);
                 if ($supplService) {
                     try {
                         $this->_helper->allowed('read', $supplService);
                         $this->_helper->filterNotAllowedFields('read_field', $supplService);
                         $this->view->supplService = $supplService;
                     } catch (PermissionException $e) {
                     }
                 }
             } catch (\Exception $e) {
                 \App::log()->warn($e);
             }
         }
     }
     if (($namespace = $this->_getParam('permissions')) || ($namespace = $this->getRequest()->getHeader('Realm'))) {
         if ($namespace == 1) {
             $namespace = null;
         }
         $this->view->permissions = \Core\Service\PermissionService::getInstance()->load(\App::getUserLogged()->getRoleId(), $namespace);
     }
 }
Ejemplo n.º 9
0
 public function testRepeatedNumberExtra()
 {
     $old_srv = \Application\Service\SupplServicesService::getInstance();
     $data = array('applicationOriginatedSms' => SupplServicesModel::ST_ACTIVATED, 'published' => SupplServicesModel::STATUS_PUBLISHED, 'customerId' => 1, 'applicationOriginatedSmsMsisdn' => '346777888212', 'additionalMsisdn' => array(array('msisdn' => '346777888012', 'description' => 'Previous', 'supplServicesId' => '1')));
     \Application\Service\SupplServicesService::setInstance(new FakeService($data));
     $msisdnData = array("supplServicesId" => "1", "msisdn" => "346777888012", "description" => "Test descrip");
     $smsMsisdn = new SmsMsisdnModel($msisdnData);
     $this->assertFalse($this->_validator->isValid($smsMsisdn));
     $this->assertEquals(array('msisdn' => array('numberRepeated' => "346777888012 number is repeated")), $this->_validator->getMessages());
     \Application\Service\SupplServicesService::setInstance($old_srv);
 }
Ejemplo n.º 10
0
 protected function _checkCustomerOrg($org)
 {
     if ($org->getType() == OrgCustomerModel::ORG_TYPE) {
         if (is_null($org->getSupplementaryServicesId())) {
             throw new \Application\Exceptions\ForbiddenException('Organization ' . $org->getId() . ' does not have supplementary services assigned. User cannot login.', PermissionCodes::AUTH_ORG_NO_SUPPL_SERVICE);
         }
         // Check if the customer has supplementary services configured
         // with self-management option activated
         $services = SupplServicesService::getInstance()->load($org->getSupplementaryServicesId());
         if (!$services || $services->getSelfManagement() != SupplServicesModel::ST_ACTIVATED) {
             throw new \Application\Exceptions\ForbiddenException('Self-management service unavailable for your organization (' . $org->getId() . '); please contact your Service Provider.', PermissionCodes::AUTH_NO_SELF_MANAGEMENT);
         }
     }
 }
 public function init()
 {
     $this->_ssSrv = \Application\Service\SupplServicesService::getInstance();
     $this->_orgSrv = \Application\Service\OrgService::getInstance();
 }
 public function init()
 {
     $this->srv = SupplServicesService::getInstance();
     $this->enumSrv = Application\Service\EnumeratedService::getInstance();
 }