def filter_mechanism_list(mechanisms, properties, allow_insecure = False,<EOL>server_side = False):
<EOL>result = []<EOL>for mechanism in mechanisms:<EOL><INDENT>try:<EOL><INDENT>if server_side:<EOL><INDENT>klass = SERVER_MECHANISMS_D[mechanism]<EOL><DEDENT>else:<EOL><INDENT>klass = CLIENT_MECHANISMS_D[mechanism]<EOL><DEDENT><DEDENT>except KeyError:<EOL><INDENT>logger.debug("<STR_LIT>".format(mechanism))<EOL>continue<EOL><DEDENT>secure = properties.get("<STR_LIT>")<EOL>if not allow_insecure and not klass._pyxmpp_sasl_secure and not secure:<EOL><INDENT>logger.debug("<STR_LIT>".format(mechanism))<EOL>continue<EOL><DEDENT>if not klass.are_properties_sufficient(properties):<EOL><INDENT>logger.debug("<STR_LIT>"<EOL>.format(mechanism))<EOL>continue<EOL><DEDENT>result.append(mechanism)<EOL><DEDENT>return result<EOL>
Filter a mechanisms list only to include those mechanisms that cans
    succeed with the provided properties and are secure enough.

    :Parameters:
        - `mechanisms`: list of the mechanisms names
        - `properties`: available authentication properties
        - `allow_insecure`: allow insecure mechanisms
    :Types:
        - `mechanisms`: sequence of `unicode`
        - `properties`: mapping
        - `allow_insecure`: `bool`

    :returntype: `list` of `unicode`