ModuleOptions.php 3.35 KB
Newer Older
Bertrand Gauthier's avatar
Bertrand Gauthier committed
1
<?php
2

Bertrand Gauthier's avatar
Bertrand Gauthier committed
3
4
5
6
namespace UnicaenAuth\Options;

/**
 * Classe encapsulant les options de fonctionnement du module.
7
 *
Bertrand Gauthier's avatar
Bertrand Gauthier committed
8
9
 * @author Bertrand GAUTHIER <bertrand.gauthier@unicaen.fr>
 */
10
class ModuleOptions extends \ZfcUser\Options\ModuleOptions
Bertrand Gauthier's avatar
Bertrand Gauthier committed
11
12
{
    /**
13
     * @var array
Bertrand Gauthier's avatar
Bertrand Gauthier committed
14
     */
15
    protected $usurpationAllowedUsernames = [];
Bertrand Gauthier's avatar
Bertrand Gauthier committed
16
17
18
19
20
21

    /**
     * @var bool
     */
    protected $saveLdapUserInDatabase = false;

22
23
24
25
26
    /**
     * @var string
     */
    protected $ldapUsername;

27
28
29
30
31
    /**
     * @var array
     */
    protected $shibboleth = [];

Bertrand Gauthier's avatar
Bertrand Gauthier committed
32
33
34
    /**
     * @var array
     */
35
    protected $cas = [];
Bertrand Gauthier's avatar
Bertrand Gauthier committed
36

37
38
39
40
    /**
     * @var string
     */
    protected $entityManagerName = 'doctrine.entitymanager.orm_default';
41

Bertrand Gauthier's avatar
Bertrand Gauthier committed
42
    /**
43
     * set usernames allowed to make usurpation
44
     *
45
     * @param array $usurpationAllowedUsernames
46
     *
Bertrand Gauthier's avatar
Bertrand Gauthier committed
47
48
     * @return ModuleOptions
     */
49
    public function setUsurpationAllowedUsernames(array $usurpationAllowedUsernames = [])
Bertrand Gauthier's avatar
Bertrand Gauthier committed
50
    {
51
        $this->usurpationAllowedUsernames = $usurpationAllowedUsernames;
52

Bertrand Gauthier's avatar
Bertrand Gauthier committed
53
54
55
56
        return $this;
    }

    /**
57
     * get usernames allowed to make usurpation
58
     *
59
     * @return array
Bertrand Gauthier's avatar
Bertrand Gauthier committed
60
     */
61
    public function getUsurpationAllowedUsernames()
Bertrand Gauthier's avatar
Bertrand Gauthier committed
62
    {
63
        return $this->usurpationAllowedUsernames;
Bertrand Gauthier's avatar
Bertrand Gauthier committed
64
    }
65

Bertrand Gauthier's avatar
Bertrand Gauthier committed
66
67
68
69
70
    /**
     * Spécifie si l'utilisateur authentifié doit être enregistré dans la base
     * de données de l'appli
     *
     * @param bool $flag
71
     *
Bertrand Gauthier's avatar
Bertrand Gauthier committed
72
73
74
75
     * @return ModuleOptions
     */
    public function setSaveLdapUserInDatabase($flag = true)
    {
76
77
        $this->saveLdapUserInDatabase = (bool)$flag;

Bertrand Gauthier's avatar
Bertrand Gauthier committed
78
79
        return $this;
    }
80

Bertrand Gauthier's avatar
Bertrand Gauthier committed
81
    /**
82
     * Retourne la valeur du flag spécifiant si l'utilisateur authentifié doit être
Bertrand Gauthier's avatar
Bertrand Gauthier committed
83
84
85
86
87
88
89
90
     * enregistré dans la base de données de l'appli
     *
     * @return bool
     */
    public function getSaveLdapUserInDatabase()
    {
        return $this->saveLdapUserInDatabase;
    }
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117



    /**
     * @return string
     */
    public function getLdapUsername()
    {
        return $this->ldapUsername;
    }



    /**
     * @param string $ldapUsername
     *
     * @return ModuleOptions
     */
    public function setLdapUsername($ldapUsername)
    {
        $this->ldapUsername = $ldapUsername;

        return $this;
    }



Bertrand Gauthier's avatar
Bertrand Gauthier committed
118
    /**
Bertrand Gauthier's avatar
Bertrand Gauthier committed
119
     * set cas connection params
Bertrand Gauthier's avatar
Bertrand Gauthier committed
120
     *
Bertrand Gauthier's avatar
Bertrand Gauthier committed
121
     * @param array $cas
122
     *
Bertrand Gauthier's avatar
Bertrand Gauthier committed
123
124
     * @return ModuleOptions
     */
125
    public function setCas(array $cas = [])
Bertrand Gauthier's avatar
Bertrand Gauthier committed
126
    {
Bertrand Gauthier's avatar
Bertrand Gauthier committed
127
        $this->cas = $cas;
128

Bertrand Gauthier's avatar
Bertrand Gauthier committed
129
130
        return $this;
    }
131

Bertrand Gauthier's avatar
Bertrand Gauthier committed
132
    /**
Bertrand Gauthier's avatar
Bertrand Gauthier committed
133
     * get cas connection params
Bertrand Gauthier's avatar
Bertrand Gauthier committed
134
135
136
     *
     * @return array
     */
Bertrand Gauthier's avatar
Bertrand Gauthier committed
137
    public function getCas()
Bertrand Gauthier's avatar
Bertrand Gauthier committed
138
    {
Bertrand Gauthier's avatar
Bertrand Gauthier committed
139
        return $this->cas;
Bertrand Gauthier's avatar
Bertrand Gauthier committed
140
    }
141

142
143
144
145
146
147
148
149
150
151
    /**
     * set shibboleth connection params
     *
     * @param array $shibboleth
     *
     * @return ModuleOptions
     */
    public function setShibboleth(array $shibboleth = [])
    {
        $this->shibboleth = $shibboleth;
152

153
154
        return $this;
    }
155

156
157
158
159
160
161
162
163
164
    /**
     * get shibboleth connection params
     *
     * @return array
     */
    public function getShibboleth()
    {
        return $this->shibboleth;
    }
165

166
167
168
169
170
171
172
    /**
     * @return string
     */
    public function getEntityManagerName()
    {
        return $this->entityManagerName;
    }
173

174
175
176
177
178
179
180
181
182
183
184
    /**
     * @param string $entityManagerName
     *
     * @return ModuleOptions
     */
    public function setEntityManagerName($entityManagerName)
    {
        $this->entityManagerName = $entityManagerName;

        return $this;
    }
Bertrand Gauthier's avatar
Bertrand Gauthier committed
185
}