2
0
mirror of https://github.com/openkmip/pykmip synced 2025-12-21 10:43:15 +00:00

Add CryptographicUsageMask 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 Usage Masks. 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 Usage Mask filtering. Simply use the
"--cryptographic-usage-mask" flag to specify one or more
Cryptographic Usage Mask enumeration values for the Locate script
to filter on.
This commit is contained in:
Peter Hamilton
2019-08-12 15:22:04 -04:00
committed by Peter Hamilton
parent 4a6a2eccc1
commit b5a8739157
7 changed files with 302 additions and 0 deletions

View File

@@ -43,6 +43,7 @@ if __name__ == '__main__':
object_type = opts.object_type
cryptographic_algorithm = opts.cryptographic_algorithm
cryptographic_length = opts.cryptographic_length
cryptographic_usage_masks = opts.cryptographic_usage_masks
unique_identifier = opts.unique_identifier
operation_policy_name = opts.operation_policy_name
@@ -174,6 +175,29 @@ if __name__ == '__main__':
)
client.close()
sys.exit(-6)
if cryptographic_usage_masks:
masks = []
for cryptographic_usage_mask in cryptographic_usage_masks:
mask = getattr(
enums.CryptographicUsageMask,
cryptographic_usage_mask,
None
)
if mask:
masks.append(mask)
else:
logger.error(
"Invalid cryptographic usage mask provided: {}".format(
cryptographic_usage_mask
)
)
sys.exit(-7)
attributes.append(
attribute_factory.create_attribute(
enums.AttributeType.CRYPTOGRAPHIC_USAGE_MASK,
masks
)
)
if unique_identifier:
attributes.append(
attribute_factory.create_attribute(