class SemanticsInformation(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.OptionalNamedType('semanticsIndentifier', univ.ObjectIdentifier()), namedtype.OptionalNamedType('nameRegistrationAuthorities', NameRegistrationAuthorities())) subtypeSpec = constraint.ConstraintsUnion( constraint.WithComponentsConstraint( ('semanticsIndentifier', constraint.ComponentPresentConstraint())), constraint.WithComponentsConstraint( ('nameRegistrationAuthorities', constraint.ComponentPresentConstraint())))
def testEmptyConstraint(self): c = constraint.WithComponentsConstraint() try: c({'A': 1}) except error.ValueConstraintError: assert 0, 'constraint check fails'
def testGoodValWithExtraFields(self): c = constraint.WithComponentsConstraint( ('A', constraint.ComponentPresentConstraint()), ('B', constraint.ComponentAbsentConstraint())) try: c({'A': 1, 'C': 2}) except error.ValueConstraintError: assert 0, 'constraint check fails'
def testBadValExtraFields(self): c = constraint.WithComponentsConstraint( ('A', constraint.ComponentPresentConstraint())) try: c({'B': 2, 'C': 3}) except error.ValueConstraintError: pass else: assert 0, 'constraint check fails'
class EnhancedJWTClaimConstraints(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.OptionalNamedType( 'mustInclude', JWTClaimNames().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 0))), namedtype.OptionalNamedType( 'permittedValues', JWTClaimValuesList().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 1))), namedtype.OptionalNamedType( 'mustExclude', JWTClaimNames().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 2)))) subtypeSpec = constraint.ConstraintsUnion( constraint.WithComponentsConstraint( ('mustInclude', constraint.ComponentPresentConstraint())), constraint.WithComponentsConstraint( ('permittedValues', constraint.ComponentPresentConstraint())), constraint.WithComponentsConstraint( ('mustExclude', constraint.ComponentPresentConstraint())))
class CMSAlgorithmProtection(univ.Sequence): pass CMSAlgorithmProtection.componentType = namedtype.NamedTypes( namedtype.NamedType('digestAlgorithm', DigestAlgorithmIdentifier()), namedtype.OptionalNamedType('signatureAlgorithm', SignatureAlgorithmIdentifier().subtype( implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))), namedtype.OptionalNamedType('macAlgorithm', MessageAuthenticationCodeAlgorithm().subtype( implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))) ) CMSAlgorithmProtection.subtypeSpec = constraint.ConstraintsUnion( constraint.WithComponentsConstraint( ('signatureAlgorithm', constraint.ComponentPresentConstraint()), ('macAlgorithm', constraint.ComponentAbsentConstraint())), constraint.WithComponentsConstraint( ('signatureAlgorithm', constraint.ComponentAbsentConstraint()), ('macAlgorithm', constraint.ComponentPresentConstraint())) ) aa_cmsAlgorithmProtection = rfc5652.Attribute() aa_cmsAlgorithmProtection['attrType'] = id_aa_cmsAlgorithmProtect aa_cmsAlgorithmProtection['attrValues'][0] = CMSAlgorithmProtection() # Map of Attribute Type OIDs to Attributes are # added to the ones that are in rfc5652.py
class JWTClaimConstraints(univ.Sequence): pass JWTClaimConstraints.componentType = namedtype.NamedTypes( namedtype.OptionalNamedType('mustInclude', JWTClaimNames().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))), namedtype.OptionalNamedType('permittedValues', JWTClaimPermittedValuesList().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))) ) JWTClaimConstraints.subtypeSpec = constraint.ConstraintsUnion( constraint.WithComponentsConstraint( ('mustInclude', constraint.ComponentPresentConstraint())), constraint.WithComponentsConstraint( ('permittedValues', constraint.ComponentPresentConstraint())) ) id_pe_JWTClaimConstraints = _OID(1, 3, 6, 1, 5, 5, 7, 1, 27) class ServiceProviderCode(char.IA5String): pass class TelephoneNumber(char.IA5String): pass
class LogotypeData(univ.Sequence): pass LogotypeData.componentType = namedtype.NamedTypes( namedtype.OptionalNamedType( 'image', univ.SequenceOf(componentType=LogotypeImage())), namedtype.OptionalNamedType( 'audio', univ.SequenceOf(componentType=LogotypeAudio()).subtype( implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))) LogotypeData.subtypeSpec = constraint.ConstraintsUnion( constraint.WithComponentsConstraint( ('image', constraint.ComponentPresentConstraint())), constraint.WithComponentsConstraint( ('audio', constraint.ComponentPresentConstraint()))) class LogotypeReference(univ.Sequence): pass LogotypeReference.componentType = namedtype.NamedTypes( namedtype.NamedType( 'refStructHash', univ.SequenceOf(componentType=HashAlgAndValue()).subtype( sizeSpec=constraint.ValueSizeConstraint(1, MAX))), namedtype.NamedType( 'refStructURI',