Filename | /var/www/foswikidev/core/lib/Foswiki/Users/Password.pm |
Statements | Executed 16 statements in 533µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 15µs | 28µs | BEGIN@17 | Foswiki::Users::Password::
1 | 1 | 1 | 10µs | 10µs | new | Foswiki::Users::Password::
1 | 1 | 1 | 10µs | 14µs | BEGIN@18 | Foswiki::Users::Password::
1 | 1 | 1 | 9µs | 34µs | BEGIN@19 | Foswiki::Users::Password::
1 | 1 | 1 | 7µs | 7µs | finish | Foswiki::Users::Password::
1 | 1 | 1 | 4µs | 4µs | BEGIN@21 | Foswiki::Users::Password::
1 | 1 | 1 | 1µs | 1µs | readOnly | Foswiki::Users::Password::
0 | 0 | 0 | 0s | 0s | canFetchUsers | Foswiki::Users::Password::
0 | 0 | 0 | 0s | 0s | checkPassword | Foswiki::Users::Password::
0 | 0 | 0 | 0s | 0s | encrypt | Foswiki::Users::Password::
0 | 0 | 0 | 0s | 0s | error | Foswiki::Users::Password::
0 | 0 | 0 | 0s | 0s | fetchPass | Foswiki::Users::Password::
0 | 0 | 0 | 0s | 0s | fetchUsers | Foswiki::Users::Password::
0 | 0 | 0 | 0s | 0s | findUserByEmail | Foswiki::Users::Password::
0 | 0 | 0 | 0s | 0s | getEmails | Foswiki::Users::Password::
0 | 0 | 0 | 0s | 0s | isManagingEmails | Foswiki::Users::Password::
0 | 0 | 0 | 0s | 0s | removeUser | Foswiki::Users::Password::
0 | 0 | 0 | 0s | 0s | setEmails | Foswiki::Users::Password::
0 | 0 | 0 | 0s | 0s | setPassword | Foswiki::Users::Password::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # See bottom of file for license and copyright information | ||||
2 | |||||
3 | =begin TML | ||||
4 | |||||
5 | ---+ package Foswiki::Users::Password | ||||
6 | |||||
7 | Base class of all password handlers. Default behaviour is no passwords, | ||||
8 | so anyone can be anyone they like. | ||||
9 | |||||
10 | The methods of this class should be overridded by subclasses that want | ||||
11 | to implement other password handling methods. | ||||
12 | |||||
13 | =cut | ||||
14 | |||||
15 | package Foswiki::Users::Password; | ||||
16 | |||||
17 | 2 | 28µs | 2 | 42µs | # spent 28µs (15+14) within Foswiki::Users::Password::BEGIN@17 which was called:
# once (15µs+14µs) by Foswiki::Users::TopicUserMapping::new at line 17 # spent 28µs making 1 call to Foswiki::Users::Password::BEGIN@17
# spent 14µs making 1 call to strict::import |
18 | 2 | 23µs | 2 | 18µs | # spent 14µs (10+4) within Foswiki::Users::Password::BEGIN@18 which was called:
# once (10µs+4µs) by Foswiki::Users::TopicUserMapping::new at line 18 # spent 14µs making 1 call to Foswiki::Users::Password::BEGIN@18
# spent 4µs making 1 call to warnings::import |
19 | 2 | 46µs | 2 | 59µs | # spent 34µs (9+25) within Foswiki::Users::Password::BEGIN@19 which was called:
# once (9µs+25µs) by Foswiki::Users::TopicUserMapping::new at line 19 # spent 34µs making 1 call to Foswiki::Users::Password::BEGIN@19
# spent 25µs making 1 call to Exporter::import |
20 | |||||
21 | # spent 4µs within Foswiki::Users::Password::BEGIN@21 which was called:
# once (4µs+0s) by Foswiki::Users::TopicUserMapping::new at line 26 | ||||
22 | 1 | 5µs | if ( $Foswiki::cfg{UseLocale} ) { | ||
23 | require locale; | ||||
24 | import locale(); | ||||
25 | } | ||||
26 | 1 | 404µs | 1 | 4µs | } # spent 4µs making 1 call to Foswiki::Users::Password::BEGIN@21 |
27 | |||||
28 | =begin TML | ||||
29 | |||||
30 | ---++ ClassMethod new( $session ) -> $object | ||||
31 | |||||
32 | Constructs a new password handler of this type, referring to $session | ||||
33 | for any required Foswiki services. | ||||
34 | |||||
35 | =cut | ||||
36 | |||||
37 | # spent 10µs within Foswiki::Users::Password::new which was called:
# once (10µs+0s) by Foswiki::Users::TopicUserMapping::new at line 66 of /var/www/foswikidev/core/lib/Foswiki/Users/TopicUserMapping.pm | ||||
38 | 1 | 900ns | my ( $class, $session ) = @_; | ||
39 | |||||
40 | 1 | 7µs | my $this = bless( { session => $session }, $class ); | ||
41 | 1 | 900ns | $this->{error} = undef; | ||
42 | 1 | 5µs | return $this; | ||
43 | } | ||||
44 | |||||
45 | =begin TML | ||||
46 | |||||
47 | ---++ ObjectMethod finish() | ||||
48 | Break circular references. | ||||
49 | |||||
50 | =cut | ||||
51 | |||||
52 | # Note to developers; please undef *all* fields in the object explicitly, | ||||
53 | # whether they are references or not. That way this method is "golden | ||||
54 | # documentation" of the live fields in the object. | ||||
55 | # spent 7µs within Foswiki::Users::Password::finish which was called:
# once (7µs+0s) by Foswiki::Users::TopicUserMapping::finish at line 97 of /var/www/foswikidev/core/lib/Foswiki/Users/TopicUserMapping.pm | ||||
56 | 1 | 1µs | my $this = shift; | ||
57 | 1 | 700ns | undef $this->{error}; | ||
58 | 1 | 5µs | undef $this->{session}; | ||
59 | } | ||||
60 | |||||
61 | =begin TML | ||||
62 | |||||
63 | ---++ ObjectMethod readOnly( ) -> boolean | ||||
64 | |||||
65 | returns true if the password database is not currently modifyable | ||||
66 | also needs to set $this->{session}->enter_context('passwords_modifyable'); | ||||
67 | if you want to be able to use the existing TopicUserMappingContrib ChangePassword topics | ||||
68 | |||||
69 | =cut | ||||
70 | |||||
71 | # spent 1µs within Foswiki::Users::Password::readOnly which was called:
# once (1µs+0s) by Foswiki::Users::TopicUserMapping::new at line 68 of /var/www/foswikidev/core/lib/Foswiki/Users/TopicUserMapping.pm | ||||
72 | 1 | 5µs | return 1; #there _is_ no password file. | ||
73 | } | ||||
74 | |||||
75 | =begin TML | ||||
76 | |||||
77 | ---++ ObjectMethod fetchPass( $login ) -> $passwordE | ||||
78 | |||||
79 | Implements Foswiki::Password | ||||
80 | |||||
81 | Returns encrypted password if succeeds. | ||||
82 | Returns 0 if login is invalid. | ||||
83 | Returns undef otherwise. | ||||
84 | |||||
85 | =cut | ||||
86 | |||||
87 | sub fetchPass { | ||||
88 | return; | ||||
89 | } | ||||
90 | |||||
91 | =begin TML | ||||
92 | |||||
93 | ---++ ObjectMethod checkPassword( $login, $passwordU ) -> $boolean | ||||
94 | |||||
95 | Finds if the password is valid for the given user. | ||||
96 | |||||
97 | Returns 1 on success, undef on failure. | ||||
98 | |||||
99 | =cut | ||||
100 | |||||
101 | sub checkPassword { | ||||
102 | my $this = shift; | ||||
103 | $this->{error} = undef; | ||||
104 | return 1; | ||||
105 | } | ||||
106 | |||||
107 | =begin TML | ||||
108 | |||||
109 | ---++ ObjectMethod removeUser( $login ) -> $boolean | ||||
110 | |||||
111 | Delete the users entry. | ||||
112 | |||||
113 | =cut | ||||
114 | |||||
115 | sub removeUser { | ||||
116 | my $this = shift; | ||||
117 | $this->{error} = undef; | ||||
118 | return 1; | ||||
119 | } | ||||
120 | |||||
121 | =begin TML | ||||
122 | |||||
123 | ---++ ObjectMethod setPassword( $login, $newPassU, $oldPassU ) -> $boolean | ||||
124 | |||||
125 | If the $oldPassU matches matches the user's password, then it will | ||||
126 | replace it with $newPassU. | ||||
127 | |||||
128 | If $oldPassU is not correct and not 1, will return 0. | ||||
129 | |||||
130 | If $oldPassU is 1, will force the change irrespective of | ||||
131 | the existing password, adding the user if necessary. | ||||
132 | |||||
133 | Otherwise returns 1 on success, undef on failure. | ||||
134 | |||||
135 | =cut | ||||
136 | |||||
137 | sub setPassword { | ||||
138 | my $this = shift; | ||||
139 | $this->{error} = 'System does not support changing passwords'; | ||||
140 | return 1; | ||||
141 | } | ||||
142 | |||||
143 | =begin TML | ||||
144 | |||||
145 | ---++ encrypt( $login, $passwordU, $fresh ) -> $passwordE | ||||
146 | |||||
147 | Will return an encrypted password. Repeated calls | ||||
148 | to encrypt with the same login/passU will return the same passE. | ||||
149 | |||||
150 | However if the passU is changed, and subsequently changed _back_ | ||||
151 | to the old login/passU pair, then the old passE is no longer valid. | ||||
152 | |||||
153 | If $fresh is true, then a new password not based on any pre-existing | ||||
154 | salt will be used. Set this if you are generating a completely | ||||
155 | new password. | ||||
156 | |||||
157 | =cut | ||||
158 | |||||
159 | sub encrypt { | ||||
160 | return ''; | ||||
161 | } | ||||
162 | |||||
163 | =begin TML | ||||
164 | |||||
165 | ---++ ObjectMethod error() -> $string | ||||
166 | |||||
167 | Return any error raised by the last method call, or undef if the last | ||||
168 | method call succeeded. | ||||
169 | |||||
170 | =cut | ||||
171 | |||||
172 | sub error { | ||||
173 | my $this = shift; | ||||
174 | |||||
175 | return $this->{error}; | ||||
176 | } | ||||
177 | |||||
178 | =begin TML | ||||
179 | |||||
180 | ---++ ObjectMethod isManagingEmails() -> $boolean | ||||
181 | Determines if this manager can store and retrieve emails. The password | ||||
182 | manager is used in preference to the user mapping manager for storing | ||||
183 | emails, on the basis that emails need to be secure, and the password | ||||
184 | database is the most secure place. If a password manager does not | ||||
185 | manage emails, then Foswiki will fall back to using the user mapping | ||||
186 | manager (which by default will store emails in user topics) | ||||
187 | |||||
188 | The default ('none') password manager does *not* manage emails. | ||||
189 | |||||
190 | =cut | ||||
191 | |||||
192 | sub isManagingEmails { | ||||
193 | return 0; | ||||
194 | } | ||||
195 | |||||
196 | =begin TML | ||||
197 | |||||
198 | ---++ ObjectMethod getEmails($login) -> @emails | ||||
199 | Fetch the email address(es) for the given login. Default | ||||
200 | behaviour is to return an empty list. Called by Users.pm. | ||||
201 | Only used if =isManagingEmails= -> =true=. | ||||
202 | |||||
203 | =cut | ||||
204 | |||||
205 | sub getEmails { | ||||
206 | ASSERT( 0, "should never be called" ) if DEBUG; | ||||
207 | } | ||||
208 | |||||
209 | =begin TML | ||||
210 | |||||
211 | ---++ ObjectMethod setEmails($login, @emails) -> $boolean | ||||
212 | Set the email address(es) for the given login name. Returns true if | ||||
213 | the emails were set successfully. | ||||
214 | Default behaviour is a nop, which will result in the user mapping manager | ||||
215 | taking over. Called by Users.pm. | ||||
216 | Only used if =isManagingEmails= -> =true=. | ||||
217 | |||||
218 | =cut | ||||
219 | |||||
220 | sub setEmails { | ||||
221 | ASSERT( 0, "should never be called" ) if DEBUG; | ||||
222 | } | ||||
223 | |||||
224 | =begin TML | ||||
225 | |||||
226 | ---++ ObjectMethod findUserByEmail($email) -> \@users | ||||
227 | Returns an array of login names that relate to a email address. | ||||
228 | Defaut behaviour is a nop, which will result in the user mapping manager | ||||
229 | being asked for its opinion. If subclass implementations return a value for | ||||
230 | this, then the user mapping manager will *not* be asked. | ||||
231 | Only used if =isManagingEmails= -> =true=. | ||||
232 | |||||
233 | Called by Users.pm. | ||||
234 | |||||
235 | =cut | ||||
236 | |||||
237 | sub findUserByEmail { | ||||
238 | ASSERT( 0, "should never be called" ) if DEBUG; | ||||
239 | } | ||||
240 | |||||
241 | =begin TML | ||||
242 | |||||
243 | ---++ ObjectMethod canFetchUsers() -> boolean | ||||
244 | |||||
245 | returns true if the fetchUsers method is implemented and can return an iterator of users. | ||||
246 | returns undef / nothing in this case, as we are unable to generate a list of users | ||||
247 | |||||
248 | =cut | ||||
249 | |||||
250 | sub canFetchUsers { | ||||
251 | return; | ||||
252 | } | ||||
253 | |||||
254 | =begin TML | ||||
255 | |||||
256 | ---++ ObjectMethod fetchUsers() -> $iterator | ||||
257 | |||||
258 | returns an Iterator of loginnames from the password source. If AllowLoginNames is false | ||||
259 | this is used to remove the need for a WikiUsers topic. | ||||
260 | |||||
261 | =cut | ||||
262 | |||||
263 | sub fetchUsers { | ||||
264 | |||||
265 | die "not Implemented in Base class"; | ||||
266 | |||||
267 | #return new Foswiki::ListIterator(\@users); | ||||
268 | } | ||||
269 | |||||
270 | 1 | 2µs | 1; | ||
271 | __END__ |