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