Token/Empty.pm untested

filter: Statementstmt 0.0% 0 / 41 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 68 CC 7 SCAR 21.2
CC
7
Cov
0%
setError
12.0
AUTOLOAD
12.0
new
6.0
CRAP 8.3
1 ## OpenCA::Token::Empty.pm
2 ##
3 ## Written by Michael Bell for the OpenCA project 2003
4 ## Copyright (C) 2003-2004 The OpenCA Project
5 ## All rights reserved.
6 ##
7 ## This library is free software; you can redistribute it and/or
8 ## modify it under the terms of the GNU Lesser General Public
9 ## License as published by the Free Software Foundation; either
10 ## version 2.1 of the License, or (at your option) any later version.
11 ##
12 ## This library is distributed in the hope that it will be useful,
13 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 ## Lesser General Public License for more details.
16 ##
17 ## You should have received a copy of the GNU Lesser General Public
18 ## License along with this library; if not, write to the Free Software
19 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 ##
21  
22 use strict;
23  
24 ###############################################################
25 ## ============ Empty Example ============= ##
26 ###############################################################
27  
28 package OpenCA::Token::Empty;
29  
30 our ($errno, $errval);
31  
32 ($OpenCA::Token::Empty::VERSION = '$Revision: 1.1.1.1 $' )=~ s/(?:^.*: (\d+))|(?:\s+\$$)/defined $1?"0\.9":""/eg;
33  
34 # Preloaded methods go here.
35  
36 ## Create an instance of the Class
37 sub new {
38 my $that = shift;
39 my $class = ref($that) || $that;
40  
41 my $self = {
42 DEBUG => 0,
43 };
44  
45 bless $self, $class;
46  
47 my $keys = { @_ };
48 $self->{CRYPTO} = $keys->{OPENCA_CRYPTO};
49 return undef if (not $self->{CRYPTO});
50  
51 return $self;
52 }
53  
54 sub setError {
55 my $self = shift;
56  
57 if (scalar (@_) == 4) {
58 my $keys = { @_ };
59 $errval = $keys->{ERRVAL};
60 $errno = $keys->{ERRNO};
61 } else {
62 $errno = $_[0];
63 $errval = $_[1];
64 }
65  
66 return undef if (not $errno);
67  
68 $self->debug ("setError: $errno: $errval");
69  
70 ## support for: return $self->setError (1234, "Something fails.") if (not $xyz);
71 return undef;
72 }
73  
74 sub debug {
75  
76 my $self = shift;
77  
78 return 1 if (not $self->{DEBUG});
79  
80 foreach my $msg (@_) {
81 print STDERR "OpenCA::Crypto->$msg\n";
82 }
83  
84 return 1;
85 }
86  
87 ## failover to default token
88 sub AUTOLOAD {
89 my $self = shift;
90 use vars qw($AUTOLOAD);
91  
92 $self->debug ("OpenCA::Token::EMPTY: AUTOLOAD => $AUTOLOAD");
93  
94 return 1 if ($AUTOLOAD eq 'OpenCA::Token::EMPTY::DESTROY');
95  
96 my $function = $AUTOLOAD;
97 $function =~ s/.*:://g;
98 my $ret = $self->{CRYPTO}->$function ( @_ );
99 $self->setError ($OpenCA::OpenSSL::errno, $OpenCA::OpenSSL::errval) if (not defined $ret);
100 return $ret;
101 }
102  
103 1;