本文整理汇总了Python中MaKaC.authentication.AuthenticatorMgr.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Python AuthenticatorMgr.getInstance方法的具体用法?Python AuthenticatorMgr.getInstance怎么用?Python AuthenticatorMgr.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MaKaC.authentication.AuthenticatorMgr
的用法示例。
在下文中一共展示了AuthenticatorMgr.getInstance方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: authenticate
# 需要导入模块: from MaKaC.authentication import AuthenticatorMgr [as 别名]
# 或者: from MaKaC.authentication.AuthenticatorMgr import getInstance [as 别名]
def authenticate(self, id):
"""
id is MaKaC.user.LoginInfo instance, self.user is Avatar
"""
log = Logger.get('auth.ldap')
log.info("authenticate(%s)" % id.getLogin())
data = AuthenticatorMgr.getInstance().getById(self.getAuthenticatorTag()).checkLoginPassword(id.getLogin(),
id.getPassword())
if not data or self.getLogin() != id.getLogin():
return None
# modify Avatar with the up-to-date info from LDAP
av = self.user
av.clearAuthenticatorPersonalData()
udata = LDAPTools.extractUserDataFromLdapData(data)
mail = udata.get('email', '').strip()
if mail != '' and mail != av.getEmail():
av.setEmail(mail, reindex=True)
av.setAuthenticatorPersonalData('firstName', udata.get('name'))
av.setAuthenticatorPersonalData('surName', udata.get('surName'))
av.setAuthenticatorPersonalData('affiliation', udata.get('organisation'))
av.setAuthenticatorPersonalData('address', udata.get('address'))
av.setAuthenticatorPersonalData('phone', udata.get('phone'))
av.setAuthenticatorPersonalData('fax', udata.get('fax'))
return self.user
示例2: _process
# 需要导入模块: from MaKaC.authentication import AuthenticatorMgr [as 别名]
# 或者: from MaKaC.authentication.AuthenticatorMgr import getInstance [as 别名]
def _process(self):
if self._params.get("Cancel") is not None:
self._redirect(urlHandlers.UHUserDetails.getURL(self._avatar))
return
msg = ""
if self._ok:
ok = True
authManager = AuthenticatorMgr.getInstance()
#first, check if login is free
if not authManager.isLoginAvailable(self._login):
msg += "Sorry, the login you requested is already in use. Please choose another one.<br>"
ok = False
if not self._pwd:
msg += "you must enter a password<br>"
ok = False
#then, check if password is OK
if self._pwd != self._pwdBis:
msg += "You must enter the same password twice<br>"
ok = False
if ok:
#create the indentity
li = user.LoginInfo( self._login, self._pwd )
id = authManager.createIdentity( li, self._avatar, self._system )
authManager.add( id )
self._redirect( urlHandlers.UHUserDetails.getURL( self._avatar ) )
return
self._params["msg"] = msg
p = adminPages.WPIdentityCreation( self, self._avatar, self._params )
return p.display()
示例3: containsUser
# 需要导入模块: from MaKaC.authentication import AuthenticatorMgr [as 别名]
# 或者: from MaKaC.authentication.AuthenticatorMgr import getInstance [as 别名]
def containsUser(self, avatar):
# used when checking acces to private events restricted for certain groups
if not avatar:
return False
login = None
for aid in avatar.getIdentityList():
if aid.getAuthenticatorTag() == 'LDAP':
login = aid.getLogin()
if not login:
return False
return AuthenticatorMgr.getInstance().getById('LDAP').isUserInGroup((login, self.getName()))
示例4: getMemberList
# 需要导入模块: from MaKaC.authentication import AuthenticatorMgr [as 别名]
# 或者: from MaKaC.authentication.AuthenticatorMgr import getInstance [as 别名]
def getMemberList(self):
uidList = AuthenticatorMgr.getInstance().getById('LDAP').getGroupMemberList(self.getName())
avatarLists = []
for uid in uidList:
# First, try locally (fast)
lst = PrincipalHolder().match(uid , exact=1, searchInAuthenticators=False)
print "Result", lst
if not lst:
# If not found, try external
lst = PrincipalHolder().match(uid, exact=1)
avatarLists.append(lst)
return [avList[0] for avList in avatarLists if avList]
示例5: createUser
# 需要导入模块: from MaKaC.authentication import AuthenticatorMgr [as 别名]
# 或者: from MaKaC.authentication.AuthenticatorMgr import getInstance [as 别名]
def createUser(name, email, org, password):
#has problem that if no email exists and 2 users with same name will clash
#perhaps change getUser() to check for same name if no email exist.
#problem being that more than one person can have same name. Email unique.
dummy = user.Avatar()
#sets the user properties
if name == '':#if there is no username makes the email address appear in it's place
dummy.setName(email)
else:
dummy.setName(name)
dummy.setEmail(email)
dummy.setOrganisation(org)
ah.add(dummy)
avatar = ah.getById(dummy.id)
if email != '':#creates the identity and sets the password for chairs etc.
id = user.LocalIdentity(name, password, avatar)
else:#user with no email address - identity not created
return avatar
try:
AuthenticatorMgr.getInstance().add(id)
except (UserError):
pass
avatar.activateAccount()
return avatar
示例6: _process
# 需要导入模块: from MaKaC.authentication import AuthenticatorMgr [as 别名]
# 或者: from MaKaC.authentication.AuthenticatorMgr import getInstance [as 别名]
def _process(self):
authenticator = session.pop('Authenticator', None)
if authenticator is not None:
authManager = AuthenticatorMgr.getInstance()
if not authManager.isSSOLoginActive():
raise MaKaCError(_("SSO Login is not active."))
av = authManager.SSOLogin(self, authenticator)
if not av:
raise MaKaCError(_("You could not login through SSO."))
self._setSessionVars(av)
self._redirect(self._url)
elif self._authId:
session['Authenticator'] = self._authId
if self._returnURL:
session['loginReturnURL'] = self._returnURL
self._redirect(str(urlHandlers.UHSignInSSO.getURL(authId=self._authId)))
else:
raise MaKaCError(_("You did not pass the authenticator"))
示例7: _process
# 需要导入模块: from MaKaC.authentication import AuthenticatorMgr [as 别名]
# 或者: from MaKaC.authentication.AuthenticatorMgr import getInstance [as 别名]
def _process( self ):
li = LoginInfo( self._login, self._password )
av = AuthenticatorMgr.getInstance().getAvatar(li)
value = "OK"
message = ""
if not av:
value = "ERROR"
message = "Login failed"
elif not av.isActivated():
if av.isDisabled():
value = "ERROR"
message = "Acount is disabled"
else:
value = "ERROR"
message = "Acount is not activated"
else:
value = "OK"
message = "Login succesful"
session.user = av
return self._createResponse(value, message)
示例8: _makeLoginProcess
# 需要导入模块: from MaKaC.authentication import AuthenticatorMgr [as 别名]
# 或者: from MaKaC.authentication.AuthenticatorMgr import getInstance [as 别名]
def _makeLoginProcess( self ):
#Check for automatic login
authManager = AuthenticatorMgr.getInstance()
if (authManager.isSSOLoginActive() and len(authManager.getList()) == 1 and
not Config.getInstance().getDisplayLoginPage()):
self._redirect(urlHandlers.UHSignInSSO.getURL(authId=authManager.getDefaultAuthenticator().getId()))
return
if not self._signIn:
return self._signInPage.display( returnURL = self._returnURL )
else:
li = LoginInfo( self._login, self._password )
av = authManager.getAvatar(li)
if not av:
return self._signInPageFailed.display( returnURL = self._returnURL )
elif not av.isActivated():
if av.isDisabled():
self._redirect(self._disabledAccountURL(av))
else:
self._redirect(self._unactivatedAccountURL(av))
return _("your account is not activate\nPlease active it and retry")
else:
self._setSessionVars(av)
self._addExtraParamsToURL()
self._redirect(self._url)
示例9: print
# 需要导入模块: from MaKaC.authentication import AuthenticatorMgr [as 别名]
# 或者: from MaKaC.authentication.AuthenticatorMgr import getInstance [as 别名]
from MaKaC.authentication import AuthenticatorMgr
from MaKaC.authentication.LocalAuthentication import LocalIdentity
print('This script will remove all local identities from users.')
print('This will remove passwords from the database and prevent them from')
print('logging in locally (so you need e.g. LDAP authentication)')
print
if raw_input('Do you want to continue? [yes|NO]: ').lower() != 'yes':
print 'Cancelled.'
sys.exit(0)
i = 0
dbi = DBMgr.getInstance()
dbi.startRequest()
ah = AvatarHolder()
am = AuthenticatorMgr.getInstance()
for aid, avatar in ah._getIdx().iteritems():
for identity in avatar.getIdentityList():
if isinstance(identity, LocalIdentity):
print('Removing LocalIdentity(%s, %s) from %s' %
(identity.getLogin(), len(identity.password) * '*',
avatar.getFullName()))
am.removeIdentity(identity)
avatar.removeIdentity(identity)
if i % 100 == 99:
dbi.commit()
i += 1
DBMgr.getInstance().endRequest()