def setup_admin(self, client): request = pki.system.AdminSetupRequest() request.pin = self.mdict['pki_one_time_pin'] request.installToken = self.install_token self.config_client.set_admin_parameters(request) response = client.setupAdmin(request) if config.str2bool(self.mdict['pki_external']) \ or config.str2bool(self.mdict['pki_standalone']) \ or not config.str2bool(self.mdict['pki_import_admin_cert']): admin_cert = response['adminCert']['cert'] self.config_client.process_admin_cert(admin_cert)
def setup_admin(self, subsystem, client): uid = self.mdict['pki_admin_uid'] full_name = self.mdict['pki_admin_name'] email = self.mdict['pki_admin_email'] password = self.mdict['pki_admin_password'] tps_profiles = None if subsystem.type == 'TPS': tps_profiles = ['All Profiles'] request = pki.system.AdminSetupRequest() request.pin = self.mdict['pki_one_time_pin'] request.installToken = self.install_token self.config_client.set_admin_parameters(request) response = client.setupAdmin(request) subsystem.add_user( uid, full_name=full_name, email=email, password=password, user_type='adminType', state='1', tps_profiles=tps_profiles) admin_groups = subsystem.config['preop.admin.group'] groups = [x.strip() for x in admin_groups.split(',')] if subsystem.config['securitydomain.select'] == 'new': if subsystem.type == 'CA': groups.extend([ 'Security Domain Administrators', 'Enterprise CA Administrators', 'Enterprise KRA Administrators', 'Enterprise RA Administrators', 'Enterprise TKS Administrators', 'Enterprise OCSP Administrators', 'Enterprise TPS Administrators' ]) elif subsystem.type == 'KRA': groups.extend([ 'Security Domain Administrators', 'Enterprise KRA Administrators' ]) elif subsystem.type == 'OCSP': groups.extend([ 'Security Domain Administrators', 'Enterprise OCSP Administrators' ]) for group in groups: logger.info('Adding %s into %s', uid, group) subsystem.add_group_member(group, uid) admin_cert = response['adminCert']['cert'] cert_data = base64.b64decode(admin_cert) logger.info('Adding certificate for %s', uid) subsystem.add_user_cert(uid, cert_data=cert_data, cert_format='DER') if config.str2bool(self.mdict['pki_external']) \ or config.str2bool(self.mdict['pki_standalone']) \ or not config.str2bool(self.mdict['pki_import_admin_cert']): self.config_client.process_admin_cert(admin_cert)