1 <?php 2 3 /** 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. 7 * 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: 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 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. 19 * 20 * PHP Version 5 21 * 22 * @file CAS/AuthenticationException.php 23 * @category Authentication 24 * @package PhpCAS 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 28 */ 29 30 /** 31 * This interface defines methods that allow proxy-authenticated service handlers 32 * to interact with phpCAS. 33 * 34 * Proxy service handlers must implement this interface as well as call 35 * phpCAS::initializeProxiedService($this) at some point in their implementation. 36 * 37 * While not required, proxy-authenticated service handlers are encouraged to 38 * implement the CAS_ProxiedService_Testable interface to facilitate unit testing. 39 * 40 * @class CAS_AuthenticationException 41 * @category Authentication 42 * @package PhpCAS 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 46 */ 47 48 class CAS_AuthenticationException 49 extends RuntimeException 50 implements CAS_Exception 51 { 52 53 /** 54 * This method is used to print the HTML output when the user was not 55 * authenticated. 56 * 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 67 */ 68 public function __construct($client,$failure,$cas_url,$no_response, 69 $bad_response=false,$cas_response='',$err_code=-1,$err_msg='' 70 ) { 71 $messages = array(); 72 phpCAS::traceBegin(); 73 $lang = $client->getLangObj(); 74 $client->printHTMLHeader($lang->getAuthenticationFailed()); 75 printf( 76 $lang->getYouWereNotAuthenticated(), 77 htmlentities($client->getURL()), 78 isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN']:'' 79 ); 80 phpCAS::trace($messages[] = 'CAS URL: '.$cas_url); 81 phpCAS::trace($messages[] = 'Authentication failure: '.$failure); 82 if ( $no_response ) { 83 phpCAS::trace($messages[] = 'Reason: no response from the CAS server'); 84 } else { 85 if ( $bad_response ) { 86 phpCAS::trace($messages[] = 'Reason: bad response from the CAS server'); 87 } else { 88 switch ($client->getServerVersion()) { 89 case CAS_VERSION_1_0: 90 phpCAS::trace($messages[] = 'Reason: CAS error'); 91 break; 92 case CAS_VERSION_2_0: 93 case CAS_VERSION_3_0: 94 if ( $err_code === -1 ) { 95 phpCAS::trace($messages[] = 'Reason: no CAS error'); 96 } else { 97 phpCAS::trace($messages[] = 'Reason: ['.$err_code.'] CAS error: '.$err_msg); 98 } 99 break; 100 } 101 } 102 phpCAS::trace($messages[] = 'CAS response: '.$cas_response); 103 } 104 $client->printHTMLFooter(); 105 phpCAS::traceExit(); 106 107 parent::__construct(implode("\n", $messages)); 108 } 109 110 } 111 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body