Filename | /usr/local/src/github.com/foswiki/core/lib/Foswiki/AccessControlException.pm |
Statements | Executed 9 statements in 358µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 25µs | 32µs | BEGIN@47 | Foswiki::AccessControlException::
1 | 1 | 1 | 16µs | 34µs | BEGIN@48 | Foswiki::AccessControlException::
1 | 1 | 1 | 9µs | 9µs | BEGIN@50 | Foswiki::AccessControlException::
0 | 0 | 0 | 0s | 0s | new | Foswiki::AccessControlException::
0 | 0 | 0 | 0s | 0s | stringify | Foswiki::AccessControlException::
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::AccessControlException | ||||
6 | |||||
7 | Exception used raise an access control violation. This exception has the | ||||
8 | following fields: | ||||
9 | * =web= - the web which was being accessed | ||||
10 | * =topic= - the topic being accessed (if any) | ||||
11 | * =user= - canonical username of the person doing the accessing. Use | ||||
12 | the methods of the Foswiki::Users class to get more information about the | ||||
13 | user. | ||||
14 | * =mode= - the access mode e.g. CHANGE, VIEW etc | ||||
15 | * =reason= a text string giving the reason for the refusal. | ||||
16 | |||||
17 | The exception may be thrown by plugins. If a plugin throws the exception, it | ||||
18 | will normally be caught and the browser redirected to a login screen (if the | ||||
19 | user is not logged in) or reported (if they are and just don't have access). | ||||
20 | |||||
21 | API version $Date$ (revision $Rev$) | ||||
22 | |||||
23 | *Since* _date_ indicates where functions or parameters have been added since | ||||
24 | the baseline of the API (TWiki release 4.2.3). The _date_ indicates the | ||||
25 | earliest date of a Foswiki release that will support that function or | ||||
26 | parameter. | ||||
27 | |||||
28 | *Deprecated* _date_ indicates where a function or parameters has been | ||||
29 | [[http://en.wikipedia.org/wiki/Deprecation][deprecated]]. Deprecated | ||||
30 | functions will still work, though they should | ||||
31 | _not_ be called in new plugins and should be replaced in older plugins | ||||
32 | as soon as possible. Deprecated parameters are simply ignored in Foswiki | ||||
33 | releases after _date_. | ||||
34 | |||||
35 | *Until* _date_ indicates where a function or parameter has been removed. | ||||
36 | The _date_ indicates the latest date at which Foswiki releases still supported | ||||
37 | the function or parameter. | ||||
38 | |||||
39 | =cut | ||||
40 | |||||
41 | # THIS PACKAGE IS PART OF THE PUBLISHED API USED BY EXTENSION AUTHORS. | ||||
42 | # DO NOT CHANGE THE EXISTING APIS (well thought out extensions are OK) | ||||
43 | # AND ENSURE ALL POD DOCUMENTATION IS COMPLETE AND ACCURATE. | ||||
44 | |||||
45 | package Foswiki::AccessControlException; | ||||
46 | |||||
47 | 2 | 46µs | 2 | 40µs | # spent 32µs (25+8) within Foswiki::AccessControlException::BEGIN@47 which was called:
# once (25µs+8µs) by Foswiki::Plugin::BEGIN@14 at line 47 # spent 32µs making 1 call to Foswiki::AccessControlException::BEGIN@47
# spent 8µs making 1 call to strict::import |
48 | 2 | 47µs | 2 | 52µs | # spent 34µs (16+18) within Foswiki::AccessControlException::BEGIN@48 which was called:
# once (16µs+18µs) by Foswiki::Plugin::BEGIN@14 at line 48 # spent 34µs making 1 call to Foswiki::AccessControlException::BEGIN@48
# spent 18µs making 1 call to warnings::import |
49 | |||||
50 | 2 | 248µs | 1 | 9µs | # spent 9µs within Foswiki::AccessControlException::BEGIN@50 which was called:
# once (9µs+0s) by Foswiki::Plugin::BEGIN@14 at line 50 # spent 9µs making 1 call to Foswiki::AccessControlException::BEGIN@50 |
51 | 1 | 10µs | our @ISA = ('Error'); # base class | ||
52 | |||||
53 | 1 | 1µs | our $VERSION = '$Rev$'; | ||
54 | |||||
55 | =begin TML | ||||
56 | |||||
57 | ---+ ClassMethod new($mode, $user, $web, $topic, $reason) | ||||
58 | |||||
59 | * =$mode= - mode of access (view, change etc) | ||||
60 | * =$user= - canonical user name of user doing the accessing | ||||
61 | * =$web= - web being accessed | ||||
62 | * =$topic= - topic being accessed | ||||
63 | * =$reason= - string reason for failure | ||||
64 | |||||
65 | All the above fields are accessible from the object in a catch clause | ||||
66 | in the usual way e.g. =$e->{web}= and =$e->{reason}= | ||||
67 | |||||
68 | =cut | ||||
69 | |||||
70 | sub new { | ||||
71 | my ( $class, $mode, $user, $web, $topic, $reason ) = @_; | ||||
72 | |||||
73 | return $class->SUPER::new( | ||||
74 | web => $web, | ||||
75 | topic => $topic, | ||||
76 | user => $user, | ||||
77 | mode => $mode, | ||||
78 | reason => $reason, | ||||
79 | ); | ||||
80 | } | ||||
81 | |||||
82 | =begin TML | ||||
83 | |||||
84 | ---++ ObjectMethod stringify() -> $string | ||||
85 | |||||
86 | Generate a summary string. This is mainly for debugging. | ||||
87 | |||||
88 | =cut | ||||
89 | |||||
90 | sub stringify { | ||||
91 | my $this = shift; | ||||
92 | my $topic = $this->{topic} | ||||
93 | || ''; # Access checks of Web objects causes uninitialized string errors | ||||
94 | return | ||||
95 | "AccessControlException: Access to $this->{mode} $this->{web}.$topic for $this->{user} is denied. $this->{reason}"; | ||||
96 | } | ||||
97 | |||||
98 | 1 | 6µs | 1; | ||
99 | __END__ |