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