File: policy.py

package info (click to toggle)
python-pykmip 0.5.0-4%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,388 kB
  • sloc: python: 29,126; makefile: 34; sh: 32
file content (1148 lines) | stat: -rw-r--r-- 43,736 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
# Copyright (c) 2016 The Johns Hopkins University/Applied Physics Laboratory
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

from kmip.core import enums
from kmip.core.messages import contents


class AttributeRuleSet(object):
    """
    A set of flags and indicators defining how an attribute may be used.

    Every attribute defined by the KMIP specification comes with a set of
    rules defining how and under what conditions the attribute should be
    used. This class acts as a basic struct storing those rules.

    Attributes:
        always_has_value: A flag defining if the attribute is always set.
        initially_set_by: A list of entities that can implicitly set the
            attribute.
        modifiable_by_server: A flag defining if the server can modify the
            attribute.
        modifiable_by_client: A flag defining if the client can modify the
            attribute.
        deletable_by_client: A flag defining if the client can delete the
            attribute.
        multiple_instances_permitted: A flag defining if the attribute is
            multivalued.
        implicitly_set_by: A list of operations that can implicitly set the
            attribute.
        applies_to_object_types: A list of object types that the attribute
            is applicable for.
        version_added: The KMIP version in which support for the attribute
            was added.
        version_deprecated: The KMIP version in which support for the
            attribute was deprecated.
    """

    def __init__(self,
                 always_has_value,
                 initially_set_by,
                 modifiable_by_server,
                 modifiable_by_client,
                 deletable_by_client,
                 multivalued,
                 implicitly_set_by,
                 applies_to_object_types,
                 version_added,
                 version_deprecated=None):
        """
        Create an AttributeRuleSet.

        Args:
            always_has_value (bool): A flag indicating whether or not this
                attribute is always set for a managed object. Required.
            initially_set_by (list): A list of strings indicating if the
                attribute can be initially set by the 'server' and/or the
                'client'. Required.
            modifiable_by_server (bool): A flag indicating whether the server
                can independently modify the value of the attribute without
                any prompting by the client. Required.
            modifiable_by_client (bool): A flag indicating whether the client
                can modify the value of the attribute. Required.
            deletable_by_client (bool): A flag indicating whether the client
                can delete the attribute from the managed object. Required.
            multivalued (bool): A flag indicating whether or not a managed
                object can have multiple instances of the attribute set at
                the same time. Required.
            implicitly_set_by (list): A list of Operation enumerations
                detailing which server operations are allowed to set the
                value of the attribute without direct instruction by the
                client.Required.
            applies_to_object_types (list): A list of ObjectType enumerations
                detailing which managed object types the attribute applies to.
            version_added (ProtocolVersion): The KMIP version in which support
                for the attribute was added. Required.
            version_deprecated (ProtocolVersion): The KMIP version in which
                support for the attribute was deprecated. Optional, defaults
                to None.
        """
        self.always_has_value = always_has_value
        self.initially_set_by = initially_set_by
        self.modifiable_by_server = modifiable_by_server
        self.modifiable_by_client = modifiable_by_client
        self.deletable_by_client = deletable_by_client
        self.multiple_instances_permitted = multivalued
        self.implicitly_set_by = implicitly_set_by
        self.applies_to_object_types = applies_to_object_types
        self.version_added = version_added
        self.version_deprecated = version_deprecated


class AttributePolicy(object):
    """
    A collection of attribute rules and methods to query those rules.

    This policy class allows for the basic storage and retrieval of
    attribute metadata. This metadata changes slightly across KMIP versions
    and across the object types associated with different attributes. It
    includes information on which entities can modify the attributes, which
    object types the attributes are applicable to, and more. It is meant to
    be used only by the KmipEngine.

    Metadata queries include questions like:
    * Is this attribute supported in KMIP 1.0?
    * Is this attribute deprecated in KMIP 1.1?
    * Is this attribute applicable for the SymmetricKey object type?
    * Is this attribute allowed to have multiple values?
    """

    def __init__(self, version):
        """
        Create an AttributePolicy.

        Args:
            version (ProtocolVersion): The KMIP protocol version under which
                this set of attribute policies should be evaluated. Required.
        """
        self._version = version

        self._attribute_rule_sets = {
            'Unique Identifier': AttributeRuleSet(
                True,
                ('server', ),
                False,
                False,
                False,
                False,
                (
                    enums.Operation.CREATE,
                    enums.Operation.CREATE_KEY_PAIR,
                    enums.Operation.REGISTER,
                    enums.Operation.DERIVE_KEY,
                    enums.Operation.CERTIFY,
                    enums.Operation.RECERTIFY,
                    enums.Operation.REKEY,
                    enums.Operation.REKEY_KEY_PAIR
                ),
                (
                    enums.ObjectType.CERTIFICATE,
                    enums.ObjectType.SYMMETRIC_KEY,
                    enums.ObjectType.PUBLIC_KEY,
                    enums.ObjectType.PRIVATE_KEY,
                    enums.ObjectType.SPLIT_KEY,
                    enums.ObjectType.TEMPLATE,
                    enums.ObjectType.SECRET_DATA,
                    enums.ObjectType.OPAQUE_DATA
                ),
                contents.ProtocolVersion.create(1, 0)
            ),
            'Name': AttributeRuleSet(
                False,
                ('client', ),
                True,
                True,
                True,
                True,
                (
                    enums.Operation.RECERTIFY,
                    enums.Operation.REKEY,
                    enums.Operation.REKEY_KEY_PAIR
                ),
                (
                    enums.ObjectType.CERTIFICATE,
                    enums.ObjectType.SYMMETRIC_KEY,
                    enums.ObjectType.PUBLIC_KEY,
                    enums.ObjectType.PRIVATE_KEY,
                    enums.ObjectType.SPLIT_KEY,
                    enums.ObjectType.TEMPLATE,
                    enums.ObjectType.SECRET_DATA,
                    enums.ObjectType.OPAQUE_DATA
                ),
                contents.ProtocolVersion.create(1, 0)
            ),
            'Object Type': AttributeRuleSet(
                True,
                ('server', ),
                False,
                False,
                False,
                False,
                (
                    enums.Operation.CREATE,
                    enums.Operation.CREATE_KEY_PAIR,
                    enums.Operation.REGISTER,
                    enums.Operation.DERIVE_KEY,
                    enums.Operation.CERTIFY,
                    enums.Operation.RECERTIFY,
                    enums.Operation.REKEY,
                    enums.Operation.REKEY_KEY_PAIR
                ),
                (
                    enums.ObjectType.CERTIFICATE,
                    enums.ObjectType.SYMMETRIC_KEY,
                    enums.ObjectType.PUBLIC_KEY,
                    enums.ObjectType.PRIVATE_KEY,
                    enums.ObjectType.SPLIT_KEY,
                    enums.ObjectType.TEMPLATE,
                    enums.ObjectType.SECRET_DATA,
                    enums.ObjectType.OPAQUE_DATA
                ),
                contents.ProtocolVersion.create(1, 0)
            ),
            'Cryptographic Algorithm': AttributeRuleSet(
                True,
                ('server', ),
                False,
                False,
                False,
                False,
                (
                    enums.Operation.CREATE,
                    enums.Operation.CREATE_KEY_PAIR,
                    enums.Operation.REGISTER,
                    enums.Operation.DERIVE_KEY,
                    enums.Operation.CERTIFY,
                    enums.Operation.RECERTIFY,
                    enums.Operation.REKEY,
                    enums.Operation.REKEY_KEY_PAIR
                ),
                (
                    enums.ObjectType.CERTIFICATE,
                    enums.ObjectType.SYMMETRIC_KEY,
                    enums.ObjectType.PUBLIC_KEY,
                    enums.ObjectType.PRIVATE_KEY,
                    enums.ObjectType.SPLIT_KEY,
                    enums.ObjectType.TEMPLATE
                ),
                contents.ProtocolVersion.create(1, 0)
            ),
            'Cryptographic Length': AttributeRuleSet(
                True,
                ('server', ),
                False,
                False,
                False,
                False,
                (
                    enums.Operation.CREATE,
                    enums.Operation.CREATE_KEY_PAIR,
                    enums.Operation.REGISTER,
                    enums.Operation.DERIVE_KEY,
                    enums.Operation.CERTIFY,
                    enums.Operation.RECERTIFY,
                    enums.Operation.REKEY,
                    enums.Operation.REKEY_KEY_PAIR
                ),
                (
                    enums.ObjectType.CERTIFICATE,
                    enums.ObjectType.SYMMETRIC_KEY,
                    enums.ObjectType.PUBLIC_KEY,
                    enums.ObjectType.PRIVATE_KEY,
                    enums.ObjectType.SPLIT_KEY,
                    enums.ObjectType.TEMPLATE
                ),
                contents.ProtocolVersion.create(1, 0)
            ),
            'Cryptographic Parameters': AttributeRuleSet(
                False,
                ('client', ),
                False,
                True,
                True,
                True,
                (
                    enums.Operation.RECERTIFY,
                    enums.Operation.REKEY,
                    enums.Operation.REKEY_KEY_PAIR
                ),
                (
                    enums.ObjectType.CERTIFICATE,
                    enums.ObjectType.SYMMETRIC_KEY,
                    enums.ObjectType.PUBLIC_KEY,
                    enums.ObjectType.PRIVATE_KEY,
                    enums.ObjectType.SPLIT_KEY,
                    enums.ObjectType.TEMPLATE
                ),
                contents.ProtocolVersion.create(1, 0)
            ),
            'Cryptographic Domain Parameters': AttributeRuleSet(
                False,
                ('client', ),
                False,
                False,
                False,
                False,
                (
                    enums.Operation.REKEY,
                    enums.Operation.REKEY_KEY_PAIR
                ),
                (
                    enums.ObjectType.PUBLIC_KEY,
                    enums.ObjectType.PRIVATE_KEY,
                    enums.ObjectType.TEMPLATE
                ),
                contents.ProtocolVersion.create(1, 0)
            ),
            'Certificate Type': AttributeRuleSet(
                True,
                ('server', ),
                False,
                False,
                False,
                False,
                (
                    enums.Operation.REGISTER,
                    enums.Operation.CERTIFY,
                    enums.Operation.RECERTIFY
                ),
                (
                    enums.ObjectType.CERTIFICATE,
                ),
                contents.ProtocolVersion.create(1, 0)
            ),
            'Certificate Length': AttributeRuleSet(
                True,
                ('server', ),
                False,
                False,
                False,
                False,
                (
                    enums.Operation.REGISTER,
                    enums.Operation.CERTIFY,
                    enums.Operation.RECERTIFY
                ),
                (
                    enums.ObjectType.CERTIFICATE,
                ),
                contents.ProtocolVersion.create(1, 1)
            ),
            'X.509 Certificate Identifier': AttributeRuleSet(
                True,
                ('server', ),
                False,
                False,
                False,
                False,
                (
                    enums.Operation.REGISTER,
                    enums.Operation.CERTIFY,
                    enums.Operation.RECERTIFY
                ),
                (
                    # TODO (peterhamilton) Enforce only on X.509 certificates
                    enums.ObjectType.CERTIFICATE,
                ),
                contents.ProtocolVersion.create(1, 1)
            ),
            'X.509 Certificate Subject': AttributeRuleSet(
                True,
                ('server', ),
                False,
                False,
                False,
                False,
                (
                    enums.Operation.REGISTER,
                    enums.Operation.CERTIFY,
                    enums.Operation.RECERTIFY
                ),
                (
                    # TODO (peterhamilton) Enforce only on X.509 certificates
                    enums.ObjectType.CERTIFICATE,
                ),
                contents.ProtocolVersion.create(1, 1)
            ),
            'X.509 Certificate Issuer': AttributeRuleSet(
                True,
                ('server', ),
                False,
                False,
                False,
                False,
                (
                    enums.Operation.REGISTER,
                    enums.Operation.CERTIFY,
                    enums.Operation.RECERTIFY
                ),
                (
                    # TODO (peterhamilton) Enforce only on X.509 certificates
                    enums.ObjectType.CERTIFICATE,
                ),
                contents.ProtocolVersion.create(1, 1)
            ),
            'Certificate Identifier': AttributeRuleSet(
                True,
                ('server', ),
                False,
                False,
                False,
                False,
                (
                    enums.Operation.REGISTER,
                    enums.Operation.CERTIFY,
                    enums.Operation.RECERTIFY
                ),
                (
                    enums.ObjectType.CERTIFICATE,
                ),
                contents.ProtocolVersion.create(1, 0),
                contents.ProtocolVersion.create(1, 1)
            ),
            'Certificate Subject': AttributeRuleSet(
                True,
                ('server', ),
                False,
                False,
                False,
                False,
                (
                    enums.Operation.REGISTER,
                    enums.Operation.CERTIFY,
                    enums.Operation.RECERTIFY
                ),
                (
                    enums.ObjectType.CERTIFICATE,
                ),
                contents.ProtocolVersion.create(1, 0),
                contents.ProtocolVersion.create(1, 1)
            ),
            'Certificate Issuer': AttributeRuleSet(
                True,
                ('server', ),
                False,
                False,
                False,
                False,
                (
                    enums.Operation.REGISTER,
                    enums.Operation.CERTIFY,
                    enums.Operation.RECERTIFY
                ),
                (
                    enums.ObjectType.CERTIFICATE,
                ),
                contents.ProtocolVersion.create(1, 0),
                contents.ProtocolVersion.create(1, 1)
            ),
            'Digital Signature Algorithm': AttributeRuleSet(
                True,
                ('server', ),
                False,
                False,
                False,
                # TODO (peterhamilton) Enforce only for X.509 certificates
                False,  # True for PGP certificates
                (
                    enums.Operation.REGISTER,
                    enums.Operation.CERTIFY,
                    enums.Operation.RECERTIFY
                ),
                (
                    enums.ObjectType.CERTIFICATE,
                ),
                contents.ProtocolVersion.create(1, 1)
            ),
            'Digest': AttributeRuleSet(
                True,  # If the server has access to the data
                ('server', ),
                False,
                False,
                False,
                True,
                (
                    enums.Operation.CREATE,
                    enums.Operation.CREATE_KEY_PAIR,
                    enums.Operation.REGISTER,
                    enums.Operation.DERIVE_KEY,
                    enums.Operation.CERTIFY,
                    enums.Operation.RECERTIFY,
                    enums.Operation.REKEY,
                    enums.Operation.REKEY_KEY_PAIR
                ),
                (
                    enums.ObjectType.CERTIFICATE,
                    enums.ObjectType.SYMMETRIC_KEY,
                    enums.ObjectType.PUBLIC_KEY,
                    enums.ObjectType.PRIVATE_KEY,
                    enums.ObjectType.SPLIT_KEY,
                    enums.ObjectType.SECRET_DATA,
                    enums.ObjectType.OPAQUE_DATA
                ),
                contents.ProtocolVersion.create(1, 0)
            ),
            'Operation Policy Name': AttributeRuleSet(
                False,
                ('server', 'client'),
                True,
                False,
                False,
                False,
                (
                    enums.Operation.CREATE,
                    enums.Operation.CREATE_KEY_PAIR,
                    enums.Operation.REGISTER,
                    enums.Operation.DERIVE_KEY,
                    enums.Operation.CERTIFY,
                    enums.Operation.RECERTIFY,
                    enums.Operation.REKEY,
                    enums.Operation.REKEY_KEY_PAIR
                ),
                (
                    enums.ObjectType.CERTIFICATE,
                    enums.ObjectType.SYMMETRIC_KEY,
                    enums.ObjectType.PUBLIC_KEY,
                    enums.ObjectType.PRIVATE_KEY,
                    enums.ObjectType.SPLIT_KEY,
                    enums.ObjectType.TEMPLATE,
                    enums.ObjectType.SECRET_DATA,
                    enums.ObjectType.OPAQUE_DATA
                ),
                contents.ProtocolVersion.create(1, 0)
            ),
            'Cryptographic Usage Mask': AttributeRuleSet(
                True,
                ('server', 'client'),
                True,
                False,
                False,
                False,
                (
                    enums.Operation.CREATE,
                    enums.Operation.CREATE_KEY_PAIR,
                    enums.Operation.REGISTER,
                    enums.Operation.DERIVE_KEY,
                    enums.Operation.CERTIFY,
                    enums.Operation.RECERTIFY,
                    enums.Operation.REKEY,
                    enums.Operation.REKEY_KEY_PAIR
                ),
                (
                    enums.ObjectType.CERTIFICATE,
                    enums.ObjectType.SYMMETRIC_KEY,
                    enums.ObjectType.PUBLIC_KEY,
                    enums.ObjectType.PRIVATE_KEY,
                    enums.ObjectType.SPLIT_KEY,
                    enums.ObjectType.TEMPLATE,
                    enums.ObjectType.SECRET_DATA
                ),
                contents.ProtocolVersion.create(1, 0)
            ),
            'Lease Time': AttributeRuleSet(
                False,
                ('server', ),
                True,
                False,
                False,
                False,
                (
                    enums.Operation.CREATE,
                    enums.Operation.CREATE_KEY_PAIR,
                    enums.Operation.REGISTER,
                    enums.Operation.DERIVE_KEY,
                    enums.Operation.CERTIFY,
                    enums.Operation.RECERTIFY,
                    enums.Operation.REKEY,
                    enums.Operation.REKEY_KEY_PAIR
                ),
                (
                    enums.ObjectType.CERTIFICATE,
                    enums.ObjectType.SYMMETRIC_KEY,
                    enums.ObjectType.PUBLIC_KEY,
                    enums.ObjectType.PRIVATE_KEY,
                    enums.ObjectType.SPLIT_KEY,
                    enums.ObjectType.SECRET_DATA
                ),
                contents.ProtocolVersion.create(1, 0)
            ),
            'Usage Limits': AttributeRuleSet(
                False,
                ('server', 'client'),  # Values differ based on source
                True,
                True,  # Conditional on values and operations used
                True,  # Conditional on operations used
                False,
                (
                    enums.Operation.CREATE,
                    enums.Operation.CREATE_KEY_PAIR,
                    enums.Operation.REGISTER,
                    enums.Operation.DERIVE_KEY,
                    enums.Operation.REKEY,
                    enums.Operation.REKEY_KEY_PAIR,
                    enums.Operation.GET_USAGE_ALLOCATION
                ),
                (
                    enums.ObjectType.SYMMETRIC_KEY,
                    enums.ObjectType.PUBLIC_KEY,
                    enums.ObjectType.PRIVATE_KEY,
                    enums.ObjectType.SPLIT_KEY,
                    enums.ObjectType.TEMPLATE
                ),
                contents.ProtocolVersion.create(1, 0)
            ),
            'State': AttributeRuleSet(
                True,
                ('server', ),
                True,
                False,  # Only modifiable by server for certain requests
                False,
                False,
                (
                    enums.Operation.CREATE,
                    enums.Operation.CREATE_KEY_PAIR,
                    enums.Operation.REGISTER,
                    enums.Operation.DERIVE_KEY,
                    enums.Operation.ACTIVATE,
                    enums.Operation.REVOKE,
                    enums.Operation.DESTROY,
                    enums.Operation.CERTIFY,
                    enums.Operation.RECERTIFY,
                    enums.Operation.REKEY,
                    enums.Operation.REKEY_KEY_PAIR
                ),
                (
                    enums.ObjectType.CERTIFICATE,
                    enums.ObjectType.SYMMETRIC_KEY,
                    enums.ObjectType.PUBLIC_KEY,
                    enums.ObjectType.PRIVATE_KEY,
                    enums.ObjectType.SPLIT_KEY,
                    enums.ObjectType.SECRET_DATA
                ),
                contents.ProtocolVersion.create(1, 0)
            ),
            'Initial Date': AttributeRuleSet(
                True,
                ('server', ),
                False,
                False,
                False,
                False,
                (
                    enums.Operation.CREATE,
                    enums.Operation.CREATE_KEY_PAIR,
                    enums.Operation.REGISTER,
                    enums.Operation.DERIVE_KEY,
                    enums.Operation.CERTIFY,
                    enums.Operation.RECERTIFY,
                    enums.Operation.REKEY,
                    enums.Operation.REKEY_KEY_PAIR
                ),
                (
                    enums.ObjectType.CERTIFICATE,
                    enums.ObjectType.SYMMETRIC_KEY,
                    enums.ObjectType.PUBLIC_KEY,
                    enums.ObjectType.PRIVATE_KEY,
                    enums.ObjectType.SPLIT_KEY,
                    enums.ObjectType.TEMPLATE,
                    enums.ObjectType.SECRET_DATA,
                    enums.ObjectType.OPAQUE_DATA
                ),
                contents.ProtocolVersion.create(1, 0)
            ),
            'Activation Date': AttributeRuleSet(
                False,
                ('server', 'client'),
                True,  # Only while in Pre-Active state
                True,  # Only while in Pre-Active state
                False,
                False,
                (
                    enums.Operation.CREATE,
                    enums.Operation.CREATE_KEY_PAIR,
                    enums.Operation.REGISTER,
                    enums.Operation.DERIVE_KEY,
                    enums.Operation.ACTIVATE,
                    enums.Operation.CERTIFY,
                    enums.Operation.RECERTIFY,
                    enums.Operation.REKEY,
                    enums.Operation.REKEY_KEY_PAIR
                ),
                (
                    enums.ObjectType.CERTIFICATE,
                    enums.ObjectType.SYMMETRIC_KEY,
                    enums.ObjectType.PUBLIC_KEY,
                    enums.ObjectType.PRIVATE_KEY,
                    enums.ObjectType.SPLIT_KEY,
                    enums.ObjectType.TEMPLATE,
                    enums.ObjectType.SECRET_DATA
                ),
                contents.ProtocolVersion.create(1, 0)
            ),
            'Process Start Date': AttributeRuleSet(
                False,
                ('server', 'client'),
                True,  # Only while in Pre-Active / Active state and more
                True,  # Only while in Pre-Active / Active state and more
                False,
                False,
                (
                    enums.Operation.CREATE,
                    enums.Operation.REGISTER,
                    enums.Operation.DERIVE_KEY,
                    enums.Operation.REKEY
                ),
                (
                    enums.ObjectType.SYMMETRIC_KEY,
                    # Only SplitKeys of SymmetricKeys
                    enums.ObjectType.SPLIT_KEY,
                    enums.ObjectType.TEMPLATE
                ),
                contents.ProtocolVersion.create(1, 0)
            ),
            'Protect Stop Date': AttributeRuleSet(
                False,
                ('server', 'client'),
                True,  # Only while in Pre-Active / Active state and more
                True,  # Only while in Pre-Active / Active state and more
                False,
                False,
                (
                    enums.Operation.CREATE,
                    enums.Operation.REGISTER,
                    enums.Operation.DERIVE_KEY,
                    enums.Operation.REKEY
                ),
                (
                    enums.ObjectType.SYMMETRIC_KEY,
                    # Only SplitKeys of SymmetricKeys
                    enums.ObjectType.SPLIT_KEY,
                    enums.ObjectType.TEMPLATE
                ),
                contents.ProtocolVersion.create(1, 0)
            ),
            'Deactivation Date': AttributeRuleSet(
                False,
                ('server', 'client'),
                True,  # Only while in Pre-Active / Active state
                True,  # Only while in Pre-Active / Active state
                False,
                False,
                (
                    enums.Operation.CREATE,
                    enums.Operation.CREATE_KEY_PAIR,
                    enums.Operation.REGISTER,
                    enums.Operation.DERIVE_KEY,
                    enums.Operation.REVOKE,
                    enums.Operation.CERTIFY,
                    enums.Operation.RECERTIFY,
                    enums.Operation.REKEY,
                    enums.Operation.REKEY_KEY_PAIR
                ),
                (
                    enums.ObjectType.CERTIFICATE,
                    enums.ObjectType.SYMMETRIC_KEY,
                    enums.ObjectType.PUBLIC_KEY,
                    enums.ObjectType.PRIVATE_KEY,
                    enums.ObjectType.SPLIT_KEY,
                    enums.ObjectType.TEMPLATE,
                    enums.ObjectType.SECRET_DATA
                ),
                contents.ProtocolVersion.create(1, 0)
            ),
            'Destroy Date': AttributeRuleSet(
                False,
                ('server', ),
                False,
                False,
                False,
                False,
                (
                    enums.Operation.DESTROY,
                ),
                (
                    enums.ObjectType.CERTIFICATE,
                    enums.ObjectType.SYMMETRIC_KEY,
                    enums.ObjectType.PUBLIC_KEY,
                    enums.ObjectType.PRIVATE_KEY,
                    enums.ObjectType.SPLIT_KEY,
                    enums.ObjectType.SECRET_DATA,
                    enums.ObjectType.OPAQUE_DATA
                ),
                contents.ProtocolVersion.create(1, 0)
            ),
            'Compromise Occurrence Date': AttributeRuleSet(
                False,
                ('server', ),
                False,
                False,
                False,
                False,
                (
                    enums.Operation.REVOKE,
                ),
                (
                    enums.ObjectType.CERTIFICATE,
                    enums.ObjectType.SYMMETRIC_KEY,
                    enums.ObjectType.PUBLIC_KEY,
                    enums.ObjectType.PRIVATE_KEY,
                    enums.ObjectType.SPLIT_KEY,
                    enums.ObjectType.SECRET_DATA,
                    enums.ObjectType.OPAQUE_DATA
                ),
                contents.ProtocolVersion.create(1, 0)
            ),
            'Compromise Date': AttributeRuleSet(
                False,
                ('server', ),
                False,
                False,
                False,
                False,
                (
                    enums.Operation.REVOKE,
                ),
                (
                    enums.ObjectType.CERTIFICATE,
                    enums.ObjectType.SYMMETRIC_KEY,
                    enums.ObjectType.PUBLIC_KEY,
                    enums.ObjectType.PRIVATE_KEY,
                    enums.ObjectType.SPLIT_KEY,
                    enums.ObjectType.SECRET_DATA,
                    enums.ObjectType.OPAQUE_DATA
                ),
                contents.ProtocolVersion.create(1, 0)
            ),
            'Revocation Reason': AttributeRuleSet(
                False,
                ('server', ),
                True,
                False,
                False,
                False,
                (
                    enums.Operation.REVOKE,
                ),
                (
                    enums.ObjectType.CERTIFICATE,
                    enums.ObjectType.SYMMETRIC_KEY,
                    enums.ObjectType.PUBLIC_KEY,
                    enums.ObjectType.PRIVATE_KEY,
                    enums.ObjectType.SPLIT_KEY,
                    enums.ObjectType.SECRET_DATA,
                    enums.ObjectType.OPAQUE_DATA
                ),
                contents.ProtocolVersion.create(1, 0)
            ),
            'Archive Date': AttributeRuleSet(
                False,
                ('server', ),
                False,
                False,
                False,
                False,
                (
                    enums.Operation.ARCHIVE,
                ),
                (
                    enums.ObjectType.CERTIFICATE,
                    enums.ObjectType.SYMMETRIC_KEY,
                    enums.ObjectType.PUBLIC_KEY,
                    enums.ObjectType.PRIVATE_KEY,
                    enums.ObjectType.SPLIT_KEY,
                    enums.ObjectType.TEMPLATE,
                    enums.ObjectType.SECRET_DATA,
                    enums.ObjectType.OPAQUE_DATA
                ),
                contents.ProtocolVersion.create(1, 0)
            ),
            'Object Group': AttributeRuleSet(
                False,
                ('server', 'client'),
                False,
                False,
                False,
                False,
                (
                    enums.Operation.CREATE,
                    enums.Operation.CREATE_KEY_PAIR,
                    enums.Operation.REGISTER,
                    enums.Operation.DERIVE_KEY,
                    enums.Operation.CERTIFY,
                    enums.Operation.RECERTIFY,
                    enums.Operation.REKEY,
                    enums.Operation.REKEY_KEY_PAIR
                ),
                (
                    enums.ObjectType.CERTIFICATE,
                    enums.ObjectType.SYMMETRIC_KEY,
                    enums.ObjectType.PUBLIC_KEY,
                    enums.ObjectType.PRIVATE_KEY,
                    enums.ObjectType.SPLIT_KEY,
                    enums.ObjectType.TEMPLATE,
                    enums.ObjectType.SECRET_DATA,
                    enums.ObjectType.OPAQUE_DATA
                ),
                contents.ProtocolVersion.create(1, 0)
            ),
            'Fresh': AttributeRuleSet(
                False,
                ('server', 'client'),
                True,
                False,
                False,
                False,
                (
                    enums.Operation.CREATE,
                    enums.Operation.CREATE_KEY_PAIR,
                    enums.Operation.REGISTER,
                    enums.Operation.DERIVE_KEY,
                    enums.Operation.CERTIFY,
                    enums.Operation.RECERTIFY,
                    enums.Operation.REKEY,
                    enums.Operation.REKEY_KEY_PAIR
                ),
                (
                    enums.ObjectType.CERTIFICATE,
                    enums.ObjectType.SYMMETRIC_KEY,
                    enums.ObjectType.PUBLIC_KEY,
                    enums.ObjectType.PRIVATE_KEY,
                    enums.ObjectType.SPLIT_KEY,
                    enums.ObjectType.TEMPLATE,
                    enums.ObjectType.SECRET_DATA,
                    enums.ObjectType.OPAQUE_DATA
                ),
                contents.ProtocolVersion.create(1, 1)
            ),
            'Link': AttributeRuleSet(
                False,
                ('server', ),
                True,
                True,
                True,
                True,
                (
                    enums.Operation.CREATE_KEY_PAIR,
                    enums.Operation.DERIVE_KEY,
                    enums.Operation.CERTIFY,
                    enums.Operation.RECERTIFY,
                    enums.Operation.REKEY,
                    enums.Operation.REKEY_KEY_PAIR
                ),
                (
                    enums.ObjectType.CERTIFICATE,
                    enums.ObjectType.SYMMETRIC_KEY,
                    enums.ObjectType.PUBLIC_KEY,
                    enums.ObjectType.PRIVATE_KEY,
                    enums.ObjectType.SPLIT_KEY,
                    enums.ObjectType.TEMPLATE,
                    enums.ObjectType.SECRET_DATA,
                    enums.ObjectType.OPAQUE_DATA
                ),
                contents.ProtocolVersion.create(1, 0)
            ),
            'Application Specific Information': AttributeRuleSet(
                False,
                ('server', 'client'),  # Only if omitted in client request
                True,  # Only if attribute omitted in client request
                True,
                True,
                True,
                (
                    enums.Operation.RECERTIFY,
                    enums.Operation.REKEY,
                    enums.Operation.REKEY_KEY_PAIR
                ),
                (
                    enums.ObjectType.CERTIFICATE,
                    enums.ObjectType.SYMMETRIC_KEY,
                    enums.ObjectType.PUBLIC_KEY,
                    enums.ObjectType.PRIVATE_KEY,
                    enums.ObjectType.SPLIT_KEY,
                    enums.ObjectType.TEMPLATE,
                    enums.ObjectType.SECRET_DATA,
                    enums.ObjectType.OPAQUE_DATA
                ),
                contents.ProtocolVersion.create(1, 0)
            ),
            'Contact Information': AttributeRuleSet(
                False,
                ('server', 'client'),
                True,
                True,
                True,
                False,
                (
                    enums.Operation.CREATE,
                    enums.Operation.CREATE_KEY_PAIR,
                    enums.Operation.REGISTER,
                    enums.Operation.DERIVE_KEY,
                    enums.Operation.CERTIFY,
                    enums.Operation.RECERTIFY,
                    enums.Operation.REKEY,
                    enums.Operation.REKEY_KEY_PAIR
                ),
                (
                    enums.ObjectType.CERTIFICATE,
                    enums.ObjectType.SYMMETRIC_KEY,
                    enums.ObjectType.PUBLIC_KEY,
                    enums.ObjectType.PRIVATE_KEY,
                    enums.ObjectType.SPLIT_KEY,
                    enums.ObjectType.TEMPLATE,
                    enums.ObjectType.SECRET_DATA,
                    enums.ObjectType.OPAQUE_DATA
                ),
                contents.ProtocolVersion.create(1, 0)
            ),
            'Last Change Date': AttributeRuleSet(
                True,
                ('server', ),
                True,
                False,
                False,
                False,
                (
                    enums.Operation.CREATE,
                    enums.Operation.CREATE_KEY_PAIR,
                    enums.Operation.REGISTER,
                    enums.Operation.DERIVE_KEY,
                    enums.Operation.ACTIVATE,
                    enums.Operation.REVOKE,
                    enums.Operation.DESTROY,
                    enums.Operation.ARCHIVE,
                    enums.Operation.RECOVER,
                    enums.Operation.CERTIFY,
                    enums.Operation.RECERTIFY,
                    enums.Operation.REKEY,
                    enums.Operation.REKEY_KEY_PAIR,
                    enums.Operation.ADD_ATTRIBUTE,
                    enums.Operation.MODIFY_ATTRIBUTE,
                    enums.Operation.DELETE_ATTRIBUTE,
                    enums.Operation.GET_USAGE_ALLOCATION
                ),
                (
                    enums.ObjectType.CERTIFICATE,
                    enums.ObjectType.SYMMETRIC_KEY,
                    enums.ObjectType.PUBLIC_KEY,
                    enums.ObjectType.PRIVATE_KEY,
                    enums.ObjectType.SPLIT_KEY,
                    enums.ObjectType.TEMPLATE,
                    enums.ObjectType.SECRET_DATA,
                    enums.ObjectType.OPAQUE_DATA
                ),
                contents.ProtocolVersion.create(1, 0)
            ),
            'Custom Attribute': AttributeRuleSet(
                False,
                ('server', 'client'),
                True,  # Only for server-created attributes
                True,  # Only for client-created attributes
                True,  # Only for client-created attributes
                True,
                (
                    enums.Operation.CREATE,
                    enums.Operation.CREATE_KEY_PAIR,
                    enums.Operation.REGISTER,
                    enums.Operation.DERIVE_KEY,
                    enums.Operation.ACTIVATE,
                    enums.Operation.REVOKE,
                    enums.Operation.DESTROY,
                    enums.Operation.CERTIFY,
                    enums.Operation.RECERTIFY,
                    enums.Operation.REKEY,
                    enums.Operation.REKEY_KEY_PAIR
                ),
                (
                    enums.ObjectType.CERTIFICATE,
                    enums.ObjectType.SYMMETRIC_KEY,
                    enums.ObjectType.PUBLIC_KEY,
                    enums.ObjectType.PRIVATE_KEY,
                    enums.ObjectType.SPLIT_KEY,
                    enums.ObjectType.TEMPLATE,
                    enums.ObjectType.SECRET_DATA,
                    enums.ObjectType.OPAQUE_DATA
                ),
                contents.ProtocolVersion.create(1, 0)
            ),
        }

    def is_attribute_supported(self, attribute):
        """
        Check if the attribute is supported by the current KMIP version.

        Args:
            attribute (string): The name of the attribute
                (e.g., 'Cryptographic Algorithm'). Required.
        Returns:
            bool: True if the attribute is supported by the current KMIP
                version. False otherwise.
        """
        if attribute not in self._attribute_rule_sets.keys():
            return False

        rule_set = self._attribute_rule_sets.get(attribute)
        if self._version >= rule_set.version_added:
            return True
        else:
            return False

    def is_attribute_deprecated(self, attribute):
        """
        Check if the attribute is deprecated by the current KMIP version.

        Args:
            attribute (string): The name of the attribute
                (e.g., 'Unique Identifier'). Required.
        """
        rule_set = self._attribute_rule_sets.get(attribute)
        if rule_set.version_deprecated:
            if self._version >= rule_set.version_deprecated:
                return True
            else:
                return False
        else:
            return False

    def is_attribute_applicable_to_object_type(self, attribute, object_type):
        """
        Check if the attribute is supported by the given object type.

        Args:
            attribute (string): The name of the attribute (e.g., 'Name').
                Required.
            object_type (ObjectType): An ObjectType enumeration
                (e.g., ObjectType.SYMMETRIC_KEY). Required.
        Returns:
            bool: True if the attribute is applicable to the object type.
                False otherwise.
        """
        # TODO (peterhamilton) Handle applicability between certificate types
        rule_set = self._attribute_rule_sets.get(attribute)
        if object_type in rule_set.applies_to_object_types:
            return True
        else:
            return False

    def is_attribute_multivalued(self, attribute):
        """
        Check if the attribute is allowed to have multiple instances.

        Args:
            attribute (string): The name of the attribute
                (e.g., 'State'). Required.
        """
        # TODO (peterhamilton) Handle multivalue swap between certificate types
        rule_set = self._attribute_rule_sets.get(attribute)
        return rule_set.multiple_instances_permitted