def isAuthorized(port, security_attributes, request_info, stp, start_time, end_time):
    """
    Check if a request is authorized to use a certain port within the given criteria.
    """
    default = False if port.authz else True

    for rule in port.authz:
        if rule.type_ in HEADER_ATTRIBUTES:
            if any( [ rule.match(sa) for sa in security_attributes ] ):
                log.msg('AuthZ granted for port %s: Using %s attribute' % (port.name, rule.type_), system=LOG_SYSTEM)
                return True
        elif rule.type_ in REQUEST_ATTRIBUTES and rule.type_ == HOST_DN:
            if rule.value == request_info.cert_host_dn:
                log.msg('AuthZ granted for port %s: Using certificate dn %s' % (port.name, request_info.cert_host_dn), system=LOG_SYSTEM)
                return True
        else:
            log.msg("Couldn't figure out what to do with rule of type %s" % rule.type_, system='AuthZ')

    return default
dataset/ETHPy150Open NORDUnet/opennsa/opennsa/authz.py/isAuthorized/original