/usr/share/perl5/WebKDC/WebKDCException.pm is in libwebkdc-perl 4.0.2-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 | # Exception class for WebKDC call failures.
#
# Written by Roland Schemers
# Copyright 2002, 2003, 2005, 2006, 2008, 2009, 2011
# The Board of Trustees of the Leland Stanford Junior University
#
# See LICENSE for licensing terms.
package WebKDC::WebKDCException;
use strict;
use warnings;
use WebAuth;
use overload '""' => \&to_string;
BEGIN {
use Exporter ();
our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, @ErrorNames);
# set the version for version checking
$VERSION = 1.02;
@ISA = qw(Exporter);
@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
);
@EXPORT_OK = ();
}
our @EXPORT_OK;
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;}
our @ErrorNames = qw(SUCCESS
USER_AND_PASS_REQUIRED
LOGIN_FAILED
UNRECOVERABLE_ERROR
REQUEST_TOKEN_STALE
WEBAUTH_SERVER_ERROR
LOGIN_FORCED
USER_REJECTED
MULTIFACTOR_REQUIRED
MULTIFACTOR_UNAVAILABLE
LOGIN_REJECTED
LOA_UNAVAILABLE);
sub new {
my ($type, $status, $mesg, $pec) = @_;
my $self = {};
bless $self, $type;
$self->{'status'} = $status;
$self->{'mesg'} = $mesg;
$self->{'pec'} = $pec;
return $self;
}
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 verbose_message {
my $self = shift;
my $s = $self->{'status'};
my $m = $self->{'mesg'};
my $pec = $self->{'pec'};
my $msg = "WebKDC::WebKDCException ".$ErrorNames[$s].": $m";
$msg .= ": WebKDC errorCode: $pec" if (defined($pec));
return $msg;
}
sub to_string {
my ($self) = @_;
return $self->verbose_message();
}
sub match {
my $e = shift;
return 0 unless ref $e;
return 0 if !$e->isa("WebKDC::WebKDCException");
return @_ ? $e->status() == shift : 1;
}
1;
__END__
=head1 NAME
WebKDC::WebKDCException - exceptions for WebKDC
=head1 SYNOPSIS
use WebKDC;
use WebKDC::WebKDCException;
eval {
...
WebKDC::request_token_request($req, $resp);
...
};
if (WebKDC::WebKDCException::match($@)) {
my $e = $@;
# you can call the following methods on a WebKDCException object:
# $e->status()
# $e->message()
# $e->error_code()
# $e->verbose_message()
}
=head1 DESCRIPTION
The various WebKDC functions can all throw WebKDCException if something
wrong happens.
=head1 EXPORT
The following constants are exported:
WK_SUCCESS
WK_ERR_USER_AND_PASS_REQUIRED
WK_ERR_LOGIN_FAILED
WK_ERR_UNRECOVERABLE_ERROR
WK_ERR_REQUEST_TOKEN_STATLE
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
=over 4
=item WK_SUCCESS
This status code never comes back as part of an exception, though it might
be returned by a function that uses these status codes as return values.
=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 occured
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.
=item WK_ERR_WEBAUTH_SERVER_ERROR
This status code indicates something happened that most likely indicates the
webauth server that made the request is mis-configured 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.
=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.
=back
=head1 METHODS and FUNCTIONS
=over 4
=item match($exception[, $status])
This class function (not a method) returns true if the given $exception is a
WebKDC::WebKDCException. If $status is specified, then $exception->status()
will also be compared to $status.
=item new(status, message, wrapped_exception)
This method is used to created new WebKDC::WebKDCException objects.
=item status()
This method returns the WebKDC::WebKDCException status code for the
exception, which will be one of the WK_ERR_* codes.
=item message()
This method returns the error message that was used in the constructor.
=item error_code()
This method returns the WebKDC errorCode (if there was one).
=item verbose_message()
This method returns a verbose error message, which consists of the status
code, message, and any error code.
The verbose_message method is also called if the exception is used as a
string.
=back
=head1 AUTHOR
Roland Schemers (schemers@stanford.edu)
=head1 SEE ALSO
L<WebKDC>.
=cut
|