Overview

Packages

  • Auth

Classes

  • Horde_Auth
  • Horde_Auth_Auto
  • Horde_Auth_Base
  • Horde_Auth_Composite
  • Horde_Auth_Customsql
  • Horde_Auth_Cyrsql
  • Horde_Auth_Exception
  • Horde_Auth_Ftp
  • Horde_Auth_Http
  • Horde_Auth_Http_Remote
  • Horde_Auth_Imap
  • Horde_Auth_Ipbasic
  • Horde_Auth_Kolab
  • Horde_Auth_Ldap
  • Horde_Auth_Login
  • Horde_Auth_Msad
  • Horde_Auth_Pam
  • Horde_Auth_Passwd
  • Horde_Auth_Peclsasl
  • Horde_Auth_Radius
  • Horde_Auth_Shibboleth
  • Horde_Auth_Smb
  • Horde_Auth_Smbclient
  • Horde_Auth_Sql
  • Horde_Auth_Translation
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * The Horde_Auth_Http_Remote class authenticates users against a remote
 4:  * HTTP-Auth endpoint.
 5:  *
 6:  * Copyright 2007-2012 Horde LLC (http://www.horde.org/)
 7:  *
 8:  * See the enclosed file COPYING for license information (LGPL). If you did
 9:  * not receive this file, http://www.horde.org/licenses/lgpl21
10:  *
11:  * @author   Duck <duck@obala.net>
12:  * @category Horde
13:  * @license http://www.horde.org/licenses/lgpl21 LGPL-2.1
14:  * @package  Auth
15:  */
16: class Horde_Auth_Http_Remote extends Horde_Auth_Base
17: {
18:     /**
19:      * Constructor.
20:      *
21:      * @param array $params  Configuration parameters:
22:      * <pre>
23:      * 'client' - (Horde_Http_Client) [REQUIRED] TODO
24:      * 'url' - (string) [REQUIRED] TODO
25:      * </pre>
26:      *
27:      * @throws InvalidArgumentException
28:      */
29:     public function __construct(array $params = array())
30:     {
31:         if (!isset($params['url']) || !isset($params['client'])) {
32:             throw new InvalidArgumentException();
33:         }
34: 
35:         parent::__construct($params);
36:     }
37: 
38:     /**
39:      * Find out if a set of login credentials are valid.
40:      *
41:      * @param string $userId       The userId to check.
42:      * @param array  $credentials  An array of login credentials.
43:      *
44:      * @throws Horde_Auth_Exception
45:      */
46:     protected function _authenticate($userId, $credentials)
47:     {
48:         $this->_params['client']->request->username = $userId;
49:         $this->_params['client']->request->password = $credentials;
50:         $this->_params['client']->request->authenticationScheme = Horde_Http::AUTH_BASIC;
51:         $response = $this->__params['client']->get($this->_params['url']);
52:         if ($response->code != 200) {
53:             throw new Horde_Auth_Exception('', Horde_Auth::REASON_BADLOGIN);
54:         }
55:     }
56: 
57: }
58: 
API documentation generated by ApiGen