File Coverage

blib/lib/SPOPS/Exception/Security.pm
Criterion Covered Total %
statement 14 15 93.3
branch 2 4 50.0
condition n/a
subroutine 5 6 83.3
pod 0 3 0.0
total 21 28 75.0


line stmt bran cond sub pod time code
1             package SPOPS::Exception::Security;
2              
3             # $Id: Security.pm,v 3.2 2004/06/02 00:48:22 lachoy Exp $
4              
5 3     3   1784 use strict;
  3         7  
  3         145  
6 3     3   18 use base qw( SPOPS::Exception );
  3         6  
  3         2766  
7 3     3   1073 use SPOPS::Secure qw( :verbose :level );
  3         7  
  3         7566  
8              
9             $SPOPS::Exception::Security::VERSION = sprintf("%d.%02d", q$Revision: 3.2 $ =~ /(\d+)\.(\d+)/);
10             @SPOPS::Exception::Security::EXPORT_OK = qw( spops_security_error );
11              
12             my @FIELDS = qw( security_required security_found );
13             SPOPS::Exception::Security->mk_accessors( @FIELDS );
14              
15             my %LEVELS = (
16             SEC_LEVEL_NONE() => SEC_LEVEL_NONE_VERBOSE,
17             SEC_LEVEL_SUMMARY() => SEC_LEVEL_SUMMARY_VERBOSE,
18             SEC_LEVEL_READ() => SEC_LEVEL_READ_VERBOSE,
19             SEC_LEVEL_WRITE() => SEC_LEVEL_WRITE_VERBOSE,
20             );
21              
22             sub get_fields {
23 1     1 0 10 return ( $_[0]->SUPER::get_fields, @FIELDS );
24             }
25              
26             sub spops_security_error {
27 0     0 0 0 goto &SPOPS::Exception( 'SPOPS::Exception::Security', @_ );
28             }
29              
30             sub to_string {
31 1     1 0 2 my ( $self ) = @_;
32 1 50       5 my $req = ( $self->security_required )
33             ? $LEVELS{ $self->security_required }
34             : 'none specified';
35 1 50       23 my $fnd = ( $self->security_found )
36             ? $LEVELS{ $self->security_found }
37             : 'none specified';
38 1         30 return "Security violation. Object requested [$req] and got [$fnd]";
39             }
40              
41             1;
42              
43             __END__