mirror of
https://github.com/openkmip/pykmip
synced 2025-12-05 23:53:19 +00:00
Update object hierarchy read/write to support the KMIP version
This change updates the PyKMIP object hierarchy's read/write method signatures to support propagation of the KMIP version. The introduction of KMIP 2.0 introduces future KMIP message encodings that break backwards compatibility; to support this, PyKMIP must know what KMIP version is being used when encoding or decoding an object; the KMIP version residing in the client or server alone is now insufficient. Prior versions of KMIP, namely 1.0 - 1.4, have been backwards compatible, obviating the need for the KMIP version at encode/decode time. Going forward, this is no longer true. The PyKMIP client and server have been updated to include the KMIP version when making calls to read/write, as have the associated test cases covering this functionality.
This commit is contained in:
committed by
Peter Hamilton
parent
c012a430aa
commit
dcade2a264
@@ -115,6 +115,9 @@ class KmipSession(threading.Thread):
|
||||
request = messages.RequestMessage()
|
||||
|
||||
max_size = self._max_response_size
|
||||
kmip_version = contents.protocol_version_to_kmip_version(
|
||||
self._engine.default_protocol_version
|
||||
)
|
||||
|
||||
try:
|
||||
if hasattr(self._connection, 'shared_ciphers'):
|
||||
@@ -154,7 +157,7 @@ class KmipSession(threading.Thread):
|
||||
"client authentication in the client certificate."
|
||||
)
|
||||
|
||||
request.read(request_data)
|
||||
request.read(request_data, kmip_version=kmip_version)
|
||||
except exceptions.PermissionDenied as e:
|
||||
self._logger.warning("Failure verifying the client certificate.")
|
||||
self._logger.exception(e)
|
||||
@@ -189,10 +192,15 @@ class KmipSession(threading.Thread):
|
||||
)
|
||||
else:
|
||||
try:
|
||||
response, max_response_size = self._engine.process_request(
|
||||
results = self._engine.process_request(
|
||||
request,
|
||||
client_identity
|
||||
)
|
||||
response, max_response_size, protocol_version = results
|
||||
kmip_version = contents.protocol_version_to_kmip_version(
|
||||
protocol_version
|
||||
)
|
||||
|
||||
if max_response_size:
|
||||
max_size = max_response_size
|
||||
except exceptions.KmipError as e:
|
||||
@@ -215,7 +223,7 @@ class KmipSession(threading.Thread):
|
||||
)
|
||||
|
||||
response_data = utils.BytearrayStream()
|
||||
response.write(response_data)
|
||||
response.write(response_data, kmip_version=kmip_version)
|
||||
|
||||
if len(response_data) > max_size:
|
||||
self._logger.warning(
|
||||
@@ -232,7 +240,7 @@ class KmipSession(threading.Thread):
|
||||
"more information."
|
||||
)
|
||||
response_data = utils.BytearrayStream()
|
||||
response.write(response_data)
|
||||
response.write(response_data, kmip_version=kmip_version)
|
||||
|
||||
self._send_response(response_data.buffer)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user