CAS.php 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073
  1. <?php
  2. /**
  3. * Licensed to Jasig under one or more contributor license
  4. * agreements. See the NOTICE file distributed with this work for
  5. * additional information regarding copyright ownership.
  6. *
  7. * Jasig licenses this file to you under the Apache License,
  8. * Version 2.0 (the "License"); you may not use this file except in
  9. * compliance with the License. You may obtain a copy of the License at:
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. *
  20. *
  21. * Interface class of the phpCAS library
  22. * PHP Version 5
  23. *
  24. * @file CAS/CAS.php
  25. * @category Authentication
  26. * @package PhpCAS
  27. * @author Pascal Aubry <pascal.aubry@univ-rennes1.fr>
  28. * @author Olivier Berger <olivier.berger@it-sudparis.eu>
  29. * @author Brett Bieber <brett.bieber@gmail.com>
  30. * @author Joachim Fritschi <jfritschi@freenet.de>
  31. * @author Adam Franco <afranco@middlebury.edu>
  32. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
  33. * @link https://wiki.jasig.org/display/CASC/phpCAS
  34. * @ingroup public
  35. */
  36. use Psr\Log\LoggerInterface;
  37. //
  38. // hack by Vangelis Haniotakis to handle the absence of $_SERVER['REQUEST_URI']
  39. // in IIS
  40. //
  41. if (!isset($_SERVER['REQUEST_URI']) && isset($_SERVER['SCRIPT_NAME']) && isset($_SERVER['QUERY_STRING'])) {
  42. $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['QUERY_STRING'];
  43. }
  44. // ########################################################################
  45. // CONSTANTS
  46. // ########################################################################
  47. // ------------------------------------------------------------------------
  48. // CAS VERSIONS
  49. // ------------------------------------------------------------------------
  50. /**
  51. * phpCAS version. accessible for the user by phpCAS::getVersion().
  52. */
  53. define('PHPCAS_VERSION', '1.4.0');
  54. /**
  55. * @addtogroup public
  56. * @{
  57. */
  58. /**
  59. * phpCAS supported protocols. accessible for the user by phpCAS::getSupportedProtocols().
  60. */
  61. /**
  62. * CAS version 1.0
  63. */
  64. define("CAS_VERSION_1_0", '1.0');
  65. /*!
  66. * CAS version 2.0
  67. */
  68. define("CAS_VERSION_2_0", '2.0');
  69. /**
  70. * CAS version 3.0
  71. */
  72. define("CAS_VERSION_3_0", '3.0');
  73. // ------------------------------------------------------------------------
  74. // SAML defines
  75. // ------------------------------------------------------------------------
  76. /**
  77. * SAML protocol
  78. */
  79. define("SAML_VERSION_1_1", 'S1');
  80. /**
  81. * XML header for SAML POST
  82. */
  83. define("SAML_XML_HEADER", '<?xml version="1.0" encoding="UTF-8"?>');
  84. /**
  85. * SOAP envelope for SAML POST
  86. */
  87. define("SAML_SOAP_ENV", '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/>');
  88. /**
  89. * SOAP body for SAML POST
  90. */
  91. define("SAML_SOAP_BODY", '<SOAP-ENV:Body>');
  92. /**
  93. * SAMLP request
  94. */
  95. define("SAMLP_REQUEST", '<samlp:Request xmlns:samlp="urn:oasis:names:tc:SAML:1.0:protocol" MajorVersion="1" MinorVersion="1" RequestID="_192.168.16.51.1024506224022" IssueInstant="2002-06-19T17:03:44.022Z">');
  96. define("SAMLP_REQUEST_CLOSE", '</samlp:Request>');
  97. /**
  98. * SAMLP artifact tag (for the ticket)
  99. */
  100. define("SAML_ASSERTION_ARTIFACT", '<samlp:AssertionArtifact>');
  101. /**
  102. * SAMLP close
  103. */
  104. define("SAML_ASSERTION_ARTIFACT_CLOSE", '</samlp:AssertionArtifact>');
  105. /**
  106. * SOAP body close
  107. */
  108. define("SAML_SOAP_BODY_CLOSE", '</SOAP-ENV:Body>');
  109. /**
  110. * SOAP envelope close
  111. */
  112. define("SAML_SOAP_ENV_CLOSE", '</SOAP-ENV:Envelope>');
  113. /**
  114. * SAML Attributes
  115. */
  116. define("SAML_ATTRIBUTES", 'SAMLATTRIBS');
  117. /**
  118. * SAML Attributes
  119. */
  120. define("DEFAULT_ERROR", 'Internal script failure');
  121. /** @} */
  122. /**
  123. * @addtogroup publicPGTStorage
  124. * @{
  125. */
  126. // ------------------------------------------------------------------------
  127. // FILE PGT STORAGE
  128. // ------------------------------------------------------------------------
  129. /**
  130. * Default path used when storing PGT's to file
  131. */
  132. define("CAS_PGT_STORAGE_FILE_DEFAULT_PATH", session_save_path());
  133. /** @} */
  134. // ------------------------------------------------------------------------
  135. // SERVICE ACCESS ERRORS
  136. // ------------------------------------------------------------------------
  137. /**
  138. * @addtogroup publicServices
  139. * @{
  140. */
  141. /**
  142. * phpCAS::service() error code on success
  143. */
  144. define("PHPCAS_SERVICE_OK", 0);
  145. /**
  146. * phpCAS::service() error code when the PT could not retrieve because
  147. * the CAS server did not respond.
  148. */
  149. define("PHPCAS_SERVICE_PT_NO_SERVER_RESPONSE", 1);
  150. /**
  151. * phpCAS::service() error code when the PT could not retrieve because
  152. * the response of the CAS server was ill-formed.
  153. */
  154. define("PHPCAS_SERVICE_PT_BAD_SERVER_RESPONSE", 2);
  155. /**
  156. * phpCAS::service() error code when the PT could not retrieve because
  157. * the CAS server did not want to.
  158. */
  159. define("PHPCAS_SERVICE_PT_FAILURE", 3);
  160. /**
  161. * phpCAS::service() error code when the service was not available.
  162. */
  163. define("PHPCAS_SERVICE_NOT_AVAILABLE", 4);
  164. // ------------------------------------------------------------------------
  165. // SERVICE TYPES
  166. // ------------------------------------------------------------------------
  167. /**
  168. * phpCAS::getProxiedService() type for HTTP GET
  169. */
  170. define("PHPCAS_PROXIED_SERVICE_HTTP_GET", 'CAS_ProxiedService_Http_Get');
  171. /**
  172. * phpCAS::getProxiedService() type for HTTP POST
  173. */
  174. define("PHPCAS_PROXIED_SERVICE_HTTP_POST", 'CAS_ProxiedService_Http_Post');
  175. /**
  176. * phpCAS::getProxiedService() type for IMAP
  177. */
  178. define("PHPCAS_PROXIED_SERVICE_IMAP", 'CAS_ProxiedService_Imap');
  179. /** @} */
  180. // ------------------------------------------------------------------------
  181. // LANGUAGES
  182. // ------------------------------------------------------------------------
  183. /**
  184. * @addtogroup publicLang
  185. * @{
  186. */
  187. define("PHPCAS_LANG_ENGLISH", 'CAS_Languages_English');
  188. define("PHPCAS_LANG_FRENCH", 'CAS_Languages_French');
  189. define("PHPCAS_LANG_GREEK", 'CAS_Languages_Greek');
  190. define("PHPCAS_LANG_GERMAN", 'CAS_Languages_German');
  191. define("PHPCAS_LANG_JAPANESE", 'CAS_Languages_Japanese');
  192. define("PHPCAS_LANG_SPANISH", 'CAS_Languages_Spanish');
  193. define("PHPCAS_LANG_CATALAN", 'CAS_Languages_Catalan');
  194. define("PHPCAS_LANG_CHINESE_SIMPLIFIED", 'CAS_Languages_ChineseSimplified');
  195. define("PHPCAS_LANG_GALEGO", 'CAS_Languages_Galego');
  196. define("PHPCAS_LANG_PORTUGUESE", 'CAS_Languages_Portuguese');
  197. /** @} */
  198. /**
  199. * @addtogroup internalLang
  200. * @{
  201. */
  202. /**
  203. * phpCAS default language (when phpCAS::setLang() is not used)
  204. */
  205. define("PHPCAS_LANG_DEFAULT", PHPCAS_LANG_ENGLISH);
  206. /** @} */
  207. // ------------------------------------------------------------------------
  208. // DEBUG
  209. // ------------------------------------------------------------------------
  210. /**
  211. * @addtogroup publicDebug
  212. * @{
  213. */
  214. /**
  215. * The default directory for the debug file under Unix.
  216. * @return string directory for the debug file
  217. */
  218. function gettmpdir() {
  219. if (!empty($_ENV['TMP'])) { return realpath($_ENV['TMP']); }
  220. if (!empty($_ENV['TMPDIR'])) { return realpath( $_ENV['TMPDIR']); }
  221. if (!empty($_ENV['TEMP'])) { return realpath( $_ENV['TEMP']); }
  222. return "/tmp";
  223. }
  224. define('DEFAULT_DEBUG_DIR', gettmpdir()."/");
  225. /** @} */
  226. // include the class autoloader
  227. require_once __DIR__ . '/CAS/Autoload.php';
  228. /**
  229. * The phpCAS class is a simple container for the phpCAS library. It provides CAS
  230. * authentication for web applications written in PHP.
  231. *
  232. * @ingroup public
  233. * @class phpCAS
  234. * @category Authentication
  235. * @package PhpCAS
  236. * @author Pascal Aubry <pascal.aubry@univ-rennes1.fr>
  237. * @author Olivier Berger <olivier.berger@it-sudparis.eu>
  238. * @author Brett Bieber <brett.bieber@gmail.com>
  239. * @author Joachim Fritschi <jfritschi@freenet.de>
  240. * @author Adam Franco <afranco@middlebury.edu>
  241. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
  242. * @link https://wiki.jasig.org/display/CASC/phpCAS
  243. */
  244. class phpCAS
  245. {
  246. /**
  247. * This variable is used by the interface class phpCAS.
  248. *
  249. * @var CAS_Client
  250. * @hideinitializer
  251. */
  252. private static $_PHPCAS_CLIENT;
  253. /**
  254. * @var array
  255. * This variable is used to store where the initializer is called from
  256. * (to print a comprehensive error in case of multiple calls).
  257. *
  258. * @hideinitializer
  259. */
  260. private static $_PHPCAS_INIT_CALL;
  261. /**
  262. * @var array
  263. * This variable is used to store phpCAS debug mode.
  264. *
  265. * @hideinitializer
  266. */
  267. private static $_PHPCAS_DEBUG;
  268. /**
  269. * This variable is used to enable verbose mode
  270. * This pevents debug info to be show to the user. Since it's a security
  271. * feature the default is false
  272. *
  273. * @hideinitializer
  274. */
  275. private static $_PHPCAS_VERBOSE = false;
  276. // ########################################################################
  277. // INITIALIZATION
  278. // ########################################################################
  279. /**
  280. * @addtogroup publicInit
  281. * @{
  282. */
  283. /**
  284. * phpCAS client initializer.
  285. *
  286. * @param string $server_version the version of the CAS server
  287. * @param string $server_hostname the hostname of the CAS server
  288. * @param int $server_port the port the CAS server is running on
  289. * @param string $server_uri the URI the CAS server is responding on
  290. * @param bool $changeSessionID Allow phpCAS to change the session_id
  291. * (Single Sign Out/handleLogoutRequests
  292. * is based on that change)
  293. * @param \SessionHandlerInterface $sessionHandler the session handler
  294. *
  295. * @return void a newly created CAS_Client object
  296. * @note Only one of the phpCAS::client() and phpCAS::proxy functions should be
  297. * called, only once, and before all other methods (except phpCAS::getVersion()
  298. * and phpCAS::setDebug()).
  299. */
  300. public static function client($server_version, $server_hostname,
  301. $server_port, $server_uri, $changeSessionID = true, \SessionHandlerInterface $sessionHandler = null
  302. ) {
  303. phpCAS :: traceBegin();
  304. if (is_object(self::$_PHPCAS_CLIENT)) {
  305. phpCAS :: error(self::$_PHPCAS_INIT_CALL['method'] . '() has already been called (at ' . self::$_PHPCAS_INIT_CALL['file'] . ':' . self::$_PHPCAS_INIT_CALL['line'] . ')');
  306. }
  307. // store where the initializer is called from
  308. $dbg = debug_backtrace();
  309. self::$_PHPCAS_INIT_CALL = array (
  310. 'done' => true,
  311. 'file' => $dbg[0]['file'],
  312. 'line' => $dbg[0]['line'],
  313. 'method' => __CLASS__ . '::' . __FUNCTION__
  314. );
  315. // initialize the object $_PHPCAS_CLIENT
  316. try {
  317. self::$_PHPCAS_CLIENT = new CAS_Client(
  318. $server_version, false, $server_hostname, $server_port, $server_uri,
  319. $changeSessionID, $sessionHandler
  320. );
  321. } catch (Exception $e) {
  322. phpCAS :: error(get_class($e) . ': ' . $e->getMessage());
  323. }
  324. phpCAS :: traceEnd();
  325. }
  326. /**
  327. * phpCAS proxy initializer.
  328. *
  329. * @param string $server_version the version of the CAS server
  330. * @param string $server_hostname the hostname of the CAS server
  331. * @param string $server_port the port the CAS server is running on
  332. * @param string $server_uri the URI the CAS server is responding on
  333. * @param bool $changeSessionID Allow phpCAS to change the session_id
  334. * (Single Sign Out/handleLogoutRequests
  335. * is based on that change)
  336. * @param \SessionHandlerInterface $sessionHandler the session handler
  337. *
  338. * @return void a newly created CAS_Client object
  339. * @note Only one of the phpCAS::client() and phpCAS::proxy functions should be
  340. * called, only once, and before all other methods (except phpCAS::getVersion()
  341. * and phpCAS::setDebug()).
  342. */
  343. public static function proxy($server_version, $server_hostname,
  344. $server_port, $server_uri, $changeSessionID = true, \SessionHandlerInterface $sessionHandler = null
  345. ) {
  346. phpCAS :: traceBegin();
  347. if (is_object(self::$_PHPCAS_CLIENT)) {
  348. phpCAS :: error(self::$_PHPCAS_INIT_CALL['method'] . '() has already been called (at ' . self::$_PHPCAS_INIT_CALL['file'] . ':' . self::$_PHPCAS_INIT_CALL['line'] . ')');
  349. }
  350. // store where the initialzer is called from
  351. $dbg = debug_backtrace();
  352. self::$_PHPCAS_INIT_CALL = array (
  353. 'done' => true,
  354. 'file' => $dbg[0]['file'],
  355. 'line' => $dbg[0]['line'],
  356. 'method' => __CLASS__ . '::' . __FUNCTION__
  357. );
  358. // initialize the object $_PHPCAS_CLIENT
  359. try {
  360. self::$_PHPCAS_CLIENT = new CAS_Client(
  361. $server_version, true, $server_hostname, $server_port, $server_uri,
  362. $changeSessionID, $sessionHandler
  363. );
  364. } catch (Exception $e) {
  365. phpCAS :: error(get_class($e) . ': ' . $e->getMessage());
  366. }
  367. phpCAS :: traceEnd();
  368. }
  369. /**
  370. * Answer whether or not the client or proxy has been initialized
  371. *
  372. * @return bool
  373. */
  374. public static function isInitialized ()
  375. {
  376. return (is_object(self::$_PHPCAS_CLIENT));
  377. }
  378. /** @} */
  379. // ########################################################################
  380. // DEBUGGING
  381. // ########################################################################
  382. /**
  383. * @addtogroup publicDebug
  384. * @{
  385. */
  386. /**
  387. * Set/unset PSR-3 logger
  388. *
  389. * @param LoggerInterface $logger the PSR-3 logger used for logging, or
  390. * null to stop logging.
  391. *
  392. * @return void
  393. */
  394. public static function setLogger($logger = null)
  395. {
  396. if (empty(self::$_PHPCAS_DEBUG['unique_id'])) {
  397. self::$_PHPCAS_DEBUG['unique_id'] = substr(strtoupper(md5(uniqid(''))), 0, 4);
  398. }
  399. self::$_PHPCAS_DEBUG['logger'] = $logger;
  400. self::$_PHPCAS_DEBUG['indent'] = 0;
  401. phpCAS :: trace('START ('.date("Y-m-d H:i:s").') phpCAS-' . PHPCAS_VERSION . ' ******************');
  402. }
  403. /**
  404. * Set/unset debug mode
  405. *
  406. * @param string $filename the name of the file used for logging, or false
  407. * to stop debugging.
  408. *
  409. * @return void
  410. *
  411. * @deprecated
  412. */
  413. public static function setDebug($filename = '')
  414. {
  415. trigger_error('phpCAS::setDebug() is deprecated in favor of phpCAS::setLogger().', E_USER_DEPRECATED);
  416. if ($filename != false && gettype($filename) != 'string') {
  417. phpCAS :: error('type mismatched for parameter $dbg (should be false or the name of the log file)');
  418. }
  419. if ($filename === false) {
  420. self::$_PHPCAS_DEBUG['filename'] = false;
  421. } else {
  422. if (empty ($filename)) {
  423. if (preg_match('/^Win.*/', getenv('OS'))) {
  424. if (isset ($_ENV['TMP'])) {
  425. $debugDir = $_ENV['TMP'] . '/';
  426. } else {
  427. $debugDir = '';
  428. }
  429. } else {
  430. $debugDir = DEFAULT_DEBUG_DIR;
  431. }
  432. $filename = $debugDir . 'phpCAS.log';
  433. }
  434. if (empty (self::$_PHPCAS_DEBUG['unique_id'])) {
  435. self::$_PHPCAS_DEBUG['unique_id'] = substr(strtoupper(md5(uniqid(''))), 0, 4);
  436. }
  437. self::$_PHPCAS_DEBUG['filename'] = $filename;
  438. self::$_PHPCAS_DEBUG['indent'] = 0;
  439. phpCAS :: trace('START ('.date("Y-m-d H:i:s").') phpCAS-' . PHPCAS_VERSION . ' ******************');
  440. }
  441. }
  442. /**
  443. * Enable verbose errors messages in the website output
  444. * This is a security relevant since internal status info may leak an may
  445. * help an attacker. Default is therefore false
  446. *
  447. * @param bool $verbose enable verbose output
  448. *
  449. * @return void
  450. */
  451. public static function setVerbose($verbose)
  452. {
  453. if ($verbose === true) {
  454. self::$_PHPCAS_VERBOSE = true;
  455. } else {
  456. self::$_PHPCAS_VERBOSE = false;
  457. }
  458. }
  459. /**
  460. * Show is verbose mode is on
  461. *
  462. * @return bool verbose
  463. */
  464. public static function getVerbose()
  465. {
  466. return self::$_PHPCAS_VERBOSE;
  467. }
  468. /**
  469. * Logs a string in debug mode.
  470. *
  471. * @param string $str the string to write
  472. *
  473. * @return void
  474. * @private
  475. */
  476. public static function log($str)
  477. {
  478. $indent_str = ".";
  479. if (isset(self::$_PHPCAS_DEBUG['logger']) || !empty(self::$_PHPCAS_DEBUG['filename'])) {
  480. for ($i = 0; $i < self::$_PHPCAS_DEBUG['indent']; $i++) {
  481. $indent_str .= '| ';
  482. }
  483. // allow for multiline output with proper identing. Usefull for
  484. // dumping cas answers etc.
  485. $str2 = str_replace("\n", "\n" . self::$_PHPCAS_DEBUG['unique_id'] . ' ' . $indent_str, $str);
  486. $str3 = self::$_PHPCAS_DEBUG['unique_id'] . ' ' . $indent_str . $str2;
  487. if (isset(self::$_PHPCAS_DEBUG['logger'])) {
  488. self::$_PHPCAS_DEBUG['logger']->info($str3);
  489. }
  490. if (!empty(self::$_PHPCAS_DEBUG['filename'])) {
  491. // Check if file exists and modifiy file permissions to be only
  492. // readable by the webserver
  493. if (!file_exists(self::$_PHPCAS_DEBUG['filename'])) {
  494. touch(self::$_PHPCAS_DEBUG['filename']);
  495. // Chmod will fail on windows
  496. @chmod(self::$_PHPCAS_DEBUG['filename'], 0600);
  497. }
  498. error_log($str3 . "\n", 3, self::$_PHPCAS_DEBUG['filename']);
  499. }
  500. }
  501. }
  502. /**
  503. * This method is used by interface methods to print an error and where the
  504. * function was originally called from.
  505. *
  506. * @param string $msg the message to print
  507. *
  508. * @return void
  509. * @private
  510. */
  511. public static function error($msg)
  512. {
  513. phpCAS :: traceBegin();
  514. $dbg = debug_backtrace();
  515. $function = '?';
  516. $file = '?';
  517. $line = '?';
  518. if (is_array($dbg)) {
  519. for ($i = 1; $i < sizeof($dbg); $i++) {
  520. if (is_array($dbg[$i]) && isset($dbg[$i]['class']) ) {
  521. if ($dbg[$i]['class'] == __CLASS__) {
  522. $function = $dbg[$i]['function'];
  523. $file = $dbg[$i]['file'];
  524. $line = $dbg[$i]['line'];
  525. }
  526. }
  527. }
  528. }
  529. if (self::$_PHPCAS_VERBOSE) {
  530. echo "<br />\n<b>phpCAS error</b>: <font color=\"FF0000\"><b>" . __CLASS__ . "::" . $function . '(): ' . htmlentities($msg) . "</b></font> in <b>" . $file . "</b> on line <b>" . $line . "</b><br />\n";
  531. } else {
  532. echo "<br />\n<b>Error</b>: <font color=\"FF0000\"><b>". DEFAULT_ERROR ."</b><br />\n";
  533. }
  534. phpCAS :: trace($msg . ' in ' . $file . 'on line ' . $line );
  535. phpCAS :: traceEnd();
  536. throw new CAS_GracefullTerminationException(__CLASS__ . "::" . $function . '(): ' . $msg);
  537. }
  538. /**
  539. * This method is used to log something in debug mode.
  540. *
  541. * @param string $str string to log
  542. *
  543. * @return void
  544. */
  545. public static function trace($str)
  546. {
  547. $dbg = debug_backtrace();
  548. phpCAS :: log($str . ' [' . basename($dbg[0]['file']) . ':' . $dbg[0]['line'] . ']');
  549. }
  550. /**
  551. * This method is used to indicate the start of the execution of a function
  552. * in debug mode.
  553. *
  554. * @return void
  555. */
  556. public static function traceBegin()
  557. {
  558. $dbg = debug_backtrace();
  559. $str = '=> ';
  560. if (!empty ($dbg[1]['class'])) {
  561. $str .= $dbg[1]['class'] . '::';
  562. }
  563. $str .= $dbg[1]['function'] . '(';
  564. if (is_array($dbg[1]['args'])) {
  565. foreach ($dbg[1]['args'] as $index => $arg) {
  566. if ($index != 0) {
  567. $str .= ', ';
  568. }
  569. if (is_object($arg)) {
  570. $str .= get_class($arg);
  571. } else {
  572. $str .= str_replace(array("\r\n", "\n", "\r"), "", var_export($arg, true));
  573. }
  574. }
  575. }
  576. if (isset($dbg[1]['file'])) {
  577. $file = basename($dbg[1]['file']);
  578. } else {
  579. $file = 'unknown_file';
  580. }
  581. if (isset($dbg[1]['line'])) {
  582. $line = $dbg[1]['line'];
  583. } else {
  584. $line = 'unknown_line';
  585. }
  586. $str .= ') [' . $file . ':' . $line . ']';
  587. phpCAS :: log($str);
  588. if (!isset(self::$_PHPCAS_DEBUG['indent'])) {
  589. self::$_PHPCAS_DEBUG['indent'] = 0;
  590. } else {
  591. self::$_PHPCAS_DEBUG['indent']++;
  592. }
  593. }
  594. /**
  595. * This method is used to indicate the end of the execution of a function in
  596. * debug mode.
  597. *
  598. * @param mixed $res the result of the function
  599. *
  600. * @return void
  601. */
  602. public static function traceEnd($res = '')
  603. {
  604. if (empty(self::$_PHPCAS_DEBUG['indent'])) {
  605. self::$_PHPCAS_DEBUG['indent'] = 0;
  606. } else {
  607. self::$_PHPCAS_DEBUG['indent']--;
  608. }
  609. $str = '';
  610. if (is_object($res)) {
  611. $str .= '<= ' . get_class($res);
  612. } else {
  613. $str .= '<= ' . str_replace(array("\r\n", "\n", "\r"), "", var_export($res, true));
  614. }
  615. phpCAS :: log($str);
  616. }
  617. /**
  618. * This method is used to indicate the end of the execution of the program
  619. *
  620. * @return void
  621. */
  622. public static function traceExit()
  623. {
  624. phpCAS :: log('exit()');
  625. while (self::$_PHPCAS_DEBUG['indent'] > 0) {
  626. phpCAS :: log('-');
  627. self::$_PHPCAS_DEBUG['indent']--;
  628. }
  629. }
  630. /** @} */
  631. // ########################################################################
  632. // INTERNATIONALIZATION
  633. // ########################################################################
  634. /**
  635. * @addtogroup publicLang
  636. * @{
  637. */
  638. /**
  639. * This method is used to set the language used by phpCAS.
  640. *
  641. * @param string $lang string representing the language.
  642. *
  643. * @return void
  644. *
  645. * @sa PHPCAS_LANG_FRENCH, PHPCAS_LANG_ENGLISH
  646. * @note Can be called only once.
  647. */
  648. public static function setLang($lang)
  649. {
  650. phpCAS::_validateClientExists();
  651. try {
  652. self::$_PHPCAS_CLIENT->setLang($lang);
  653. } catch (Exception $e) {
  654. phpCAS :: error(get_class($e) . ': ' . $e->getMessage());
  655. }
  656. }
  657. /** @} */
  658. // ########################################################################
  659. // VERSION
  660. // ########################################################################
  661. /**
  662. * @addtogroup public
  663. * @{
  664. */
  665. /**
  666. * This method returns the phpCAS version.
  667. *
  668. * @return string the phpCAS version.
  669. */
  670. public static function getVersion()
  671. {
  672. return PHPCAS_VERSION;
  673. }
  674. /**
  675. * This method returns supported protocols.
  676. *
  677. * @return array an array of all supported protocols. Use internal protocol name as array key.
  678. */
  679. public static function getSupportedProtocols()
  680. {
  681. $supportedProtocols = array();
  682. $supportedProtocols[CAS_VERSION_1_0] = 'CAS 1.0';
  683. $supportedProtocols[CAS_VERSION_2_0] = 'CAS 2.0';
  684. $supportedProtocols[CAS_VERSION_3_0] = 'CAS 3.0';
  685. $supportedProtocols[SAML_VERSION_1_1] = 'SAML 1.1';
  686. return $supportedProtocols;
  687. }
  688. /** @} */
  689. // ########################################################################
  690. // HTML OUTPUT
  691. // ########################################################################
  692. /**
  693. * @addtogroup publicOutput
  694. * @{
  695. */
  696. /**
  697. * This method sets the HTML header used for all outputs.
  698. *
  699. * @param string $header the HTML header.
  700. *
  701. * @return void
  702. */
  703. public static function setHTMLHeader($header)
  704. {
  705. phpCAS::_validateClientExists();
  706. try {
  707. self::$_PHPCAS_CLIENT->setHTMLHeader($header);
  708. } catch (Exception $e) {
  709. phpCAS :: error(get_class($e) . ': ' . $e->getMessage());
  710. }
  711. }
  712. /**
  713. * This method sets the HTML footer used for all outputs.
  714. *
  715. * @param string $footer the HTML footer.
  716. *
  717. * @return void
  718. */
  719. public static function setHTMLFooter($footer)
  720. {
  721. phpCAS::_validateClientExists();
  722. try {
  723. self::$_PHPCAS_CLIENT->setHTMLFooter($footer);
  724. } catch (Exception $e) {
  725. phpCAS :: error(get_class($e) . ': ' . $e->getMessage());
  726. }
  727. }
  728. /** @} */
  729. // ########################################################################
  730. // PGT STORAGE
  731. // ########################################################################
  732. /**
  733. * @addtogroup publicPGTStorage
  734. * @{
  735. */
  736. /**
  737. * This method can be used to set a custom PGT storage object.
  738. *
  739. * @param CAS_PGTStorage_AbstractStorage $storage a PGT storage object that inherits from the
  740. * CAS_PGTStorage_AbstractStorage class
  741. *
  742. * @return void
  743. */
  744. public static function setPGTStorage($storage)
  745. {
  746. phpCAS :: traceBegin();
  747. phpCAS::_validateProxyExists();
  748. try {
  749. self::$_PHPCAS_CLIENT->setPGTStorage($storage);
  750. } catch (Exception $e) {
  751. phpCAS :: error(get_class($e) . ': ' . $e->getMessage());
  752. }
  753. phpCAS :: traceEnd();
  754. }
  755. /**
  756. * This method is used to tell phpCAS to store the response of the
  757. * CAS server to PGT requests in a database.
  758. *
  759. * @param string $dsn_or_pdo a dsn string to use for creating a PDO
  760. * object or a PDO object
  761. * @param string $username the username to use when connecting to the
  762. * database
  763. * @param string $password the password to use when connecting to the
  764. * database
  765. * @param string $table the table to use for storing and retrieving
  766. * PGT's
  767. * @param string $driver_options any driver options to use when connecting
  768. * to the database
  769. *
  770. * @return void
  771. */
  772. public static function setPGTStorageDb($dsn_or_pdo, $username='',
  773. $password='', $table='', $driver_options=null
  774. ) {
  775. phpCAS :: traceBegin();
  776. phpCAS::_validateProxyExists();
  777. try {
  778. self::$_PHPCAS_CLIENT->setPGTStorageDb($dsn_or_pdo, $username, $password, $table, $driver_options);
  779. } catch (Exception $e) {
  780. phpCAS :: error(get_class($e) . ': ' . $e->getMessage());
  781. }
  782. phpCAS :: traceEnd();
  783. }
  784. /**
  785. * This method is used to tell phpCAS to store the response of the
  786. * CAS server to PGT requests onto the filesystem.
  787. *
  788. * @param string $path the path where the PGT's should be stored
  789. *
  790. * @return void
  791. */
  792. public static function setPGTStorageFile($path = '')
  793. {
  794. phpCAS :: traceBegin();
  795. phpCAS::_validateProxyExists();
  796. try {
  797. self::$_PHPCAS_CLIENT->setPGTStorageFile($path);
  798. } catch (Exception $e) {
  799. phpCAS :: error(get_class($e) . ': ' . $e->getMessage());
  800. }
  801. phpCAS :: traceEnd();
  802. }
  803. /** @} */
  804. // ########################################################################
  805. // ACCESS TO EXTERNAL SERVICES
  806. // ########################################################################
  807. /**
  808. * @addtogroup publicServices
  809. * @{
  810. */
  811. /**
  812. * Answer a proxy-authenticated service handler.
  813. *
  814. * @param string $type The service type. One of
  815. * PHPCAS_PROXIED_SERVICE_HTTP_GET; PHPCAS_PROXIED_SERVICE_HTTP_POST;
  816. * PHPCAS_PROXIED_SERVICE_IMAP
  817. *
  818. * @return CAS_ProxiedService
  819. * @throws InvalidArgumentException If the service type is unknown.
  820. */
  821. public static function getProxiedService ($type)
  822. {
  823. phpCAS :: traceBegin();
  824. phpCAS::_validateProxyExists();
  825. try {
  826. $res = self::$_PHPCAS_CLIENT->getProxiedService($type);
  827. } catch (Exception $e) {
  828. phpCAS :: error(get_class($e) . ': ' . $e->getMessage());
  829. }
  830. phpCAS :: traceEnd();
  831. return $res;
  832. }
  833. /**
  834. * Initialize a proxied-service handler with the proxy-ticket it should use.
  835. *
  836. * @param CAS_ProxiedService $proxiedService Proxied Service Handler
  837. *
  838. * @return void
  839. * @throws CAS_ProxyTicketException If there is a proxy-ticket failure.
  840. * The code of the Exception will be one of:
  841. * PHPCAS_SERVICE_PT_NO_SERVER_RESPONSE
  842. * PHPCAS_SERVICE_PT_BAD_SERVER_RESPONSE
  843. * PHPCAS_SERVICE_PT_FAILURE
  844. */
  845. public static function initializeProxiedService (CAS_ProxiedService $proxiedService)
  846. {
  847. phpCAS::_validateProxyExists();
  848. try {
  849. self::$_PHPCAS_CLIENT->initializeProxiedService($proxiedService);
  850. } catch (Exception $e) {
  851. phpCAS :: error(get_class($e) . ': ' . $e->getMessage());
  852. }
  853. }
  854. /**
  855. * This method is used to access an HTTP[S] service.
  856. *
  857. * @param string $url the service to access.
  858. * @param int &$err_code an error code Possible values are
  859. * PHPCAS_SERVICE_OK (on success), PHPCAS_SERVICE_PT_NO_SERVER_RESPONSE,
  860. * PHPCAS_SERVICE_PT_BAD_SERVER_RESPONSE, PHPCAS_SERVICE_PT_FAILURE,
  861. * PHPCAS_SERVICE_NOT_AVAILABLE.
  862. * @param string &$output the output of the service (also used to give an
  863. * error message on failure).
  864. *
  865. * @return bool true on success, false otherwise (in this later case,
  866. * $err_code gives the reason why it failed and $output contains an error
  867. * message).
  868. */
  869. public static function serviceWeb($url, & $err_code, & $output)
  870. {
  871. phpCAS :: traceBegin();
  872. phpCAS::_validateProxyExists();
  873. try {
  874. $res = self::$_PHPCAS_CLIENT->serviceWeb($url, $err_code, $output);
  875. } catch (Exception $e) {
  876. phpCAS :: error(get_class($e) . ': ' . $e->getMessage());
  877. }
  878. phpCAS :: traceEnd($res);
  879. return $res;
  880. }
  881. /**
  882. * This method is used to access an IMAP/POP3/NNTP service.
  883. *
  884. * @param string $url a string giving the URL of the service,
  885. * including the mailing box for IMAP URLs, as accepted by imap_open().
  886. * @param string $service a string giving for CAS retrieve Proxy ticket
  887. * @param string $flags options given to imap_open().
  888. * @param int &$err_code an error code Possible values are
  889. * PHPCAS_SERVICE_OK (on success), PHPCAS_SERVICE_PT_NO_SERVER_RESPONSE,
  890. * PHPCAS_SERVICE_PT_BAD_SERVER_RESPONSE, PHPCAS_SERVICE_PT_FAILURE,
  891. * PHPCAS_SERVICE_NOT_AVAILABLE.
  892. * @param string &$err_msg an error message on failure
  893. * @param string &$pt the Proxy Ticket (PT) retrieved from the CAS
  894. * server to access the URL on success, false on error).
  895. *
  896. * @return object|false IMAP stream on success, false otherwise (in this later
  897. * case, $err_code gives the reason why it failed and $err_msg contains an
  898. * error message).
  899. */
  900. public static function serviceMail($url, $service, $flags, & $err_code, & $err_msg, & $pt)
  901. {
  902. phpCAS :: traceBegin();
  903. phpCAS::_validateProxyExists();
  904. try {
  905. $res = self::$_PHPCAS_CLIENT->serviceMail($url, $service, $flags, $err_code, $err_msg, $pt);
  906. } catch (Exception $e) {
  907. phpCAS :: error(get_class($e) . ': ' . $e->getMessage());
  908. }
  909. phpCAS :: traceEnd($res);
  910. return $res;
  911. }
  912. /** @} */
  913. // ########################################################################
  914. // AUTHENTICATION
  915. // ########################################################################
  916. /**
  917. * @addtogroup publicAuth
  918. * @{
  919. */
  920. /**
  921. * Set the times authentication will be cached before really accessing the
  922. * CAS server in gateway mode:
  923. * - -1: check only once, and then never again (until you pree login)
  924. * - 0: always check
  925. * - n: check every "n" time
  926. *
  927. * @param int $n an integer.
  928. *
  929. * @return void
  930. */
  931. public static function setCacheTimesForAuthRecheck($n)
  932. {
  933. phpCAS::_validateClientExists();
  934. try {
  935. self::$_PHPCAS_CLIENT->setCacheTimesForAuthRecheck($n);
  936. } catch (Exception $e) {
  937. phpCAS :: error(get_class($e) . ': ' . $e->getMessage());
  938. }
  939. }
  940. /**
  941. * Set a callback function to be run when receiving CAS attributes
  942. *
  943. * The callback function will be passed an $success_elements
  944. * payload of the response (\DOMElement) as its first parameter.
  945. *
  946. * @param string $function Callback function
  947. * @param array $additionalArgs optional array of arguments
  948. *
  949. * @return void
  950. */
  951. public static function setCasAttributeParserCallback($function, array $additionalArgs = array())
  952. {
  953. phpCAS::_validateClientExists();
  954. self::$_PHPCAS_CLIENT->setCasAttributeParserCallback($function, $additionalArgs);
  955. }
  956. /**
  957. * Set a callback function to be run when a user authenticates.
  958. *
  959. * The callback function will be passed a $logoutTicket as its first
  960. * parameter, followed by any $additionalArgs you pass. The $logoutTicket
  961. * parameter is an opaque string that can be used to map the session-id to
  962. * logout request in order to support single-signout in applications that
  963. * manage their own sessions (rather than letting phpCAS start the session).
  964. *
  965. * phpCAS::forceAuthentication() will always exit and forward client unless
  966. * they are already authenticated. To perform an action at the moment the user
  967. * logs in (such as registering an account, performing logging, etc), register
  968. * a callback function here.
  969. *
  970. * @param callable $function Callback function
  971. * @param array $additionalArgs optional array of arguments
  972. *
  973. * @return void
  974. */
  975. public static function setPostAuthenticateCallback ($function, array $additionalArgs = array())
  976. {
  977. phpCAS::_validateClientExists();
  978. self::$_PHPCAS_CLIENT->setPostAuthenticateCallback($function, $additionalArgs);
  979. }
  980. /**
  981. * Set a callback function to be run when a single-signout request is
  982. * received. The callback function will be passed a $logoutTicket as its
  983. * first parameter, followed by any $additionalArgs you pass. The
  984. * $logoutTicket parameter is an opaque string that can be used to map a
  985. * session-id to the logout request in order to support single-signout in
  986. * applications that manage their own sessions (rather than letting phpCAS
  987. * start and destroy the session).
  988. *
  989. * @param callable $function Callback function
  990. * @param array $additionalArgs optional array of arguments
  991. *
  992. * @return void
  993. */
  994. public static function setSingleSignoutCallback ($function, array $additionalArgs = array())
  995. {
  996. phpCAS::_validateClientExists();
  997. self::$_PHPCAS_CLIENT->setSingleSignoutCallback($function, $additionalArgs);
  998. }
  999. /**
  1000. * This method is called to check if the user is already authenticated
  1001. * locally or has a global cas session. A already existing cas session is
  1002. * determined by a cas gateway call.(cas login call without any interactive
  1003. * prompt)
  1004. *
  1005. * @return bool true when the user is authenticated, false when a previous
  1006. * gateway login failed or the function will not return if the user is
  1007. * redirected to the cas server for a gateway login attempt
  1008. */
  1009. public static function checkAuthentication()
  1010. {
  1011. phpCAS :: traceBegin();
  1012. phpCAS::_validateClientExists();
  1013. $auth = self::$_PHPCAS_CLIENT->checkAuthentication();
  1014. // store where the authentication has been checked and the result
  1015. self::$_PHPCAS_CLIENT->markAuthenticationCall($auth);
  1016. phpCAS :: traceEnd($auth);
  1017. return $auth;
  1018. }
  1019. /**
  1020. * This method is called to force authentication if the user was not already
  1021. * authenticated. If the user is not authenticated, halt by redirecting to
  1022. * the CAS server.
  1023. *
  1024. * @return bool Authentication
  1025. */
  1026. public static function forceAuthentication()
  1027. {
  1028. phpCAS :: traceBegin();
  1029. phpCAS::_validateClientExists();
  1030. $auth = self::$_PHPCAS_CLIENT->forceAuthentication();
  1031. // store where the authentication has been checked and the result
  1032. self::$_PHPCAS_CLIENT->markAuthenticationCall($auth);
  1033. /* if (!$auth) {
  1034. phpCAS :: trace('user is not authenticated, redirecting to the CAS server');
  1035. self::$_PHPCAS_CLIENT->forceAuthentication();
  1036. } else {
  1037. phpCAS :: trace('no need to authenticate (user `' . phpCAS :: getUser() . '\' is already authenticated)');
  1038. }*/
  1039. phpCAS :: traceEnd();
  1040. return $auth;
  1041. }
  1042. /**
  1043. * This method is called to renew the authentication.
  1044. *
  1045. * @return void
  1046. **/
  1047. public static function renewAuthentication()
  1048. {
  1049. phpCAS :: traceBegin();
  1050. phpCAS::_validateClientExists();
  1051. $auth = self::$_PHPCAS_CLIENT->renewAuthentication();
  1052. // store where the authentication has been checked and the result
  1053. self::$_PHPCAS_CLIENT->markAuthenticationCall($auth);
  1054. //self::$_PHPCAS_CLIENT->renewAuthentication();
  1055. phpCAS :: traceEnd();
  1056. }
  1057. /**
  1058. * This method is called to check if the user is authenticated (previously or by
  1059. * tickets given in the URL).
  1060. *
  1061. * @return bool true when the user is authenticated.
  1062. */
  1063. public static function isAuthenticated()
  1064. {
  1065. phpCAS :: traceBegin();
  1066. phpCAS::_validateClientExists();
  1067. // call the isAuthenticated method of the $_PHPCAS_CLIENT object
  1068. $auth = self::$_PHPCAS_CLIENT->isAuthenticated();
  1069. // store where the authentication has been checked and the result
  1070. self::$_PHPCAS_CLIENT->markAuthenticationCall($auth);
  1071. phpCAS :: traceEnd($auth);
  1072. return $auth;
  1073. }
  1074. /**
  1075. * Checks whether authenticated based on $_SESSION. Useful to avoid
  1076. * server calls.
  1077. *
  1078. * @return bool true if authenticated, false otherwise.
  1079. * @since 0.4.22 by Brendan Arnold
  1080. */
  1081. public static function isSessionAuthenticated()
  1082. {
  1083. phpCAS::_validateClientExists();
  1084. return (self::$_PHPCAS_CLIENT->isSessionAuthenticated());
  1085. }
  1086. /**
  1087. * This method returns the CAS user's login name.
  1088. *
  1089. * @return string the login name of the authenticated user
  1090. * @warning should only be called after phpCAS::forceAuthentication()
  1091. * or phpCAS::checkAuthentication().
  1092. * */
  1093. public static function getUser()
  1094. {
  1095. phpCAS::_validateClientExists();
  1096. try {
  1097. return self::$_PHPCAS_CLIENT->getUser();
  1098. } catch (Exception $e) {
  1099. phpCAS :: error(get_class($e) . ': ' . $e->getMessage());
  1100. }
  1101. }
  1102. /**
  1103. * Answer attributes about the authenticated user.
  1104. *
  1105. * @warning should only be called after phpCAS::forceAuthentication()
  1106. * or phpCAS::checkAuthentication().
  1107. *
  1108. * @return array
  1109. */
  1110. public static function getAttributes()
  1111. {
  1112. phpCAS::_validateClientExists();
  1113. try {
  1114. return self::$_PHPCAS_CLIENT->getAttributes();
  1115. } catch (Exception $e) {
  1116. phpCAS :: error(get_class($e) . ': ' . $e->getMessage());
  1117. }
  1118. }
  1119. /**
  1120. * Answer true if there are attributes for the authenticated user.
  1121. *
  1122. * @warning should only be called after phpCAS::forceAuthentication()
  1123. * or phpCAS::checkAuthentication().
  1124. *
  1125. * @return bool
  1126. */
  1127. public static function hasAttributes()
  1128. {
  1129. phpCAS::_validateClientExists();
  1130. try {
  1131. return self::$_PHPCAS_CLIENT->hasAttributes();
  1132. } catch (Exception $e) {
  1133. phpCAS :: error(get_class($e) . ': ' . $e->getMessage());
  1134. }
  1135. }
  1136. /**
  1137. * Answer true if an attribute exists for the authenticated user.
  1138. *
  1139. * @param string $key attribute name
  1140. *
  1141. * @return bool
  1142. * @warning should only be called after phpCAS::forceAuthentication()
  1143. * or phpCAS::checkAuthentication().
  1144. */
  1145. public static function hasAttribute($key)
  1146. {
  1147. phpCAS::_validateClientExists();
  1148. try {
  1149. return self::$_PHPCAS_CLIENT->hasAttribute($key);
  1150. } catch (Exception $e) {
  1151. phpCAS :: error(get_class($e) . ': ' . $e->getMessage());
  1152. }
  1153. }
  1154. /**
  1155. * Answer an attribute for the authenticated user.
  1156. *
  1157. * @param string $key attribute name
  1158. *
  1159. * @return mixed string for a single value or an array if multiple values exist.
  1160. * @warning should only be called after phpCAS::forceAuthentication()
  1161. * or phpCAS::checkAuthentication().
  1162. */
  1163. public static function getAttribute($key)
  1164. {
  1165. phpCAS::_validateClientExists();
  1166. try {
  1167. return self::$_PHPCAS_CLIENT->getAttribute($key);
  1168. } catch (Exception $e) {
  1169. phpCAS :: error(get_class($e) . ': ' . $e->getMessage());
  1170. }
  1171. }
  1172. /**
  1173. * Handle logout requests.
  1174. *
  1175. * @param bool $check_client additional safety check
  1176. * @param array $allowed_clients array of allowed clients
  1177. *
  1178. * @return void
  1179. */
  1180. public static function handleLogoutRequests($check_client = true, $allowed_clients = array())
  1181. {
  1182. phpCAS::_validateClientExists();
  1183. return (self::$_PHPCAS_CLIENT->handleLogoutRequests($check_client, $allowed_clients));
  1184. }
  1185. /**
  1186. * This method returns the URL to be used to login.
  1187. *
  1188. * @return string the login URL
  1189. */
  1190. public static function getServerLoginURL()
  1191. {
  1192. phpCAS::_validateClientExists();
  1193. return self::$_PHPCAS_CLIENT->getServerLoginURL();
  1194. }
  1195. /**
  1196. * Set the login URL of the CAS server.
  1197. *
  1198. * @param string $url the login URL
  1199. *
  1200. * @return void
  1201. * @since 0.4.21 by Wyman Chan
  1202. */
  1203. public static function setServerLoginURL($url = '')
  1204. {
  1205. phpCAS :: traceBegin();
  1206. phpCAS::_validateClientExists();
  1207. try {
  1208. self::$_PHPCAS_CLIENT->setServerLoginURL($url);
  1209. } catch (Exception $e) {
  1210. phpCAS :: error(get_class($e) . ': ' . $e->getMessage());
  1211. }
  1212. phpCAS :: traceEnd();
  1213. }
  1214. /**
  1215. * Set the serviceValidate URL of the CAS server.
  1216. * Used for all CAS versions of URL validations.
  1217. * Examples:
  1218. * CAS 1.0 http://www.exemple.com/validate
  1219. * CAS 2.0 http://www.exemple.com/validateURL
  1220. * CAS 3.0 http://www.exemple.com/p3/serviceValidate
  1221. *
  1222. * @param string $url the serviceValidate URL
  1223. *
  1224. * @return void
  1225. */
  1226. public static function setServerServiceValidateURL($url = '')
  1227. {
  1228. phpCAS :: traceBegin();
  1229. phpCAS::_validateClientExists();
  1230. try {
  1231. self::$_PHPCAS_CLIENT->setServerServiceValidateURL($url);
  1232. } catch (Exception $e) {
  1233. phpCAS :: error(get_class($e) . ': ' . $e->getMessage());
  1234. }
  1235. phpCAS :: traceEnd();
  1236. }
  1237. /**
  1238. * Set the proxyValidate URL of the CAS server.
  1239. * Used for all CAS versions of proxy URL validations
  1240. * Examples:
  1241. * CAS 1.0 http://www.exemple.com/
  1242. * CAS 2.0 http://www.exemple.com/proxyValidate
  1243. * CAS 3.0 http://www.exemple.com/p3/proxyValidate
  1244. *
  1245. * @param string $url the proxyValidate URL
  1246. *
  1247. * @return void
  1248. */
  1249. public static function setServerProxyValidateURL($url = '')
  1250. {
  1251. phpCAS :: traceBegin();
  1252. phpCAS::_validateClientExists();
  1253. try {
  1254. self::$_PHPCAS_CLIENT->setServerProxyValidateURL($url);
  1255. } catch (Exception $e) {
  1256. phpCAS :: error(get_class($e) . ': ' . $e->getMessage());
  1257. }
  1258. phpCAS :: traceEnd();
  1259. }
  1260. /**
  1261. * Set the samlValidate URL of the CAS server.
  1262. *
  1263. * @param string $url the samlValidate URL
  1264. *
  1265. * @return void
  1266. */
  1267. public static function setServerSamlValidateURL($url = '')
  1268. {
  1269. phpCAS :: traceBegin();
  1270. phpCAS::_validateClientExists();
  1271. try {
  1272. self::$_PHPCAS_CLIENT->setServerSamlValidateURL($url);
  1273. } catch (Exception $e) {
  1274. phpCAS :: error(get_class($e) . ': ' . $e->getMessage());
  1275. }
  1276. phpCAS :: traceEnd();
  1277. }
  1278. /**
  1279. * This method returns the URL to be used to logout.
  1280. *
  1281. * @return string the URL to use to log out
  1282. */
  1283. public static function getServerLogoutURL()
  1284. {
  1285. phpCAS::_validateClientExists();
  1286. return self::$_PHPCAS_CLIENT->getServerLogoutURL();
  1287. }
  1288. /**
  1289. * Set the logout URL of the CAS server.
  1290. *
  1291. * @param string $url the logout URL
  1292. *
  1293. * @return void
  1294. * @since 0.4.21 by Wyman Chan
  1295. */
  1296. public static function setServerLogoutURL($url = '')
  1297. {
  1298. phpCAS :: traceBegin();
  1299. phpCAS::_validateClientExists();
  1300. try {
  1301. self::$_PHPCAS_CLIENT->setServerLogoutURL($url);
  1302. } catch (Exception $e) {
  1303. phpCAS :: error(get_class($e) . ': ' . $e->getMessage());
  1304. }
  1305. phpCAS :: traceEnd();
  1306. }
  1307. /**
  1308. * This method is used to logout from CAS.
  1309. *
  1310. * @param string $params an array that contains the optional url and
  1311. * service parameters that will be passed to the CAS server
  1312. *
  1313. * @return void
  1314. */
  1315. public static function logout($params = "")
  1316. {
  1317. phpCAS :: traceBegin();
  1318. phpCAS::_validateClientExists();
  1319. $parsedParams = array ();
  1320. if ($params != "") {
  1321. if (is_string($params)) {
  1322. phpCAS :: error('method `phpCAS::logout($url)\' is now deprecated, use `phpCAS::logoutWithUrl($url)\' instead');
  1323. }
  1324. if (!is_array($params)) {
  1325. phpCAS :: error('type mismatched for parameter $params (should be `array\')');
  1326. }
  1327. foreach ($params as $key => $value) {
  1328. if ($key != "service" && $key != "url") {
  1329. phpCAS :: error('only `url\' and `service\' parameters are allowed for method `phpCAS::logout($params)\'');
  1330. }
  1331. $parsedParams[$key] = $value;
  1332. }
  1333. }
  1334. self::$_PHPCAS_CLIENT->logout($parsedParams);
  1335. // never reached
  1336. phpCAS :: traceEnd();
  1337. }
  1338. /**
  1339. * This method is used to logout from CAS. Halts by redirecting to the CAS
  1340. * server.
  1341. *
  1342. * @param string $service a URL that will be transmitted to the CAS server
  1343. *
  1344. * @return void
  1345. */
  1346. public static function logoutWithRedirectService($service)
  1347. {
  1348. phpCAS :: traceBegin();
  1349. phpCAS::_validateClientExists();
  1350. if (!is_string($service)) {
  1351. phpCAS :: error('type mismatched for parameter $service (should be `string\')');
  1352. }
  1353. self::$_PHPCAS_CLIENT->logout(array ( "service" => $service ));
  1354. // never reached
  1355. phpCAS :: traceEnd();
  1356. }
  1357. /**
  1358. * This method is used to logout from CAS. Halts by redirecting to the CAS
  1359. * server.
  1360. *
  1361. * @param string $url a URL that will be transmitted to the CAS server
  1362. *
  1363. * @return void
  1364. * @deprecated The url parameter has been removed from the CAS server as of
  1365. * version 3.3.5.1
  1366. */
  1367. public static function logoutWithUrl($url)
  1368. {
  1369. trigger_error('Function deprecated for cas servers >= 3.3.5.1', E_USER_DEPRECATED);
  1370. phpCAS :: traceBegin();
  1371. if (!is_object(self::$_PHPCAS_CLIENT)) {
  1372. phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()');
  1373. }
  1374. if (!is_string($url)) {
  1375. phpCAS :: error('type mismatched for parameter $url (should be `string\')');
  1376. }
  1377. self::$_PHPCAS_CLIENT->logout(array ( "url" => $url ));
  1378. // never reached
  1379. phpCAS :: traceEnd();
  1380. }
  1381. /**
  1382. * This method is used to logout from CAS. Halts by redirecting to the CAS
  1383. * server.
  1384. *
  1385. * @param string $service a URL that will be transmitted to the CAS server
  1386. * @param string $url a URL that will be transmitted to the CAS server
  1387. *
  1388. * @return void
  1389. *
  1390. * @deprecated The url parameter has been removed from the CAS server as of
  1391. * version 3.3.5.1
  1392. */
  1393. public static function logoutWithRedirectServiceAndUrl($service, $url)
  1394. {
  1395. trigger_error('Function deprecated for cas servers >= 3.3.5.1', E_USER_DEPRECATED);
  1396. phpCAS :: traceBegin();
  1397. phpCAS::_validateClientExists();
  1398. if (!is_string($service)) {
  1399. phpCAS :: error('type mismatched for parameter $service (should be `string\')');
  1400. }
  1401. if (!is_string($url)) {
  1402. phpCAS :: error('type mismatched for parameter $url (should be `string\')');
  1403. }
  1404. self::$_PHPCAS_CLIENT->logout(
  1405. array (
  1406. "service" => $service,
  1407. "url" => $url
  1408. )
  1409. );
  1410. // never reached
  1411. phpCAS :: traceEnd();
  1412. }
  1413. /**
  1414. * Set the fixed URL that will be used by the CAS server to transmit the
  1415. * PGT. When this method is not called, a phpCAS script uses its own URL
  1416. * for the callback.
  1417. *
  1418. * @param string $url the URL
  1419. *
  1420. * @return void
  1421. */
  1422. public static function setFixedCallbackURL($url = '')
  1423. {
  1424. phpCAS :: traceBegin();
  1425. phpCAS::_validateProxyExists();
  1426. try {
  1427. self::$_PHPCAS_CLIENT->setCallbackURL($url);
  1428. } catch (Exception $e) {
  1429. phpCAS :: error(get_class($e) . ': ' . $e->getMessage());
  1430. }
  1431. phpCAS :: traceEnd();
  1432. }
  1433. /**
  1434. * Set the fixed URL that will be set as the CAS service parameter. When this
  1435. * method is not called, a phpCAS script uses its own URL.
  1436. *
  1437. * @param string $url the URL
  1438. *
  1439. * @return void
  1440. */
  1441. public static function setFixedServiceURL($url)
  1442. {
  1443. phpCAS :: traceBegin();
  1444. phpCAS::_validateProxyExists();
  1445. try {
  1446. self::$_PHPCAS_CLIENT->setURL($url);
  1447. } catch (Exception $e) {
  1448. phpCAS :: error(get_class($e) . ': ' . $e->getMessage());
  1449. }
  1450. phpCAS :: traceEnd();
  1451. }
  1452. /**
  1453. * Get the URL that is set as the CAS service parameter.
  1454. *
  1455. * @return string Service Url
  1456. */
  1457. public static function getServiceURL()
  1458. {
  1459. phpCAS::_validateProxyExists();
  1460. return (self::$_PHPCAS_CLIENT->getURL());
  1461. }
  1462. /**
  1463. * Retrieve a Proxy Ticket from the CAS server.
  1464. *
  1465. * @param string $target_service Url string of service to proxy
  1466. * @param int &$err_code error code
  1467. * @param string &$err_msg error message
  1468. *
  1469. * @return string Proxy Ticket
  1470. */
  1471. public static function retrievePT($target_service, & $err_code, & $err_msg)
  1472. {
  1473. phpCAS::_validateProxyExists();
  1474. try {
  1475. return (self::$_PHPCAS_CLIENT->retrievePT($target_service, $err_code, $err_msg));
  1476. } catch (Exception $e) {
  1477. phpCAS :: error(get_class($e) . ': ' . $e->getMessage());
  1478. }
  1479. }
  1480. /**
  1481. * Set the certificate of the CAS server CA and if the CN should be properly
  1482. * verified.
  1483. *
  1484. * @param string $cert CA certificate file name
  1485. * @param bool $validate_cn Validate CN in certificate (default true)
  1486. *
  1487. * @return void
  1488. */
  1489. public static function setCasServerCACert($cert, $validate_cn = true)
  1490. {
  1491. phpCAS :: traceBegin();
  1492. phpCAS::_validateClientExists();
  1493. try {
  1494. self::$_PHPCAS_CLIENT->setCasServerCACert($cert, $validate_cn);
  1495. } catch (Exception $e) {
  1496. phpCAS :: error(get_class($e) . ': ' . $e->getMessage());
  1497. }
  1498. phpCAS :: traceEnd();
  1499. }
  1500. /**
  1501. * Set no SSL validation for the CAS server.
  1502. *
  1503. * @return void
  1504. */
  1505. public static function setNoCasServerValidation()
  1506. {
  1507. phpCAS :: traceBegin();
  1508. phpCAS::_validateClientExists();
  1509. phpCAS :: trace('You have configured no validation of the legitimacy of the cas server. This is not recommended for production use.');
  1510. self::$_PHPCAS_CLIENT->setNoCasServerValidation();
  1511. phpCAS :: traceEnd();
  1512. }
  1513. /**
  1514. * Disable the removal of a CAS-Ticket from the URL when authenticating
  1515. * DISABLING POSES A SECURITY RISK:
  1516. * We normally remove the ticket by an additional redirect as a security
  1517. * precaution to prevent a ticket in the HTTP_REFERRER or be carried over in
  1518. * the URL parameter
  1519. *
  1520. * @return void
  1521. */
  1522. public static function setNoClearTicketsFromUrl()
  1523. {
  1524. phpCAS :: traceBegin();
  1525. phpCAS::_validateClientExists();
  1526. self::$_PHPCAS_CLIENT->setNoClearTicketsFromUrl();
  1527. phpCAS :: traceEnd();
  1528. }
  1529. /** @} */
  1530. /**
  1531. * Change CURL options.
  1532. * CURL is used to connect through HTTPS to CAS server
  1533. *
  1534. * @param string $key the option key
  1535. * @param string $value the value to set
  1536. *
  1537. * @return void
  1538. */
  1539. public static function setExtraCurlOption($key, $value)
  1540. {
  1541. phpCAS :: traceBegin();
  1542. phpCAS::_validateClientExists();
  1543. self::$_PHPCAS_CLIENT->setExtraCurlOption($key, $value);
  1544. phpCAS :: traceEnd();
  1545. }
  1546. /**
  1547. * Set a salt/seed for the session-id hash to make it harder to guess.
  1548. *
  1549. * When $changeSessionID = true phpCAS will create a session-id that is derived
  1550. * from the service ticket. Doing so allows phpCAS to look-up and destroy the
  1551. * proper session on single-log-out requests. While the service tickets
  1552. * provided by the CAS server may include enough data to generate a strong
  1553. * hash, clients may provide an additional salt to ensure that session ids
  1554. * are not guessable if the session tickets do not have enough entropy.
  1555. *
  1556. * @param string $salt The salt to combine with the session ticket.
  1557. *
  1558. * @return void
  1559. */
  1560. public static function setSessionIdSalt($salt) {
  1561. phpCAS :: traceBegin();
  1562. phpCAS::_validateClientExists();
  1563. self::$_PHPCAS_CLIENT->setSessionIdSalt($salt);
  1564. phpCAS :: traceEnd();
  1565. }
  1566. /**
  1567. * If you want your service to be proxied you have to enable it (default
  1568. * disabled) and define an accepable list of proxies that are allowed to
  1569. * proxy your service.
  1570. *
  1571. * Add each allowed proxy definition object. For the normal CAS_ProxyChain
  1572. * class, the constructor takes an array of proxies to match. The list is in
  1573. * reverse just as seen from the service. Proxies have to be defined in reverse
  1574. * from the service to the user. If a user hits service A and gets proxied via
  1575. * B to service C the list of acceptable on C would be array(B,A). The definition
  1576. * of an individual proxy can be either a string or a regexp (preg_match is used)
  1577. * that will be matched against the proxy list supplied by the cas server
  1578. * when validating the proxy tickets. The strings are compared starting from
  1579. * the beginning and must fully match with the proxies in the list.
  1580. * Example:
  1581. * phpCAS::allowProxyChain(new CAS_ProxyChain(array(
  1582. * 'https://app.example.com/'
  1583. * )));
  1584. * phpCAS::allowProxyChain(new CAS_ProxyChain(array(
  1585. * '/^https:\/\/app[0-9]\.example\.com\/rest\//',
  1586. * 'http://client.example.com/'
  1587. * )));
  1588. *
  1589. * For quick testing or in certain production screnarios you might want to
  1590. * allow allow any other valid service to proxy your service. To do so, add
  1591. * the "Any" chain:
  1592. * phpCAS::allowProxyChain(new CAS_ProxyChain_Any);
  1593. * THIS SETTING IS HOWEVER NOT RECOMMENDED FOR PRODUCTION AND HAS SECURITY
  1594. * IMPLICATIONS: YOU ARE ALLOWING ANY SERVICE TO ACT ON BEHALF OF A USER
  1595. * ON THIS SERVICE.
  1596. *
  1597. * @param CAS_ProxyChain_Interface $proxy_chain A proxy-chain that will be
  1598. * matched against the proxies requesting access
  1599. *
  1600. * @return void
  1601. */
  1602. public static function allowProxyChain(CAS_ProxyChain_Interface $proxy_chain)
  1603. {
  1604. phpCAS :: traceBegin();
  1605. phpCAS::_validateClientExists();
  1606. if (self::$_PHPCAS_CLIENT->getServerVersion() !== CAS_VERSION_2_0
  1607. && self::$_PHPCAS_CLIENT->getServerVersion() !== CAS_VERSION_3_0
  1608. ) {
  1609. phpCAS :: error('this method can only be used with the cas 2.0/3.0 protocols');
  1610. }
  1611. self::$_PHPCAS_CLIENT->getAllowedProxyChains()->allowProxyChain($proxy_chain);
  1612. phpCAS :: traceEnd();
  1613. }
  1614. /**
  1615. * Answer an array of proxies that are sitting in front of this application.
  1616. * This method will only return a non-empty array if we have received and
  1617. * validated a Proxy Ticket.
  1618. *
  1619. * @return array
  1620. * @access public
  1621. * @since 6/25/09
  1622. */
  1623. public static function getProxies ()
  1624. {
  1625. phpCAS::_validateProxyExists();
  1626. return(self::$_PHPCAS_CLIENT->getProxies());
  1627. }
  1628. // ########################################################################
  1629. // PGTIOU/PGTID and logoutRequest rebroadcasting
  1630. // ########################################################################
  1631. /**
  1632. * Add a pgtIou/pgtId and logoutRequest rebroadcast node.
  1633. *
  1634. * @param string $rebroadcastNodeUrl The rebroadcast node URL. Can be
  1635. * hostname or IP.
  1636. *
  1637. * @return void
  1638. */
  1639. public static function addRebroadcastNode($rebroadcastNodeUrl)
  1640. {
  1641. phpCAS::traceBegin();
  1642. phpCAS::log('rebroadcastNodeUrl:'.$rebroadcastNodeUrl);
  1643. phpCAS::_validateClientExists();
  1644. try {
  1645. self::$_PHPCAS_CLIENT->addRebroadcastNode($rebroadcastNodeUrl);
  1646. } catch (Exception $e) {
  1647. phpCAS :: error(get_class($e) . ': ' . $e->getMessage());
  1648. }
  1649. phpCAS::traceEnd();
  1650. }
  1651. /**
  1652. * This method is used to add header parameters when rebroadcasting
  1653. * pgtIou/pgtId or logoutRequest.
  1654. *
  1655. * @param String $header Header to send when rebroadcasting.
  1656. *
  1657. * @return void
  1658. */
  1659. public static function addRebroadcastHeader($header)
  1660. {
  1661. phpCAS :: traceBegin();
  1662. phpCAS::_validateClientExists();
  1663. try {
  1664. self::$_PHPCAS_CLIENT->addRebroadcastHeader($header);
  1665. } catch (Exception $e) {
  1666. phpCAS :: error(get_class($e) . ': ' . $e->getMessage());
  1667. }
  1668. phpCAS :: traceEnd();
  1669. }
  1670. /**
  1671. * Checks if a client already exists
  1672. *
  1673. * @throws CAS_OutOfSequenceBeforeClientException
  1674. *
  1675. * @return void
  1676. */
  1677. private static function _validateClientExists()
  1678. {
  1679. if (!is_object(self::$_PHPCAS_CLIENT)) {
  1680. throw new CAS_OutOfSequenceBeforeClientException();
  1681. }
  1682. }
  1683. /**
  1684. * Checks of a proxy client aready exists
  1685. *
  1686. * @throws CAS_OutOfSequenceBeforeProxyException
  1687. *
  1688. * @return void
  1689. */
  1690. private static function _validateProxyExists()
  1691. {
  1692. if (!is_object(self::$_PHPCAS_CLIENT)) {
  1693. throw new CAS_OutOfSequenceBeforeProxyException();
  1694. }
  1695. }
  1696. /**
  1697. * @return CAS_Client
  1698. */
  1699. public static function getCasClient()
  1700. {
  1701. return self::$_PHPCAS_CLIENT;
  1702. }
  1703. /**
  1704. * For testing purposes, use this method to set the client to a test double
  1705. *
  1706. * @return void
  1707. */
  1708. public static function setCasClient(\CAS_Client $client)
  1709. {
  1710. self::$_PHPCAS_CLIENT = $client;
  1711. }
  1712. }
  1713. // ########################################################################
  1714. // DOCUMENTATION
  1715. // ########################################################################
  1716. // ########################################################################
  1717. // MAIN PAGE
  1718. /**
  1719. * @mainpage
  1720. *
  1721. * The following pages only show the source documentation.
  1722. *
  1723. */
  1724. // ########################################################################
  1725. // MODULES DEFINITION
  1726. /** @defgroup public User interface */
  1727. /** @defgroup publicInit Initialization
  1728. * @ingroup public */
  1729. /** @defgroup publicAuth Authentication
  1730. * @ingroup public */
  1731. /** @defgroup publicServices Access to external services
  1732. * @ingroup public */
  1733. /** @defgroup publicConfig Configuration
  1734. * @ingroup public */
  1735. /** @defgroup publicLang Internationalization
  1736. * @ingroup publicConfig */
  1737. /** @defgroup publicOutput HTML output
  1738. * @ingroup publicConfig */
  1739. /** @defgroup publicPGTStorage PGT storage
  1740. * @ingroup publicConfig */
  1741. /** @defgroup publicDebug Debugging
  1742. * @ingroup public */
  1743. /** @defgroup internal Implementation */
  1744. /** @defgroup internalAuthentication Authentication
  1745. * @ingroup internal */
  1746. /** @defgroup internalBasic CAS Basic client features (CAS 1.0, Service Tickets)
  1747. * @ingroup internal */
  1748. /** @defgroup internalProxy CAS Proxy features (CAS 2.0, Proxy Granting Tickets)
  1749. * @ingroup internal */
  1750. /** @defgroup internalSAML CAS SAML features (SAML 1.1)
  1751. * @ingroup internal */
  1752. /** @defgroup internalPGTStorage PGT storage
  1753. * @ingroup internalProxy */
  1754. /** @defgroup internalPGTStorageDb PGT storage in a database
  1755. * @ingroup internalPGTStorage */
  1756. /** @defgroup internalPGTStorageFile PGT storage on the filesystem
  1757. * @ingroup internalPGTStorage */
  1758. /** @defgroup internalCallback Callback from the CAS server
  1759. * @ingroup internalProxy */
  1760. /** @defgroup internalProxyServices Proxy other services
  1761. * @ingroup internalProxy */
  1762. /** @defgroup internalService CAS client features (CAS 2.0, Proxied service)
  1763. * @ingroup internal */
  1764. /** @defgroup internalConfig Configuration
  1765. * @ingroup internal */
  1766. /** @defgroup internalBehave Internal behaviour of phpCAS
  1767. * @ingroup internalConfig */
  1768. /** @defgroup internalOutput HTML output
  1769. * @ingroup internalConfig */
  1770. /** @defgroup internalLang Internationalization
  1771. * @ingroup internalConfig
  1772. *
  1773. * To add a new language:
  1774. * - 1. define a new constant PHPCAS_LANG_XXXXXX in CAS/CAS.php
  1775. * - 2. copy any file from CAS/languages to CAS/languages/XXXXXX.php
  1776. * - 3. Make the translations
  1777. */
  1778. /** @defgroup internalDebug Debugging
  1779. * @ingroup internal */
  1780. /** @defgroup internalMisc Miscellaneous
  1781. * @ingroup internal */
  1782. // ########################################################################
  1783. // EXAMPLES
  1784. /**
  1785. * @example example_simple.php
  1786. */
  1787. /**
  1788. * @example example_service.php
  1789. */
  1790. /**
  1791. * @example example_service_that_proxies.php
  1792. */
  1793. /**
  1794. * @example example_service_POST.php
  1795. */
  1796. /**
  1797. * @example example_proxy_serviceWeb.php
  1798. */
  1799. /**
  1800. * @example example_proxy_serviceWeb_chaining.php
  1801. */
  1802. /**
  1803. * @example example_proxy_POST.php
  1804. */
  1805. /**
  1806. * @example example_proxy_GET.php
  1807. */
  1808. /**
  1809. * @example example_lang.php
  1810. */
  1811. /**
  1812. * @example example_html.php
  1813. */
  1814. /**
  1815. * @example example_pgt_storage_file.php
  1816. */
  1817. /**
  1818. * @example example_pgt_storage_db.php
  1819. */
  1820. /**
  1821. * @example example_gateway.php
  1822. */
  1823. /**
  1824. * @example example_logout.php
  1825. */
  1826. /**
  1827. * @example example_rebroadcast.php
  1828. */
  1829. /**
  1830. * @example example_custom_urls.php
  1831. */
  1832. /**
  1833. * @example example_advanced_saml11.php
  1834. */