summaryrefslogtreecommitdiff
path: root/perl/Wallet/ACL.pm
diff options
context:
space:
mode:
authorRuss Allbery <rra@stanford.edu>2007-09-17 15:49:25 +0000
committerRuss Allbery <rra@stanford.edu>2007-09-17 15:49:25 +0000
commita793a836222b551517e359b47ba0882b4910944d (patch)
tree58dfce77002ca1f6eed78eda49d4844350e87be1 /perl/Wallet/ACL.pm
parent8e0d26958a8c7991f434f878ce1b9b85454d390b (diff)
Add a show method to Wallet::ACL.
Diffstat (limited to 'perl/Wallet/ACL.pm')
-rw-r--r--perl/Wallet/ACL.pm28
1 files changed, 28 insertions, 0 deletions
diff --git a/perl/Wallet/ACL.pm b/perl/Wallet/ACL.pm
index a0417f8..d6cc29c 100644
--- a/perl/Wallet/ACL.pm
+++ b/perl/Wallet/ACL.pm
@@ -278,6 +278,26 @@ sub list {
}
}
+# Return as a string a human-readable description of an ACL, including its
+# membership. This method is only for human-readable output; use the list()
+# method if you are using the results in other code. Returns undef on
+# failure.
+sub show {
+ my ($self) = @_;
+ my @entries = $self->list;
+ if (@entries == 1 and not defined ($entries[0])) {
+ return undef;
+ }
+ my $name = $self->name;
+ my $id = $self->id;
+ my $output = "Members of ACL $name (id: $id) are:\n";
+ for my $entry (sort { $$a[0] cmp $$b[0] or $$a[1] cmp $$b[1] } @entries) {
+ my ($scheme, $identifier) = @$entry;
+ $output .= " $scheme $identifier\n";
+ }
+ return $output;
+}
+
# Given a principal, check whether it should be granted access according to
# this ACL. Returns 1 if access was granted, 0 if access was denied, and
# undef on some error. Errors from ACL verifiers do not cause an error
@@ -488,6 +508,14 @@ failure, the caller should call error() to get the error message.
Note that rename() operations are not logged in the ACL history.
+=item show()
+
+Returns a human-readable description of this ACL, including its membership.
+This method should only be used for display of the ACL to humans. Use the
+list(), name(), and id() methods instead to get ACL information for use in
+other code. On failure, returns undef, and the caller should call error()
+to get the error message.
+
=back
=head1 SEE ALSO