phpCAS::retrievePT PHP Méthode

retrievePT() public static méthode

Retrieve a Proxy Ticket from the CAS server.
public static retrievePT ( string $target_service, &$err_code, &$err_msg ) : string
$target_service string Url string of service to proxy
Résultat string Proxy Ticket
    public static function retrievePT($target_service, &$err_code, &$err_msg)
    {
        phpCAS::_validateProxyExists();
        try {
            return self::$_PHPCAS_CLIENT->retrievePT($target_service, $err_code, $err_msg);
        } catch (Exception $e) {
            phpCAS::error(get_class($e) . ': ' . $e->getMessage());
        }
    }

Usage Example

Exemple #1
0
    /**
     * Inject IMAP authentication credentials
     *
     * @param array $args arguments from rcmail
     * @return array modified arguments
     */
    function imap_connect($args) {
        // retrieve configurations
        $cfg = rcmail::get_instance()->config->all();
        
        // RoundCube is acting as CAS proxy
        if ($cfg['cas_proxy']) {
            // a proxy ticket has been retrieved, the IMAP server caches proxy tickets, and this is the first connection attempt
            if ($_SESSION['cas_pt'][php_uname('n')] && $cfg['cas_imap_caching'] && $args['attempt'] == 1) {
                // use existing proxy ticket in session
                $args['pass'] = $_SESSION['cas_pt'][php_uname('n')];
            }

            // no proxy tickets have been retrieved, the IMAP server doesn't cache proxy tickets, or the first connection attempt has failed
            else {
                // initialize CAS client
                $this->cas_init();

                // retrieve a new proxy ticket and store it in session
                if (phpCAS::forceAuthentication()) {
                    $_SESSION['cas_pt'][php_uname('n')] = phpCAS::retrievePT($cfg['cas_imap_name'], $err_code, $output);
                    $args['pass'] = $_SESSION['cas_pt'][php_uname('n')];
                }
            }
            
            // enable retry on the first connection attempt only
            if ($args['attempt'] <= 1) {
                $args['retry'] = true;
            }
        }
        $args['valid'] = true;
        return $args;
    }
All Usage Examples Of phpCAS::retrievePT