2
0
mirror of https://github.com/openkmip/pykmip synced 2025-12-16 00:04:26 +00:00

Add CryptographicAlgorithm filtering support for Locate

This change updates Locate operation support in the PyKMIP server,
allowing users to filter objects based on the object's
Cryptographic Algorithm. If an object's type does not support the
Cryptographic Algorithm attribute, that object is not a match.
Unit tests and integration tests have been added to test and
verify the correctness of this feature.

Additionally, the Locate demo scripts have also been updated to
support Cryptographic Algorithm filtering. Simply use the
"--cryptographic-algorithm" flag to specify a Cryptographic
Algorithm enumeration for the Locate script to filter on.
This commit is contained in:
Peter Hamilton
2019-07-30 18:05:26 -04:00
committed by Peter Hamilton
parent d74b394261
commit bf518c8393
7 changed files with 232 additions and 1 deletions

View File

@@ -1623,6 +1623,26 @@ class KmipEngine(object):
for payload_attribute in payload.attributes:
name = payload_attribute.attribute_name.value
value = payload_attribute.attribute_value
# Verify that the attribute is applicable to the current
# object. If not, the object doesn't match, so skip it.
policy = self._attribute_policy
if not policy.is_attribute_applicable_to_object_type(
name,
managed_object.object_type
):
self._logger.debug(
"Failed match: "
"the specified attribute ({}) is not applicable "
"for the object's object type ({}).".format(
name,
managed_object.object_type.name)
)
add_object = False
break
# Fetch the attribute from the object and check if it
# matches. If not, the object doesn't match, so skip it.
attribute = self._get_attribute_from_managed_object(
managed_object,
name
@@ -1667,6 +1687,20 @@ class KmipEngine(object):
)
add_object = False
break
elif name == "Cryptographic Algorithm":
value = value.value
if value != attribute:
self._logger.debug(
"Failed match: "
"the specified cryptographic algorithm ({}) "
"does not match the object's cryptographic "
"algorithm ({}).".format(
value.name,
attribute.name
)
)
add_object = False
break
elif name == enums.AttributeType.INITIAL_DATE.value:
initial_date["value"] = attribute
self._track_date_attributes(