Skip to content
Snippets Groups Projects
Commit 400cf47f authored by Jon Robertson's avatar Jon Robertson
Browse files

Cleanup and added $principal->getAttributeNames

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..
parent bf1d02fb
No related branches found
No related tags found
No related merge requests found
...@@ -510,31 +510,9 @@ sub _sec2days { ...@@ -510,31 +510,9 @@ sub _sec2days {
} }
} }
# Given an attribute bitmask, convert it into a string of attribute text. # Given a principal name, dump the information about that principal to a
sub _attr2str { # given filehandle, or STDOUT if none is given. The format of the output
my $mask = shift; # should be identical to that of kadmin's 'get' command.
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);
}
sub dump sub dump
{ {
my $sp = shift; my $sp = shift;
...@@ -560,7 +538,8 @@ sub dump ...@@ -560,7 +538,8 @@ sub dump
printf $io "%21s: %d\n", 'Failed login count', $sp->getFailAuthCounts; 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", 'Last modified', _sec2date($sp->getModDate);
printf $io "%21s: %s\n", 'Modifier', $sp->getModName; 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; my @keys;
foreach my $kt (@{$sp->getKeytypes}) foreach my $kt (@{$sp->getKeytypes})
{ {
...@@ -569,6 +548,34 @@ sub dump ...@@ -569,6 +548,34 @@ sub dump
printf $io "%21s: %s\n\n", 'Keytypes', join(', ',@keys); 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. # Autoload methods go after =cut, and are processed by the autosplit program.
package Heimdal::Kadm5; package Heimdal::Kadm5;
...@@ -796,6 +803,12 @@ How many failed login attempts was done against this principal. ...@@ -796,6 +803,12 @@ How many failed login attempts was done against this principal.
my $bitmask = $principal->getAttributes(); 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(); my $arrayref = $principal->getKeyTypes();
getKeyTypes returns an array reference consisting of a list of array getKeyTypes returns an array reference consisting of a list of array
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment