1 |
efrain |
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 7
|
|
|
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 |
|
|
|
76 |
if (phpCAS::getVerbose()) {
|
|
|
77 |
printf(
|
|
|
78 |
$lang->getYouWereNotAuthenticated(),
|
|
|
79 |
htmlentities($client->getURL()),
|
|
|
80 |
$_SERVER['SERVER_ADMIN'] ?? ''
|
|
|
81 |
);
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
phpCAS::trace($messages[] = 'CAS URL: '.$cas_url);
|
|
|
85 |
phpCAS::trace($messages[] = 'Authentication failure: '.$failure);
|
|
|
86 |
if ( $no_response ) {
|
|
|
87 |
phpCAS::trace($messages[] = 'Reason: no response from the CAS server');
|
|
|
88 |
} else {
|
|
|
89 |
if ( $bad_response ) {
|
|
|
90 |
phpCAS::trace($messages[] = 'Reason: bad response from the CAS server');
|
|
|
91 |
} else {
|
|
|
92 |
switch ($client->getServerVersion()) {
|
|
|
93 |
case CAS_VERSION_1_0:
|
|
|
94 |
phpCAS::trace($messages[] = 'Reason: CAS error');
|
|
|
95 |
break;
|
|
|
96 |
case CAS_VERSION_2_0:
|
|
|
97 |
case CAS_VERSION_3_0:
|
|
|
98 |
if ( $err_code === -1 ) {
|
|
|
99 |
phpCAS::trace($messages[] = 'Reason: no CAS error');
|
|
|
100 |
} else {
|
|
|
101 |
phpCAS::trace($messages[] = 'Reason: ['.$err_code.'] CAS error: '.$err_msg);
|
|
|
102 |
}
|
|
|
103 |
break;
|
|
|
104 |
}
|
|
|
105 |
}
|
|
|
106 |
phpCAS::trace($messages[] = 'CAS response: '.$cas_response);
|
|
|
107 |
}
|
|
|
108 |
$client->printHTMLFooter();
|
|
|
109 |
phpCAS::traceExit();
|
|
|
110 |
|
|
|
111 |
parent::__construct(implode("\n", $messages));
|
|
|
112 |
}
|
|
|
113 |
|
|
|
114 |
}
|
|
|
115 |
?>
|