getErrorsPageTemplatePath()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * \AppserverIo\Appserver\Core\ServerNodeConfiguration
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Johann Zelger <[email protected]>
15
 * @copyright 2015 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/appserver-io/appserver
18
 * @link      http://www.appserver.io
19
 */
20
21
namespace AppserverIo\Appserver\Core;
22
23
use AppserverIo\Appserver\Core\Utilities\SslOptionKeys;
24
use AppserverIo\Appserver\Core\Api\Node\ServerNodeInterface;
25
use AppserverIo\Server\Interfaces\ServerConfigurationInterface;
26
27
/**
28
 * Wrapper for the sever node passed from the appserver-io-psr/server package.
29
 *
30
 * @author    Johann Zelger <[email protected]>
31
 * @copyright 2015 TechDivision GmbH <[email protected]>
32
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
33
 * @link      https://github.com/appserver-io/appserver
34
 * @link      http://www.appserver.io
35
 */
36
class ServerNodeConfiguration implements ServerConfigurationInterface
37
{
38
39
    /**
40
     * The server node instance.
41
     *
42
     * @var \AppserverIo\Appserver\Core\Api\Node\ServerNodeInterface
43
     */
44
    protected $node;
45
46
    /**
47
     * The analytics array.
48
     *
49
     * @var array
50
     */
51
    protected $analytics;
52
53
    /**
54
     * The headers array.
55
     *
56
     * @var array
57
     */
58
    protected $headers;
59
60
    /**
61
     * The handlers array.
62
     *
63
     * @var array
64
     */
65
    protected $handlers;
66
67
    /**
68
     * Hold's the connection handler array
69
     *
70
     * @var array
71
     */
72
    protected $connectionHandlers;
73
74
    /**
75
     * The virtual hosts array.
76
     *
77
     * @var array
78
     */
79
    protected $virtualHosts;
80
81
    /**
82
     * The authentications array.
83
     *
84
     * @var array
85
     */
86
    protected $authentications;
87
88
    /**
89
     * The modules array.
90
     *
91
     * @var array
92
     */
93
    protected $modules;
94
95
    /**
96
     * The rewrites array.
97
     *
98
     * @var array
99
     */
100
    protected $rewrites;
101
102
    /**
103
     * The array with the rewrite maps.
104
     *
105
     * @var array
106
     */
107
    protected $rewriteMaps;
108
109
    /**
110
     * The accesses array.
111
     *
112
     * @var array
113
     */
114
    protected $accesses;
115
116
    /**
117
     * The environmentVariables array.
118
     *
119
     * @var array
120
     */
121
    protected $environmentVariables;
122
123
    /**
124
     * The locations array.
125
     *
126
     * @var array
127
     */
128
    protected $locations;
129
130
    /**
131
     * Initializes the configuration with the values found in
132
     * the passed server configuration node.
133
     *
134
     * @param \AppserverIo\Appserver\Core\Api\Node\ServerNodeInterface $node The server node instance
135
     */
136 35
    public function __construct(ServerNodeInterface $node)
137
    {
138
139
        // set the node itself
140 35
        $this->node = $node;
141
142
        // pre-load the nodes data
143 35
        $this->analytics = $node->getAnalyticsAsArray();
144 35
        $this->virtualHosts = $node->getVirtualHostsAsArray();
145 35
        $this->handlers = $node->getFileHandlersAsArray();
146 35
        $this->headers = $node->getHeadersAsArray();
0 ignored issues
show
Bug introduced by
The method getHeadersAsArray() does not exist on AppserverIo\Appserver\Co...ode\ServerNodeInterface. Did you maybe mean getHeaders()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

146
        /** @scrutinizer ignore-call */ 
147
        $this->headers = $node->getHeadersAsArray();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
147 35
        $this->connectionHandlers = $node->getConnectionHandlersAsArray();
148 35
        $this->authentications = $node->getAuthenticationsAsArray();
149 35
        $this->rewrites = $node->getRewritesAsArray();
150 35
        $this->rewriteMaps = $node->getRewriteMapsAsArray();
151 35
        $this->accesses = $node->getAccessesAsArray();
152 35
        $this->environmentVariables = $node->getEnvironmentVariablesAsArray();
153 35
        $this->locations = $node->getLocationsAsArray();
154 35
        $this->certificates = $node->getCertificatesAsArray();
0 ignored issues
show
Bug Best Practice introduced by
The property certificates does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
155
156
        // modules can have params, so not make them flat
157 35
        $this->modules = $node->getModules();
158 35
    }
159
160
    /**
161
     * Returns analytics
162
     *
163
     * @return string
164
     */
165 1
    public function getAnalytics()
166
    {
167 1
        return $this->analytics;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->analytics returns the type array which is incompatible with the documented return type string.
Loading history...
168
    }
169
170
    /**
171
     * Returns the username we want to execute the processes with.
172
     *
173
     * @return string
174
     */
175 1
    public function getUser()
176
    {
177 1
        return $this->node->getParam('user');
178
    }
179
180
    /**
181
     * Returns the groupname we want to execute the processes with.
182
     *
183
     * @return string
184
     */
185 1
    public function getGroup()
186
    {
187 1
        return $this->node->getParam('group');
188
    }
189
190
    /**
191
     * Returns the server socket flags.
192
     *
193
     * @return string
194
     */
195
    public function getFlags()
196
    {
197
        return $this->node->getParam('flags');
198
    }
199
200
    /**
201
     * Returns type
202
     *
203
     * @return string
204
     */
205 1
    public function getType()
206
    {
207 1
        return $this->node->getType();
208
    }
209
210
    /**
211
     * Returns logger name
212
     *
213
     * @return string
214
     */
215 1
    public function getLoggerName()
216
    {
217 1
        return $this->node->getLoggerName();
218
    }
219
220
    /**
221
     * Returns servers name
222
     *
223
     * @return string
224
     */
225 1
    public function getName()
226
    {
227 1
        return $this->node->getName();
228
    }
229
230
    /**
231
     * Returns transport
232
     *
233
     * @return string
234
     */
235 1
    public function getTransport()
236
    {
237 1
        return $this->node->getParam('transport');
238
    }
239
240
    /**
241
     * Returns address
242
     *
243
     * @return string
244
     */
245 1
    public function getAddress()
246
    {
247 1
        return $this->node->getParam('address');
248
    }
249
250
    /**
251
     * Returns port
252
     *
253
     * @return int
254
     */
255 1
    public function getPort()
256
    {
257 1
        return $this->node->getParam('port');
258
    }
259
260
    /**
261
     * Returns software
262
     *
263
     * @return string
264
     */
265 1
    public function getSoftware()
266
    {
267 1
        return $this->node->getParam('software');
268
    }
269
270
    /**
271
     * Returns admin
272
     *
273
     * @return string
274
     */
275 1
    public function getAdmin()
276
    {
277 1
        return $this->node->getParam('admin');
278
    }
279
280
    /**
281
     * Returns keep-alive max connection
282
     *
283
     * @return int
284
     */
285 1
    public function getKeepAliveMax()
286
    {
287 1
        return (int)$this->node->getParam('keepAliveMax');
288
    }
289
290
    /**
291
     * Returns keep-alive timeout
292
     *
293
     * @return int
294
     */
295 1
    public function getKeepAliveTimeout()
296
    {
297 1
        return (int)$this->node->getParam('keepAliveTimeout');
298
    }
299
300
    /**
301
     * Returns template file path for errors page
302
     *
303
     * @return string
304
     */
305 1
    public function getErrorsPageTemplatePath()
306
    {
307 1
        return (string)$this->node->getParam('errorsPageTemplatePath');
308
    }
309
310
    /**
311
     * Returns template path for possible configured welcome page
312
     *
313
     * @return string
314
     */
315
    public function getWelcomePageTemplatePath()
316
    {
317
        return (string)$this->node->getParam('welcomePageTemplatePath');
318
    }
319
320
    /**
321
     * Returns template path for possible configured auto index page
322
     *
323
     * @return string
324
     */
325
    public function getAutoIndexTemplatePath()
326
    {
327
        return (string)$this->node->getParam('autoIndexTemplatePath');
328
    }
329
330
    /**
331
     * Returns worker number
332
     *
333
     * @return int
334
     */
335 1
    public function getWorkerNumber()
336
    {
337 1
        return $this->node->getParam('workerNumber');
338
    }
339
340
    /**
341
     * Returns worker's accept min count
342
     *
343
     * @return int
344
     */
345 1
    public function getWorkerAcceptMin()
346
    {
347 1
        return $this->node->getParam('workerAcceptMin');
348
    }
349
350
    /**
351
     * Returns worker's accept max count
352
     *
353
     * @return int
354
     */
355 1
    public function getWorkerAcceptMax()
356
    {
357 1
        return $this->node->getParam('workerAcceptMax');
358
    }
359
360
    /**
361
     * Returns the auto index configuration
362
     *
363
     * @return boolean
364
     */
365
    public function getAutoIndex()
366
    {
367
        return $this->node->getParam('autoIndex');
368
    }
369
370
    /**
371
     * Returns context type
372
     *
373
     * @return string
374
     */
375 1
    public function getServerContextType()
376
    {
377 1
        return $this->node->getServerContext();
378
    }
379
380
    /**
381
     * Returns request type
382
     *
383
     * @return string
384
     */
385 1
    public function getRequestContextType()
386
    {
387 1
        return $this->node->getRequestContext();
388
    }
389
390
    /**
391
     * Returns socket type
392
     *
393
     * @return string
394
     */
395 1
    public function getSocketType()
396
    {
397 1
        return $this->node->getSocket();
398
    }
399
400
    /**
401
     * Returns worker type
402
     *
403
     * @return string
404
     */
405 1
    public function getWorkerType()
406
    {
407 1
        return $this->node->getWorker();
408
    }
409
410
    /**
411
     * Returns document root
412
     *
413
     * @return string
414
     */
415 1
    public function getDocumentRoot()
416
    {
417 1
        return $this->node->getParam('documentRoot');
418
    }
419
420
    /**
421
     * Returns directory index definition
422
     *
423
     * @return string
424
     */
425 1
    public function getDirectoryIndex()
426
    {
427 1
        return $this->node->getParam('directoryIndex');
428
    }
429
430
    /**
431
     * Returns cert path
432
     *
433
     * @return string
434
     */
435 1
    public function getCertPath()
436
    {
437 1
        return $this->node->getParam(SslOptionKeys::CERT_PATH);
438
    }
439
440
    /**
441
     * Returns passphrase
442
     *
443
     * @return string
444
     */
445 1
    public function getPassphrase()
446
    {
447 1
        return $this->node->getParam(SslOptionKeys::PASSPHRASE);
448
    }
449
450
    /**
451
     * Returns DH param path
452
     *
453
     * @return string
454
     */
455
    public function getDhParamPath()
456
    {
457
        return $this->node->getParam(SslOptionKeys::DH_PARAM_PATH);
458
    }
459
460
    /**
461
     * Return's private key path
462
     *
463
     * @return string
464
     */
465
    public function getPrivateKeyPath()
466
    {
467
        return $this->node->getParam(SslOptionKeys::PRIVATE_KEY_PATH);
468
    }
469
470
    /**
471
     * Return's the crypto method to use
472
     *
473
     * @return string
474
     */
475
    public function getCryptoMethod()
476
    {
477
        return $this->node->getParam(SslOptionKeys::CRYPTO_METHOD);
478
    }
479
480
    /**
481
     * Return's the peer name to be used, if this value is not set, then the name is guessed based on the hostname used when opening the stream
482
     *
483
     * @return string
484
     */
485
    public function getPeerName()
486
    {
487
        return $this->node->getParam(SslOptionKeys::PEER_NAME);
488
    }
489
490
    /**
491
     * Return's TRUE it the verification of use SSL certificate has to be required
492
     *
493
     * @return boolean
494
     */
495
    public function getVerifyPeer()
496
    {
497
        return $this->node->getParam(SslOptionKeys::VERIFY_PEER);
498
    }
499
500
    /**
501
     * Return's TRUE it the peer name has to be verified
502
     *
503
     * @return boolean
504
     */
505
    public function getVerifyPeerName()
506
    {
507
        return $this->node->getParam(SslOptionKeys::VERIFY_PEER_NAME);
508
    }
509
510
    /**
511
     * Return's TRUE to disable TLS compression. This can help mitigate the CRIME attack vector
512
     *
513
     * @return boolean
514
     */
515
    public function getDisableCompression()
516
    {
517
        return $this->node->getParam(SslOptionKeys::DISABLE_COMPRESSION);
518
    }
519
520
    /**
521
     * Return's TRUE if self-signed certificates has to be allowed, but requires verify_peer to be FALSE
522
     *
523
     * @return boolean
524
     */
525
    public function getAllowSelfSigned()
526
    {
527
        return $this->node->getParam(SslOptionKeys::ALLOW_SELF_SIGNED);
528
    }
529
530
    /**
531
     * Return's TRUE if control cipher ordering preferences during negotiation has to be allowed
532
     *
533
     * @return boolean
534
     */
535
    public function getHonorCipherOrder()
536
    {
537
        return $this->node->getParam(SslOptionKeys::HONOR_CIPHER_ORDER);
538
    }
539
540
    /**
541
     * Return's the curve to use with ECDH ciphers, if not specified prime256v1 will be used
542
     *
543
     * @return string
544
     */
545
    public function getEcdhCurve()
546
    {
547
        return $this->node->getParam(SslOptionKeys::ECDH_CURVE);
548
    }
549
550
    /**
551
     * Return's TRUE if a new key pair has to be created in scenarios where ECDH cipher suites are negotiated (instead of the preferred ECDHE ciphers)
552
     *
553
     * @return boolean
554
     */
555
    public function getSingleEcdhUse()
556
    {
557
        return $this->node->getParam(SslOptionKeys::SINGLE_ECDH_USE);
558
    }
559
560
    /**
561
     * Return's TRUE if new key pair has to be created created when using DH parameters (improves forward secrecy)
562
     *
563
     * @return boolean
564
     */
565
    public function getSingleDhUse()
566
    {
567
        return $this->node->getParam(SslOptionKeys::SINGLE_DH_USE);
568
    }
569
570
    /**
571
     * Return's the list of available ciphers.
572
     *
573
     * @return string
574
     * @link http://php.net/manual/en/context.ssl.php#context.ssl.ciphers
575
     * @link https://www.openssl.org/docs/manmaster/apps/ciphers.html#CIPHER_LIST_FORMAT
576
     */
577
    public function getCiphers()
578
    {
579
        return $this->node->getParam(SslOptionKeys::CIPHERS);
580
    }
581
582
    /**
583
     * Returns connection handlers
584
     *
585
     * @return array
586
     */
587 1
    public function getConnectionHandlers()
588
    {
589 1
        return $this->connectionHandlers;
590
    }
591
592
    /**
593
     * Returns modules
594
     *
595
     * @return array
596
     */
597 1
    public function getModules()
598
    {
599 1
        return $this->modules;
600
    }
601
602
    /**
603
     * Returns handlers
604
     *
605
     * @return array
606
     */
607 1
    public function getHandlers()
608
    {
609 1
        return $this->handlers;
610
    }
611
612
    /**
613
     * Returns headers
614
     *
615
     * @return array
616
     */
617
    public function getHeaders()
618
    {
619
        return $this->headers;
620
    }
621
622
    /**
623
     * Returns virtual hosts
624
     *
625
     * @return array
626
     */
627 1
    public function getVirtualHosts()
628
    {
629 1
        return $this->virtualHosts;
630
    }
631
632
    /**
633
     * Returns the authentication configuration.
634
     *
635
     * @return array The array with the authentication configuration
636
     */
637 1
    public function getAuthentications()
638
    {
639 1
        return $this->authentications;
640
    }
641
642
    /**
643
     * Returns the rewrite configuration.
644
     *
645
     * @return array
646
     */
647 1
    public function getRewrites()
648
    {
649 1
        return $this->rewrites;
650
    }
651
652
    /**
653
     * Returns the access configuration.
654
     *
655
     * @return array
656
     */
657 1
    public function getAccesses()
658
    {
659 1
        return $this->accesses;
660
    }
661
662
    /**
663
     * Returns the environment variable configuration
664
     *
665
     * @return array
666
     */
667 1
    public function getEnvironmentVariables()
668
    {
669 1
        return $this->environmentVariables;
670
    }
671
672
    /**
673
     * Returns the locations.
674
     *
675
     * @return array
676
     */
677 1
    public function getLocations()
678
    {
679 1
        return $this->locations;
680
    }
681
682
    /**
683
     * Returns the locations.
684
     *
685
     * @return array
686
     */
687 1
    public function getRewriteMaps()
688
    {
689 1
        return $this->rewriteMaps;
690
    }
691
692
    /**
693
     * Returns stream context type
694
     *
695
     * @return string
696
     */
697
    public function getStreamContextType()
698
    {
699
        return $this->node->getStreamContext();
700
    }
701
702
    /**
703
     * Returns the certificates used by the server
704
     *
705
     * @return array
706
     */
707
    public function getCertificates()
708
    {
709
        return $this->certificates;
710
    }
711
}
712