def auth(self,name,password,dup=None,sasl=0): """ Authenticate component "name" with password "password".""" self._User,self._Password,self._Resource=name,password,'' try: if self.component: sasl=1 if sasl: auth.SASL(name,password).PlugIn(self) if not sasl or self.SASL.startsasl=='not-supported': if auth.NonSASL(name,password,'').PlugIn(self): self.connected+='+old_auth' return 'old_auth' return self.SASL.auth() while self.SASL.startsasl=='in-process' and self.Process(): pass if self.SASL.startsasl=='success': if self.component: self._component=self.component for domain in self.domains: auth.ComponentBind().PlugIn(self) while self.ComponentBind.bound is None: self.Process() if (not self.ComponentBind.Bind(domain)): self.ComponentBind.PlugOut() return self.ComponentBind.PlugOut() self.connected+='+sasl' return 'sasl' else: raise auth.NotAuthorized(self.SASL.startsasl) except Exception: self.DEBUG(self.DBG,"Failed to authenticate %s"%name,'error')
def dobind(self, sasl): # This has to be done before binding, because we can receive a route stanza before binding finishes self._route = self.route if self.bind: for domain in self.domains: auth.ComponentBind(sasl).PlugIn(self) while self.ComponentBind.bound is None: self.Process(1) if (not self.ComponentBind.Bind(domain)): self.ComponentBind.PlugOut() return self.ComponentBind.PlugOut()