summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-07-04 10:00:53 +0200
committerDaniel Friesel <derf@finalrewind.org>2011-07-04 10:00:53 +0200
commit2a03eac098be689fa11c371b926d3f2d8ae4c96d (patch)
tree8ae1e9e3a779ff8ea722c68885aad70f31ade3bf
parent1bc1cec23206cf212573fd283d81f8e030155261 (diff)
Raps2.pm: Add pw_load_info method (pw_load for unencrypted data)
-rw-r--r--Changelog1
-rwxr-xr-xbin/raps24
-rw-r--r--lib/App/Raps2.pm48
3 files changed, 39 insertions, 14 deletions
diff --git a/Changelog b/Changelog
index 8096a3c..86f6b64 100644
--- a/Changelog
+++ b/Changelog
@@ -7,6 +7,7 @@ git HEAD
* pw_load now also returns the salt
* file_to_hash now returns a hashref instead of a hash
* Allow password to be passed as argument to get_master_password
+ * Add pw_load_info method
App::Raps2 0.4 - Sun Jul 03 2011
diff --git a/bin/raps2 b/bin/raps2
index 689ecd2..cb74009 100755
--- a/bin/raps2
+++ b/bin/raps2
@@ -141,7 +141,7 @@ sub cmd_info {
exit 2;
}
- my $key = $raps2->file_to_hash($pwfile);
+ my $key = $raps2->pw_load_info( file => $pwfile );
$raps2->ui->output( [ 'URL', $key->{url} ], [ 'Login', $key->{login} ], );
return;
@@ -151,7 +151,7 @@ sub cmd_list {
my @files = read_dir( data_home('raps2') );
for my $file ( sort @files ) {
- my $key = $raps2->file_to_hash( data_files("raps2/${file}") );
+ my $key = $raps2->pw_load_info( name => $file );
$raps2->ui->list(
[ 'Account', $file ],
[ 'Login', $key->{login} ],
diff --git a/lib/App/Raps2.pm b/lib/App/Raps2.pm
index 720e942..96f37d7 100644
--- a/lib/App/Raps2.pm
+++ b/lib/App/Raps2.pm
@@ -177,6 +177,20 @@ sub pw_load {
};
}
+sub pw_load_info {
+ my ( $self, %data ) = @_;
+
+ $data{file} //= $self->{xdg_data} . "/$data{name}";
+
+ my $key = $self->file_to_hash( $data{file} );
+
+ return {
+ url => $key->{url},
+ login => $key->{login},
+ salt => $key->{salt},
+ };
+}
+
1;
__END__
@@ -203,7 +217,7 @@ This manual documents App::Raps2 version 0.4
=over
-=item $raps2 = App::Raps2->new(I<%conf>)
+=item $raps2 = App::Raps2->new( I<%conf> )
Returns a new B<App::Raps2> object.
@@ -217,17 +231,12 @@ B<cost> of key setup, passed on to App::Raps2::Password(3pm).
=back
-=item $raps2->file_to_hash(I<$file>)
-
-Reads $file (lines with key/value separated by whitespace) and returns a
-hashref with its key/value pairs.
-
-=item $raps2->get_master_password([I<$password>])
+=item $raps2->get_master_password( [I<$password>] )
Sets the master password used to encrypt all accounts. Uses I<password> if
specified, otherwise it asks the user via App::Raps2::UI(3pm).
-=item $raps2->pw_save(I<%data>)
+=item $raps2->pw_save( I<%data> )
Write an account as specified by I<data> to the store. Requires
B<get_master_password> to have been called before.
@@ -250,11 +259,21 @@ The following I<data> keys are supported:
=back
-=item $raps2->pw_load(B<file> => I<file> | B<name> => I<name>)
+=item $raps2->pw_load( B<file> => I<file> | B<name> => I<name> )
+
+Load a password from I<file> (or account I<name>), requires
+B<get_master_password> to have been called before.
+
+Returns a hashref containing its url, login, salt and decrypted password and
+extra.
+
+=item $raps2->pw_load_info( B<file> => I<file> | B<name> => I<name> )
-Loads a password from I<file> (or account I<name>), requires
-B<get_master_password> to have been called before. Returns a hashref
-containing its url, login and decrypted password and extra.
+Load all unencrypted data from I<file> (or account I<name>). Unlike
+B<pw_load>, this method does not require a prior call to
+B<get_master_password>.
+
+Returns a hashref with url, login and salt.
=back
@@ -288,6 +307,11 @@ Returns the App::Raps2::Password(3pm) object.
Returns the App::Raps2::UI(3pm) object.
+=item $raps2->file_to_hash( I<$file> )
+
+Reads $file (lines with key/value separated by whitespace) and returns a
+hashref with its key/value pairs.
+
=back
=head1 DIAGNOSTICS