From c5eb54321d631431d290fb27624bcbbf03626ff6 Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Thu, 18 Feb 2010 16:34:24 -0800 Subject: Refactor Wallet::Kadmin::Heimdal constructor Remove the separate kadmin_client method by combining it with the constructor, since that was the only place it was called. --- perl/Wallet/Kadmin/Heimdal.pm | 45 +++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/perl/Wallet/Kadmin/Heimdal.pm b/perl/Wallet/Kadmin/Heimdal.pm index 3047b2f..2d393e2 100644 --- a/perl/Wallet/Kadmin/Heimdal.pm +++ b/perl/Wallet/Kadmin/Heimdal.pm @@ -39,30 +39,6 @@ sub canonicalize_principal { return $principal; } -############################################################################## -# kadmin Interaction -############################################################################## - -# Create a Heimdal::Kadm5 client object and return it. It should load -# configuration from Wallet::Config. -sub kadmin_client { - my ($self) = @_; - unless (defined ($Wallet::Config::KEYTAB_PRINCIPAL) - and defined ($Wallet::Config::KEYTAB_FILE) - and defined ($Wallet::Config::KEYTAB_REALM)) { - die "keytab object implementation not configured\n"; - } - my @options = (RaiseError => 1, - Principal => $Wallet::Config::KEYTAB_PRINCIPAL, - Realm => $Wallet::Config::KEYTAB_REALM, - Keytab => $Wallet::Config::KEYTAB_FILE); - if ($Wallet::Config::KEYTAB_HOST) { - push (@options, Server => $Wallet::Config::KEYTAB_HOST); - } - my $client = Heimdal::Kadm5::Client->new (@options); - return $client; -} - ############################################################################## # Public interfaces ############################################################################## @@ -198,14 +174,25 @@ sub delprinc { return 1; } -# Create a new Heimdal kadmin object. +# Create a new Wallet::Kadmin::Heimdal object and its underlying +# Heimdal::Kadm5 object. sub new { my ($class) = @_; - my $self = { - client => undef, - }; + unless (defined ($Wallet::Config::KEYTAB_PRINCIPAL) + and defined ($Wallet::Config::KEYTAB_FILE) + and defined ($Wallet::Config::KEYTAB_REALM)) { + die "keytab object implementation not configured\n"; + } + my @options = (RaiseError => 1, + Principal => $Wallet::Config::KEYTAB_PRINCIPAL, + Realm => $Wallet::Config::KEYTAB_REALM, + Keytab => $Wallet::Config::KEYTAB_FILE); + if ($Wallet::Config::KEYTAB_HOST) { + push (@options, Server => $Wallet::Config::KEYTAB_HOST); + } + my $client = Heimdal::Kadm5::Client->new (@options); + my $self = { client => $client }; bless ($self, $class); - $self->{client} = $self->kadmin_client; return $self; } -- cgit v1.2.3