本文整理汇总了Python中org.jboss.seam.contexts.Contexts.getEventContext方法的典型用法代码示例。如果您正苦于以下问题:Python Contexts.getEventContext方法的具体用法?Python Contexts.getEventContext怎么用?Python Contexts.getEventContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jboss.seam.contexts.Contexts
的用法示例。
在下文中一共展示了Contexts.getEventContext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prepareForStep
# 需要导入模块: from org.jboss.seam.contexts import Contexts [as 别名]
# 或者: from org.jboss.seam.contexts.Contexts import getEventContext [as 别名]
def prepareForStep(self, configurationAttributes, requestParameters, step):
context = Contexts.getEventContext()
authenticationService = AuthenticationService.instance()
server_flag = configurationAttributes.get("oneid_server_flag").getValue2()
callback_attrs = configurationAttributes.get("oneid_callback_attrs").getValue2()
creds_file = configurationAttributes.get("oneid_creds_file").getValue2()
# Create OneID
authn = OneID(server_flag)
# Set path to credentials file
authn.creds_file = creds_file;
if (step == 1):
print "OneId. Prepare for step 1"
request = FacesContext.getCurrentInstance().getExternalContext().getRequest()
validation_page = request.getContextPath() + "/postlogin?" + "request_uri=&" + authenticationService.parametersAsString()
print "OneId. Prepare for step 1. validation_page: " + validation_page
oneid_login_button = authn.draw_signin_button(validation_page, callback_attrs, True)
print "OneId. Prepare for step 1. oneid_login_button: " + oneid_login_button
context.set("oneid_login_button", oneid_login_button)
context.set("oneid_script_header", authn.script_header)
context.set("oneid_form_script", authn.oneid_form_script)
return True
elif (step == 2):
print "OneId. Prepare for step 2"
return True
else:
return False
示例2: authenticate
# 需要导入模块: from org.jboss.seam.contexts import Contexts [as 别名]
# 或者: from org.jboss.seam.contexts.Contexts import getEventContext [as 别名]
def authenticate(self, configurationAttributes, requestParameters, step):
duo_host = configurationAttributes.get("duo_host").getValue2()
credentials = Identity.instance().getCredentials()
user_name = credentials.getUsername()
if (step == 1):
print "Duo. Authenticate for step 1"
user_password = credentials.getPassword()
logged_in = False
if (StringHelper.isNotEmptyString(user_name) and StringHelper.isNotEmptyString(user_password)):
userService = UserService.instance()
logged_in = userService.authenticate(user_name, user_password)
if (not logged_in):
return False
authenticationService = AuthenticationService.instance()
user = authenticationService.getAuthenticatedUser()
if (self.use_duo_group):
print "Duo. Authenticate for step 1. Checking if user belong to Duo group"
is_member_duo_group = self.isUserMemberOfGroup(user, self.audit_attribute, self.duo_group)
if (is_member_duo_group):
print "Duo. Authenticate for step 1. User '" + user.getUserId() + "' member of Duo group"
duo_count_login_steps = 2
else:
self.processAuditGroup(user)
duo_count_login_steps = 1
context = Contexts.getEventContext()
context.set("duo_count_login_steps", duo_count_login_steps)
return True
elif (step == 2):
print "Duo. Authenticate for step 2"
sig_response_array = requestParameters.get("sig_response")
if ArrayHelper.isEmpty(sig_response_array):
print "Duo. Authenticate for step 2. sig_response is empty"
return False
duo_sig_response = sig_response_array[0]
print "Duo. Authenticate for step 2. duo_sig_response: " + duo_sig_response
authenticated_username = duo_web.verify_response(self.ikey, self.skey, self.akey, duo_sig_response)
print "Duo. Authenticate for step 2. authenticated_username: " + authenticated_username + ", expected user_name: " + user_name
if (not StringHelper.equals(user_name, authenticated_username)):
return False
authenticationService = AuthenticationService.instance()
user = authenticationService.getAuthenticatedUser()
self.processAuditGroup(user)
return True
else:
return False
示例3: prepareForStep
# 需要导入模块: from org.jboss.seam.contexts import Contexts [as 别名]
# 或者: from org.jboss.seam.contexts.Contexts import getEventContext [as 别名]
def prepareForStep(self, configurationAttributes, requestParameters, step):
context = Contexts.getEventContext()
duo_host = configurationAttributes.get("duo_host").getValue2()
credentials = Identity.instance().getCredentials()
user_name = credentials.getUsername()
if (step == 1):
print "Duo prepare for step 1"
return True
elif (step == 2):
print "Duo prepare for step 2"
passed_step1 = self.isPassedStep1
if (not passed_step1):
return False
duo_sig_request = duo_web.sign_request(self.ikey, self.skey, self.akey, user_name)
print "Duo prepare for step 2. duo_sig_request: " + duo_sig_request
context.set("duo_host", duo_host)
context.set("duo_sig_request", duo_sig_request)
return True
else:
return False
示例4: prepareForStep
# 需要导入模块: from org.jboss.seam.contexts import Contexts [as 别名]
# 或者: from org.jboss.seam.contexts.Contexts import getEventContext [as 别名]
def prepareForStep(self, configurationAttributes, requestParameters, step):
context = Contexts.getEventContext()
authenticationService = AuthenticationService.instance()
if (step == 1):
print "Saml. Prepare for step 1"
httpService = HttpService.instance();
request = FacesContext.getCurrentInstance().getExternalContext().getRequest()
assertionConsumerServiceUrl = httpService.constructServerUrl(request) + "/postlogin"
print "Saml. Prepare for step 1. Prepared assertionConsumerServiceUrl:", assertionConsumerServiceUrl
currentSamlConfiguration = self.getCurrentSamlConfiguration(self.samlConfiguration, configurationAttributes, requestParameters)
if (currentSamlConfiguration == None):
print "Saml. Prepare for step 1. Client saml configuration is invalid"
return False
# Generate an AuthRequest and send it to the identity provider
samlAuthRequest = AuthRequest(currentSamlConfiguration)
external_auth_request_uri = currentSamlConfiguration.getIdpSsoTargetUrl() + "?SAMLRequest=" + samlAuthRequest.getRequest(True, assertionConsumerServiceUrl)
print "Saml. Prepare for step 1. external_auth_request_uri:", external_auth_request_uri
context.set("external_auth_request_uri", external_auth_request_uri)
return True
elif (step == 2):
print "Saml. Prepare for step 2"
return True
else:
return False
示例5: getCountAuthenticationSteps
# 需要导入模块: from org.jboss.seam.contexts import Contexts [as 别名]
# 或者: from org.jboss.seam.contexts.Contexts import getEventContext [as 别名]
def getCountAuthenticationSteps(self, configurationAttributes):
context = Contexts.getEventContext()
session_attributes = context.get("sessionAttributes")
if session_attributes.containsKey("otp_count_login_steps"):
return StringHelper.toInteger(session_attributes.get("otp_count_login_steps"))
else:
return 2
示例6: getCountAuthenticationSteps
# 需要导入模块: from org.jboss.seam.contexts import Contexts [as 别名]
# 或者: from org.jboss.seam.contexts.Contexts import getEventContext [as 别名]
def getCountAuthenticationSteps(self, configurationAttributes):
context = Contexts.getEventContext()
sessionAttributes = context.get("sessionAttributes")
if (sessionAttributes != None) and sessionAttributes.containsKey("wikid_count_login_steps"):
return java.lang.Integer.valueOf(sessionAttributes.get("wikid_count_login_steps"))
return 2
示例7: prepareForStep
# 需要导入模块: from org.jboss.seam.contexts import Contexts [as 别名]
# 或者: from org.jboss.seam.contexts.Contexts import getEventContext [as 别名]
def prepareForStep(self, configurationAttributes, requestParameters, step):
credentials = Identity.instance().getCredentials()
context = Contexts.getEventContext()
session_attributes = context.get("sessionAttributes")
self.setEventContextParameters(context)
if step == 1:
print "OTP. Prepare for step 1"
return True
elif step == 2:
print "OTP. Prepare for step 2"
session_state_validation = self.validateSessionState(session_attributes)
if not session_state_validation:
return False
otp_auth_method = session_attributes.get("otp_auth_method")
print "OTP. Prepare for step 2. otp_auth_method: '%s'" % otp_auth_method
if otp_auth_method == 'enroll':
authenticationService = AuthenticationService.instance()
user = authenticationService.getAuthenticatedUser()
if user == None:
print "OTP. Prepare for step 2. Failed to load user enty"
return False
if self.otpType == "hotp":
otp_secret_key = self.generateSecretHotpKey()
otp_enrollment_request = self.generateHotpSecretKeyUri(otp_secret_key, self.otpIssuer, user.getAttribute("displayName"))
elif self.otpType == "totp":
otp_secret_key = self.generateSecretTotpKey()
otp_enrollment_request = self.generateTotpSecretKeyUri(otp_secret_key, self.otpIssuer, user.getAttribute("displayName"))
else:
print "OTP. Prepare for step 2. Unknown OTP type: '%s'" % self.otpType
return False
print "OTP. Prepare for step 2. Prepared enrollment request for user: '%s'" % user.getUserId()
context.set("otp_secret_key", self.toBase64Url(otp_secret_key))
context.set("otp_enrollment_request", otp_enrollment_request)
return True
elif step == 3:
print "OTP. Prepare for step 3"
session_state_validation = self.validateSessionState(session_attributes)
if not session_state_validation:
return False
otp_auth_method = session_attributes.get("otp_auth_method")
print "OTP. Prepare for step 3. otp_auth_method: '%s'" % otp_auth_method
if otp_auth_method == 'enroll':
return True
return False
示例8: getSessionAttribute
# 需要导入模块: from org.jboss.seam.contexts import Contexts [as 别名]
# 或者: from org.jboss.seam.contexts.Contexts import getEventContext [as 别名]
def getSessionAttribute(self, attribute_name):
context = Contexts.getEventContext()
# Try to get attribute value from Seam event context
if context.isSet(attribute_name):
return context.get(attribute_name)
# Try to get attribute from persistent session
session_attributes = context.get("sessionAttributes")
if session_attributes.containsKey(attribute_name):
return session_attributes.get(attribute_name)
return None
示例9: getNextStep
# 需要导入模块: from org.jboss.seam.contexts import Contexts [as 别名]
# 或者: from org.jboss.seam.contexts.Contexts import getEventContext [as 别名]
def getNextStep(self, configurationAttributes, requestParameters, step):
print "Basic (demo reset step). Get next step for step '%s'" % step
# If user not pass current step authenticaton change step to previous
context = Contexts.getEventContext()
pass_authentication = context.get("pass_authentication")
if not pass_authentication:
if step > 1:
resultStep = step - 1
print "Basic (demo reset step). Get next step. Changing step to '%s'" % resultStep
return resultStep
return -1
示例10: prepareForStep
# 需要导入模块: from org.jboss.seam.contexts import Contexts [as 别名]
# 或者: from org.jboss.seam.contexts.Contexts import getEventContext [as 别名]
def prepareForStep(self, configurationAttributes, requestParameters, step):
context = Contexts.getEventContext()
if (step == 1):
return True
elif (step == 2):
print "U2F. Prepare for step 2"
session_state = SessionStateService.instance().getSessionStateFromCookie()
if StringHelper.isEmpty(session_state):
print "U2F. Prepare for step 2. Failed to determine session_state"
return False
credentials = Identity.instance().getCredentials()
user = credentials.getUser()
if (user == None):
print "U2F. Prepare for step 2. Failed to determine user name"
return False
u2f_application_id = configurationAttributes.get("u2f_application_id").getValue2()
# Check if user have registered devices
deviceRegistrationService = DeviceRegistrationService.instance()
userInum = user.getAttribute("inum")
authenticationRequest = None
deviceRegistrations = deviceRegistrationService.findUserDeviceRegistrations(userInum, u2f_application_id)
if (deviceRegistrations.size() > 0):
print "U2F. Prepare for step 2. Call FIDO U2F in order to start authentication workflow"
try:
authenticationRequestService = FidoU2fClientFactory.instance().createAuthenticationRequestService(self.metaDataConfiguration)
authenticationRequest = authenticationRequestService.startAuthentication(user.getUserId(), None, u2f_application_id, session_state)
except ClientResponseFailure, ex:
if (ex.getResponse().getResponseStatus() != Response.Status.NOT_FOUND):
print "U2F. Prepare for step 2. Failed to start authentication workflow. Exception:", sys.exc_info()[1]
return False
print "U2F. Prepare for step 2. Call FIDO U2F in order to start registration workflow"
registrationRequestService = FidoU2fClientFactory.instance().createRegistrationRequestService(self.metaDataConfiguration)
registrationRequest = registrationRequestService.startRegistration(user.getUserId(), u2f_application_id, session_state)
context.set("fido_u2f_authentication_request", ServerUtil.asJson(authenticationRequest))
context.set("fido_u2f_registration_request", ServerUtil.asJson(registrationRequest))
return True
示例11: getPageForStep
# 需要导入模块: from org.jboss.seam.contexts import Contexts [as 别名]
# 或者: from org.jboss.seam.contexts.Contexts import getEventContext [as 别名]
def getPageForStep(self, configurationAttributes, step):
if step == 2:
context = Contexts.getEventContext()
session_attributes = context.get("sessionAttributes")
otp_auth_method = session_attributes.get("otp_auth_method")
print "OTP. Gep page for step 2. otp_auth_method: '%s'" % otp_auth_method
if otp_auth_method == 'enroll':
return "/auth/otp/enroll.xhtml"
else:
return "/auth/otp/otplogin.xhtml"
elif step == 3:
return "/auth/otp/otplogin.xhtml"
return ""
示例12: getPageForStep
# 需要导入模块: from org.jboss.seam.contexts import Contexts [as 别名]
# 或者: from org.jboss.seam.contexts.Contexts import getEventContext [as 别名]
def getPageForStep(self, configurationAttributes, step):
context = Contexts.getEventContext()
is_wikid_registration = False
if (context.isSet("wikid_registration")):
is_wikid_registration = context.get("wikid_registration")
if (step == 2):
if (is_wikid_registration):
return "/auth/wikid/wikidregister.xhtml"
else:
return "/auth/wikid/wikidlogin.xhtml"
if (step == 3):
return "/auth/wikid/wikidlogin.xhtml"
return ""
示例13: prepareForStep
# 需要导入模块: from org.jboss.seam.contexts import Contexts [as 别名]
# 或者: from org.jboss.seam.contexts.Contexts import getEventContext [as 别名]
def prepareForStep(self, configurationAttributes, requestParameters, step):
if (step == 1):
print "InWebo. Prepare for step 1"
context = Contexts.getEventContext()
iw_helium_enabled = Boolean(configurationAttributes.get("iw_helium_enabled").getValue2()).booleanValue()
context.set("helium_enabled", iw_helium_enabled)
iw_helium_alias = None
if (iw_helium_enabled):
iw_helium_alias = configurationAttributes.get("iw_helium_alias").getValue2()
context.set("helium_alias", iw_helium_alias)
print "InWebo. Prepare for step 1. Helium status:", iw_helium_enabled
return True
示例14: prepareForStep
# 需要导入模块: from org.jboss.seam.contexts import Contexts [as 别名]
# 或者: from org.jboss.seam.contexts.Contexts import getEventContext [as 别名]
def prepareForStep(self, configurationAttributes, requestParameters, step):
context = Contexts.getEventContext()
if (step == 1):
context.set("display_register_action", True)
return True
elif (step == 2):
print "oxPush2. Prepare for step 2"
credentials = Identity.instance().getCredentials()
user = credentials.getUser()
if (user == None):
print "oxPush2. Prepare for step 2. Failed to determine user name"
return False
session_attributes = context.get("sessionAttributes")
if session_attributes.containsKey("oxpush2_request"):
print "oxPush2. Prepare for step 2. Request was generated already"
return True
session_state = SessionStateService.instance().getSessionStateFromCookie()
if StringHelper.isEmpty(session_state):
print "oxPush2. Prepare for step 2. Failed to determine session_state"
return False
auth_method = session_attributes.get("oxpush2_auth_method")
if StringHelper.isEmpty(auth_method):
print "oxPush2. Prepare for step 2. Failed to determine auth_method"
return False
print "oxPush2. Prepare for step 2. auth_method: '%s'" % auth_method
issuer = ConfigurationFactory.instance().getConfiguration().getIssuer()
oxpush2_request = json.dumps({'username': user.getUserId(),
'app': self.u2f_application_id,
'issuer': issuer,
'method': auth_method,
'state': session_state}, separators=(',',':'))
print "oxPush2. Prepare for step 2. Prepared oxpush2_request:", oxpush2_request
context.set("oxpush2_request", oxpush2_request)
return True
else:
return False
示例15: prepareForStep
# 需要导入模块: from org.jboss.seam.contexts import Contexts [as 别名]
# 或者: from org.jboss.seam.contexts.Contexts import getEventContext [as 别名]
def prepareForStep(self, configurationAttributes, requestParameters, step):
print "Cert. Prepare for step %d" % step
context = Contexts.getEventContext()
if step == 1:
if self.enabled_recaptcha:
context.set("recaptcha_site_key", self.recaptcha_creds['site_key'])
elif step == 2:
# Store certificate in session
request = FacesContext.getCurrentInstance().getExternalContext().getRequest()
x509Certificates = request.getAttribute('javax.servlet.request.X509Certificate')
if (x509Certificates != None) and (len(x509Certificates) > 0):
context.set("cert_x509", self.certToString(x509Certificates))
print "Cert. Prepare for step 2. Storing user certificate"
if step < 4:
return True
else:
return False