MsTtlsProfile::getWinlogonCred()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/* 
4
 * To change this license header, choose License Headers in Project Properties.
5
 * To change this template file, choose Tools | Templates
6
 * and open the template in the editor.
7
 */
8
9
namespace devices\ms;
10
11
class MsTtlsProfile extends MsEapProfile
12
{
13
    const MS_TTLS_NS = 'http://www.microsoft.com/provisioning/EapTtlsConnectionPropertiesV1';
14
15
    public function __construct()
16
    {
17
        $this->type = \core\common\EAP::TTLS;
18
        $this->authorId = 311;
19
    }
20
    
21
    public function getConfig()
22
    {
23
        $element = new \core\DeviceXMLmain();
24
        $element->setChild('EapTtls', $this->getEapTtls(), self::MS_TTLS_NS);
25
        return($element);
26
    }
27
    
28
    private function getEapTtls()
29
    {
30
        $element = new \core\DeviceXMLmain();
31
        $element->setChild('ServerValidation', $this->getTtlsServerValidation());
32
        $element->setChild('Phase2Authentication', $this->getPhase2Auth());
33
        $element->setChild('Phase1Identity', $this->getPhase1Identity());
34
        return($element);
35
    }
36
    
37
    private function getTtlsServerValidation()
38
    {
39
        $element = new \core\DeviceXMLmain();
40
        $element->setChild('ServerNames', $this->serverNames);
41
        $element->setChild('TrustedRootCAHash', $this->getTrustedRootCAHash());
42
        $element->setChild('DisablePrompt', 'true');
43
        return($element);
44
    }
45
    
46
    private function getTrustedRootCAHash()
47
    {
48
        $retArray = [];
49
        foreach ($this->caList as $ca) {
50
            $hash = $ca['sha1'];
51
            $retArray[] = chunk_split($hash, 2, ' ');
52
        }
53
        return($retArray);
54
    }
55
    
56
    private function getPhase2Auth() {
57
        $element = new \core\DeviceXMLmain();
58
        if ($this->innerType == \core\common\EAP::NE_MSCHAP2) {
59
            $element->setChild('MSCHAPv2Authentication', $this->getWinlogonCred());
60
        }
61
        if ($this->innerType == \core\common\EAP::NE_PAP) {
62
            $element->setChild('PAPAuthentication', '');
63
        }
64
        if ($this->innerType == \core\common\EAP::NONE) {
65
            $element->setChild('PAPAuthentication', '');
66
        }
67
        return($element);
68
    }
69
    
70
    private function getWinlogonCred() {
71
        $element = new \core\DeviceXMLmain();
72
        $element->setChild('UseWinlogonCredentials', 'false');
73
        return($element);
74
    }
75
76
    private function getPhase1Identity()
77
    {
78
        $element = new \core\DeviceXMLmain();
79
        if ($this->outerId == NULL) {
80
            $element->setChild('IdentityPrivacy', 'false');
81
        } else {
82
            $element->setChild('IdentityPrivacy', 'true');
83
            $element->setChild('AnonymousIdentity', $this->outerId);
84
        }
85
        return($element);
86
    }
87
    
88
    private function getTtlsTustedRoot($hash)
0 ignored issues
show
Unused Code introduced by
The method getTtlsTustedRoot() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
89
    {
90
        $element = new \core\DeviceXMLmain();
91
        $element->setChild('TrustedRootCAHash', chunk_split($hash, 2, ' '));
92
        return($element);
93
    }    
94
}
95