summaryrefslogtreecommitdiffstats
path: root/base/common/python
diff options
context:
space:
mode:
Diffstat (limited to 'base/common/python')
-rw-r--r--base/common/python/pki/__init__.py14
-rw-r--r--base/common/python/pki/cert.py130
-rw-r--r--base/common/python/pki/cli.py2
-rw-r--r--base/common/python/pki/encoder.py4
-rw-r--r--base/common/python/pki/key.py32
-rw-r--r--base/common/python/pki/profile.py82
-rw-r--r--base/common/python/pki/upgrade.py4
7 files changed, 134 insertions, 134 deletions
diff --git a/base/common/python/pki/__init__.py b/base/common/python/pki/__init__.py
index 01ac26393..d80e6c6c7 100644
--- a/base/common/python/pki/__init__.py
+++ b/base/common/python/pki/__init__.py
@@ -27,10 +27,10 @@ import re
import requests
-CONF_DIR = '/etc/pki'
+CONF_DIR = '/etc/pki'
SHARE_DIR = '/usr/share/pki'
-BASE_DIR = '/var/lib'
-LOG_DIR = '/var/log/pki'
+BASE_DIR = '/var/lib'
+LOG_DIR = '/var/log/pki'
PACKAGE_VERSION = SHARE_DIR + '/VERSION'
CERT_HEADER = "-----BEGIN CERTIFICATE-----"
@@ -117,7 +117,7 @@ def implementation_version():
raise Exception('Missing implementation version.')
-#pylint: disable-msg=R0903
+#pylint: disable=R0903
class Attribute(object):
"""
Class representing a key/value pair.
@@ -131,7 +131,7 @@ class Attribute(object):
self.value = value
-#pylint: disable-msg=R0903
+#pylint: disable=R0903
class AttributeList(object):
"""
Class representing a list of attributes.
@@ -139,7 +139,7 @@ class AttributeList(object):
This class is needed because of a JavaMapper used in the REST API.
"""
- # pylint: disable-msg=C0103
+ # pylint: disable=C0103
def __init__(self):
""" Constructor """
self.Attribute = []
@@ -151,7 +151,7 @@ class ResourceMessage(object):
It is essentially a list of attributes.
"""
- # pylint: disable-msg=C0103
+ # pylint: disable=C0103
def __init__(self, class_name):
""" Constructor """
self.Attributes = AttributeList()
diff --git a/base/common/python/pki/cert.py b/base/common/python/pki/cert.py
index 6a27ee723..1fe323f24 100644
--- a/base/common/python/pki/cert.py
+++ b/base/common/python/pki/cert.py
@@ -344,9 +344,9 @@ class CertSearchRequest(object):
setattr(self, CertSearchRequest.search_params[param], value)
setattr(self, 'serialNumberRangeInUse', True)
- if param in {
- 'email', 'common_name', 'user_id', 'org_unit', 'org',
- 'locality', 'state', 'country', 'match_exactly'
+ if param in {\
+ 'email', 'common_name', 'user_id', 'org_unit', 'org',\
+ 'locality', 'state', 'country', 'match_exactly'\
}:
setattr(self, CertSearchRequest.search_params[param], value)
setattr(self, 'subjectInUse', True)
@@ -382,16 +382,16 @@ class CertSearchRequest(object):
setattr(self, CertSearchRequest.search_params[param], value)
setattr(self, 'validNotAfterInUse', True)
- if param in {
- 'validity_operation', 'validity_count', 'validity_unit'
+ if param in {\
+ 'validity_operation', 'validity_count', 'validity_unit'\
}:
setattr(self, CertSearchRequest.search_params[param], value)
setattr(self, 'validityLengthInUse', True)
- if param in {
- 'cert_type_sub_email_ca', 'cert_type_sub_ssl_ca',
- 'cert_type_secure_email', 'cert_type_ssl_client',
- 'cert_type_ssl_server'
+ if param in {\
+ 'cert_type_sub_email_ca', 'cert_type_sub_ssl_ca',\
+ 'cert_type_secure_email', 'cert_type_ssl_client',\
+ 'cert_type_ssl_server'\
}:
setattr(self, CertSearchRequest.search_params[param], value)
setattr(self, 'certTypeInUse', True)
@@ -1045,8 +1045,8 @@ def main():
cert_client.get_enrollment_template('caUserCert')
#Enrolling an user certificate
- print('Enrolling an user certificate')
- print('-----------------------------')
+ print 'Enrolling an user certificate'
+ print '-----------------------------'
inputs = dict()
inputs['cert_request_type'] = 'crmf'
@@ -1072,19 +1072,19 @@ def main():
for enrollment_result in enrollment_results:
request_data = enrollment_result.request
cert_data = enrollment_result.cert
- print('Request ID: ' + request_data.request_id)
- print('Request Status:' + request_data.request_status)
- print('Serial Number: ' + cert_data.serial_number)
- print('Issuer: ' + cert_data.issuer_dn)
- print('Subject: ' + cert_data.subject_dn)
- print('Pretty Print:')
- print(cert_data.pretty_repr)
+ print 'Request ID: ' + request_data.request_id
+ print 'Request Status:' + request_data.request_status
+ print 'Serial Number: ' + cert_data.serial_number
+ print 'Issuer: ' + cert_data.issuer_dn
+ print 'Subject: ' + cert_data.subject_dn
+ print 'Pretty Print:'
+ print cert_data.pretty_repr
print
# Enrolling a server certificate
- print("Enrolling a server certificate")
- print('------------------------------')
+ print "Enrolling a server certificate"
+ print '------------------------------'
inputs = dict()
inputs['cert_request_type'] = 'pkcs10'
@@ -1109,40 +1109,40 @@ def main():
for enrollment_result in enrollment_results_2:
request_data = enrollment_result.request
cert_data = enrollment_result.cert
- print('Request ID: ' + request_data.request_id)
- print('Request Status:' + request_data.request_status)
+ print 'Request ID: ' + request_data.request_id
+ print 'Request Status:' + request_data.request_status
if cert_data is not None:
# store cert_id for usage later
cert_id = cert_data.serial_number
- print('Serial Number: ' + cert_id)
- print('Issuer: ' + cert_data.issuer_dn)
- print('Subject: ' + cert_data.subject_dn)
- print('Pretty Print:')
- print(cert_data.pretty_repr)
+ print 'Serial Number: ' + cert_id
+ print 'Issuer: ' + cert_data.issuer_dn
+ print 'Subject: ' + cert_data.subject_dn
+ print 'Pretty Print:'
+ print cert_data.pretty_repr
print
# List all the VALID certs
- print('An example listing all VALID certs')
- print('----------------------------------')
+ print 'An example listing all VALID certs'
+ print '----------------------------------'
search_params = {'status': 'VALID'}
cert_data_list = cert_client.list_certs(**search_params)
for cert_data_info in cert_data_list:
- print("Serial Number: " + cert_data_info.serial_number)
- print("Subject DN: " + cert_data_info.subject_dn)
- print("Status: " + cert_data_info.status)
+ print "Serial Number: " + cert_data_info.serial_number
+ print "Subject DN: " + cert_data_info.subject_dn
+ print "Status: " + cert_data_info.status
print
#Trying to get a non-existing cert
#Assuming that there is no certificate with serial number = 100
try:
cert_data = cert_client.get_cert(100)
- print('Serial Number: ' + cert_data.serial_number)
- print('Issuer: ' + cert_data.issuer_dn)
- print('Subject: ' + cert_data.subject_dn)
+ print 'Serial Number: ' + cert_data.serial_number
+ print 'Issuer: ' + cert_data.issuer_dn
+ print 'Subject: ' + cert_data.subject_dn
except pki.CertNotFoundException:
- print("Certificate with ID 100 does not exist")
+ print "Certificate with ID 100 does not exist"
print
# Certificate Serial Number used for CertClient methods.
@@ -1151,54 +1151,54 @@ def main():
# before.
#Get certificate data
- print('Getting information of a certificate')
- print('------------------------------------')
+ print 'Getting information of a certificate'
+ print '------------------------------------'
cert_data = cert_client.get_cert(cert_id)
# Print the certificate information
- print('Serial Number: ' + cert_data.serial_number)
- print('Issuer: ' + cert_data.issuer_dn)
- print('Subject: ' + cert_data.subject_dn)
- print('Status: ' + cert_data.status)
- print('Not Before: ' + cert_data.not_before)
- print('Not After: ' + cert_data.not_after)
- print('Encoded: ')
- print(cert_data.encoded)
- print("Pretty print format: ")
- print(cert_data.pretty_repr)
+ print 'Serial Number: ' + cert_data.serial_number
+ print 'Issuer: ' + cert_data.issuer_dn
+ print 'Subject: ' + cert_data.subject_dn
+ print 'Status: ' + cert_data.status
+ print 'Not Before: ' + cert_data.not_before
+ print 'Not After: ' + cert_data.not_after
+ print 'Encoded: '
+ print cert_data.encoded
+ print "Pretty print format: "
+ print cert_data.pretty_repr
print
# Review a certificate - used to get a nonce for revoke request.
- print('Reviewing a certificate')
- print('-----------------------')
+ print 'Reviewing a certificate'
+ print '-----------------------'
cert_data = cert_client.review_cert(cert_id)
- print('Serial Number: ' + cert_data.serial_number)
- print('Issuer: ' + cert_data.issuer_dn)
- print('Subject: ' + cert_data.subject_dn)
- print('Status: ' + cert_data.status)
- print('Nonce: ' + str(cert_data.nonce))
+ print 'Serial Number: ' + cert_data.serial_number
+ print 'Issuer: ' + cert_data.issuer_dn
+ print 'Subject: ' + cert_data.subject_dn
+ print 'Status: ' + cert_data.status
+ print 'Nonce: ' + str(cert_data.nonce)
print
#Revoke a certificate
- print('Revoking a certificate')
- print('----------------------')
+ print 'Revoking a certificate'
+ print '----------------------'
cert_request_info = cert_client.hold_cert(cert_data.serial_number,
comments="Test revoking a cert")
- print('Request ID: ' + cert_request_info.request_id)
- print('Request Type: ' + cert_request_info.request_type)
- print('Request Status: ' + cert_request_info.request_status)
+ print 'Request ID: ' + cert_request_info.request_id
+ print 'Request Type: ' + cert_request_info.request_type
+ print 'Request Status: ' + cert_request_info.request_status
print
#Un-revoke a certificate
- print('Un-revoking a certificate')
- print('-------------------------')
+ print 'Un-revoking a certificate'
+ print '-------------------------'
cert_request_info = cert_client.unrevoke_cert(cert_data.serial_number)
- print('Request ID: ' + cert_request_info.request_id)
- print('Request Type: ' + cert_request_info.request_type)
- print('Request Status: ' + cert_request_info.request_status)
+ print 'Request ID: ' + cert_request_info.request_id
+ print 'Request Type: ' + cert_request_info.request_type
+ print 'Request Status: ' + cert_request_info.request_status
print
diff --git a/base/common/python/pki/cli.py b/base/common/python/pki/cli.py
index d44875fcb..2b6811314 100644
--- a/base/common/python/pki/cli.py
+++ b/base/common/python/pki/cli.py
@@ -124,7 +124,7 @@ class CLI(object):
# Module doesn't have children. Keep looking.
# If there's no more dashes, stop.
- if i<0:
+ if i < 0:
break
position = i + 1
diff --git a/base/common/python/pki/encoder.py b/base/common/python/pki/encoder.py
index 88a92f243..7b621f290 100644
--- a/base/common/python/pki/encoder.py
+++ b/base/common/python/pki/encoder.py
@@ -31,7 +31,7 @@ class CustomTypeEncoder(json.JSONEncoder):
http://stackoverflow.com/questions/12949064/python-what-happens-
when-instance-variable-name-is-same-as-method-name
"""
- # pylint: disable-msg=E0202
+ # pylint: disable=E0202
def default(self, obj):
for k, v in TYPES.items():
if isinstance(obj, v):
@@ -44,7 +44,7 @@ class CustomTypeEncoder(json.JSONEncoder):
def attr_name_conversion(attr_dict, object_class):
if not hasattr(object_class, 'json_attribute_names'):
return attr_dict
- reverse_dict = {v: k for k,v in
+ reverse_dict = {v: k for k, v in
object_class.json_attribute_names.iteritems()}
new_dict = dict()
for k, v in attr_dict.items():
diff --git a/base/common/python/pki/key.py b/base/common/python/pki/key.py
index bcc56747e..3ff6e3dba 100644
--- a/base/common/python/pki/key.py
+++ b/base/common/python/pki/key.py
@@ -34,7 +34,7 @@ import pki.encoder as encoder
#should be moved to request.py
-#pylint: disable-msg=R0903
+#pylint: disable=R0903
class RequestId(object):
"""
Class representing a Request ID
@@ -45,7 +45,7 @@ class RequestId(object):
self.value = req_id
-#pylint: disable-msg=R0903
+#pylint: disable=R0903
class KeyData(object):
"""
This is the object that contains the encoded wrapped secret
@@ -57,7 +57,7 @@ class KeyData(object):
'nonceData': 'nonce_data', 'wrappedPrivateData': 'wrapped_private_data'
}
- # pylint: disable-msg=C0103
+ # pylint: disable=C0103
def __init__(self):
""" Constructor """
self.algorithm = None
@@ -108,7 +108,7 @@ class KeyInfo(object):
'ownerName': 'owner_name', 'publicKey': 'public_key'
}
- # pylint: disable-msg=C0103
+ # pylint: disable=C0103
def __init__(self):
""" Constructor """
self.client_key_id = None
@@ -140,7 +140,7 @@ class KeyInfo(object):
return None
-#pylint: disable-msg=R0903
+#pylint: disable=R0903
class KeyInfoCollection(object):
"""
This class represents data returned when searching the DRM archived
@@ -176,7 +176,7 @@ class KeyRequestInfo(object):
'keyURL': 'key_url', 'requestStatus': 'request_status'
}
- # pylint: disable-msg=C0103
+ # pylint: disable=C0103
def __init__(self):
""" Constructor """
self.request_url = None
@@ -212,7 +212,7 @@ class KeyRequestInfo(object):
return None
-#pylint: disable-msg=R0903
+#pylint: disable=R0903
class KeyRequestInfoCollection(object):
"""
This class represents the data returned when searching the key
@@ -248,7 +248,7 @@ class KeyRequestResponse(object):
which contains the wrapped secret (if that operation is supported).
"""
- # pylint: disable-msg=C0103
+ # pylint: disable=C0103
def __init__(self):
""" Constructor """
self.request_info = None
@@ -705,14 +705,14 @@ class KeyClient(object):
key_size=key_size)
@pki.handle_exceptions()
- def archive_encrypted_data(self,
- client_key_id,
- data_type,
- encrypted_data,
- wrapped_session_key,
- algorithm_oid=None,
- nonce_iv=None,
- key_algorithm=None,
+ def archive_encrypted_data(self,\
+ client_key_id,\
+ data_type,\
+ encrypted_data,\
+ wrapped_session_key,\
+ algorithm_oid=None,\
+ nonce_iv=None,\
+ key_algorithm=None,\
key_size=None):
"""
Archive a secret (symmetric key or passphrase) on the DRM.
diff --git a/base/common/python/pki/profile.py b/base/common/python/pki/profile.py
index 42efec1c6..050f854a4 100644
--- a/base/common/python/pki/profile.py
+++ b/base/common/python/pki/profile.py
@@ -1168,46 +1168,46 @@ def main():
#Fetching a list of profiles
profile_data_infos = profile_client.list_profiles()
- print('List of profiles:')
- print('-----------------')
+ print 'List of profiles:'
+ print '-----------------'
for profile_data_info in profile_data_infos:
- print(' Profile ID: ' + profile_data_info.profile_id)
- print(' Profile Name: ' + profile_data_info.profile_name)
- print(' Profile Description: ' + profile_data_info.profile_description)
+ print ' Profile ID: ' + profile_data_info.profile_id
+ print ' Profile Name: ' + profile_data_info.profile_name
+ print ' Profile Description: ' + profile_data_info.profile_description
print
# Get a specific profile
profile_data = profile_client.get_profile('caUserCert')
- print('Profile Data for caUserCert:')
- print('----------------------------')
- print(' Profile ID: ' + profile_data.profile_id)
- print(' Profile Name: ' + profile_data.name)
- print(' Profile Description: ' + profile_data.description)
- print(' Is profile enabled? ' + str(profile_data.enabled))
- print(' Is profile visible? ' + str(profile_data.visible))
+ print 'Profile Data for caUserCert:'
+ print '----------------------------'
+ print ' Profile ID: ' + profile_data.profile_id
+ print ' Profile Name: ' + profile_data.name
+ print ' Profile Description: ' + profile_data.description
+ print ' Is profile enabled? ' + str(profile_data.enabled)
+ print ' Is profile visible? ' + str(profile_data.visible)
print
# Disabling a profile
- print('Disabling a profile:')
- print('--------------------')
+ print 'Disabling a profile:'
+ print '--------------------'
profile_client.disable_profile('caUserCert')
profile = profile_client.get_profile('caUserCert')
- print(' Profile ID: ' + profile.profile_id)
- print(' Is profile enabled? ' + str(profile.enabled))
+ print ' Profile ID: ' + profile.profile_id
+ print ' Is profile enabled? ' + str(profile.enabled)
print
# Disabling a profile
- print('Enabling a profile:')
- print('-------------------')
+ print 'Enabling a profile:'
+ print '-------------------'
profile_client.enable_profile('caUserCert')
profile = profile_client.get_profile('caUserCert')
- print(' Profile ID: ' + profile_data.profile_id)
- print(' Is profile enabled? ' + str(profile.enabled))
+ print ' Profile ID: ' + profile_data.profile_id
+ print ' Is profile enabled? ' + str(profile.enabled)
print
#profile_client.delete_profile('MySampleProfile')
# Create a new sample profile
- print('Creating a new profile:')
- print('-----------------------')
+ print 'Creating a new profile:'
+ print '-----------------------'
profile_data = Profile(name="My Sample User Cert Enrollment",
profile_id="MySampleProfile",
@@ -1323,12 +1323,12 @@ def main():
sort_keys=True, indent=4))
# Create a new profile
created_profile = profile_client.create_profile(profile_data)
- print(created_profile)
+ print created_profile
print
# Test creating a new profile with a duplicate profile id
- print ("Create a profile with duplicate profile id.")
- print ("-------------------------------------------")
+ print "Create a profile with duplicate profile id."
+ print "-------------------------------------------"
try:
profile_data = Profile(name="My Sample User Cert Enrollment",
@@ -1351,14 +1351,14 @@ def main():
profile_data.add_input(profile_input)
profile_client.create_profile(profile_data)
- # pylint: disable-msg=W0703
+ # pylint: disable=W0703
except pki.BadRequestException as e:
print 'MySampleProfile ' + str(e)
print
# Modify the above created profile
- print('Modifying the profile MySampleProfile.')
- print('-----------------------------------')
+ print 'Modifying the profile MySampleProfile.'
+ print '-----------------------------------'
fetch = profile_client.get_profile('MySampleProfile')
profile_input2 = ProfileInput("i2", "keyGenInputImpl")
@@ -1373,40 +1373,40 @@ def main():
output_file.write(json.dumps(fetch, cls=encoder.CustomTypeEncoder,
sort_keys=True, indent=4))
- print(modified_profile)
+ print modified_profile
print
# Delete a profile
- print ("Deleting the profile MySampleProfile.")
- print ("----------------------------------")
+ print "Deleting the profile MySampleProfile."
+ print "----------------------------------"
profile_client.delete_profile('MySampleProfile')
- print ("Deleted profile MySampleProfile.")
+ print "Deleted profile MySampleProfile."
print
# Testing deletion of a profile
- print('Test profile deletion.')
- print('----------------------')
+ print 'Test profile deletion.'
+ print '----------------------'
try:
profile_client.get_profile('MySampleProfile')
- # pylint: disable-msg=W0703
+ # pylint: disable=W0703
except pki.ProfileNotFoundException as e:
print str(e)
print
# Creating a profile from file
- print('Creating a profile using file input.')
- print('------------------------------------')
+ print 'Creating a profile using file input.'
+ print '------------------------------------'
original = profile_client.create_profile_from_file(
file_path + 'original.json')
- print(original)
+ print original
print
# Modifying a profile from file
- print('Modifying a profile using file input.')
- print('------------------------------------')
+ print 'Modifying a profile using file input.'
+ print '------------------------------------'
modified = profile_client.modify_profile_from_file(
file_path + 'modified.json')
- print(modified)
+ print modified
print
# Test clean up
diff --git a/base/common/python/pki/upgrade.py b/base/common/python/pki/upgrade.py
index 9ff89fa92..5534069c1 100644
--- a/base/common/python/pki/upgrade.py
+++ b/base/common/python/pki/upgrade.py
@@ -622,7 +622,7 @@ class PKIUpgrader(object):
except pki.PKIException:
raise
- except Exception as e: # pylint: disable-msg=W0703
+ except Exception as e: # pylint: disable=W0703
print
@@ -689,7 +689,7 @@ class PKIUpgrader(object):
except pki.PKIException:
raise
- except Exception as e: # pylint: disable-msg=W0703
+ except Exception as e: # pylint: disable=W0703
print