1<?php 2 3namespace Sabre\HTTP\Auth; 4 5use Sabre\HTTP\RequestInterface; 6use Sabre\HTTP\ResponseInterface; 7 8/** 9 * HTTP Authentication base class. 10 * 11 * This class provides some common functionality for the various base classes. 12 * 13 * @copyright Copyright (C) 2009-2015 fruux GmbH (https://fruux.com/). 14 * @author Evert Pot (http://evertpot.com/) 15 * @license http://sabre.io/license/ Modified BSD License 16 */ 17abstract class AbstractAuth { 18 19 /** 20 * Authentication realm 21 * 22 * @var string 23 */ 24 protected $realm; 25 26 /** 27 * Request object 28 * 29 * @var RequestInterface 30 */ 31 protected $request; 32 33 /** 34 * Response object 35 * 36 * @var ResponseInterface 37 */ 38 protected $response; 39 40 /** 41 * Creates the object 42 * 43 * @param string $realm 44 * @return void 45 */ 46 function __construct($realm = 'SabreTooth', RequestInterface $request, ResponseInterface $response) { 47 48 $this->realm = $realm; 49 $this->request = $request; 50 $this->response = $response; 51 52 } 53 54 /** 55 * This method sends the needed HTTP header and statuscode (401) to force 56 * the user to login. 57 * 58 * @return void 59 */ 60 abstract function requireLogin(); 61 62 /** 63 * Returns the HTTP realm 64 * 65 * @return string 66 */ 67 function getRealm() { 68 69 return $this->realm; 70 71 } 72 73} 74