2009-09-10 15:15:14 -05:00
|
|
|
# Authors:
|
|
|
|
# Rob Crittenden <rcritten@@redhat.com>
|
|
|
|
#
|
|
|
|
# Copyright (C) 2009 Red Hat
|
|
|
|
# see file 'COPYING' for use and warranty information
|
|
|
|
#
|
2010-12-09 06:59:11 -06:00
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
2009-09-10 15:15:14 -05:00
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2010-12-09 06:59:11 -06:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2009-09-10 15:15:14 -05:00
|
|
|
|
|
|
|
"""
|
|
|
|
Backend plugin for RA activities.
|
|
|
|
|
|
|
|
The `ra` plugin provides access to the CA to issue, retrieve, and revoke
|
|
|
|
certificates via the following methods:
|
|
|
|
|
|
|
|
* `ra.check_request_status()` - check certificate request status.
|
|
|
|
* `ra.get_certificate()` - retrieve an existing certificate.
|
|
|
|
* `ra.request_certificate()` - request a new certificate.
|
|
|
|
* `ra.revoke_certificate()` - revoke a certificate.
|
|
|
|
* `ra.take_certificate_off_hold()` - take a certificate off hold.
|
|
|
|
"""
|
|
|
|
|
|
|
|
from ipalib import api
|
|
|
|
from ipalib import Backend
|
|
|
|
from ipalib import errors
|
|
|
|
from ipaserver.install import certs
|
|
|
|
import os
|
2014-05-29 07:47:17 -05:00
|
|
|
from ipaplatform.paths import paths
|
2009-09-10 15:15:14 -05:00
|
|
|
|
|
|
|
class rabase(Backend):
|
|
|
|
"""
|
|
|
|
Request Authority backend plugin.
|
|
|
|
"""
|
2015-06-22 05:58:43 -05:00
|
|
|
def __init__(self, api):
|
2010-03-30 14:27:28 -05:00
|
|
|
if api.env.in_tree:
|
2009-09-10 15:15:14 -05:00
|
|
|
self.sec_dir = api.env.dot_ipa + os.sep + 'alias'
|
|
|
|
self.pwd_file = self.sec_dir + os.sep + '.pwd'
|
|
|
|
else:
|
2014-05-29 07:47:17 -05:00
|
|
|
self.sec_dir = paths.HTTPD_ALIAS_DIR
|
|
|
|
self.pwd_file = paths.ALIAS_PWDFILE_TXT
|
2015-06-22 05:58:43 -05:00
|
|
|
super(rabase, self).__init__(api)
|
2009-09-10 15:15:14 -05:00
|
|
|
|
|
|
|
|
|
|
|
def check_request_status(self, request_id):
|
|
|
|
"""
|
|
|
|
Check status of a certificate signing request.
|
|
|
|
|
|
|
|
:param request_id: request ID
|
|
|
|
"""
|
|
|
|
raise errors.NotImplementedError(name='%s.check_request_status' % self.name)
|
|
|
|
|
|
|
|
def get_certificate(self, serial_number=None):
|
|
|
|
"""
|
|
|
|
Retrieve an existing certificate.
|
|
|
|
|
|
|
|
:param serial_number: certificate serial number
|
|
|
|
"""
|
2009-11-19 15:18:45 -06:00
|
|
|
raise errors.NotImplementedError(name='%s.get_certificate' % self.name)
|
2009-09-10 15:15:14 -05:00
|
|
|
|
2015-05-08 01:23:24 -05:00
|
|
|
def request_certificate(self, csr, profile_id, request_type='pkcs10'):
|
2009-09-10 15:15:14 -05:00
|
|
|
"""
|
|
|
|
Submit certificate signing request.
|
|
|
|
|
|
|
|
:param csr: The certificate signing request.
|
2015-05-08 01:23:24 -05:00
|
|
|
:param profile_id: Profile to use for this request.
|
2009-09-10 15:15:14 -05:00
|
|
|
:param request_type: The request type (defaults to ``'pkcs10'``).
|
|
|
|
"""
|
2009-11-19 15:18:45 -06:00
|
|
|
raise errors.NotImplementedError(name='%s.request_certificate' % self.name)
|
2009-09-10 15:15:14 -05:00
|
|
|
|
|
|
|
def revoke_certificate(self, serial_number, revocation_reason=0):
|
|
|
|
"""
|
|
|
|
Revoke a certificate.
|
|
|
|
|
|
|
|
The integer ``revocation_reason`` code must have one of these values:
|
|
|
|
|
|
|
|
* ``0`` - unspecified
|
|
|
|
* ``1`` - keyCompromise
|
|
|
|
* ``2`` - cACompromise
|
|
|
|
* ``3`` - affiliationChanged
|
|
|
|
* ``4`` - superseded
|
|
|
|
* ``5`` - cessationOfOperation
|
|
|
|
* ``6`` - certificateHold
|
|
|
|
* ``8`` - removeFromCRL
|
|
|
|
* ``9`` - privilegeWithdrawn
|
|
|
|
* ``10`` - aACompromise
|
|
|
|
|
|
|
|
Note that reason code ``7`` is not used. See RFC 5280 for more details:
|
|
|
|
|
|
|
|
http://www.ietf.org/rfc/rfc5280.txt
|
|
|
|
|
|
|
|
:param serial_number: Certificate serial number.
|
|
|
|
:param revocation_reason: Integer code of revocation reason.
|
|
|
|
"""
|
2009-11-19 15:18:45 -06:00
|
|
|
raise errors.NotImplementedError(name='%s.revoke_certificate' % self.name)
|
2009-09-10 15:15:14 -05:00
|
|
|
|
|
|
|
def take_certificate_off_hold(self, serial_number):
|
|
|
|
"""
|
|
|
|
Take revoked certificate off hold.
|
|
|
|
|
|
|
|
:param serial_number: Certificate serial number.
|
|
|
|
"""
|
2011-02-17 13:35:50 -06:00
|
|
|
raise errors.NotImplementedError(name='%s.take_certificate_off_hold' % self.name)
|
2009-09-10 15:15:14 -05:00
|
|
|
|
2012-11-15 09:55:33 -06:00
|
|
|
|
|
|
|
def find(self, options):
|
|
|
|
"""
|
|
|
|
Search for certificates
|
|
|
|
|
|
|
|
:param options: dictionary of search options
|
|
|
|
"""
|
|
|
|
raise errors.NotImplementedError(name='%s.find' % self.name)
|