This file is indexed.

/usr/share/perl5/WebKDC/WebKDCException.pm is in libwebkdc-perl 4.6.1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
# Exception class for WebKDC call failures.
#
# Written by Roland Schemers
# Copyright 2002, 2003, 2005, 2006, 2008, 2009, 2011, 2012, 2013
#     The Board of Trustees of the Leland Stanford Junior University
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.

package WebKDC::WebKDCException;

use 5.008;

use strict;
use warnings;

use base qw(Exporter);
use overload '""' => \&to_string;

our $VERSION;

# This version matches the version of WebAuth with which this module was
# released, but with two digits for the minor and patch versions.
BEGIN {
    $VERSION = '4.0601';
}

# Export the error codes.  This list MUST be kept in sync and follow the same
# order as the sequence number of the error codes defined below in the
# constant subs or we won't map errors to the correct name.
our @EXPORT;
BEGIN {
    @EXPORT = qw(WK_SUCCESS
                 WK_ERR_USER_AND_PASS_REQUIRED
                 WK_ERR_LOGIN_FAILED
                 WK_ERR_UNRECOVERABLE_ERROR
                 WK_ERR_REQUEST_TOKEN_STALE
                 WK_ERR_WEBAUTH_SERVER_ERROR
                 WK_ERR_LOGIN_FORCED
                 WK_ERR_USER_REJECTED
                 WK_ERR_CREDS_EXPIRED
                 WK_ERR_MULTIFACTOR_REQUIRED
                 WK_ERR_MULTIFACTOR_UNAVAILABLE
                 WK_ERR_LOGIN_REJECTED
                 WK_ERR_LOA_UNAVAILABLE
                 WK_ERR_AUTH_REJECTED
                 WK_ERR_AUTH_REPLAY
                 WK_ERR_AUTH_LOCKOUT);
}

# This hash maps the error codes to names, used when stringifying.
our %ERROR_NAMES;
{
    my $i = 0;
    %ERROR_NAMES = map {
        my $n = $_;
        $n =~ s/^WK_(?:ERR_)?//;
        $i++ => $n;
    } @EXPORT;
}

# The error code constants.
sub WK_SUCCESS                     () {  0 }
sub WK_ERR_USER_AND_PASS_REQUIRED  () {  1 }
sub WK_ERR_LOGIN_FAILED            () {  2 }
sub WK_ERR_UNRECOVERABLE_ERROR     () {  3 }
sub WK_ERR_REQUEST_TOKEN_STALE     () {  4 }
sub WK_ERR_WEBAUTH_SERVER_ERROR    () {  5 }
sub WK_ERR_LOGIN_FORCED            () {  6 }
sub WK_ERR_USER_REJECTED           () {  7 }
sub WK_ERR_CREDS_EXPIRED           () {  8 }
sub WK_ERR_MULTIFACTOR_REQUIRED    () {  9 }
sub WK_ERR_MULTIFACTOR_UNAVAILABLE () { 10 }
sub WK_ERR_LOGIN_REJECTED          () { 11 }
sub WK_ERR_LOA_UNAVAILABLE         () { 12 }
sub WK_ERR_AUTH_REJECTED           () { 13 }
sub WK_ERR_AUTH_REPLAY             () { 14 }
sub WK_ERR_AUTH_LOCKOUT            () { 15 }

# Create a new WebKDC::WebKDCException object and initialize the status,
# message, protocol error, and data.
sub new {
    my ($type, $status, $mesg, $pec, $data) = @_;
    my $self = {
        status => $status,
        mesg   => $mesg,
        pec    => $pec,
        data   => $data
    };
    bless ($self, $type);
    return $self;
}

# Basic accessors.
sub status     { my $self = shift; return $self->{status} }
sub message    { my $self = shift; return $self->{mesg}   }
sub error_code { my $self = shift; return $self->{pec}    }
sub data       { my $self = shift; return $self->{data}   }

# A full verbose message with all the information from the exception except
# the exception data.
sub verbose_message {
    my $self = shift;
    my $s = $self->{'status'};
    my $m = $self->{'mesg'};
    my $pec = $self->{'pec'};
    my $msg = 'WebKDC::WebKDCException ' . $ERROR_NAMES{$s} . ": $m";
    $msg .= ": WebKDC errorCode: $pec" if defined $pec;
    return $msg;
}

# The string conversion of this exception is the full verbose message.
sub to_string {
    my ($self) = @_;
    return $self->verbose_message;
}

1;

__END__

=for stopwords
WebKDC username login WebAuth WebKdcPermittedRealms multifactor logins
errorCode Allbery WebLogin

=head1 NAME

WebKDC::WebKDCException - Exceptions for WebKDC communications

=head1 SYNOPSIS

    use WebKDC;
    use WebKDC::WebKDCException;

    eval {
        # ...
        WebKDC::request_token_request($req, $resp);
        # ...
    };
    my $e = $@;
    if (ref $e and $e->isa ('WebKDC::WebKDCException')) {
        # you can call the following methods on a WebKDCException object:
        # $e->status()
        # $e->message()
        # $e->error_code()
        # $e->verbose_message()
    }

=head1 DESCRIPTION

Various WebKDC functions may return a WebKDC::WebKDCException object if
anything goes wrong.  This object encapsulates various information about
the error.

This module also defines the status codes returned by the WebKDC
functions.

=head1 CONSTANTS

The following constants are exported:

=over 4

=item WK_SUCCESS

This status code never comes back as part of an exception.  It is returned
for success.

=item WK_ERR_USER_AND_PASS_REQUIRED

This status code indicates that a function was called that required a
username and password. The user should be prompted for their username and
the function should be called again.

=item WK_ERR_LOGIN_FAILED

This status code indicates that a function was called that attempted to
validate the username and password and could not, due to an invalid user
or password.  The user should be re-prompted for their username/password
and the function should be called again.

=item WK_ERR_UNRECOVERABLE_ERROR

This status code indicates that a function was called and an error
occurred that can not be recovered from.  If you are in the process of
attempting to log a user in, you have no choice but to display an error
message to the user and not prompt again.

=item WK_ERR_REQUEST_TOKEN_STALE

This status code indicates the user took too long to login, and the the
request token is too old to be used.  The user should be told to retry the
action that caused them to be prompted for authentication.

=item WK_ERR_WEBAUTH_SERVER_ERROR

This status code indicates something happened that most likely indicates
the WebAuth server that made the request is misconfigured and/or
unauthorized to make the request.  It is similar to
WK_ERR_UNRECOVERABLE_ERROR except that the error message to the user
should indicate that the problem is most likely with the server that
redirected them.

=item WK_ERR_LOGIN_FORCED

This status code indicates that a function was called that required a
username and password even if single sign-on credentials were available.
The user should be prompted for their username and password and the
function should be called again with that data.

=item WK_ERR_USER_REJECTED

This status code indicates that the authenticated principal was rejected
by the WebKDC configuration (usually because WebKdcPermittedRealms was set
and the realm of the principal wasn't in that list).

=item WK_ERR_CREDS_EXPIRED

This status code indicates that the principal we attempted to authenticate
to has an expired password.  If possible, the user should be prompted to
change their password and then the operation retried.

=item WK_ERR_MULTIFACTOR_REQUIRED

This status code indicates that authentication was successful but that
authentication with a second factor is also required.  The user should be
prompted for their second factor and then the login reattempted with that
information plus the returned proxy tokens.

=item WK_ERR_MULTIFACTOR_UNAVAILABLE

This status code indicates that the desired site requires multifactor, but
the user does not have multifactor configured or does not have the correct
second factor to authenticate to that site.

=item WK_ERR_LOGIN_REJECT

This status code indicates that this user is not allowed to log on to that
site at this time for security reasons.  This is a transitory error; the
user may be permitted to authenticate later, or from a different location.
This error message is used for rejected logins from particular locations,
logins that appear to be from a compromised account, or accounts that have
been locked out due to too many failed logins.

=item WK_ERR_LOA_UNAVAILABLE

This status code indicates that the site requested a Level of Assurance
for the user's authentication that is higher than this user can provide,
either because of insufficient proof of identity available to the system
or due to an insufficiently strong configured authentication method.

=item WK_ERR_AUTH_REJECTED

This user is not permitted to authenticate to the desired destination
WebAuth Application Server at this time.  This may be due to local policy,
security limitations placed on the user, missing prerequisite actions that
the user must take (such as training or a usage agreement), or some other
local factor.

=item WK_ERR_AUTH_REPLAY

This authentication attempt appears to be a replay.  Replays may be
rejected as a security measure to protect against people who walked away
with a browser open and left the WebLogin form submission in the browser
cache.

=item WK_ERR_AUTH_LOCKOUT

This account has been locked out due to too many unsuccessful login
attempts.  The login should be retried later.

=back

=head1 CLASS METHODS

=over 4

=item new (STATUS, MESSAGE[, ERROR[, DATA]])

Create a new WebKDC::WebKDCException object.  STATUS is one of the status
constants defined above other than WK_SUCCESS.  MESSAGE is the error
message for the exception.  ERROR, if present, is a protocol error code
that caused the exception.  DATA, if present, is additional data about the
exception, currently used to carry the HTML error message to display to
the user if one is available.

=back

=head1 INSTANCE METHODS

=over 4

=item data ()

Returns the additional exception data (if there was any).

=item error_code ()

Returns the WebKDC protocol errorCode (if there was one).

=item message ()

Returns the error message that was passed to the constructor.

=item status ()

Returns the WebKDC::WebKDCException status code for the exception, which
will be one of the WK_ERR_* codes.

=item verbose_message ()

This method returns a verbose error message, which consists of the status
code, message, and any error code.

=item to_string ()

This method is called if the exception is used as a string.  It is a
wrapper around the verbose_message method.

=back

=head1 AUTHOR

Roland Schemers and Russ Allbery <eagle@eyrie.org>

=head1 SEE ALSO

WebKDC(3)

This module is part of WebAuth.  The current version is available from
L<http://webauth.stanford.edu/>.

=cut