本文整理汇总了Python中org.gluu.util.StringHelper.equalsIgnoreCase方法的典型用法代码示例。如果您正苦于以下问题:Python StringHelper.equalsIgnoreCase方法的具体用法?Python StringHelper.equalsIgnoreCase怎么用?Python StringHelper.equalsIgnoreCase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.gluu.util.StringHelper
的用法示例。
在下文中一共展示了StringHelper.equalsIgnoreCase方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: is_session_authenticated
# 需要导入模块: from org.gluu.util import StringHelper [as 别名]
# 或者: from org.gluu.util.StringHelper import equalsIgnoreCase [as 别名]
def is_session_authenticated(self, sessionId):
if sessionId == None:
return False
state = sessionId.getState()
custom_state = sessionId.getSessionAttributes().get(SessionIdService.SESSION_CUSTOM_STATE)
if state == None:
print "Super-Gluu-RO. Session {%s} has no state variable set" % sessionId.getId()
return False
state_unauthenticated = SessionIdState.UNAUTHENTICATED == state
state_authenticated = SessionIdState.AUTHENTICATED == state
custom_state_declined = StringHelper.equalsIgnoreCase("declined",custom_state)
custom_state_expired = StringHelper.equalsIgnoreCase("expired",custom_state)
custom_stated_approved = StringHelper.equalsIgnoreCase("approved",custom_state)
if state_unauthenticated and (custom_state_declined or custom_state_expired):
print "Super-Gluu-RO. Session {%s} isn't authenticated" % sessionId.getId()
return False
if state_authenticated or (state_unauthenticated and custom_stated_approved):
print "Super-Gluu-RO. Session {%s} is authenticated" % sessionId.getId()
return True
return False
示例2: sendDevicePushNotification
# 需要导入模块: from org.gluu.util import StringHelper [as 别名]
# 或者: from org.gluu.util.StringHelper import equalsIgnoreCase [as 别名]
def sendDevicePushNotification(self, user, app_id, u2f_device, super_gluu_request):
device_data = u2f_device.getDeviceData()
if device_data == None:
return {"send_android":0,"send_ios":0}
platform = device_data.getPlatform()
push_token = device_data.getPushToken()
pushNotificationContext = PushNotificationContext(app_id,super_gluu_request)
pushNotificationContext.debugEnabled = self.debugEnabled
pushNotificationContext.user = user
pushNotificationContext.u2fDevice = u2f_device
pushNotificationContext.devicePlatform = platform
pushNotificationContext.pushToken = push_token
send_ios = 0
send_android = 0
if StringHelper.equalsIgnoreCase(platform,"ios") and StringHelper.isNotEmpty(push_token):
# Sending notification to iOS user's device
if self.pushAppleService == None:
print "Super-Gluu-Push. Apple push notification service disabled"
else:
self.sendApplePushNotification(pushNotificationContext)
send_ios = 1
if StringHelper.equalsIgnoreCase(platform,"android") and StringHelper.isNotEmpty(push_token):
# Sending notification to android user's device
if self.pushAndroidService == None:
print "Super-Gluu-Push. Android push notification service disabled"
else:
self.sendAndroidPushNotification(pushNotificationContext)
send_android = 1
return {"send_android":send_android,"send_ios":send_ios}
示例3: verify_session_ownership
# 需要导入模块: from org.gluu.util import StringHelper [as 别名]
# 或者: from org.gluu.util.StringHelper import equalsIgnoreCase [as 别名]
def verify_session_ownership(self, sessionId, user, client):
session_attributes = sessionId.getSessionAttributes()
client_id = session_attributes.get(self.clientIdSessionParamName)
if not StringHelper.equalsIgnoreCase(client.getClientId(),client_id):
print "Super-Gluu-RO. Session {%s} client_id mismatch" % sessionId.getId()
return False
user_id = session_attributes.get(Constants.AUTHENTICATED_USER)
if not StringHelper.equalsIgnoreCase(user_id,user.getUserId()):
print "Super-Gluu-RO. Session {%s} user_id mismatch" % sessionId.getId()
return False
return True
示例4: authenticate
# 需要导入模块: from org.gluu.util import StringHelper [as 别名]
# 或者: from org.gluu.util.StringHelper import equalsIgnoreCase [as 别名]
def authenticate(self, context):
if self.perform_preliminary_user_authentication(context) == False:
print "Super-Gluu-Radius. User authentication state not validated"
return False
step = context.getHttpRequest().getParameter(self.stepParamName)
if StringHelper.equalsIgnoreCase(step,self.initiateAuthStepName):
return self.initiate_authentication(context)
elif StringHelper.equalsIgnoreCase(step,self.resendNotificationStepName):
return self.resend_push_notification(context)
elif StringHelper.equalsIgnoreCase(step,self.verifyAuthStepName):
return self.verify_authentication(context)
else:
context.setUser(None)
print "Super-Gluu-RO. Unknown authentication step '%s'" % step
return False
示例5: isUserMemberOfGroup
# 需要导入模块: from org.gluu.util import StringHelper [as 别名]
# 或者: from org.gluu.util.StringHelper import equalsIgnoreCase [as 别名]
def isUserMemberOfGroup(self, user, attribute, group):
is_member = False
member_of_list = user.getAttributeValues(attribute)
if (member_of_list != None):
for member_of in member_of_list:
if StringHelper.equalsIgnoreCase(group, member_of) or member_of.endswith(group):
is_member = True
break
return is_member
示例6: __init__
# 需要导入模块: from org.gluu.util import StringHelper [as 别名]
# 或者: from org.gluu.util.StringHelper import equalsIgnoreCase [as 别名]
def __init__(self, serviceMode, credentialsFile):
self.pushSnsMode = False
self.pushGluuMode = False
self.pushNotificationsEnabled = False
self.titleTemplate = "Super-Gluu"
self.messageTemplate = "Super-Gluu login request to %s"
self.debugEnabled = True
self.httpConnTimeout = 15 * 1000 # in milliseconds
creds = self.loadCredentials(credentialsFile)
if creds == None:
return None
if StringHelper.equalsIgnoreCase(serviceMode,"sns"):
self.initSnsPushNotifications(creds)
elif StringHelper.equalsIgnoreCase(serviceMode,"gluu"):
self.initGluuPushNotifications(creds)
else:
self.initNativePushNotifications(creds)
示例7: loadOtpConfiguration
# 需要导入模块: from org.gluu.util import StringHelper [as 别名]
# 或者: from org.gluu.util.StringHelper import equalsIgnoreCase [as 别名]
def loadOtpConfiguration(self, configurationAttributes):
print "OTP. Load OTP configuration"
if not configurationAttributes.containsKey("otp_conf_file"):
return False
otp_conf_file = configurationAttributes.get("otp_conf_file").getValue2()
# Load configuration from file
f = open(otp_conf_file, 'r')
try:
otpConfiguration = json.loads(f.read())
except:
print "OTP. Load OTP configuration. Failed to load configuration from file:", otp_conf_file
return False
finally:
f.close()
# Check configuration file settings
try:
self.hotpConfiguration = otpConfiguration["hotp"]
self.totpConfiguration = otpConfiguration["totp"]
hmacShaAlgorithm = self.totpConfiguration["hmacShaAlgorithm"]
hmacShaAlgorithmType = None
if StringHelper.equalsIgnoreCase(hmacShaAlgorithm, "sha1"):
hmacShaAlgorithmType = HmacShaAlgorithm.HMAC_SHA_1
elif StringHelper.equalsIgnoreCase(hmacShaAlgorithm, "sha256"):
hmacShaAlgorithmType = HmacShaAlgorithm.HMAC_SHA_256
elif StringHelper.equalsIgnoreCase(hmacShaAlgorithm, "sha512"):
hmacShaAlgorithmType = HmacShaAlgorithm.HMAC_SHA_512
else:
print "OTP. Load OTP configuration. Invalid TOTP HMAC SHA algorithm: '%s'" % hmacShaAlgorithm
self.totpConfiguration["hmacShaAlgorithmType"] = hmacShaAlgorithmType
except:
print "OTP. Load OTP configuration. Invalid configuration file '%s' format. Exception: '%s'" % (otp_conf_file, sys.exc_info()[1])
return False
return True
示例8: getGeolocation
# 需要导入模块: from org.gluu.util import StringHelper [as 别名]
# 或者: from org.gluu.util.StringHelper import equalsIgnoreCase [as 别名]
def getGeolocation(self, identity):
session_attributes = identity.getSessionId().getSessionAttributes()
if session_attributes.containsKey("remote_ip"):
remote_ip = session_attributes.get("remote_ip")
if StringHelper.isNotEmpty(remote_ip):
httpService = CdiUtil.bean(HttpService)
http_client = httpService.getHttpsClient()
http_client_params = http_client.getParams()
http_client_params.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 4 * 1000)
geolocation_service_url = "http://ip-api.com/json/%s?fields=country,city,status,message" % remote_ip
geolocation_service_headers = { "Accept" : "application/json" }
try:
http_service_response = httpService.executeGet(http_client, geolocation_service_url, geolocation_service_headers)
http_response = http_service_response.getHttpResponse()
except:
print "Casa. Determine remote location. Exception: ", sys.exc_info()[1]
return None
try:
if not httpService.isResponseStastusCodeOk(http_response):
print "Casa. Determine remote location. Get non 200 OK response from server:", str(http_response.getStatusLine().getStatusCode())
httpService.consume(http_response)
return None
response_bytes = httpService.getResponseContent(http_response)
response_string = httpService.convertEntityToString(response_bytes, Charset.forName("UTF-8"))
httpService.consume(http_response)
finally:
http_service_response.closeConnection()
if response_string == None:
print "Casa. Determine remote location. Get empty response from location server"
return None
response = json.loads(response_string)
if not StringHelper.equalsIgnoreCase(response['status'], "success"):
print "Casa. Determine remote location. Get response with status: '%s'" % response['status']
return None
return response
return None
示例9: prepareForStep
# 需要导入模块: from org.gluu.util import StringHelper [as 别名]
# 或者: from org.gluu.util.StringHelper import equalsIgnoreCase [as 别名]
def prepareForStep(self, configurationAttributes, requestParameters, step):
extensionResult = self.extensionPrepareForStep(configurationAttributes, requestParameters, step)
if extensionResult != None:
return extensionResult
print "Passport. prepareForStep called %s" % str(step)
identity = CdiUtil.bean(Identity)
if step == 1:
#re-read the strategies config (for instance to know which strategies have enabled the email account linking)
self.parseProviderConfigs()
identity.setWorkingParameter("externalProviders", json.dumps(self.registeredProviders))
providerParam = self.customAuthzParameter
url = None
sessionAttributes = identity.getSessionId().getSessionAttributes()
self.skipProfileUpdate = StringHelper.equalsIgnoreCase(sessionAttributes.get("skipPassportProfileUpdate"), "true")
#this param could have been set previously in authenticate step if current step is being retried
provider = identity.getWorkingParameter("selectedProvider")
if provider != None:
url = self.getPassportRedirectUrl(provider)
identity.setWorkingParameter("selectedProvider", None)
elif providerParam != None:
paramValue = sessionAttributes.get(providerParam)
if paramValue != None:
print "Passport. prepareForStep. Found value in custom param of authorization request: %s" % paramValue
provider = self.getProviderFromJson(paramValue)
if provider == None:
print "Passport. prepareForStep. A provider value could not be extracted from custom authorization request parameter"
elif not provider in self.registeredProviders:
print "Passport. prepareForStep. Provider '%s' not part of known configured IDPs/OPs" % provider
else:
url = self.getPassportRedirectUrl(provider)
if url == None:
print "Passport. prepareForStep. A page to manually select an identity provider will be shown"
else:
facesService = CdiUtil.bean(FacesService)
facesService.redirectToExternalURL(url)
return True
示例10: get_geolocation_data
# 需要导入模块: from org.gluu.util import StringHelper [as 别名]
# 或者: from org.gluu.util.StringHelper import equalsIgnoreCase [as 别名]
def get_geolocation_data(self, remote_ip):
print "NetApi. Determining remote location for ip address '%s'" % remote_ip
httpService = CdiUtil.bean(HttpService)
http_client = httpService.getHttpsClient()
http_client_params = http_client.getParams()
http_client_params.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT,self.conn_timeout)
geolocation_service_url = "http://ip-api.com/json/%s?fields=49177" % remote_ip
geolocation_service_headers = { "Accept": "application/json"}
try:
http_service_response = httpService.executeGet(http_client,geolocation_service_url,geolocation_service_headers)
http_response = http_service_response.getHttpResponse()
except:
print "NetApi. Could not determine remote location: ", sys.exc_info()[1]
return None
try:
if not httpService.isResponseStastusCodeOk(http_response):
http_error_str = str(http_response.getStatusLine().getStatusCode())
print "NetApi. Could not determine remote location: ",http_error_str
httpService.consume(http_response)
return None
response_bytes = httpService.getResponseContent(http_response)
response_string = httpService.convertEntityToString(response_bytes)
httpService.consume(http_response)
finally:
http_service_response.closeConnection()
if response_string == None:
print "NetApi. Could not determine remote location. Empty respone from server"
return None
response = json.loads(response_string)
if not StringHelper.equalsIgnoreCase(response['status'],"success"):
print "NetApi. Could not determine remote location. ip-api status: '%s'" % response['status']
return None
return GeolocationData(response)
示例11: init
# 需要导入模块: from org.gluu.util import StringHelper [as 别名]
# 或者: from org.gluu.util.StringHelper import equalsIgnoreCase [as 别名]
def init(self, configurationAttributes):
print "Super-Gluu-RO Init"
if not configurationAttributes.containsKey("application_id"):
print "Super-Gluu-Radius RO PW Init Failed. application_id property is required"
return False
if not configurationAttributes.containsKey("credentials_file"):
print "Super-Gluu-RO Init Failed. credentials_file is required"
return False
notificationServiceMode = None
if configurationAttributes.containsKey("notification_service_mode"):
notificationServiceMode = configurationAttributes.get("notification_service_mode").getValue2()
self.applicationId = "*" # wildcard. Selects all devices irrespective of the application
if configurationAttributes.containsKey("application_id"):
self.applicationId = configurationAttributes.get("application_id").getValue2()
credentialsFile = configurationAttributes.get("credentials_file").getValue2()
if configurationAttributes.containsKey("push_notification_title"):
self.pushNotificationManager.titleTemplate = configurationAttributes.get("push_notification_title").getValue2()
if configurationAttributes.containsKey("push_notification_message"):
self.pushNotificationManager.messageTemplate = configurationAttributes.get("push_notification_message").getValue2()
self.authWithoutPassword = False
if configurationAttributes.containsKey("auth_without_password"):
auth_without_password = configurationAttributes.get("auth_without_password").getValue2()
if StringHelper.equalsIgnoreCase(auth_without_password,"yes"):
self.authWithoutPassword = True
self.issuerId = CdiUtil.bean(ConfigurationFactory).getAppConfiguration().getIssuer()
if configurationAttributes.containsKey("issuer_id"):
self.issuerId = configurationAttributes.get("issuer_id").getValue2()
self.pushNotificationManager = PushNotificationManager(notificationServiceMode,credentialsFile)
self.networkApi = NetworkApi()
return True
示例12: authenticate
# 需要导入模块: from org.gluu.util import StringHelper [as 别名]
# 或者: from org.gluu.util.StringHelper import equalsIgnoreCase [as 别名]
#.........这里部分代码省略.........
return True
elif (step == 2):
print "UAF. Authenticate for step 2"
session_id = CdiUtil.bean(SessionIdService).getSessionIdFromCookie()
if StringHelper.isEmpty(session_id):
print "UAF. Prepare for step 2. Failed to determine session_id"
return False
user = authenticationService.getAuthenticatedUser()
if (user == None):
print "UAF. Authenticate for step 2. Failed to determine user name"
return False
user_name = user.getUserId()
uaf_auth_result = ServerUtil.getFirstValue(requestParameters, "auth_result")
if uaf_auth_result != "success":
print "UAF. Authenticate for step 2. auth_result is '%s'" % uaf_auth_result
return False
# Restore state from session
uaf_auth_method = session_attributes.get("uaf_auth_method")
if not uaf_auth_method in ['enroll', 'authenticate']:
print "UAF. Authenticate for step 2. Failed to authenticate user. uaf_auth_method: '%s'" % uaf_auth_method
return False
# Request STATUS_OBB
if True:
#TODO: Remove this condition
# It's workaround becuase it's not possible to call STATUS_OBB 2 times. First time on browser and second ime on server
uaf_user_device_handle = ServerUtil.getFirstValue(requestParameters, "auth_handle")
else:
uaf_obb_auth_method = session_attributes.get("uaf_obb_auth_method")
uaf_obb_server_uri = session_attributes.get("uaf_obb_server_uri")
uaf_obb_start_response = session_attributes.get("uaf_obb_start_response")
# Prepare STATUS_OBB
uaf_obb_start_response_json = json.loads(uaf_obb_start_response)
uaf_obb_status_request_dictionary = { "operation": "STATUS_%s" % uaf_obb_auth_method,
"userName": user_name,
"needDetails": 1,
"oobStatusHandle": uaf_obb_start_response_json["oobStatusHandle"],
}
uaf_obb_status_request = json.dumps(uaf_obb_status_request_dictionary, separators=(',',':'))
print "UAF. Authenticate for step 2. Prepared STATUS request: '%s' to send to '%s'" % (uaf_obb_status_request, uaf_obb_server_uri)
uaf_status_obb_response = self.executePost(uaf_obb_server_uri, uaf_obb_status_request)
if uaf_status_obb_response == None:
return False
print "UAF. Authenticate for step 2. Get STATUS response: '%s'" % uaf_status_obb_response
uaf_status_obb_response_json = json.loads(uaf_status_obb_response)
if uaf_status_obb_response_json["statusCode"] != 4000:
print "UAF. Authenticate for step 2. UAF operation status is invalid. statusCode: '%s'" % uaf_status_obb_response_json["statusCode"]
return False
uaf_user_device_handle = uaf_status_obb_response_json["additionalInfo"]["authenticatorsResult"]["handle"]
if StringHelper.isEmpty(uaf_user_device_handle):
print "UAF. Prepare for step 2. Failed to get UAF handle"
return False
uaf_user_external_uid = "uaf:%s" % uaf_user_device_handle
print "UAF. Authenticate for step 2. UAF handle: '%s'" % uaf_user_external_uid
if uaf_auth_method == "authenticate":
# Validate if user used device with same keYHandle
user_enrollments = self.findEnrollments(credentials)
if len(user_enrollments) == 0:
uaf_auth_method = "enroll"
print "UAF. Authenticate for step 2. There is no UAF enrollment for user '%s'." % user_name
return False
for user_enrollment in user_enrollments:
if StringHelper.equalsIgnoreCase(user_enrollment, uaf_user_device_handle):
print "UAF. Authenticate for step 2. There is UAF enrollment for user '%s'. User authenticated successfully" % user_name
return True
else:
userService = CdiUtil.bean(UserService)
# Double check just to make sure. We did checking in previous step
# Check if there is user which has uaf_user_external_uid
# Avoid mapping user cert to more than one IDP account
find_user_by_external_uid = userService.getUserByAttribute("oxExternalUid", uaf_user_external_uid)
if find_user_by_external_uid == None:
# Add uaf_user_external_uid to user's external GUID list
find_user_by_external_uid = userService.addUserAttribute(user_name, "oxExternalUid", uaf_user_external_uid)
if find_user_by_external_uid == None:
print "UAF. Authenticate for step 2. Failed to update current user"
return False
return True
return False
else:
return False
示例13: prepareForStep
# 需要导入模块: from org.gluu.util import StringHelper [as 别名]
# 或者: from org.gluu.util.StringHelper import equalsIgnoreCase [as 别名]
def prepareForStep(self, configurationAttributes, requestParameters, step):
authenticationService = CdiUtil.bean(AuthenticationService)
identity = CdiUtil.bean(Identity)
credentials = identity.getCredentials()
session_attributes = identity.getSessionId().getSessionAttributes()
self.setRequestScopedParameters(identity)
if (step == 1):
return True
elif (step == 2):
print "UAF. Prepare for step 2"
session_id = CdiUtil.bean(SessionIdService).getSessionIdFromCookie()
if StringHelper.isEmpty(session_id):
print "UAF. Prepare for step 2. Failed to determine session_id"
return False
user = authenticationService.getAuthenticatedUser()
if (user == None):
print "UAF. Prepare for step 2. Failed to determine user name"
return False
uaf_auth_method = session_attributes.get("uaf_auth_method")
if StringHelper.isEmpty(uaf_auth_method):
print "UAF. Prepare for step 2. Failed to determine auth_method"
return False
print "UAF. Prepare for step 2. uaf_auth_method: '%s'" % uaf_auth_method
uaf_obb_auth_method = "OOB_REG"
uaf_obb_server_uri = self.uaf_server_uri + "/nnl/v2/reg"
if StringHelper.equalsIgnoreCase(uaf_auth_method, "authenticate"):
uaf_obb_auth_method = "OOB_AUTH"
uaf_obb_server_uri = self.uaf_server_uri + "/nnl/v2/auth"
# Prepare START_OBB
uaf_obb_start_request_dictionary = { "operation": "START_%s" % uaf_obb_auth_method,
"userName": user.getUserId(),
"policyName": "default",
"oobMode":
{ "qr": "true", "rawData": "false", "push": "false" }
}
uaf_obb_start_request = json.dumps(uaf_obb_start_request_dictionary, separators=(',',':'))
print "UAF. Prepare for step 2. Prepared START request: '%s' to send to '%s'" % (uaf_obb_start_request, uaf_obb_server_uri)
# Request START_OBB
uaf_obb_start_response = self.executePost(uaf_obb_server_uri, uaf_obb_start_request)
if uaf_obb_start_response == None:
return False
print "UAF. Prepare for step 2. Get START response: '%s'" % uaf_obb_start_response
uaf_obb_start_response_json = json.loads(uaf_obb_start_response)
# Prepare STATUS_OBB
#TODO: Remove needDetails parameter
uaf_obb_status_request_dictionary = { "operation": "STATUS_%s" % uaf_obb_auth_method,
"userName": user.getUserId(),
"needDetails": 1,
"oobStatusHandle": uaf_obb_start_response_json["oobStatusHandle"],
}
uaf_obb_status_request = json.dumps(uaf_obb_status_request_dictionary, separators=(',',':'))
print "UAF. Prepare for step 2. Prepared STATUS request: '%s' to send to '%s'" % (uaf_obb_status_request, uaf_obb_server_uri)
identity.setWorkingParameter("uaf_obb_auth_method", uaf_obb_auth_method)
identity.setWorkingParameter("uaf_obb_server_uri", uaf_obb_server_uri)
identity.setWorkingParameter("uaf_obb_start_response", uaf_obb_start_response)
identity.setWorkingParameter("qr_image", uaf_obb_start_response_json["modeResult"]["qrCode"]["qrImage"])
identity.setWorkingParameter("uaf_obb_status_request", uaf_obb_status_request)
return True
else:
return False