Esempio n. 1
0
 /**
  * Process posts
  */
 public function post_check(array $args)
 {
     $auth = null;
     $ocs = new com_meego_ocs_OCSWriter();
     if (!isset($_POST['login'])) {
         $ocs->writeError('The login argument is mandatory', 101);
         $ocs->endDocument();
         self::output_xml($ocs);
         return;
     }
     $tokens = com_meego_ocs_utils::prepare_tokens();
     switch (midgardmvc_core::get_instance()->configuration->ocs_authentication) {
         case 'LDAP':
             $info = com_meego_ocs_utils::ldap_check($tokens);
             $auth = com_meego_ocs_utils::authenticate();
             break;
         case 'basic':
         default:
             $info = new midgardmvc_core_services_authentication_basic();
             $e = new Exception("Requires HTTP Basic authentication");
             $info->handle_exception($e);
     }
     if (!$info || !$auth) {
         $ocs->writeError('Invalid account', 102);
         $ocs->endDocument();
         self::output_xml($ocs);
         return;
     }
     $ocs->writeMeta(null, null, 'Valid account', 'ok', 100);
     $ocs->writePersonCheck($info['username'], $info['email']);
     $ocs->endDocument();
     self::output_xml($ocs);
 }
Esempio n. 2
0
 /**
  * Performs authentication
  *
  * Limitation: only LDAP auth is supported properly at the moment
  *
  * @return boolean
  */
 public function authenticate()
 {
     $auth = null;
     switch (midgardmvc_core::get_instance()->configuration->ocs_authentication) {
         case 'LDAP':
             $tokens = self::prepare_tokens();
             $auth = self::ldap_auth($tokens);
             break;
         case 'basic':
         default:
             $auth = new midgardmvc_core_services_authentication_basic();
             $e = new Exception("Vote posting requires Basic authentication");
             $auth->handle_exception($e);
     }
     return $auth;
 }