gluu
公開メンバ関数 | 公開変数類 | 全メンバ一覧
allowed_countries.PersonAuthentication クラス
allowed_countries.PersonAuthentication の継承関係図
Inheritance graph
allowed_countries.PersonAuthentication 連携図
Collaboration graph

公開メンバ関数

def __init__ (self, currentTimeMillis)
 
def init (self, configurationAttributes)
 
def destroy (self, configurationAttributes)
 
def getApiVersion (self)
 
def isValidAuthenticationMethod (self, usageType, configurationAttributes)
 
def getAlternativeAuthenticationMethod (self, usageType, configurationAttributes)
 
def authenticate (self, configurationAttributes, requestParameters, step)
 
def prepareForStep (self, configurationAttributes, requestParameters, step)
 
def getExtraParametersForStep (self, configurationAttributes, step)
 
def getCountAuthenticationSteps (self, configurationAttributes)
 
def getPageForStep (self, configurationAttributes, step)
 
def logout (self, configurationAttributes, requestParameters)
 
def determineGeolocationData (self, remote_ip)
 

公開変数類

 currentTimeMillis
 
 allowedCountries
 

詳解

構築子と解体子

◆ __init__()

def allowed_countries.PersonAuthentication.__init__ (   self,
  currentTimeMillis 
)
29  def __init__(self, currentTimeMillis):
30  self.currentTimeMillis = currentTimeMillis
31 

関数詳解

◆ authenticate()

def allowed_countries.PersonAuthentication.authenticate (   self,
  configurationAttributes,
  requestParameters,
  step 
)
52  def authenticate(self, configurationAttributes, requestParameters, step):
53  identity = CdiUtil.bean(Identity)
54  session_attributes = identity.getSessionId().getSessionAttributes()
55  authenticationService = CdiUtil.bean(AuthenticationService)
56  allowedCountriesListArray = StringHelper.split(self.allowedCountries, ",")
57  if (len(allowedCountriesListArray) > 0 and session_attributes.containsKey("remote_ip")):
58  remote_ip = session_attributes.get("remote_ip")
59  remote_loc_dic = self.determineGeolocationData(remote_ip)
60  if remote_loc_dic == None:
61  print "Super-Gluu. Prepare for step 2. Failed to determine remote location by remote IP '%s'" % remote_ip
62  return
63  remote_loc = "%s" % ( remote_loc_dic['countryCode'])
64  print "Your remote location is "+remote_loc
65  if remote_loc in allowedCountriesListArray:
66  print "you are allowed to access"
67  else:
68  return False
69 
70 
71  if (step == 1):
72  print "Basic. Authenticate for step 1"
73  identity = CdiUtil.bean(Identity)
74  credentials = identity.getCredentials()
75  user_name = credentials.getUsername()
76  user_password = credentials.getPassword()
77 
78  logged_in = False
79  if (StringHelper.isNotEmptyString(user_name) and StringHelper.isNotEmptyString(user_password)):
80  logged_in = authenticationService.authenticate(user_name, user_password)
81 
82  if (not logged_in):
83  return False
84 
85  return True
86  else:
87  return False
88 

◆ destroy()

def allowed_countries.PersonAuthentication.destroy (   self,
  configurationAttributes 
)
38  def destroy(self, configurationAttributes):
39  print "Basic. Destroy"
40  print "Basic. Destroyed successfully"
41  return True
42 

◆ determineGeolocationData()

def allowed_countries.PersonAuthentication.determineGeolocationData (   self,
  remote_ip 
)
108  def determineGeolocationData(self, remote_ip):
109  print "Super-Gluu. Determine remote location. remote_ip: '%s'" % remote_ip
110  httpService = CdiUtil.bean(HttpService)
111  http_client = httpService.getHttpsClient()
112  http_client_params = http_client.getParams()
113  http_client_params.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 15 * 1000)
114  geolocation_service_url = "http://ip-api.com/json/%s?fields=520191" % remote_ip
115  geolocation_service_headers = { "Accept" : "application/json" }
116  try:
117  http_service_response = httpService.executeGet(http_client, geolocation_service_url, geolocation_service_headers)
118  http_response = http_service_response.getHttpResponse()
119  except:
120  print "Super-Gluu. Determine remote location. Exception: ", sys.exc_info()[1]
121  return None
122 
123  try:
124  if not httpService.isResponseStastusCodeOk(http_response):
125  print "Super-Gluu. Determine remote location. Get invalid response from validation server: ", str(http_response.getStatusLine().getStatusCode())
126  httpService.consume(http_response)
127  return None
128  response_bytes = httpService.getResponseContent(http_response)
129  response_string = httpService.convertEntityToString(response_bytes)
130  httpService.consume(http_response)
131  finally:
132  http_service_response.closeConnection()
133 
134  if response_string == None:
135  print "Super-Gluu. Determine remote location. Get empty response from location server"
136  return None
137 
138 
139  response = json.loads(response_string)
140 
141  if not StringHelper.equalsIgnoreCase(response['status'], "success"):
142  print "Super-Gluu. Determine remote location. Get response with status: '%s'" % response['status']
143  return None
144 
145  return response
146 

◆ getAlternativeAuthenticationMethod()

def allowed_countries.PersonAuthentication.getAlternativeAuthenticationMethod (   self,
  usageType,
  configurationAttributes 
)
49  def getAlternativeAuthenticationMethod(self, usageType, configurationAttributes):
50  return None
51 

◆ getApiVersion()

def allowed_countries.PersonAuthentication.getApiVersion (   self)
43  def getApiVersion(self):
44  return 1
45 

◆ getCountAuthenticationSteps()

def allowed_countries.PersonAuthentication.getCountAuthenticationSteps (   self,
  configurationAttributes 
)
99  def getCountAuthenticationSteps(self, configurationAttributes):
100  return 1
101 

◆ getExtraParametersForStep()

def allowed_countries.PersonAuthentication.getExtraParametersForStep (   self,
  configurationAttributes,
  step 
)
96  def getExtraParametersForStep(self, configurationAttributes, step):
97  return None
98 

◆ getPageForStep()

def allowed_countries.PersonAuthentication.getPageForStep (   self,
  configurationAttributes,
  step 
)
102  def getPageForStep(self, configurationAttributes, step):
103  return ""
104 

◆ init()

def allowed_countries.PersonAuthentication.init (   self,
  configurationAttributes 
)
32  def init(self, configurationAttributes):
33  print "Basic. Initialization"
34  self.allowedCountries = configurationAttributes.get("allowed_countries").getValue2()
35  print "Basic. Initialized successfully"
36  return True
37 

◆ isValidAuthenticationMethod()

def allowed_countries.PersonAuthentication.isValidAuthenticationMethod (   self,
  usageType,
  configurationAttributes 
)
46  def isValidAuthenticationMethod(self, usageType, configurationAttributes):
47  return True
48 

◆ logout()

def allowed_countries.PersonAuthentication.logout (   self,
  configurationAttributes,
  requestParameters 
)
105  def logout(self, configurationAttributes, requestParameters):
106  return True
107 

◆ prepareForStep()

def allowed_countries.PersonAuthentication.prepareForStep (   self,
  configurationAttributes,
  requestParameters,
  step 
)
89  def prepareForStep(self, configurationAttributes, requestParameters, step):
90  if (step == 1):
91  print "Basic. Prepare for Step 1"
92  return True
93  else:
94  return False
95 

メンバ詳解

◆ allowedCountries

allowed_countries.PersonAuthentication.allowedCountries

◆ currentTimeMillis

allowed_countries.PersonAuthentication.currentTimeMillis

このクラス詳解は次のファイルから抽出されました: