/**
  * Get singleton instance
  * @return object ilOpenIdProviders 
  */
 public static function getInstance()
 {
     if (self::$instance) {
         return self::$instance;
     }
     return self::$instance = new ilOpenIdProviders();
 }
 /**
  * Parse provider
  * @return 
  */
 public function parse()
 {
     $providers = ilOpenIdProviders::getInstance()->getProvider();
     $data = array();
     for ($i = 0; $i < count($providers); $i++) {
         $data[$i]['provider_id'] = $providers[$i]->getId();
         $data[$i]['title'] = $providers[$i]->getName();
         $data[$i]['url'] = $providers[$i]->getURL();
     }
     $this->setData($data);
 }
Esempio n. 3
0
 /**
  * Show openid login if enabled
  * @return 
  */
 protected function showOpenIdLoginForm($page_editor_html)
 {
     global $lng, $tpl;
     include_once './Services/OpenId/classes/class.ilOpenIdSettings.php';
     if (!ilOpenIdSettings::getInstance()->isActive()) {
         return $page_editor_html;
     }
     $lng->loadLanguageModule('auth');
     include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
     $form = new ilPropertyFormGUI();
     //$form->setTableWidth('500');
     $form->setShowTopButtons(false);
     $form->setFormAction($this->ctrl->getFormAction($this));
     $form->setTitle($lng->txt('login_to_ilias_via_openid'));
     $openid = new ilTextInputGUI($lng->txt('auth_openid_login'), 'oid_username');
     $openid->setSize(18);
     $openid->setMaxLength(255);
     $openid->setRequired(true);
     $openid->setCssClass('ilOpenIDBox');
     $openid->setInfo($lng->txt('auth_openid_login_info_a'));
     $form->addItem($openid);
     include_once './Services/OpenId/classes/class.ilOpenIdProviders.php';
     $pro = new ilSelectInputGUI($lng->txt('auth_openid_provider'), 'oid_provider');
     $pro->setOptions(ilOpenIdProviders::getInstance()->getProviderSelection());
     $pro->setValue(ilOpenIdProviders::getInstance()->getSelectedProvider());
     $form->addItem($pro);
     $form->addCommandButton("showLogin", $lng->txt("log_in"));
     return $this->substituteLoginPageElements($tpl, $page_editor_html, $form->getHTML(), '[list-openid-login-form]', 'OID_LOGIN_FORM');
 }
Esempio n. 4
0
 /**
  * Parse username
  * @return 
  */
 protected function parseUsername(&$username, $auth)
 {
     if ($_POST['oid_provider']) {
         include_once './Services/OpenId/classes/class.ilOpenIdProviders.php';
         try {
             $url = ilOpenIdProviders::getInstance()->getProviderById($_POST['oid_provider'])->getURL();
             $username = sprintf($url, (string) $username);
             $GLOBALS['ilLog']->write(__METHOD__ . ': Using ' . $username . ' for authentication');
             return true;
         } catch (UnexpectedValueException $e) {
             $GLOBALS['ilLog']->write(__METHOD__ . ': Unknown provider id given: ' . $username);
             $auth->status = AUTH_WRONG_LOGIN;
             return false;
         }
     }
     if ($this->settings->forcedProviderSelection()) {
         $auth->status = AUTH_WRONG_LOGIN;
         return false;
     }
     $GLOBALS['ilLog']->write(__METHOD__ . ': Trying openid url: ' . $username);
     return true;
 }