def sasl_factory(): saslc = sasl.Client() saslc.setAttr("host", str(conf.host)) saslc.setAttr("service", str(conf.kerberos_principal)) if conf.mechanism == 'PLAIN': saslc.setAttr("username", str(conf.username)) saslc.setAttr("password", str(conf.password)) # Defaults to 'hue' for a non-empty string unless using LDAP else: saslc.setAttr("maxbufsize", SASL_MAX_BUFFER.get()) saslc.init() return saslc