| 1 | package OpenInteract2::Exception::Security; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # $Id: Security.pm,v 1.13 2005/03/17 14:58:02 sjn Exp $ | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 87 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 87 | ▶ | use base qw( OpenInteract2::Exception Class::Accessor::Fast ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 87 | ▶ | use SPOPS::Secure qw( :verbose :level ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 87 | $OpenInteract2::Exception::Security::VERSION = sprintf("%d.%02d", q$Revision: 1.13 $ =~ /(\d+)\.(\d+)/); | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 87 | my @FIELDS = qw( security_required security_found ); | |||||||||||||||||||||||||||
| 12 | 87 | OpenInteract2::Exception::Security->mk_accessors( @FIELDS ); | |||||||||||||||||||||||||||
| 13 | 2 | ▶ | sub Fields { return @FIELDS } | ||||||||||||||||||||||||||
|
Subroutine
Fields: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 87 | my ( $CTX ); | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 87 | my $DEFAULT_MSG = "Security violation. Object requires '%s' but got '%s'"; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 87 | 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 | 2 | ▶ | sub full_message { | ||||||||||||||||||||||||||
|
Subroutine
full_message: called CC=7 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||
| 27 | 2 | my ( $self ) = @_; | |||||||||||||||||||||||||||
| 28 | my $required = ( $self->security_required ) | ||||||||||||||||||||||||||||
| 29 | 2 | ▶ | ? $LEVELS{ $self->security_required } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | : 'none specified'; | ||||||||||||||||||||||||||||
| 31 | my $found = ( $self->security_found ) | ||||||||||||||||||||||||||||
| 32 | 2 | ▶ | ? $LEVELS{ $self->security_found } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | : 'none specified'; | ||||||||||||||||||||||||||||
| 34 | 2 | ▶ | unless ( $CTX ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 2 | require OpenInteract2::Context; | |||||||||||||||||||||||||||
| 36 | 2 | $CTX = OpenInteract2::Context->instance( 1 ); | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | 2 | my ( $msg ); | |||||||||||||||||||||||||||
| 39 | 2 | ▶ | if ( $CTX && $CTX->request ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$CTX and $CTX->request
MC/DC0%0/2
$CTX and $CTX->request
$CTX
$CTX->request
Truth table33%1/3
A and B
A= $CTXB= $CTX->request
| |||||||||||||||||||||||||||||
| 40 | 0 | $msg = eval { | |||||||||||||||||||||||||||
| 41 | 0 | $CTX->request | |||||||||||||||||||||||||||
| 42 | ->language_handle | ||||||||||||||||||||||||||||
| 43 | ->maketext( 'global.exception.security', $required, $found ); | ||||||||||||||||||||||||||||
| 44 | }; | ||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | 2 | ▶ | unless ( $msg ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | 2 | $msg = sprintf( $DEFAULT_MSG, $required, $found ); | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | 2 | return $msg; | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 87 | 1; | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | __END__ | ||||||||||||||||||||||||||||