Skip to content

Commit 39859ae

Browse files
committed
Replace PKIDeployer.sd_connection with sd_client
1 parent 8d096fe commit 39859ae

2 files changed

Lines changed: 21 additions & 22 deletions

File tree

base/common/python/pki/client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,9 @@ def __init__(
416416

417417
self.info_client = pki.info.InfoClient(self)
418418

419+
def authenticate(self, username=None, password=None):
420+
self.connection.authenticate(username, password)
421+
419422
def set_client_auth(self, client_cert, client_key=None):
420423
self.connection.set_authentication_cert(client_cert, client_key)
421424

base/server/python/pki/server/deployment/__init__.py

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def __init__(self):
120120
if not len(self.dns_domainname):
121121
self.dns_domainname = self.hostname
122122

123-
self.sd_connection = None
123+
self.sd_client = None
124124

125125
self.domain_info = None
126126
self.sd_host = None
@@ -2622,15 +2622,10 @@ def ds_close(self, ds_connection):
26222622

26232623
def sd_connect(self):
26242624

2625-
if self.sd_connection:
2626-
return self.sd_connection
2625+
if self.sd_client:
2626+
return self.sd_client
26272627

26282628
sd_url = self.mdict['pki_security_domain_uri']
2629-
2630-
url = urllib.parse.urlparse(sd_url)
2631-
sd_hostname = url.hostname
2632-
sd_port = str(url.port)
2633-
26342629
logger.info('Connecting to security domain at %s', sd_url)
26352630

26362631
conf_dir = os.path.join(pki.server.PKIServer.CONFIG_DIR,
@@ -2651,38 +2646,38 @@ def sd_connect(self):
26512646

26522647
ca_cert = cert_chain_path
26532648

2654-
self.sd_connection = pki.client.PKIConnection(
2655-
protocol='https',
2656-
hostname=sd_hostname,
2657-
port=sd_port,
2649+
self.sd_client = pki.client.PKIClient(
2650+
url=sd_url,
26582651
trust_env=False,
2659-
cert_paths=ca_cert)
2652+
ca_bundle=ca_cert)
26602653

2661-
return self.sd_connection
2654+
return self.sd_client
26622655

26632656
def get_domain_info(self):
26642657

26652658
logger.info('Getting security domain info')
26662659

26672660
self.sd_connect()
26682661

2669-
sd_client = pki.system.SecurityDomainClient(self.sd_connection)
2670-
domain_info = sd_client.get_domain_info()
2662+
ca_client = pki.ca.CAClient(self.sd_client)
2663+
domain_client = pki.system.SecurityDomainClient(ca_client)
2664+
domain_info = domain_client.get_domain_info()
26712665

26722666
return domain_info
26732667

26742668
def sd_login(self):
26752669

26762670
sd_user = self.mdict['pki_security_domain_user']
26772671
sd_password = self.mdict['pki_security_domain_password']
2672+
self.sd_client.authenticate(sd_user, sd_password)
26782673

2679-
self.sd_connection.authenticate(sd_user, sd_password)
2680-
2681-
account = pki.account.AccountClient(self.sd_connection, subsystem='ca')
2674+
ca_client = pki.ca.CAClient(self.sd_client)
2675+
account = pki.account.AccountClient(ca_client)
26822676
account.login()
26832677

26842678
def sd_logout(self):
2685-
account = pki.account.AccountClient(self.sd_connection, subsystem='ca')
2679+
ca_client = pki.ca.CAClient(self.sd_client)
2680+
account = pki.account.AccountClient(ca_client)
26862681
account.logout()
26872682

26882683
def get_install_token(self):
@@ -2692,8 +2687,9 @@ def get_install_token(self):
26922687
hostname = self.mdict['pki_hostname']
26932688
subsystem = self.subsystem_type
26942689

2695-
sd_client = pki.system.SecurityDomainClient(self.sd_connection)
2696-
install_token = sd_client.get_install_token(hostname, subsystem)
2690+
ca_client = pki.ca.CAClient(self.sd_client)
2691+
token_client = pki.system.SecurityDomainClient(ca_client)
2692+
install_token = token_client.get_install_token(hostname, subsystem)
26972693

26982694
# Sleep for a bit to allow the install token to replicate to other clones.
26992695
# In the future this can be replaced with signed tokens.

0 commit comments

Comments
 (0)