ProxyTicketException.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. * PHP Version 5
  20. *
  21. * @class CAS/ProxyTicketException.php
  22. * @category Authentication
  23. * @package PhpCAS
  24. * @author Adam Franco <afranco@middlebury.edu>
  25. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
  26. * @link https://wiki.jasig.org/display/CASC/phpCAS
  27. *
  28. */
  29. /**
  30. * An Exception for errors related to fetching or validating proxy tickets.
  31. *
  32. * @class CAS_ProxyTicketException
  33. * @category Authentication
  34. * @package PhpCAS
  35. * @author Adam Franco <afranco@middlebury.edu>
  36. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
  37. * @link https://wiki.jasig.org/display/CASC/phpCAS
  38. */
  39. class CAS_ProxyTicketException
  40. extends BadMethodCallException
  41. implements CAS_Exception
  42. {
  43. /**
  44. * Constructor
  45. *
  46. * @param string $message Message text
  47. * @param int $code Error code
  48. *
  49. * @return void
  50. */
  51. public function __construct ($message, $code = PHPCAS_SERVICE_PT_FAILURE)
  52. {
  53. // Warn if the code is not in our allowed list
  54. $ptCodes = array(
  55. PHPCAS_SERVICE_PT_FAILURE,
  56. PHPCAS_SERVICE_PT_NO_SERVER_RESPONSE,
  57. PHPCAS_SERVICE_PT_BAD_SERVER_RESPONSE,
  58. );
  59. if (!in_array($code, $ptCodes)) {
  60. trigger_error(
  61. 'Invalid code '.$code
  62. .' passed. Must be one of PHPCAS_SERVICE_PT_FAILURE, PHPCAS_SERVICE_PT_NO_SERVER_RESPONSE, or PHPCAS_SERVICE_PT_BAD_SERVER_RESPONSE.'
  63. );
  64. }
  65. parent::__construct($message, $code);
  66. }
  67. }