Get.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. * @file CAS/ProxiedService/Http/Get.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. * This class is used to make proxied service requests via the HTTP GET method.
  30. *
  31. * Usage Example:
  32. *
  33. * try {
  34. * $service = phpCAS::getProxiedService(PHPCAS_PROXIED_SERVICE_HTTP_GET);
  35. * $service->setUrl('http://www.example.com/path/');
  36. * $service->send();
  37. * if ($service->getResponseStatusCode() == 200)
  38. * return $service->getResponseBody();
  39. * else
  40. * // The service responded with an error code 404, 500, etc.
  41. * throw new Exception('The service responded with an error.');
  42. *
  43. * } catch (CAS_ProxyTicketException $e) {
  44. * if ($e->getCode() == PHPCAS_SERVICE_PT_FAILURE)
  45. * return "Your login has timed out. You need to log in again.";
  46. * else
  47. * // Other proxy ticket errors are from bad request format
  48. * // (shouldn't happen) or CAS server failure (unlikely)
  49. * // so lets just stop if we hit those.
  50. * throw $e;
  51. * } catch (CAS_ProxiedService_Exception $e) {
  52. * // Something prevented the service request from being sent or received.
  53. * // We didn't even get a valid error response (404, 500, etc), so this
  54. * // might be caused by a network error or a DNS resolution failure.
  55. * // We could handle it in some way, but for now we will just stop.
  56. * throw $e;
  57. * }
  58. *
  59. * @class CAS_ProxiedService_Http_Get
  60. * @category Authentication
  61. * @package PhpCAS
  62. * @author Adam Franco <afranco@middlebury.edu>
  63. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
  64. * @link https://wiki.jasig.org/display/CASC/phpCAS
  65. */
  66. class CAS_ProxiedService_Http_Get
  67. extends CAS_ProxiedService_Http_Abstract
  68. {
  69. /**
  70. * Add any other parts of the request needed by concrete classes
  71. *
  72. * @param CAS_Request_RequestInterface $request request interface
  73. *
  74. * @return void
  75. */
  76. protected function populateRequest (CAS_Request_RequestInterface $request)
  77. {
  78. // do nothing, since the URL has already been sent and that is our
  79. // only data.
  80. }
  81. }
  82. ?>