root/trunk/src/main/php/net/stubbles/websites/processors/stubAbstractProcessor.php @ 1442

Revision 1442, 2.6 kB (checked in by mikey, 2 years ago)

refactoring #137, part 5: replaced stubAbstractPageProcessor by interface stubPageBasedProcessor

Line 
1<?php
2/**
3 * Base processor implementation.
4 *
5 * @author      Frank Kleine <mikey@stubbles.net>
6 * @package     stubbles
7 * @subpackage  websites_processors
8 */
9stubClassLoader::load('net::stubbles::websites::processors::stubProcessor',
10                      'net::stubbles::util::validators::stubEqualValidator',
11                      'net::stubbles::util::validators::stubRegexValidator'
12);
13/**
14 * Base processor implementation.
15 *
16 * @package     stubbles
17 * @subpackage  websites_processors
18 */
19abstract class stubAbstractProcessor extends stubBaseObject implements stubProcessor
20{
21    /**
22     * the request
23     *
24     * @var  stubRequest
25     */
26    protected $request;
27    /**
28     * current session
29     *
30     * @var  stubSession
31     */
32    protected $session;
33    /**
34     * the created response
35     *
36     * @var  stubResponse
37     */
38    protected $response;
39    /**
40     * the interceptor descriptor
41     *
42     * @var  string
43     */
44    protected $interceptorDescriptor = 'interceptors';
45    /**
46     * switch whether we are running in ssl mode or not
47     *
48     * @var  bool
49     */
50    private $ssl                    = null;
51
52    /**
53     * constructor
54     *
55     * @param  stubRequest   $request   the current request
56     * @param  stubSession   $session   the current session
57     * @param  stubResponse  $response  the current response
58     */
59    public function __construct(stubRequest $request, stubSession $session, stubResponse $response)
60    {
61        $this->request   = $request;
62        $this->session   = $session;
63        $this->response  = $response;
64    }
65
66    /**
67     * sets the interceptor descriptor
68     *
69     * @param  string  $interceptorDescriptor
70     */
71    public function setInterceptorDescriptor($interceptorDescriptor)
72    {
73        $this->interceptorDescriptor = $interceptorDescriptor;
74    }
75
76    /**
77     * returns the interceptor descriptor
78     *
79     * @return  string
80     */
81    public function getInterceptorDescriptor()
82    {
83        return $this->interceptorDescriptor;
84    }
85
86    /**
87     * checks whether the current request forces ssl or not
88     *
89     * @return  bool
90     */
91    public function forceSSL()
92    {
93        return false;
94    }
95
96    /**
97     * checks whether the request is ssl or not
98     *
99     * @return  bool
100     */
101    public function isSSL()
102    {
103        if (null === $this->ssl) {
104            $this->ssl = false;
105            if ($this->request->validateValue(new stubEqualValidator(443), 'SERVER_PORT', stubRequest::SOURCE_HEADER) === true) {
106                $this->ssl = true;
107            }
108        }
109       
110        return $this->ssl;
111    }
112}
113?>
Note: See TracBrowser for help on using the browser.