def generatePasswords(self, request, **kw): entries = [] for k, v in kw.items(): if not k.startswith('dn_'): continue k = k[len('dn_'):] if not v: continue assert k in self.ldapObjects entries.append(self.ldapObjects[k]) if not entries: return _('No passwords to change.') d = generate_password.generate(reactor, len(entries)) def _gotPasswords(passwords, entries): assert len(passwords) == len(entries) l = [] for entry, pwd in zip(entries, passwords): d = entry.setPassword(newPasswd=pwd) def _cb(entry, pwd): return (entry, pwd) d.addCallback(_cb, pwd) l.append(d) return defer.DeferredList(l, consumeErrors=True) d.addCallback(_gotPasswords, entries) d.addCallback(MassPasswordChangeStatus) return d
def generatePasswords(self, request, **kw): entries = [] for k,v in kw.items(): if not k.startswith('dn_'): continue k = k[len('dn_'):] if not v: continue assert k in self.ldapObjects entries.append(self.ldapObjects[k]) if not entries: return _('No passwords to change.') d=generate_password.generate(reactor, len(entries)) def _gotPasswords(passwords, entries): assert len(passwords)==len(entries) l=[] for entry, pwd in zip(entries, passwords): d=entry.setPassword(newPasswd=pwd) def _cb(entry, pwd): return (entry, pwd) d.addCallback(_cb, pwd) l.append(d) return defer.DeferredList(l, consumeErrors=True) d.addCallback(_gotPasswords, entries) d.addCallback(MassPasswordChangeStatus) return d
def generateRandom(self, ctx): d = generate_password.generate(reactor) def _first(passwords): assert len(passwords) == 1 return passwords[0] d.addCallback(_first) def _setPass(newPassword, ctx): e = getEntry(ctx, self.dn) d = e.setPassword(newPassword) def _getName(_, ctx): d = getServiceName(ctx, self.dn) return d d.addCallback(_getName, ctx) def _report(name, newPassword): return _('Service %r password set to %s') % (name, newPassword) d.addCallback(_report, newPassword) return d d.addCallback(_setPass, ctx) return d
def _generate(self, ctx, serviceName): d=generate_password.generate(reactor) def _first(passwords): assert len(passwords)==1 return passwords[0] d.addCallback(_first) def _cb(newPassword, serviceName): d = self._cbSetPassword(ctx, newPassword, serviceName) d.addCallback(lambda dummy: _('Added service %r with password %s') % (serviceName, newPassword)) return d d.addCallback(_cb, serviceName) return d
def generateRandom(self, ctx): d=generate_password.generate(reactor) def _first(passwords): assert len(passwords)==1 return passwords[0] d.addCallback(_first) def _status(newPassword, ctx): d = self._setPassword(ctx, newPassword) d.addCallback(lambda dummy: _('Password set to %s') % newPassword) return d d.addCallback(_status, ctx) def eb(fail): return _("Failed: %s") % fail.getErrorMessage() d.addErrback(eb) return d
def _generate(self, ctx, serviceName): d = generate_password.generate(reactor) def _first(passwords): assert len(passwords) == 1 return passwords[0] d.addCallback(_first) def _cb(newPassword, serviceName): d = self._cbSetPassword(ctx, newPassword, serviceName) d.addCallback(lambda dummy: _('Added service %r with password %s') % (serviceName, newPassword)) return d d.addCallback(_cb, serviceName) return d
def generateRandom(self, ctx): d = generate_password.generate(reactor) def _first(passwords): assert len(passwords) == 1 return passwords[0] d.addCallback(_first) def _status(newPassword, ctx): d = self._setPassword(ctx, newPassword) d.addCallback(lambda dummy: _('Password set to %s') % newPassword) return d d.addCallback(_status, ctx) def eb(fail): return _("Failed: %s") % fail.getErrorMessage() d.addErrback(eb) return d
def generateRandom(self, ctx): d=generate_password.generate(reactor) def _first(passwords): assert len(passwords)==1 return passwords[0] d.addCallback(_first) def _setPass(newPassword, ctx): e = getEntry(ctx, self.dn) d = e.setPassword(newPassword) def _getName(_, ctx): d = getServiceName(ctx, self.dn) return d d.addCallback(_getName, ctx) def _report(name, newPassword): return _('Service %r password set to %s') % (name, newPassword) d.addCallback(_report, newPassword) return d d.addCallback(_setPass, ctx) return d
def getPassword(self, dn): if not self.factory.generatePasswords: pwd = getpass.getpass("NEW Password for %s: " % dn) return defer.succeed((pwd, )) else: return generate_password.generate(reactor)