K = qw(
encode_json decode_json
json_true json_false
json_null
);
sub create_from_json {
my $json = shift;
my $class = shift;
my $opts = decode_json($json);
return unde
de_json { return Crypt::Keyczar::Util::JSON::encode(@_); }
sub decode_json { return Crypt::Keyczar::Util::JSON::decode(@_); }
sub json_true { return Crypt::Keyczar::Util::JSON::true(); }
sub json_fa
lse { return Crypt::Keyczar::Util::JSON::false(); }
sub json_null { return Crypt::Keyczar::Util::JSON::null(); }
sub encode {
my $src = shift;
return undef if !defined $src;
my $resu
return $self;
}
sub read {
my $class = shift;
my $json_string = shift;
my $obj = Crypt::Keyczar::Util::decode_json($json_string);
my $self = bless $obj, $class;
$self->init()
>{aesKeyString}) }
sub read {
my $class = shift;
my $json_string = shift;
my $obj = Crypt::Keyczar::Util::decode_json($json_string);
my $self = bless $obj, $class;
$self->{hmacK
ink($path) == 1;
}
sub _put {
my $path = shift;
my $json = shift;
open my $fh, '>', $path or croak "can't open file: $path: $!";
print $fh $json, "\n";
close $fh;
}
1;
__END__
Keyczar::Util qw(json_true json_false);
use Carp;
sub new {
my $class = shift;
my ($version, $status, $exportable) = @_;
my $self = bless {
exportable => json_false(),
my $json_string = shift;
my $obj = from_json($json_string);
return bless $obj, $class;
}
sub exportable {
my $self = shift;
$self->{exportable} = $_[0] ? json_true() : json_false
() if @_;
return $self->{exportable} eq json_true() ? 1 : undef;
}
sub status {
my $self = shift;
if (@_) {
if (uc $_[0] eq 'ACTIVE') {
$self->{status} = uc $_[0];
return $expose;
}
sub read {
my $class = shift;
my $json_string = shift;
my $obj = Crypt::Keyczar::Util::decode_json($json_string);
my $self = bless $obj, $class;
$self->{publi
hift;
my $json_key = undef;
return $json_key;
}
sub get_metadata {
croak "Please override, 'Crypt::Keyczar::Reader' is abstract class";
my $self = shift;
my $json_metadata = un
def;
return $json_metadata;
}
1;
__END__
}
return $key->generate($size);
}
sub read_key {
my $class = shift;
my ($type, $json_string_key) = @_;
if (!exists $POLICY{uc $type}) {
croak "unsupported key type: $typ
{
croak "$type: $@";
}
return $key->read($json_string_key);
}
sub to_string {
return Crypt::Keyczar::Util::encode_json($_[0]->expose);
}
1;
package Crypt::Keyczar::_NullSignE
return $expose;
}
sub read {
my $class = shift;
my $json_string = shift;
my $obj = Crypt::Keyczar::Util::decode_json($json_string);
my $self = bless $obj, $class;
$self->init()
return $expose;
}
sub read {
my $class = shift;
my $json_string = shift;
my $obj = Crypt::Keyczar::Util::decode_json($json_string);
my $self = bless $obj, $class;
$self->{publi
e warnings;
use Crypt::Keyczar::KeyVersion;
use Crypt::Keyczar::Util qw(decode_json encode_json json_true json_false json_null);
sub get_name { $_[0]->{name} }
sub get_purpose { $_[0]->{purpose} }
s
}, $class;
return $self;
}
sub read {
my $class = shift;
my $json_string = shift;
my $obj = decode_json($json_string);
my $self = $class->new($obj->{name}, $obj->{purpose}, $obj->
= $self->{encrypted} ? json_true() : json_false();
$expose->{versions} = [];
for my $v ($self->get_versions) {
push @{$expose->{versions}}, $v ? $v->expose : json_null();
}
re
return $expose;
}
sub read {
my $class = shift;
my $json_string = shift;
my $obj = Crypt::Keyczar::Util::decode_json($json_string);
my $self = bless $obj, $class;
$self->init()