⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cas.php

📁 很棒的在线教学系统
💻 PHP
📖 第 1 页 / 共 3 页
字号:
  function checkAuthentication()    {      global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;      phpCAS::traceBegin();      if ( !is_object($PHPCAS_CLIENT) ) {        phpCAS::error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()');      }      $auth = $PHPCAS_CLIENT->checkAuthentication();      // store where the authentication has been checked and the result      $dbg = phpCAS::backtrace();      $PHPCAS_AUTH_CHECK_CALL = array('done' => TRUE,				      'file' => $dbg[0]['file'],				      'line' => $dbg[0]['line'],				      'method' => __CLASS__.'::'.__FUNCTION__,				      'result' => $auth );      phpCAS::traceEnd($auth);      return $auth;     }    /**   * This method is called to force authentication if the user was not already    * authenticated. If the user is not authenticated, halt by redirecting to    * the CAS server.   */  function forceAuthentication()    {      global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;      phpCAS::traceBegin();      if ( !is_object($PHPCAS_CLIENT) ) {        phpCAS::error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()');      }            $auth = $PHPCAS_CLIENT->forceAuthentication();      // store where the authentication has been checked and the result      $dbg = phpCAS::backtrace();      $PHPCAS_AUTH_CHECK_CALL = array('done' => TRUE,				      'file' => $dbg[0]['file'],				      'line' => $dbg[0]['line'],				      'method' => __CLASS__.'::'.__FUNCTION__,				      'result' => $auth );      if ( !$auth ) {        phpCAS::trace('user is not authenticated, redirecting to the CAS server');        $PHPCAS_CLIENT->forceAuthentication();      } else {        phpCAS::trace('no need to authenticate (user `'.phpCAS::getUser().'\' is already authenticated)');      }      phpCAS::traceEnd();      return $auth;     }    /**   * This method has been left from version 0.4.1 for compatibility reasons.   */  function authenticate()    {      phpCAS::error('this method is deprecated. You should use '.__CLASS__.'::forceAuthentication() instead');    }    /**   * This method is called to check if the user is authenticated (previously or by   * tickets given in the URL).   *   * @return TRUE when the user is authenticated.   */  function isAuthenticated()    {      global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;      phpCAS::traceBegin();      if ( !is_object($PHPCAS_CLIENT) ) {        phpCAS::error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()');      }      // call the isAuthenticated method of the global $PHPCAS_CLIENT object      $auth = $PHPCAS_CLIENT->isAuthenticated();      // store where the authentication has been checked and the result      $dbg = phpCAS::backtrace();      $PHPCAS_AUTH_CHECK_CALL = array('done' => TRUE,                                     'file' => $dbg[0]['file'],                                     'line' => $dbg[0]['line'],                                     'method' => __CLASS__.'::'.__FUNCTION__,                                     'result' => $auth );      phpCAS::traceEnd($auth);      return $auth;    }    /**   * Checks whether authenticated based on $_SESSION. Useful to avoid   * server calls.   * @return true if authenticated, false otherwise.   * @since 0.4.22 by Brendan Arnold   */  function isSessionAuthenticated ()	{      global $PHPCAS_CLIENT;      if ( !is_object($PHPCAS_CLIENT) ) {        phpCAS::error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()');      }      return($PHPCAS_CLIENT->isSessionAuthenticated());    }  /**   * This method returns the CAS user's login name.   * @warning should not be called only after phpCAS::forceAuthentication()   * or phpCAS::checkAuthentication().   *   * @return the login name of the authenticated user   */  function getUser()    {      global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;      if ( !is_object($PHPCAS_CLIENT) ) {	phpCAS::error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()');      }      if ( !$PHPCAS_AUTH_CHECK_CALL['done'] ) {	phpCAS::error('this method should only be called after '.__CLASS__.'::forceAuthentication() or '.__CLASS__.'::isAuthenticated()');      }      if ( !$PHPCAS_AUTH_CHECK_CALL['result'] ) {	phpCAS::error('authentication was checked (by '.$PHPCAS_AUTH_CHECK_CALL['method'].'() at '.$PHPCAS_AUTH_CHECK_CALL['file'].':'.$PHPCAS_AUTH_CHECK_CALL['line'].') but the method returned FALSE');      }      return $PHPCAS_CLIENT->getUser();    }  /**   * This method returns the URL to be used to login.   * or phpCAS::isAuthenticated().   *   * @return the login name of the authenticated user   */  function getServerLoginURL()    {      global $PHPCAS_CLIENT;      if ( !is_object($PHPCAS_CLIENT) ) {	phpCAS::error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()');      }      return $PHPCAS_CLIENT->getServerLoginURL();    }  /**   * Set the login URL of the CAS server.   * @param $url the login URL   * @since 0.4.21 by Wyman Chan   */  function setServerLoginURL($url='')   {     global $PHPCAS_CLIENT;     phpCAS::traceBegin();     if ( !is_object($PHPCAS_CLIENT) ) {        phpCAS::error('this method should only be called after'.__CLASS__.'::client()');     }     if ( gettype($url) != 'string' ) {        phpCAS::error('type mismatched for parameter $url (should be`string\')');     }     $PHPCAS_CLIENT->setServerLoginURL($url);     phpCAS::traceEnd();   }  /**   * This method returns the URL to be used to login.   * or phpCAS::isAuthenticated().   *   * @return the login name of the authenticated user   */  function getServerLogoutURL()    {      global $PHPCAS_CLIENT;      if ( !is_object($PHPCAS_CLIENT) ) {	phpCAS::error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()');      }      return $PHPCAS_CLIENT->getServerLogoutURL();    }  /**   * Set the logout URL of the CAS server.   * @param $url the logout URL   * @since 0.4.21 by Wyman Chan   */  function setServerLogoutURL($url='')   {     global $PHPCAS_CLIENT;     phpCAS::traceBegin();     if ( !is_object($PHPCAS_CLIENT) ) {        phpCAS::error('this method should only be called after'.__CLASS__.'::client()');     }     if ( gettype($url) != 'string' ) {        phpCAS::error('type mismatched for parameter $url (should be`string\')');     }     $PHPCAS_CLIENT->setServerLogoutURL($url);     phpCAS::traceEnd();   }  /**   * This method is used to logout from CAS. Halts by redirecting to the CAS server.   * @param $url a URL that will be transmitted to the CAS server (to come back to when logged out)   */  function logout($url = "")    {      global $PHPCAS_CLIENT;      phpCAS::traceBegin();      if ( !is_object($PHPCAS_CLIENT) ) {	phpCAS::error('this method should only be called after '.__CLASS__.'::client() or'.__CLASS__.'::proxy()');      }      $PHPCAS_CLIENT->logout($url);      // never reached      phpCAS::traceEnd();    }  /**   * Set the fixed URL that will be used by the CAS server to transmit the PGT.   * When this method is not called, a phpCAS script uses its own URL for the callback.   *   * @param $url the URL   */  function setFixedCallbackURL($url='')   {     global $PHPCAS_CLIENT;     phpCAS::traceBegin();     if ( !is_object($PHPCAS_CLIENT) ) {        phpCAS::error('this method should only be called after '.__CLASS__.'::proxy()');     }     if ( !$PHPCAS_CLIENT->isProxy() ) {        phpCAS::error('this method should only be called after '.__CLASS__.'::proxy()');     }     if ( gettype($url) != 'string' ) {        phpCAS::error('type mismatched for parameter $url (should be `string\')');     }     $PHPCAS_CLIENT->setCallbackURL($url);     phpCAS::traceEnd();   }     /**   * Set the fixed URL that will be set as the CAS service parameter. When this   * method is not called, a phpCAS script uses its own URL.   *   * @param $url the URL   */   function setFixedServiceURL($url)   {     global $PHPCAS_CLIENT;     phpCAS::traceBegin();     if ( !is_object($PHPCAS_CLIENT) ) {         phpCAS::error('this method should only be called after '.__CLASS__.'::proxy()');     }       if ( gettype($url) != 'string' ) {        phpCAS::error('type mismatched for parameter $url (should be `string\')');     }     $PHPCAS_CLIENT->setURL($url);     phpCAS::traceEnd();   }  /**   * Get the URL that is set as the CAS service parameter.   */   function getServiceURL()   {     global $PHPCAS_CLIENT;     if ( !is_object($PHPCAS_CLIENT) ) {        phpCAS::error('this method should only be called after '.__CLASS__.'::proxy()');     }       return($PHPCAS_CLIENT->getURL());   }  /**   * Retrieve a Proxy Ticket from the CAS server.   */   function retrievePT($target_service,&$err_code,&$err_msg)   {     global $PHPCAS_CLIENT;     if ( !is_object($PHPCAS_CLIENT) ) {        phpCAS::error('this method should only be called after '.__CLASS__.'::proxy()');     }       if ( gettype($target_service) != 'string' ) {        phpCAS::error('type mismatched for parameter $target_service(should be `string\')');     }     return($PHPCAS_CLIENT->retrievePT($target_service,$err_code,$err_msg));   }  /** @} */}// ########################################################################// DOCUMENTATION// ########################################################################// ########################################################################//  MAIN PAGE/** * @mainpage * * The following pages only show the source documentation. * * For more information on phpCAS, please refer to http://esup-phpcas.sourceforge.net * */// ########################################################################//  MODULES DEFINITION/** @defgroup public User interface *//** @defgroup publicInit Initialization *  @ingroup public *//** @defgroup publicAuth Authentication *  @ingroup public *//** @defgroup publicServices Access to external services *  @ingroup public *//** @defgroup publicConfig Configuration *  @ingroup public *//** @defgroup publicLang Internationalization *  @ingroup publicConfig *//** @defgroup publicOutput HTML output *  @ingroup publicConfig *//** @defgroup publicPGTStorage PGT storage *  @ingroup publicConfig *//** @defgroup publicDebug Debugging *  @ingroup public *//** @defgroup internal Implementation *//** @defgroup internalAuthentication Authentication *  @ingroup internal *//** @defgroup internalBasic CAS Basic client features (CAS 1.0, Service Tickets) *  @ingroup internal *//** @defgroup internalProxy CAS Proxy features (CAS 2.0, Proxy Granting Tickets) *  @ingroup internal *//** @defgroup internalPGTStorage PGT storage *  @ingroup internalProxy *//** @defgroup internalPGTStorageDB PGT storage in a database *  @ingroup internalPGTStorage *//** @defgroup internalPGTStorageFile PGT storage on the filesystem *  @ingroup internalPGTStorage *//** @defgroup internalCallback Callback from the CAS server *  @ingroup internalProxy *//** @defgroup internalProxied CAS proxied client features (CAS 2.0, Proxy Tickets) *  @ingroup internal *//** @defgroup internalConfig Configuration *  @ingroup internal *//** @defgroup internalOutput HTML output *  @ingroup internalConfig *//** @defgroup internalLang Internationalization *  @ingroup internalConfig * * To add a new language: * - 1. define a new constant PHPCAS_LANG_XXXXXX in CAS/CAS.php * - 2. copy any file from CAS/languages to CAS/languages/XXXXXX.php * - 3. Make the translations *//** @defgroup internalDebug Debugging *  @ingroup internal *//** @defgroup internalMisc Miscellaneous *  @ingroup internal */// ########################################################################//  EXAMPLES/** * @example example_simple.php *//** * @example example_proxy.php *//** * @example example_proxy2.php *//** * @example example_lang.php *//** * @example example_html.php *//** * @example example_file.php *//** * @example example_db.php *//** * @example example_service.php *//** * @example example_session_proxy.php *//** * @example example_session_service.php *//** * @example example_gateway.php */?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -