2 /*******************************************************************************
3 * Copyright (C) 2007 Easter-eggs
4 * http://ldapsaisie.labs.libre-entreprise.org
6 * Author: See AUTHORS file in top-level directory.
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version 2
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 ******************************************************************************/
24 * CAS Authentication provider for LSauth
26 * @author Benjamin Renard <brenard@easter-eggs.com>
28 class LSauthMethod_CAS extends LSauthMethod {
30 function LSauthMethod_CAS() {
31 LSauth :: disableLoginForm();
33 if (!parent :: LSauthMethod())
36 if (LSsession :: includeFile(PHP_CAS_PATH)) {
37 if (defined('PHP_CAS_DEBUG_FILE')) {
38 phpCAS::setDebug(PHP_CAS_DEBUG_FILE);
40 phpCAS::client(constant(LSAUTH_CAS_VERSION),LSAUTH_CAS_SERVER_HOSTNAME,LSAUTH_CAS_SERVER_PORT,LSAUTH_CAS_SERVER_URI,false);
41 if (LSAUTH_CAS_SERVER_NO_SSL_VALIDATION) {
42 phpCAS::setNoCasServerValidation();
45 if (defined(LSAUTH_CAS_SERVER_SSL_CERT)) {
46 phpCAS::setCasServerCert(LSAUTH_CAS_SERVER_SSL_CERT);
49 if (defined(LSAUTH_CAS_SERVER_SSL_CACERT)) {
50 phpCAS::setCasServerCACert(LSAUTH_CAS_SERVER_SSL_CACERT);
53 if (LSAUTH_CAS_DISABLE_LOGOUT) {
54 LSauth :: disableLogoutBtn();
60 LSerror :: addErrorCode('LSauthMethod_CAS_01');
68 * Return authentication data or false
70 * @retval Array|false Array of authentication data or False
72 public function getAuthData() {
74 if (class_exists('phpCAS')) {
77 phpCAS::forceAuthentication();
79 $this -> authData = array(
80 'username' => phpCAS::getUser()
82 return $this -> authData;
90 * @retval boolean True on success or False
92 public function logout() {
93 if(class_exists('phpCAS')) {
94 if (LSauth :: displayLogoutBtn()) {
95 phpCAS :: forceAuthentication();
107 LSerror :: defineError('LSauthMethod_CAS_01',
108 _("LSauthMethod_CAS : Failed to load phpCAS.")