class _StandardSignable(Signable, _StandardSaml2Initialization):
    """mixin class to provide standard initialization and signability."""
    def S_GET_KEYNAME(self):
        return self.Issuer.value()


class _AssertionTypeExtension(_StandardSignable, Picklable):
    """Application generated ``Assertion``."""
    def is_valid(self, context=None):
        cs = self.Conditions
        return cs is None or cs.is_valid(context)


enhance('AssertionType')


class ConditionsCheckContext(object):
    """Base class used for condition validity checks.

  Supports the standard condition types.
  """

    #  handling the `Condition` extension point
    #   override as necessary to handle your conditions
    def is_condition_valid(self, condition):
        return False

    # audience restriction
    # must be overridden by derived classes
class _StandardSignable(Signable, _StandardSaml2Initialization):
  """mixin class to provide standard initialization and signability."""

  def S_GET_KEYNAME(self): return self.Issuer.value()


class _AssertionTypeExtension(_StandardSignable, Picklable):
  """Application generated ``Assertion``."""

  def is_valid(self, context=None):
    cs = self.Conditions
    return cs is None or cs.is_valid(context)


enhance('AssertionType')

class ConditionsCheckContext(object):
  """Base class used for condition validity checks.

  Supports the standard condition types.
  """
  #  handling the `Condition` extension point
  #   override as necessary to handle your conditions
  def is_condition_valid(self, condition): return False

  # audience restriction
  # must be overridden by derived classes
  def audience_id(self): return None
  def belongs_to_audience(self, audience):
    return audience == self.audience_id()
##  Requester
##  Responder
##  VersionMismatch

##  # second level status codes
##  AuthnFailed
##  InvalidAttrNameOrValue
##  UnkownAttrProfile
##  InvalidNameIDPolicy
##  NoAuthnContext
##  NoAvailableIDP
##  NoPassive
##  PartialLogout
##  # there are more, but we do not expect we will use them

enhance('StatusResponseType', _ResponseTypeExtension)
enhance('ResponseType')

# assertion request and assertion query
enhance('AssertionIDRequestType', _RequestAbstractTypeExtension)
enhance('AuthnQueryType', _RequestAbstractTypeExtension)
enhance('AttributeQueryType', _RequestAbstractTypeExtension)
enhance('AuthzDecisionQueryType', _RequestAbstractTypeExtension)

# authentication request
enhance('AuthnRequestType', _RequestAbstractTypeExtension)

# artifact resolution
enhance('ArtifactResolveType', _RequestAbstractTypeExtension)
enhance('ArtifactResponseType', _ResponseTypeExtension)
Пример #4
0
  """mixin class to provide standard initialization of 'ID'."""

  def __init__(self, *args, **kw):
    if 'ID' not in kw: kw['ID'] = '_' + uuid()
    super(_StandardSaml2Initialization, self).__init__(*args, **kw)


class _StandardSignable(Signable, _StandardSaml2Initialization):
  """mixin class to provide standard initialization and signability."""

  def S_GET_KEYNAME(self): return self.entityID


class _EntityDescriptorTypeExtension(_StandardSignable, Picklable): pass

enhance('EntityDescriptorType')


class _RoleDescriptorTypeExtension(object):
  """mixin class to provide standard initialization of ``protocolSupportEnumeration``."""
  def __init__(self, *args, **kw):
    pse = kw.get('protocolSupportEnumeration')
    proto = 'urn:oasis:names:tc:SAML:2.0:protocol'
    if pse is None: pse = kw['protocolSupportEnumeration'] = proto
    if proto not in pse: kw['protocolSupportEnumeration'] += ' ' + proto
    super(_RoleDescriptorTypeExtension, self).__init__(*args, **kw)
  
enhance('IDPSSODescriptorType', _RoleDescriptorTypeExtension)
enhance('SPSSODescriptorType', _RoleDescriptorTypeExtension)
enhance('AuthnAuthorityDescriptorType', _RoleDescriptorTypeExtension)
enhance('AttributeAuthorityDescriptorType', _RoleDescriptorTypeExtension)