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

Revision 1547, 3.3 kB (checked in by mikey, 3 months ago)

refactoring #139, part 6: moved net::stubbles::util::validators to net::stubbles::ipo::request::validators

Line 
1 <?php
2 /**
3  * Base processor implementation.
4  *
5  * @author      Frank Kleine <mikey@stubbles.net>
6  * @package     stubbles
7  * @subpackage  websites_processors
8  */
9 stubClassLoader::load('net::stubbles::ipo::request::validator::stubEqualValidator',
10                       'net::stubbles::ipo::request::validator::stubRegexValidator',
11                       'net::stubbles::websites::processors::stubProcessor'
12 );
13 /**
14  * Base processor implementation.
15  *
16  * @package     stubbles
17  * @subpackage  websites_processors
18  */
19 abstract 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         $this->doConstruct();
65     }
66
67     /**
68      * optional template method to do some constructor work in derived classes
69      */
70     protected function doConstruct()
71     {
72         // intentionally empty
73     }
74
75     /**
76      * returns the request instance
77      *
78      * @return  stubRequest
79      */
80     public function getRequest()
81     {
82         return $this->request;
83     }
84
85     /**
86      * returns the session instance
87      *
88      * @return  stubSession
89      */
90     public function getSession()
91     {
92         return $this->session;
93     }
94
95     /**
96      * returns the response instance
97      *
98      * @return  stubResponse
99      */
100     public function getResponse()
101     {
102         return $this->response;
103     }
104
105     /**
106      * sets the interceptor descriptor
107      *
108      * @param  string  $interceptorDescriptor
109      */
110     public function setInterceptorDescriptor($interceptorDescriptor)
111     {
112         $this->interceptorDescriptor = $interceptorDescriptor;
113     }
114
115     /**
116      * returns the interceptor descriptor
117      *
118      * @return  string
119      */
120     public function getInterceptorDescriptor()
121     {
122         return $this->interceptorDescriptor;
123     }
124
125     /**
126      * checks whether the current request forces ssl or not
127      *
128      * @return  bool
129      */
130     public function forceSSL()
131     {
132         return false;
133     }
134
135     /**
136      * checks whether the request is ssl or not
137      *
138      * @return  bool
139      */
140     public function isSSL()
141     {
142         if (null === $this->ssl) {
143             $this->ssl = false;
144             if ($this->request->validateValue(new stubEqualValidator(443), 'SERVER_PORT', stubRequest::SOURCE_HEADER) === true) {
145                 $this->ssl = true;
146             }
147         }
148         
149         return $this->ssl;
150     }
151 }
152 ?>
Note: See TracBrowser for help on using the browser.