← Index
NYTProf Performance Profile   « line view »
For ./view
  Run on Fri Jul 31 19:05:14 2015
Reported on Fri Jul 31 19:08:10 2015

Filename/var/www/foswiki11/lib/Foswiki/Users/Password.pm
StatementsExecuted 392 statements in 1.44ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
37711421µs421µsFoswiki::Users::Password::::canFetchUsersFoswiki::Users::Password::canFetchUsers
11114µs27µsFoswiki::Users::Password::::BEGIN@17Foswiki::Users::Password::BEGIN@17
11111µs24µsFoswiki::Users::Password::::BEGIN@19Foswiki::Users::Password::BEGIN@19
11111µs11µsFoswiki::Users::Password::::newFoswiki::Users::Password::new
1119µs15µsFoswiki::Users::Password::::BEGIN@18Foswiki::Users::Password::BEGIN@18
1116µs6µsFoswiki::Users::Password::::finishFoswiki::Users::Password::finish
1111µs1µsFoswiki::Users::Password::::readOnlyFoswiki::Users::Password::readOnly
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
17227µs241µ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
use strict;
# spent 27µs making 1 call to Foswiki::Users::Password::BEGIN@17 # spent 13µs making 1 call to strict::import
18223µs221µ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
use warnings;
# spent 15µs making 1 call to Foswiki::Users::Password::BEGIN@18 # spent 6µs making 1 call to warnings::import
192398µs238µ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
use Assert;
# 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
25Constructs a new password handler of this type, referring to $session
26for 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
sub new {
3111µs my ( $class, $session ) = @_;
32
3317µs my $this = bless( { session => $session }, $class );
341900ns $this->{error} = undef;
3515µs return $this;
36}
37
38=begin TML
39
40---++ ObjectMethod finish()
41Break 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
sub finish {
491600ns my $this = shift;
5011µs undef $this->{error};
5117µs undef $this->{session};
52}
53
54=begin TML
55
56---++ ObjectMethod readOnly( ) -> boolean
57
58returns true if the password database is not currently modifyable
59also needs to set $this->{session}->enter_context('passwords_modifyable');
60if 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
sub readOnly {
6513µs return 1; #there _is_ no password file.
66}
67
68=begin TML
69
70---++ ObjectMethod fetchPass( $login ) -> $passwordE
71
72Implements Foswiki::Password
73
74Returns encrypted password if succeeds.
75Returns 0 if login is invalid.
76Returns undef otherwise.
77
78=cut
79
80sub fetchPass {
81 return;
82}
83
84=begin TML
85
86---++ ObjectMethod checkPassword( $login, $passwordU ) -> $boolean
87
88Finds if the password is valid for the given user.
89
90Returns 1 on success, undef on failure.
91
92=cut
93
94sub checkPassword {
95 my $this = shift;
96 $this->{error} = undef;
97 return 1;
98}
99
100=begin TML
101
102---++ ObjectMethod removeUser( $login ) -> $boolean
103
104Delete the users entry.
105
106=cut
107
108sub 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
118If the $oldPassU matches matches the user's password, then it will
119replace it with $newPassU.
120
121If $oldPassU is not correct and not 1, will return 0.
122
123If $oldPassU is 1, will force the change irrespective of
124the existing password, adding the user if necessary.
125
126Otherwise returns 1 on success, undef on failure.
127
128=cut
129
130sub 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
140Will return an encrypted password. Repeated calls
141to encrypt with the same login/passU will return the same passE.
142
143However if the passU is changed, and subsequently changed _back_
144to the old login/passU pair, then the old passE is no longer valid.
145
146If $fresh is true, then a new password not based on any pre-existing
147salt will be used. Set this if you are generating a completely
148new password.
149
150=cut
151
152sub encrypt {
153 return '';
154}
155
156=begin TML
157
158---++ ObjectMethod error() -> $string
159
160Return any error raised by the last method call, or undef if the last
161method call succeeded.
162
163=cut
164
165sub error {
166 my $this = shift;
167
168 return $this->{error};
169}
170
171=begin TML
172
173---++ ObjectMethod isManagingEmails() -> $boolean
174Determines if this manager can store and retrieve emails. The password
175manager is used in preference to the user mapping manager for storing
176emails, on the basis that emails need to be secure, and the password
177database is the most secure place. If a password manager does not
178manage emails, then Foswiki will fall back to using the user mapping
179manager (which by default will store emails in user topics)
180
181The default ('none') password manager does *not* manage emails.
182
183=cut
184
185sub isManagingEmails {
186 return 0;
187}
188
189=begin TML
190
191---++ ObjectMethod getEmails($login) -> @emails
192Fetch the email address(es) for the given login. Default
193behaviour is to return an empty list. Called by Users.pm.
194Only used if =isManagingEmails= -> =true=.
195
196=cut
197
198sub getEmails {
199 ASSERT( 0, "should never be called" ) if DEBUG;
200}
201
202=begin TML
203
204---++ ObjectMethod setEmails($login, @emails) -> $boolean
205Set the email address(es) for the given login name. Returns true if
206the emails were set successfully.
207Default behaviour is a nop, which will result in the user mapping manager
208taking over. Called by Users.pm.
209Only used if =isManagingEmails= -> =true=.
210
211=cut
212
213sub setEmails {
214 ASSERT( 0, "should never be called" ) if DEBUG;
215}
216
217=begin TML
218
219---++ ObjectMethod findUserByEmail($email) -> \@users
220Returns an array of login names that relate to a email address.
221Defaut behaviour is a nop, which will result in the user mapping manager
222being asked for its opinion. If subclass implementations return a value for
223this, then the user mapping manager will *not* be asked.
224Only used if =isManagingEmails= -> =true=.
225
226Called by Users.pm.
227
228=cut
229
230sub findUserByEmail {
231 ASSERT( 0, "should never be called" ) if DEBUG;
232}
233
234=begin TML
235
236---++ ObjectMethod canFetchUsers() -> boolean
237
238returns true if the fetchUsers method is implemented and can return an iterator of users.
239returns 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
sub canFetchUsers {
244377962µs return;
245}
246
247=begin TML
248
249---++ ObjectMethod fetchUsers() -> $iterator
250
251returns an Iterator of loginnames from the password source. If AllowLoginNames is false
252this is used to remove the need for a WikiUsers topic.
253
254=cut
255
256sub fetchUsers {
257
258 die "not Implemented in Base class";
259
260 #return new Foswiki::ListIterator(\@users);
261}
262
26312µs1;
264__END__