4 * Licensed to Jasig under one or more contributor license
5 * agreements. See the NOTICE file distributed with this work for
6 * additional information regarding copyright ownership.
8 * Jasig licenses this file to you under the Apache License,
9 * Version 2.0 (the "License"); you may not use this file except in
10 * compliance with the License. You may obtain a copy of the License at:
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 * @file CAS/AuthenticationException.php
23 * @category Authentication
25 * @author Joachim Fritschi <jfritschi@freenet.de>
26 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
27 * @link https://wiki.jasig.org/display/CASC/phpCAS
31 * This interface defines methods that allow proxy-authenticated service handlers
32 * to interact with phpCAS.
34 * Proxy service handlers must implement this interface as well as call
35 * phpCAS::initializeProxiedService($this) at some point in their implementation.
37 * While not required, proxy-authenticated service handlers are encouraged to
38 * implement the CAS_ProxiedService_Testable interface to facilitate unit testing.
40 * @class CAS_AuthenticationException
41 * @category Authentication
43 * @author Joachim Fritschi <jfritschi@freenet.de>
44 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
45 * @link https://wiki.jasig.org/display/CASC/phpCAS
48 class CAS_AuthenticationException
49 extends RuntimeException
50 implements CAS_Exception
54 * This method is used to print the HTML output when the user was not
57 * @param CAS_Client $client phpcas client
58 * @param string $failure the failure that occured
59 * @param string $cas_url the URL the CAS server was asked for
60 * @param bool $no_response the response from the CAS server (other
61 * parameters are ignored if TRUE)
62 * @param bool $bad_response bad response from the CAS server ($err_code
63 * and $err_msg ignored if TRUE)
64 * @param string $cas_response the response of the CAS server
65 * @param int $err_code the error code given by the CAS server
66 * @param string $err_msg the error message given by the CAS server
68 public function __construct($client,$failure,$cas_url,$no_response,
69 $bad_response='',$cas_response='',$err_code='',$err_msg=''
72 $lang = $client->getLangObj();
73 $client->printHTMLHeader($lang->getAuthenticationFailed());
75 $lang->getYouWereNotAuthenticated(),
76 htmlentities($client->getURL()),
77 $_SERVER['SERVER_ADMIN']
79 phpCAS::trace('CAS URL: '.$cas_url);
80 phpCAS::trace('Authentication failure: '.$failure);
82 phpCAS::trace('Reason: no response from the CAS server');
84 if ( $bad_response ) {
85 phpCAS::trace('Reason: bad response from the CAS server');
87 switch ($client->getServerVersion()) {
89 phpCAS::trace('Reason: CAS error');
92 if ( empty($err_code) ) {
93 phpCAS::trace('Reason: no CAS error');
95 phpCAS::trace('Reason: ['.$err_code.'] CAS error: '.$err_msg);
100 phpCAS::trace('CAS response: '.$cas_response);
102 $client->printHTMLFooter();