]> eyrie.org Git - kerberos/heimdal-kadm5.git/commitdiff
Cleanup and added $principal->getAttributeNames
authorJon Robertson <jonrober@stanford.edu>
Tue, 12 Jan 2010 00:10:17 +0000 (16:10 -0800)
committerJon Robertson <jonrober@stanford.edu>
Fri, 5 Feb 2010 22:19:56 +0000 (14:19 -0800)
Cleaned up the code and perldocs for word wrapping.  Also added
getAttributeNames, which wraps getAttributes, translating the bitmask into
an array of attribute names and returning that bitmask..

Kadm5.pm

index 85918ed8fc1475ebfa86cb9ffd4c2fdf54d2fcae..f3683544ccb596782404c9cfcbdac592adaf0401 100644 (file)
--- a/Kadm5.pm
+++ b/Kadm5.pm
@@ -510,31 +510,9 @@ sub _sec2days {
     }
 }
 
-# Given an attribute bitmask, convert it into a string of attribute text.
-sub _attr2str {
-    my $mask = shift;
-    my @attrs = ();
-    my @possible = ('KRB5_KDB_DISALLOW_ALL_TIX',
-                   'KRB5_KDB_DISALLOW_DUP_SKEY',
-                   'KRB5_KDB_DISALLOW_FORWARDABLE',
-                   'KRB5_KDB_DISALLOW_POSTDATED',
-                   'KRB5_KDB_DISALLOW_PROXIABLE',
-                   'KRB5_KDB_DISALLOW_RENEWABLE',
-                   'KRB5_KDB_DISALLOW_SVR',
-                   'KRB5_KDB_DISALLOW_TGT_BASED',
-                   'KRB5_KDB_NEW_PRINC',
-                   'KRB5_KDB_REQUIRES_HW_AUTH',
-                   'KRB5_KDB_REQUIRES_PRE_AUTH',
-                   'KRB5_KDB_REQUIRES_PWCHANGE',
-                   'KRB5_KDB_SUPPORT_DESMD5',
-                   );
-
-    foreach my $test (@possible) {
-       push (@attrs, $test) if $mask & &{"Heimdal::Kadm5::$test"}();
-    }
-    return join (', ', sort @attrs);
-}
-
+# Given a principal name, dump the information about that principal to a
+# given filehandle, or STDOUT if none is given.  The format of the output
+# should be identical to that of kadmin's 'get' command.
 sub dump
   {
     my $sp = shift;
@@ -560,7 +538,8 @@ sub dump
     printf $io "%21s: %d\n", 'Failed login count', $sp->getFailAuthCounts;
     printf $io "%21s: %s\n", 'Last modified', _sec2date($sp->getModDate);
     printf $io "%21s: %s\n", 'Modifier', $sp->getModName;
-    printf $io "%21s: %s\n", 'Attributes', _attr2str($sp->getAttributes);
+    printf $io "%21s: %s\n", 'Attributes',
+               join (', ', sort $sp->getAttributeNames);
     my @keys;
     foreach my $kt (@{$sp->getKeytypes}) 
       {
@@ -569,6 +548,34 @@ sub dump
     printf $io "%21s: %s\n\n", 'Keytypes', join(', ',@keys);
   }
 
+# A wrapper around getAttributes, which translates the bitmask into an array
+# of attribute names and returns that array.
+sub getAttributeNames
+  {
+    my $sp = shift;
+    my $bitmask = $sp->getAttributes;
+    my @attrs = ();
+    my @possible = ('KRB5_KDB_DISALLOW_ALL_TIX',
+                   'KRB5_KDB_DISALLOW_DUP_SKEY',
+                   'KRB5_KDB_DISALLOW_FORWARDABLE',
+                   'KRB5_KDB_DISALLOW_POSTDATED',
+                   'KRB5_KDB_DISALLOW_PROXIABLE',
+                   'KRB5_KDB_DISALLOW_RENEWABLE',
+                   'KRB5_KDB_DISALLOW_SVR',
+                   'KRB5_KDB_DISALLOW_TGT_BASED',
+                   'KRB5_KDB_NEW_PRINC',
+                   'KRB5_KDB_REQUIRES_HW_AUTH',
+                   'KRB5_KDB_REQUIRES_PRE_AUTH',
+                   'KRB5_KDB_REQUIRES_PWCHANGE',
+                   'KRB5_KDB_SUPPORT_DESMD5',
+       );
+
+    foreach my $test (@possible) {
+       push (@attrs, $test) if $bitmask & &{"Heimdal::Kadm5::$test"}();
+    }
+    return @attrs;
+  }
+
 # Autoload methods go after =cut, and are processed by the autosplit program.
 
 package Heimdal::Kadm5;
@@ -796,6 +803,12 @@ How many failed login attempts was done against this principal.
 
 my $bitmask = $principal->getAttributes();
 
+The bitmask of attributes for this principal.
+
+my @names = $principal->getAttributeNames();
+
+The list of attribute names for this principal, expanded from the bitmask.
+
 my $arrayref = $principal->getKeyTypes();
 
 getKeyTypes returns an array reference consisting of a list of array