diff --git a/CHANGELOG b/CHANGELOG index fcd2de6..296c972 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +1.13 + added Crypt::PWSafe3::PasswordPolicy submodule, which allows + to access the password policy of a PasswordSafe record. + 1.12 I somehow managed to mangle version numbers of sub modules, now all properly incremented. diff --git a/lib/Crypt/PWSafe3.pm b/lib/Crypt/PWSafe3.pm index 614a10b..7209df4 100644 --- a/lib/Crypt/PWSafe3.pm +++ b/lib/Crypt/PWSafe3.pm @@ -22,12 +22,13 @@ use Data::Dumper; use Exporter (); use vars qw(@ISA @EXPORT); -$Crypt::PWSafe3::VERSION = '1.12'; +$Crypt::PWSafe3::VERSION = '1.13'; use Crypt::PWSafe3::Field; use Crypt::PWSafe3::HeaderField; use Crypt::PWSafe3::Record; use Crypt::PWSafe3::SHA256; +use Crypt::PWSafe3::PasswordPolicy; require 5.10.0; diff --git a/lib/Crypt/PWSafe3/PasswordPolicy.pm b/lib/Crypt/PWSafe3/PasswordPolicy.pm index 40ca638..6db1313 100644 --- a/lib/Crypt/PWSafe3/PasswordPolicy.pm +++ b/lib/Crypt/PWSafe3/PasswordPolicy.pm @@ -67,6 +67,8 @@ sub new { sub decode { my($this, $raw) = @_; + return if $raw eq ''; + # expected input: ffffnnnllluuudddsss # create a 6-elemt array @@ -136,7 +138,7 @@ Crypt::PWSafe3::PasswordPolicy - represent a passwordsafe v3 passwprd policy ent use Crypt::PWSafe3; use Crypt::PWSafe3::PasswordPolicy; my $record = $vault->getrecord($uuid); - my $policy = Crypt::PWSafe3::PasswordPolicy->new(raw => $record->pwpol); + my $policy = $record->policy; # print current values print Dumper($policy); @@ -149,7 +151,9 @@ Crypt::PWSafe3::PasswordPolicy - represent a passwordsafe v3 passwprd policy ent $policy->MinSymbols(2); # put back into record - $record->raw($policy->encode()); + $record->policy($policy); + + =head1 DESCRIPTION diff --git a/lib/Crypt/PWSafe3/Record.pm b/lib/Crypt/PWSafe3/Record.pm index 73719a4..07ce1fc 100644 --- a/lib/Crypt/PWSafe3/Record.pm +++ b/lib/Crypt/PWSafe3/Record.pm @@ -9,7 +9,7 @@ my %map2type = %Crypt::PWSafe3::Field::map2type; my %map2name = %Crypt::PWSafe3::Field::map2name; -$Crypt::PWSafe3::Record::VERSION = '1.06'; +$Crypt::PWSafe3::Record::VERSION = '1.07'; foreach my $field (keys %map2type ) { eval qq( @@ -144,6 +144,22 @@ sub addfield { $this->{field}->{ $name } = $field; } +sub policy { + # + # return or set a password policy + my ($this, $policy) = @_; + + if($policy) { + $this->{policy} = $policy; + $this->pwpol($policy->encode()); + } + else { + $this->{policy} = Crypt::PWSafe3::PasswordPolicy->new(raw => $this->pwpol); + } + + return $this->{policy}; +} + =head1 NAME Crypt::PWSafe3::Record - Represents a Passwordsafe v3 data record @@ -265,9 +281,18 @@ for more details. Returns the password policy without argument. Sets the password policy if an argument is given. -B doesn't update the pwpol field currently. So if -you mind, do it yourself. Refer to L -for more details. +This is the raw encoded policy string. If you want to access it, use the +B method, see below. + +=head2 B + +If called without arguments, returns a Crypt::PWSafe3::PasswordPolicy +object. See L for details, how to access +it. + +To modify the password policy, create new Crypt::PWSafe3::PasswordPolicy +object or modify the existing one and pass it as argument to the +B method. =head2 B