← Index
NYTProf Performance Profile   « line view »
For ./view
  Run on Fri Jul 31 18:42:36 2015
Reported on Fri Jul 31 18:48:15 2015

Filename/var/www/foswikidev/core/lib/Foswiki/Users/Password.pm
StatementsExecuted 16 statements in 533µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11115µs28µsFoswiki::Users::Password::::BEGIN@17Foswiki::Users::Password::BEGIN@17
11110µs10µsFoswiki::Users::Password::::newFoswiki::Users::Password::new
11110µs14µsFoswiki::Users::Password::::BEGIN@18Foswiki::Users::Password::BEGIN@18
1119µs34µsFoswiki::Users::Password::::BEGIN@19Foswiki::Users::Password::BEGIN@19
1117µs7µsFoswiki::Users::Password::::finishFoswiki::Users::Password::finish
1114µs4µsFoswiki::Users::Password::::BEGIN@21Foswiki::Users::Password::BEGIN@21
1111µs1µsFoswiki::Users::Password::::readOnlyFoswiki::Users::Password::readOnly
0000s0sFoswiki::Users::Password::::canFetchUsersFoswiki::Users::Password::canFetchUsers
0000s0sFoswiki::Users::Password::::checkPasswordFoswiki::Users::Password::checkPassword
0000s0sFoswiki::Users::Password::::encryptFoswiki::Users::Password::encrypt
0000s0sFoswiki::Users::Password::::errorFoswiki::Users::Password::error
0000s0sFoswiki::Users::Password::::fetchPassFoswiki::Users::Password::fetchPass
0000s0sFoswiki::Users::Password::::fetchUsersFoswiki::Users::Password::fetchUsers
0000s0sFoswiki::Users::Password::::findUserByEmailFoswiki::Users::Password::findUserByEmail
0000s0sFoswiki::Users::Password::::getEmailsFoswiki::Users::Password::getEmails
0000s0sFoswiki::Users::Password::::isManagingEmailsFoswiki::Users::Password::isManagingEmails
0000s0sFoswiki::Users::Password::::removeUserFoswiki::Users::Password::removeUser
0000s0sFoswiki::Users::Password::::setEmailsFoswiki::Users::Password::setEmails
0000s0sFoswiki::Users::Password::::setPasswordFoswiki::Users::Password::setPassword
Call graph for these subroutines as a Graphviz dot language file.
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
7Base class of all password handlers. Default behaviour is no passwords,
8so anyone can be anyone they like.
9
10The methods of this class should be overridded by subclasses that want
11to implement other password handling methods.
12
13=cut
14
15package Foswiki::Users::Password;
16
17228µs242µ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
use strict;
# spent 28µs making 1 call to Foswiki::Users::Password::BEGIN@17 # spent 14µs making 1 call to strict::import
18223µs218µ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
use warnings;
# spent 14µs making 1 call to Foswiki::Users::Password::BEGIN@18 # spent 4µs making 1 call to warnings::import
19246µs259µ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
use Assert;
# 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
BEGIN {
2215µs if ( $Foswiki::cfg{UseLocale} ) {
23 require locale;
24 import locale();
25 }
261404µs14µs}
# spent 4µs making 1 call to Foswiki::Users::Password::BEGIN@21
27
28=begin TML
29
30---++ ClassMethod new( $session ) -> $object
31
32Constructs a new password handler of this type, referring to $session
33for 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
sub new {
381900ns my ( $class, $session ) = @_;
39
4017µs my $this = bless( { session => $session }, $class );
411900ns $this->{error} = undef;
4215µs return $this;
43}
44
45=begin TML
46
47---++ ObjectMethod finish()
48Break 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
sub finish {
5611µs my $this = shift;
571700ns undef $this->{error};
5815µs undef $this->{session};
59}
60
61=begin TML
62
63---++ ObjectMethod readOnly( ) -> boolean
64
65returns true if the password database is not currently modifyable
66also needs to set $this->{session}->enter_context('passwords_modifyable');
67if 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
sub readOnly {
7215µs return 1; #there _is_ no password file.
73}
74
75=begin TML
76
77---++ ObjectMethod fetchPass( $login ) -> $passwordE
78
79Implements Foswiki::Password
80
81Returns encrypted password if succeeds.
82Returns 0 if login is invalid.
83Returns undef otherwise.
84
85=cut
86
87sub fetchPass {
88 return;
89}
90
91=begin TML
92
93---++ ObjectMethod checkPassword( $login, $passwordU ) -> $boolean
94
95Finds if the password is valid for the given user.
96
97Returns 1 on success, undef on failure.
98
99=cut
100
101sub checkPassword {
102 my $this = shift;
103 $this->{error} = undef;
104 return 1;
105}
106
107=begin TML
108
109---++ ObjectMethod removeUser( $login ) -> $boolean
110
111Delete the users entry.
112
113=cut
114
115sub 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
125If the $oldPassU matches matches the user's password, then it will
126replace it with $newPassU.
127
128If $oldPassU is not correct and not 1, will return 0.
129
130If $oldPassU is 1, will force the change irrespective of
131the existing password, adding the user if necessary.
132
133Otherwise returns 1 on success, undef on failure.
134
135=cut
136
137sub 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
147Will return an encrypted password. Repeated calls
148to encrypt with the same login/passU will return the same passE.
149
150However if the passU is changed, and subsequently changed _back_
151to the old login/passU pair, then the old passE is no longer valid.
152
153If $fresh is true, then a new password not based on any pre-existing
154salt will be used. Set this if you are generating a completely
155new password.
156
157=cut
158
159sub encrypt {
160 return '';
161}
162
163=begin TML
164
165---++ ObjectMethod error() -> $string
166
167Return any error raised by the last method call, or undef if the last
168method call succeeded.
169
170=cut
171
172sub error {
173 my $this = shift;
174
175 return $this->{error};
176}
177
178=begin TML
179
180---++ ObjectMethod isManagingEmails() -> $boolean
181Determines if this manager can store and retrieve emails. The password
182manager is used in preference to the user mapping manager for storing
183emails, on the basis that emails need to be secure, and the password
184database is the most secure place. If a password manager does not
185manage emails, then Foswiki will fall back to using the user mapping
186manager (which by default will store emails in user topics)
187
188The default ('none') password manager does *not* manage emails.
189
190=cut
191
192sub isManagingEmails {
193 return 0;
194}
195
196=begin TML
197
198---++ ObjectMethod getEmails($login) -> @emails
199Fetch the email address(es) for the given login. Default
200behaviour is to return an empty list. Called by Users.pm.
201Only used if =isManagingEmails= -> =true=.
202
203=cut
204
205sub getEmails {
206 ASSERT( 0, "should never be called" ) if DEBUG;
207}
208
209=begin TML
210
211---++ ObjectMethod setEmails($login, @emails) -> $boolean
212Set the email address(es) for the given login name. Returns true if
213the emails were set successfully.
214Default behaviour is a nop, which will result in the user mapping manager
215taking over. Called by Users.pm.
216Only used if =isManagingEmails= -> =true=.
217
218=cut
219
220sub setEmails {
221 ASSERT( 0, "should never be called" ) if DEBUG;
222}
223
224=begin TML
225
226---++ ObjectMethod findUserByEmail($email) -> \@users
227Returns an array of login names that relate to a email address.
228Defaut behaviour is a nop, which will result in the user mapping manager
229being asked for its opinion. If subclass implementations return a value for
230this, then the user mapping manager will *not* be asked.
231Only used if =isManagingEmails= -> =true=.
232
233Called by Users.pm.
234
235=cut
236
237sub findUserByEmail {
238 ASSERT( 0, "should never be called" ) if DEBUG;
239}
240
241=begin TML
242
243---++ ObjectMethod canFetchUsers() -> boolean
244
245returns true if the fetchUsers method is implemented and can return an iterator of users.
246returns undef / nothing in this case, as we are unable to generate a list of users
247
248=cut
249
250sub canFetchUsers {
251 return;
252}
253
254=begin TML
255
256---++ ObjectMethod fetchUsers() -> $iterator
257
258returns an Iterator of loginnames from the password source. If AllowLoginNames is false
259this is used to remove the need for a WikiUsers topic.
260
261=cut
262
263sub fetchUsers {
264
265 die "not Implemented in Base class";
266
267 #return new Foswiki::ListIterator(\@users);
268}
269
27012µs1;
271__END__