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