diff options
author | Jan Cholasta <jcholast@redhat.com> | 2016-06-14 09:44:22 +0200 |
---|---|---|
committer | Jan Cholasta <jcholast@redhat.com> | 2016-06-21 09:45:20 +0200 |
commit | b00dbca98fee86f0c7584f1f37db376db9a57566 (patch) | |
tree | 690847a763400c28f9224a5ec577eac003f24022 /ipaclient | |
parent | 9b2146be402990448c019cfcd93dcf570ef30fbc (diff) | |
download | freeipa-b00dbca98fee86f0c7584f1f37db376db9a57566.tar.gz freeipa-b00dbca98fee86f0c7584f1f37db376db9a57566.tar.xz freeipa-b00dbca98fee86f0c7584f1f37db376db9a57566.zip |
cert: allow search by certificate
Allow search by certificate data or file in cert-find.
https://fedorahosted.org/freeipa/ticket/5381
Reviewed-By: David Kupka <dkupka@redhat.com>
Reviewed-By: Pavel Vomacka <pvomacka@redhat.com>
Diffstat (limited to 'ipaclient')
-rw-r--r-- | ipaclient/plugins/cert.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/ipaclient/plugins/cert.py b/ipaclient/plugins/cert.py index 7e8e15662..de4318b68 100644 --- a/ipaclient/plugins/cert.py +++ b/ipaclient/plugins/cert.py @@ -25,6 +25,7 @@ from ipalib import x509 from ipalib import util from ipalib.parameters import File from ipalib.plugable import Registry +from ipalib.text import _ register = Registry() @@ -51,3 +52,25 @@ class cert_show(MethodOverride): raise errors.NoCertificateError(entry=keys[-1]) else: return super(cert_show, self).forward(*keys, **options) + + +@register(override=True) +class cert_find(MethodOverride): + takes_options = ( + File( + 'file?', + label=_("Input filename"), + doc=_('File to load the certificate from.'), + include='cli', + ), + ) + + def forward(self, *args, **options): + if self.api.env.context == 'cli': + if 'certificate' in options and 'file' in options: + raise errors.MutuallyExclusiveError( + reason=_("cannot specify both raw certificate and file")) + if 'certificate' not in options and 'file' in options: + options['certificate'] = x509.strip_header(options.pop('file')) + + return super(cert_find, self).forward(*args, **options) |