Skip to content

Commit

Permalink
Add pki-server ocsp-crl-issuingpoint-find
Browse files Browse the repository at this point in the history
The pki-server ocsp-crl-issuingpoint-find has been added
to wrap OCSPCRLIssuingPointFindCLI.
  • Loading branch information
edewata committed Feb 12, 2021
1 parent d92efa3 commit 0c3f7e0
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 0 deletions.
88 changes: 88 additions & 0 deletions base/server/python/pki/server/cli/ocsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def __init__(self):

self.add_module(pki.server.cli.audit.AuditCLI(self))
self.add_module(OCSPCloneCLI())
self.add_module(OCSPCRLCLI())
self.add_module(pki.server.cli.config.SubsystemConfigCLI(self))
self.add_module(pki.server.cli.db.SubsystemDBCLI(self))
self.add_module(pki.server.cli.group.GroupCLI(self))
Expand Down Expand Up @@ -171,3 +172,90 @@ def execute(self, argv):

finally:
shutil.rmtree(tmpdir)


class OCSPCRLCLI(pki.cli.CLI):

def __init__(self):
super(OCSPCRLCLI, self).__init__(
'crl', 'OCSP CRL management commands')

self.add_module(OCSPCRLIssuingPointCLI())


class OCSPCRLIssuingPointCLI(pki.cli.CLI):

def __init__(self):
super(OCSPCRLIssuingPointCLI, self).__init__(
'issuingpoint', 'OCSP CRL issuing point management commands')

self.add_module(OCSPCRLIssuingPointFindCLI())


class OCSPCRLIssuingPointFindCLI(pki.cli.CLI):

def __init__(self):
super(OCSPCRLIssuingPointFindCLI, self).__init__(
'find',
'Find OCSP CRL issuing points')

def print_help(self):
print('Usage: pki-server ocsp-crl-issuingpoint-find [OPTIONS]')
print()
print(' -i, --instance <instance ID> Instance ID (default: pki-tomcat)')
print(' --size <size> Page size')
print(' -v, --verbose Run in verbose mode.')
print(' --debug Run in debug mode.')
print(' --help Show help message.')
print()

def execute(self, argv):
try:
opts, _ = getopt.gnu_getopt(argv, 'i:v', [
'instance=', 'size=',
'verbose', 'debug', 'help'])

except getopt.GetoptError as e:
logger.error(e)
self.print_help()
sys.exit(1)

instance_name = 'pki-tomcat'
size = None

for o, a in opts:
if o in ('-i', '--instance'):
instance_name = a

elif o == '--size':
size = a

elif o in ('-v', '--verbose'):
logging.getLogger().setLevel(logging.INFO)

elif o == '--debug':
logging.getLogger().setLevel(logging.DEBUG)

elif o == '--help':
self.print_help()
sys.exit()

else:
logger.error('Invalid option: %s', o)
self.print_help()
sys.exit(1)

instance = pki.server.instance.PKIServerFactory.create(instance_name)
if not instance.exists():
logger.error('Invalid instance: %s', instance_name)
sys.exit(1)

instance.load()

subsystem = instance.get_subsystem('ocsp')

if not subsystem:
logger.error('No OCSP subsystem in instance %s', instance_name)
sys.exit(1)

subsystem.find_crl_issuing_point(size=size)
18 changes: 18 additions & 0 deletions base/server/python/pki/server/subsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -1771,6 +1771,24 @@ class OCSPSubsystem(PKISubsystem):
def __init__(self, instance):
super(OCSPSubsystem, self).__init__(instance, 'ocsp')

def find_crl_issuing_point(
self,
size=None,
as_current_user=False):

cmd = [self.name + '-crl-issuingpoint-find']

if size:
cmd.extend(['--size', size])

if logger.isEnabledFor(logging.DEBUG):
cmd.append('--debug')

elif logger.isEnabledFor(logging.INFO):
cmd.append('--verbose')

self.run(cmd, as_current_user=as_current_user)


class TKSSubsystem(PKISubsystem):

Expand Down

0 comments on commit 0c3f7e0

Please sign in to comment.