}
}
-# 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;
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})
{
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;
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