line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OpenInteract2::Exception::Security; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# $Id: Security.pm,v 1.13 2005/03/17 14:58:02 sjn Exp $ |
4
|
|
|
|
|
|
|
|
5
|
86
|
|
|
86
|
|
635
|
use strict; |
|
86
|
|
|
|
|
230
|
|
|
86
|
|
|
|
|
3346
|
|
6
|
86
|
|
|
86
|
|
456
|
use base qw( OpenInteract2::Exception Class::Accessor::Fast ); |
|
86
|
|
|
|
|
150
|
|
|
86
|
|
|
|
|
11015
|
|
7
|
86
|
|
|
86
|
|
85933
|
use SPOPS::Secure qw( :verbose :level ); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
$OpenInteract2::Exception::Security::VERSION = sprintf("%d.%02d", q$Revision: 1.13 $ =~ /(\d+)\.(\d+)/); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my @FIELDS = qw( security_required security_found ); |
12
|
|
|
|
|
|
|
OpenInteract2::Exception::Security->mk_accessors( @FIELDS ); |
13
|
|
|
|
|
|
|
sub Fields { return @FIELDS } |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my ( $CTX ); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $DEFAULT_MSG = "Security violation. Object requires '%s' but got '%s'"; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my %LEVELS = ( |
20
|
|
|
|
|
|
|
SEC_LEVEL_NONE() => SEC_LEVEL_NONE_VERBOSE, |
21
|
|
|
|
|
|
|
SEC_LEVEL_SUMMARY() => SEC_LEVEL_SUMMARY_VERBOSE, |
22
|
|
|
|
|
|
|
SEC_LEVEL_READ() => SEC_LEVEL_READ_VERBOSE, |
23
|
|
|
|
|
|
|
SEC_LEVEL_WRITE() => SEC_LEVEL_WRITE_VERBOSE, |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub full_message { |
27
|
|
|
|
|
|
|
my ( $self ) = @_; |
28
|
|
|
|
|
|
|
my $required = ( $self->security_required ) |
29
|
|
|
|
|
|
|
? $LEVELS{ $self->security_required } |
30
|
|
|
|
|
|
|
: 'none specified'; |
31
|
|
|
|
|
|
|
my $found = ( $self->security_found ) |
32
|
|
|
|
|
|
|
? $LEVELS{ $self->security_found } |
33
|
|
|
|
|
|
|
: 'none specified'; |
34
|
|
|
|
|
|
|
unless ( $CTX ) { |
35
|
|
|
|
|
|
|
require OpenInteract2::Context; |
36
|
|
|
|
|
|
|
$CTX = OpenInteract2::Context->instance( 1 ); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
my ( $msg ); |
39
|
|
|
|
|
|
|
if ( $CTX && $CTX->request ) { |
40
|
|
|
|
|
|
|
$msg = eval { |
41
|
|
|
|
|
|
|
$CTX->request |
42
|
|
|
|
|
|
|
->language_handle |
43
|
|
|
|
|
|
|
->maketext( 'global.exception.security', $required, $found ); |
44
|
|
|
|
|
|
|
}; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
unless ( $msg ) { |
47
|
|
|
|
|
|
|
$msg = sprintf( $DEFAULT_MSG, $required, $found ); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
return $msg; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__END__ |