1 | <?php |
||
35 | class SecureWebRequest extends WebRequest |
||
36 | { |
||
37 | |||
38 | /** |
||
39 | * Check whether or not the current request is over a secure connection |
||
40 | * (HTTPS) |
||
41 | * |
||
42 | * @return bool true if HTTPS is on, false otherwise |
||
43 | * |
||
44 | * @author Markus Lervik <[email protected]> |
||
45 | * @author David Zülke <[email protected]> |
||
46 | * @since 0.10.0 |
||
47 | */ |
||
48 | public function isHTTPS() |
||
53 | |||
54 | /** |
||
55 | * Check if the client certificate is a valid one |
||
56 | * |
||
57 | * @return bool true if the certificate is valid, false otherwise |
||
58 | * |
||
59 | * @author Markus Lervik <[email protected]> |
||
60 | * @author David Zülke <[email protected]> |
||
61 | * @since 0.10.0 |
||
62 | */ |
||
63 | public function hasValidClientCert() |
||
68 | |||
69 | // ------------------------------------------------------------------------- |
||
70 | |||
71 | /** |
||
72 | * Get the client CN (Common Name) field from the client X.509 certificate |
||
73 | * if one is available |
||
74 | * |
||
75 | * @return mixed the CN field if it's available, otherwise null |
||
76 | * |
||
77 | * @author Markus Lervik <[email protected]> |
||
78 | * @author David Zülke <[email protected]> |
||
79 | * @since 0.10.0 |
||
80 | */ |
||
81 | public function getClientCertCN() |
||
88 | |||
89 | // ------------------------------------------------------------------------- |
||
90 | |||
91 | /** |
||
92 | * Get the client DN (Distinguished Name) field from the client X.509 |
||
93 | * certificate if one is available |
||
94 | * |
||
95 | * @return mixed the DN field if it's available, otherwise null |
||
96 | * |
||
97 | * @author Markus Lervik <[email protected]> |
||
98 | * @author David Zülke <[email protected]> |
||
99 | * @since 0.10.0 |
||
100 | */ |
||
101 | public function getClientCertDN() |
||
108 | |||
109 | /** |
||
110 | * Get the client GN (General Name) field from the client X.509 certificate |
||
111 | * if one is available |
||
112 | * |
||
113 | * @return mixed the GN field if it's available, otherwise null |
||
114 | * |
||
115 | * @author Markus Lervik <[email protected]> |
||
116 | * @author David Zülke <[email protected]> |
||
117 | * @since 0.10.0 |
||
118 | */ |
||
119 | public function getClientCertGN() |
||
126 | |||
127 | /** |
||
128 | * Get the client SN (Subject Name) field from the client X.509 certificate |
||
129 | * if one is available |
||
130 | * |
||
131 | * @return mixed the SN field if it's available, otherwise null |
||
132 | * |
||
133 | * @author Markus Lervik <[email protected]> |
||
134 | * @author David Zülke <[email protected]> |
||
135 | * @since 0.10.0 |
||
136 | */ |
||
137 | public function getClientCertSN() |
||
144 | |||
145 | /** |
||
146 | * Get the client O (Organisation) field from the client X.509 certificate |
||
147 | * if one is available |
||
148 | * |
||
149 | * @return mixed the O field if it's available, otherwise null |
||
150 | * |
||
151 | * @author Markus Lervik <[email protected]> |
||
152 | * @author David Zülke <[email protected]> |
||
153 | * @since 0.10.0 |
||
154 | */ |
||
155 | public function getClientCertO() |
||
162 | |||
163 | /** |
||
164 | * Get the client OU (Organisation Unit) field from the client X.509 |
||
165 | * certificate if one is available |
||
166 | * |
||
167 | * @return mixed the OU field if it's available, otherwise null |
||
168 | * |
||
169 | * @author Markus Lervik <[email protected]> |
||
170 | * @author David Zülke <[email protected]> |
||
171 | * @since 0.10.0 |
||
172 | */ |
||
173 | public function getClientCertOU() |
||
180 | |||
181 | /** |
||
182 | * Get the date from which the client certificate is valid |
||
183 | * if one is available |
||
184 | * |
||
185 | * @return mixed the date field if it's available, otherwise null |
||
186 | * |
||
187 | * @author Markus Lervik <[email protected]> |
||
188 | * @author David Zülke <[email protected]> |
||
189 | * @since 0.10.0 |
||
190 | */ |
||
191 | public function getClientCertValidityStart() |
||
198 | |||
199 | /** |
||
200 | * Get the date until which the client certificate is valid |
||
201 | * if one is available |
||
202 | * |
||
203 | * @return mixed the date field if it's available, otherwise null |
||
204 | * @author Markus Lervik <[email protected]> |
||
205 | * @author David Zülke <[email protected]> |
||
206 | * @since 0.10.0 |
||
207 | */ |
||
208 | public function getClientCertValidityEnd() |
||
215 | |||
216 | /** |
||
217 | * Get the cipher type used for this connection |
||
218 | * if one is available |
||
219 | * |
||
220 | * @return mixed the cipher type if it's available, otherwise null |
||
221 | * @author Markus Lervik <[email protected]> |
||
222 | * @author David Zülke <[email protected]> |
||
223 | * @since 0.10.0 |
||
224 | */ |
||
225 | public function getSSLChipherType() |
||
232 | |||
233 | /** |
||
234 | * Get the issuer DN (Distinguished Name) field from the issuer X.509 |
||
235 | * certificate if one is available |
||
236 | * |
||
237 | * @return mixed the DN field if it's available, otherwise null |
||
238 | * @author Markus Lervik <[email protected]> |
||
239 | * @author David Zülke <[email protected]> |
||
240 | * @since 0.10.0 |
||
241 | */ |
||
242 | public function getIssuerCertDN() |
||
249 | |||
250 | /** |
||
251 | * Get the issuer CN (Common Name) field from the issuer X.509 certificate |
||
252 | * if one is available |
||
253 | * |
||
254 | * @return mixed the CN field if it's available, otherwise null |
||
255 | * @author Markus Lervik <[email protected]> |
||
256 | * @author David Zülke <[email protected]> |
||
257 | * @since 0.10.0 |
||
258 | */ |
||
259 | public function getIssuerCertCN() |
||
266 | |||
267 | /** |
||
268 | * Get the issuer C (Country) field from the issuer X.509 certificate |
||
269 | * if one is available |
||
270 | * |
||
271 | * @return mixed the C field if it's available, otherwise null |
||
272 | * @author Markus Lervik <[email protected]> |
||
273 | * @author David Zülke <[email protected]> |
||
274 | * @since 0.10.0 |
||
275 | */ |
||
276 | public function getIssuerCertC() |
||
283 | |||
284 | /** |
||
285 | * Get the issuer O (Organisation) field from the issuer X.509 certificate |
||
286 | * if one is available |
||
287 | * |
||
288 | * @return mixed the O field if it's available, otherwise null |
||
289 | * @author Markus Lervik <[email protected]> |
||
290 | * @author David Zülke <[email protected]> |
||
291 | * @since 0.10.0 |
||
292 | */ |
||
293 | public function getIssuerCertO() |
||
300 | |||
301 | /** |
||
302 | * Get the issuer OU (Organisation Unit) field from the issuer X.509 |
||
303 | * certificate if one is available |
||
304 | * |
||
305 | * @return mixed the OU field if it's available, otherwise null |
||
306 | * @author Markus Lervik <[email protected]> |
||
307 | * @author David Zülke <[email protected]> |
||
308 | * @since 0.10.0 |
||
309 | */ |
||
310 | public function getIssuerCertOU() |
||
317 | |||
318 | /** |
||
319 | * Get the issuer ST (State) field from the issuer X.509 certificate |
||
320 | * if one is available |
||
321 | * |
||
322 | * @return mixed the ST field if it's available, otherwise null |
||
323 | * @author Markus Lervik <[email protected]> |
||
324 | * @author David Zülke <[email protected]> |
||
325 | * @since 0.10.0.0 |
||
326 | */ |
||
327 | public function getIssuerCertST() |
||
334 | } |
||
335 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: