Exemplo n.º 1
0
 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')
Exemplo n.º 2
0
 def auth(self,name,password,dup=None):
     """ Authenticate component "name" with password "password"."""
     self._User,self._Password,self._Resource=name,password,''
     try:
         if self.sasl: auth.SASL(name,password).PlugIn(self)
         if not self.sasl or self.SASL.startsasl=='not-supported':
             if auth.NonSASL(name,password,'').PlugIn(self):
                 self.dobind(sasl=False)
                 self.connected+='+old_auth'
                 return 'old_auth'
             return
         self.SASL.auth()
         while self.SASL.startsasl=='in-process' and self.Process(1): pass
         if self.SASL.startsasl=='success':
             self.dobind(sasl=True)
             self.connected+='+sasl'
             return 'sasl'
         else:
             raise auth.NotAuthorized(self.SASL.startsasl)
     except:
         self.DEBUG(self.DBG,"Failed to authenticate %s"%name,'error')