/** * Walidacja poprawności parametrów * @param array $data */ public function isValid($data) { $isValid = parent::isValid($data); switch ($data['operator_id']) { case Logic_Sms::LWS_Plus: foreach (array('crt', 'pem') as $type) { $this->getElement($type)->addFilter(new Zend_Filter_File_Rename(array('target' => $data['service_login'] . ".{$type}"))); $certFileName[$type] = $this->_receiveFiles($type); } if (!$this->_edit && !empty($certFileName)) { if (null === $certFileName['crt'] || null === $certFileName['pem']) { try { Logic_Sms_Operator_Plus::checkValidCertificates($data['service_login']); } catch (Exception $exc) { $this->getElement('pem')->setRequired(true); $this->getElement('crt')->setRequired(true)->addError($exc->getMessage()); $isValid = false; } } else { try { Logic_Ws_Cert::isCertificateValid($certFileName['crt']); } catch (Exception $exc) { $this->getElement('crt')->addError($exc->getMessage()); $isValid = false; } } } } return $isValid; }
/** * Walidacja poprawności parametrów * @param array $data */ public function isValid($data) { $isValid = parent::isValid($data); $wsServiceSmsModel = new WsServiceSms(); $wsServiceSmsRow = $wsServiceSmsModel->findOne($data['service_id']); foreach (array('crt', 'pem') as $type) { $this->getElement($type)->addFilter(new Zend_Filter_File_Rename(array('target' => $wsServiceSmsRow->service_login . ".{$type}"))); $certFileName[$type] = $this->_receiveFiles($type); } try { Logic_Ws_Cert::isCertificateValid($certFileName['crt']); } catch (Exception $exc) { $this->getElement('crt')->addError($exc->getMessage()); $isValid = false; } return $isValid; }
/** * Metoda sprawdza, czy istnieją aktualne pliki certyfikatów. * @param string $login Login usługi Multiinfo */ public static function checkValidCertificates($login) { $config = Zend_Registry::get('config'); if (false === is_file($config['services']['Plus']['pathToPem'] . $login . '.pem')) { throw new Logic_Sms_Operator_Exception("Selected PEM certificate file does not exitst or is not accessible!"); } //check dates of certificate Logic_Ws_Cert::isCertificateValid($config['services']['Plus']['pathToCrt'] . $login . '.crt'); }