Fixed Lint complaints
This commit is contained in:
parent
aa0a31f90e
commit
de9ad82011
|
@ -3,10 +3,8 @@ import arrow
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
from lemur.plugins import lemur_entrust as ENTRUST
|
from lemur.plugins import lemur_entrust as ENTRUST
|
||||||
from OpenSSL import crypto
|
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
from lemur.extensions import metrics, sentry
|
from lemur.extensions import metrics
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def log_status_code(r, *args, **kwargs):
|
def log_status_code(r, *args, **kwargs):
|
||||||
|
@ -20,6 +18,7 @@ def log_status_code(r, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
metrics.send("ENTRUST_status_code_{}".format(r.status_code), "counter", 1)
|
metrics.send("ENTRUST_status_code_{}".format(r.status_code), "counter", 1)
|
||||||
|
|
||||||
|
|
||||||
def process_options(options):
|
def process_options(options):
|
||||||
"""
|
"""
|
||||||
Processes and maps the incoming issuer options to fields/options that
|
Processes and maps the incoming issuer options to fields/options that
|
||||||
|
@ -45,11 +44,12 @@ def process_options(options):
|
||||||
"signingAlg": "SHA-2",
|
"signingAlg": "SHA-2",
|
||||||
"eku": "SERVER_AND_CLIENT_AUTH",
|
"eku": "SERVER_AND_CLIENT_AUTH",
|
||||||
"certType": product_type,
|
"certType": product_type,
|
||||||
"certExpiryDate" : expiry_date,
|
"certExpiryDate": expiry_date,
|
||||||
"tracking": tracking_data
|
"tracking": tracking_data
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
class EntrustIssuerPlugin(IssuerPlugin):
|
class EntrustIssuerPlugin(IssuerPlugin):
|
||||||
title = "ENTRUST"
|
title = "ENTRUST"
|
||||||
slug = "entrust-issuer"
|
slug = "entrust-issuer"
|
||||||
|
@ -67,7 +67,7 @@ class EntrustIssuerPlugin(IssuerPlugin):
|
||||||
user = current_app.config.get("ENTRUST_API_USER")
|
user = current_app.config.get("ENTRUST_API_USER")
|
||||||
passw = current_app.config.get("ENTRUST_API_PASS")
|
passw = current_app.config.get("ENTRUST_API_PASS")
|
||||||
self.session.cert = (cert_file_path, key_file_path)
|
self.session.cert = (cert_file_path, key_file_path)
|
||||||
self.session.auth = (user,passw)
|
self.session.auth = (user, passw)
|
||||||
self.session.hooks = dict(response=log_status_code)
|
self.session.hooks = dict(response=log_status_code)
|
||||||
# self.session.config['keep_alive'] = False
|
# self.session.config['keep_alive'] = False
|
||||||
super(EntrustIssuerPlugin, self).__init__(*args, **kwargs)
|
super(EntrustIssuerPlugin, self).__init__(*args, **kwargs)
|
||||||
|
@ -93,13 +93,12 @@ class EntrustIssuerPlugin(IssuerPlugin):
|
||||||
"Entrust-Request Data (id: {1}) : {0}".format(data, current_req)
|
"Entrust-Request Data (id: {1}) : {0}".format(data, current_req)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = self.session.post(url, json=data, timeout=(15, 40))
|
response = self.session.post(url, json=data, timeout=(15, 40))
|
||||||
except requests.exceptions.Timeout:
|
except requests.exceptions.Timeout:
|
||||||
raise Exception("Timeout Error while posting to ENTRUST (ID: {0})".format(current_req))
|
raise Exception("Timeout Error while posting to ENTRUST (ID: {0})".format(current_req))
|
||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
raise Exception("Error while posting to ENTRUST (ID: {1}): {0}".format(e,current_req))
|
raise Exception("Error while posting to ENTRUST (ID: {1}): {0}".format(e, current_req))
|
||||||
|
|
||||||
current_app.logger.info(
|
current_app.logger.info(
|
||||||
"After Post and Errorhandling (ID: {1}) : {0}".format(response.status_code, current_req)
|
"After Post and Errorhandling (ID: {1}) : {0}".format(response.status_code, current_req)
|
||||||
|
@ -107,7 +106,7 @@ class EntrustIssuerPlugin(IssuerPlugin):
|
||||||
|
|
||||||
response_dict = json.loads(response.content)
|
response_dict = json.loads(response.content)
|
||||||
if response.status_code != 201:
|
if response.status_code != 201:
|
||||||
raise Exception("Error with ENTRUST (ID: {1}): {0}".format(response_dict['errors'], current_req))
|
raise Exception("Error with ENTRUST (ID: {1}): {0}".format(response_dict['errors'], current_req))
|
||||||
current_app.logger.info("Response: {0}, {1} ".format(response.status_code, response_dict))
|
current_app.logger.info("Response: {0}, {1} ".format(response.status_code, response_dict))
|
||||||
external_id = response_dict['trackingId']
|
external_id = response_dict['trackingId']
|
||||||
cert = response_dict['endEntityCert']
|
cert = response_dict['endEntityCert']
|
||||||
|
@ -132,8 +131,7 @@ class EntrustIssuerPlugin(IssuerPlugin):
|
||||||
entrust_issuing = current_app.config.get("ENTRUST_ISSUING")
|
entrust_issuing = current_app.config.get("ENTRUST_ISSUING")
|
||||||
role = {"username": "", "password": "", "name": "entrust"}
|
role = {"username": "", "password": "", "name": "entrust"}
|
||||||
current_app.logger.info("Creating Auth: {0} {1}".format(options, entrust_issuing))
|
current_app.logger.info("Creating Auth: {0} {1}".format(options, entrust_issuing))
|
||||||
return entrust_root, "" , [role]
|
return entrust_root, "", [role]
|
||||||
|
|
||||||
|
|
||||||
def revoke_certificate(self, certificate, comments):
|
def revoke_certificate(self, certificate, comments):
|
||||||
raise NotImplementedError("Not implemented\n", self, certificate, comments)
|
raise NotImplementedError("Not implemented\n", self, certificate, comments)
|
||||||
|
@ -164,9 +162,9 @@ class EntrustSourcePlugin(SourcePlugin):
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_certificates(self, options, **kwargs):
|
def get_certificates(self, options, **kwargs):
|
||||||
#Not needed for ENTRUST
|
# Not needed for ENTRUST
|
||||||
raise NotImplementedError("Not implemented\n", self, options, **kwargs)
|
raise NotImplementedError("Not implemented\n", self, options, **kwargs
|
||||||
|
|
||||||
def get_endpoints(self, options, **kwargs):
|
def get_endpoints(self, options, **kwargs):
|
||||||
# There are no endpoints in ENTRUST
|
# There are no endpoints in ENTRUST
|
||||||
raise NotImplementedError("Not implemented\n", self, options, **kwargs)
|
raise NotImplementedError("Not implemented\n", self, options, **kwargs)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue