Skip to content
Snippets Groups Projects
Select Git revision
  • 7ceb3cb62a480d2764d386abae18f25bcb831c84
  • 3.9 default
  • develop
  • 6.0
  • 5.0
  • 4.0
  • scrutinizer-patch-4
  • scrutinizer-patch-3
  • scrutinizer-patch-2
  • scrutinizer-patch-1
  • 3.7
  • 3.8
  • 3.6
  • 3.9_backported
  • 3.8_backported
  • 3.7_backported
  • 3.5
  • 3.6_backported
  • 3.5_backported
  • 3.4
  • 3.3_backported
  • 6.0.4
  • 6.0.3
  • 5.0.7
  • 6.0.2
  • 6.0.1
  • 5.0.6
  • 6.0.0
  • 5.0.5
  • 6.0.0-rc
  • 5.0.4
  • 6.0.0-beta
  • 5.0.3
  • 4.0.6
  • 5.0.2
  • 5.0.1
  • 4.0.5
  • 5.0.0
  • 4.0.4
  • 5.0.0-rc2
  • 5.0.0-rc1
41 results

tcpdi_parser.php

Blame
  • Version2.php 2.75 KiB
    <?php
    /**
     * Class representing a CAS server which supports the CAS2 protocol.
     *
     * PHP version 5
     *
     * @category  Authentication
     * @package   SimpleCAS
     * @author    Brett Bieber <brett.bieber@gmail.com>
     * @copyright 2008 Regents of the University of Nebraska
     * @license   http://www1.unl.edu/wdn/wiki/Software_License BSD License
     * @link      http://code.google.com/p/simplecas/
     */
    class SimpleCAS_Protocol_Version2 extends SimpleCAS_Protocol_Version1 implements SimpleCAS_SingleSignOut, SimpleCAS_ProxyGranting
    {
        const VERSION = '2.0';
        
        /**
         * Returns the URL used to validate a ticket.
         *
         * @param string $ticket  Ticket to validate
         * @param string $service URL to the service requesting authentication
         *
         * @return string
         */
        function getValidationURL($ticket, $service, $pgtUrl = null)
        {
            return 'https://' . $this->hostname . '/'
                              . $this->uri . '/serviceValidate?'
                              . 'service=' . urlencode($service)
                              . '&ticket=' . $ticket
                              . '&pgtUrl=' . urlencode($pgtUrl);
        }
        
        /**
         * Function to validate a ticket and service combination.
         *
         * @param string $ticket  Ticket given by the CAS Server
         * @param string $service Service requesting authentication
         *
         * @return false|string False on failure, user name on success.
         */
        function validateTicket($ticket, $service)
        {
            $validation_url = $this->getValidationURL($ticket, $service);
            
            $http_request = clone $this->getRequest();
            
            $defaultClass = SimpleCAS_Protocol::DEFAULT_REQUEST_CLASS;
            if ($http_request instanceof $defaultClass) {
                $http_request->setURL($validation_url);
                
                $response = $http_request->send();
            } else {
                $http_request->setUri($validation_url);
                
                $response = $http_request->request();
            }
            
            if ($response->getStatus() == 200) {
                $validationResponse = new SimpleCAS_Protocol_Version2_ValidationResponse($response->getBody());
                if ($validationResponse->authenticationSuccess()) {
                    return $validationResponse->__toString();
                }
            }
            return false;
        }
        
        /**
         * Validates a single sign out logout request.
         *
         * @param mixed $post $_POST data
         *
         * @return bool
         */
        function validateLogoutRequest($post)
        {
            if (false) {
                return $ticket;
            }
            return false;
        }
        
        function getProxyTicket()
        {
            throw new Exception('not implemented');
        }
        
        function validateProxyTicket($ticket)
        {
            throw new Exception('not implemented');
        }
    }
    ?>