gluu
公開メンバ関数 | 公開変数類 | 全メンバ一覧
InWeboExternalAuthenticator.PersonAuthentication クラス
InWeboExternalAuthenticator.PersonAuthentication の継承関係図
Inheritance graph
InWeboExternalAuthenticator.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 isPassedDefaultAuthentication (self)
 
def validateInweboToken (self, iw_api_uri, iw_service_id, user_name, iw_token)
 
def logout (self, configurationAttributes, requestParameters)
 

公開変数類

 currentTimeMillis
 
 client
 

詳解

構築子と解体子

◆ __init__()

def InWeboExternalAuthenticator.PersonAuthentication.__init__ (   self,
  currentTimeMillis 
)
23  def __init__(self, currentTimeMillis):
24  self.currentTimeMillis = currentTimeMillis
25  self.client = None
26 

関数詳解

◆ authenticate()

def InWeboExternalAuthenticator.PersonAuthentication.authenticate (   self,
  configurationAttributes,
  requestParameters,
  step 
)
70  def authenticate(self, configurationAttributes, requestParameters, step):
71  userService = CdiUtil.bean(UserService)
72  authenticationService = CdiUtil.bean(AuthenticationService)
73 
74  identity = CdiUtil.bean(Identity)
75 
76  iw_api_uri = configurationAttributes.get("iw_api_uri").getValue2()
77  iw_service_id = configurationAttributes.get("iw_service_id").getValue2()
78  iw_helium_enabled = Boolean(configurationAttributes.get("iw_helium_enabled").getValue2()).booleanValue()
79 
80  if (iw_helium_enabled):
81  identity.setWorkingParameter("iw_count_login_steps", 1)
82 
83  credentials = identity.getCredentials()
84 
85  user_name = credentials.getUsername()
86 
87  if (step == 1):
88  print "InWebo. Authenticate for step 1"
89 
90  print "InWebo. Authenticate for step 1. iw_helium_enabled:", iw_helium_enabled
91  user_password = credentials.getPassword()
92  if (iw_helium_enabled):
93  login_array = requestParameters.get("login")
94  if ArrayHelper.isEmpty(login_array):
95  print "InWebo. Authenticate for step 1. login is empty"
96  return False
97 
98  user_name = login_array[0]
99 
100  password_array = requestParameters.get("password")
101  if ArrayHelper.isEmpty(password_array):
102  print "InWebo. Authenticate for step 1. password is empty"
103  return False
104 
105  user_password = password_array[0]
106 
107  response_validation = self.validateInweboToken(iw_api_uri, iw_service_id, user_name, user_password)
108  if (not response_validation):
109  return False
110 
111  logged_in = False
112  if (StringHelper.isNotEmptyString(user_name)):
113  userService = CdiUtil.bean(UserService)
114  logged_in = authenticationService.authenticate(user_name)
115 
116  return logged_in
117  else:
118  logged_in = False
119  if (StringHelper.isNotEmptyString(user_name) and StringHelper.isNotEmptyString(user_password)):
120  userService = CdiUtil.bean(UserService)
121  logged_in = authenticationService.authenticate(user_name, user_password)
122 
123  return logged_in
124 
125  return True
126  elif (step == 2):
127  print "InWebo. Authenticate for step 2"
128 
129  passed_step1 = self.isPassedDefaultAuthentication
130  if (not passed_step1):
131  return False
132 
133  iw_token_array = requestParameters.get("iw_token")
134  if ArrayHelper.isEmpty(iw_token_array):
135  print "InWebo. Authenticate for step 2. iw_token is empty"
136  return False
137 
138  iw_token = iw_token_array[0]
139 
140  response_validation = self.validateInweboToken(iw_api_uri, iw_service_id, user_name, iw_token)
141 
142  return response_validation
143  else:
144  return False
145 

◆ destroy()

def InWeboExternalAuthenticator.PersonAuthentication.destroy (   self,
  configurationAttributes 
)
56  def destroy(self, configurationAttributes):
57  print "InWebo. Destroy"
58  print "InWebo. Destroyed successfully"
59  return True
60 

◆ getAlternativeAuthenticationMethod()

def InWeboExternalAuthenticator.PersonAuthentication.getAlternativeAuthenticationMethod (   self,
  usageType,
  configurationAttributes 
)
67  def getAlternativeAuthenticationMethod(self, usageType, configurationAttributes):
68  return None
69 

◆ getApiVersion()

def InWeboExternalAuthenticator.PersonAuthentication.getApiVersion (   self)
61  def getApiVersion(self):
62  return 1
63 

◆ getCountAuthenticationSteps()

def InWeboExternalAuthenticator.PersonAuthentication.getCountAuthenticationSteps (   self,
  configurationAttributes 
)
166  def getCountAuthenticationSteps(self, configurationAttributes):
167  identity = CdiUtil.bean(Identity)
168  if (identity.isSetWorkingParameter("iw_count_login_steps")):
169  return identity.getWorkingParameter("iw_count_login_steps")
170 
171  return 2
172 

◆ getExtraParametersForStep()

def InWeboExternalAuthenticator.PersonAuthentication.getExtraParametersForStep (   self,
  configurationAttributes,
  step 
)
163  def getExtraParametersForStep(self, configurationAttributes, step):
164  return None
165 

◆ getPageForStep()

def InWeboExternalAuthenticator.PersonAuthentication.getPageForStep (   self,
  configurationAttributes,
  step 
)
173  def getPageForStep(self, configurationAttributes, step):
174  if (step == 1):
175  return "/auth/inwebo/iwlogin.xhtml"
176  if (step == 2):
177  return "/auth/inwebo/iwauthenticate.xhtml"
178  else:
179  return ""
180 

◆ init()

def InWeboExternalAuthenticator.PersonAuthentication.init (   self,
  configurationAttributes 
)
27  def init(self, configurationAttributes):
28  print "InWebo. Initialization"
29 
30  iw_cert_store_type = configurationAttributes.get("iw_cert_store_type").getValue2()
31  iw_cert_path = configurationAttributes.get("iw_cert_path").getValue2()
32  iw_creds_file = configurationAttributes.get("iw_creds_file").getValue2()
33 
34  # Load credentials from file
35  f = open(iw_creds_file, 'r')
36  try:
37  creds = json.loads(f.read())
38  except:
39  return False
40  finally:
41  f.close()
42 
43  iw_cert_password = creds["CERT_PASSWORD"]
44  try:
45  encryptionService = CdiUtil.bean(EncryptionService)
46  iw_cert_password = encryptionService.decrypt(iw_cert_password)
47  except:
48  return False
49 
50  httpService = CdiUtil.bean(HttpService)
51  self.client = httpService.getHttpsClient(None, None, None, iw_cert_store_type, iw_cert_path, iw_cert_password)
52  print "InWebo. Initialized successfully"
53 
54  return True
55 

◆ isPassedDefaultAuthentication()

def InWeboExternalAuthenticator.PersonAuthentication.isPassedDefaultAuthentication (   self)
181  def isPassedDefaultAuthentication(self):
182  identity = CdiUtil.bean(Identity)
183  credentials = identity.getCredentials()
184 
185  user_name = credentials.getUsername()
186  passed_step1 = StringHelper.isNotEmptyString(user_name)
187 
188  return passed_step1
189 

◆ isValidAuthenticationMethod()

def InWeboExternalAuthenticator.PersonAuthentication.isValidAuthenticationMethod (   self,
  usageType,
  configurationAttributes 
)
64  def isValidAuthenticationMethod(self, usageType, configurationAttributes):
65  return True
66 

◆ logout()

def InWeboExternalAuthenticator.PersonAuthentication.logout (   self,
  configurationAttributes,
  requestParameters 
)
233  def logout(self, configurationAttributes, requestParameters):
234  return True
235 

◆ prepareForStep()

def InWeboExternalAuthenticator.PersonAuthentication.prepareForStep (   self,
  configurationAttributes,
  requestParameters,
  step 
)
146  def prepareForStep(self, configurationAttributes, requestParameters, step):
147  if (step == 1):
148  print "InWebo. Prepare for step 1"
149  identity = CdiUtil.bean(Identity)
150 
151  iw_helium_enabled = Boolean(configurationAttributes.get("iw_helium_enabled").getValue2()).booleanValue()
152  identity.setWorkingParameter("helium_enabled", iw_helium_enabled)
153 
154  iw_helium_alias = None
155  if (iw_helium_enabled):
156  iw_helium_alias = configurationAttributes.get("iw_helium_alias").getValue2()
157  identity.setWorkingParameter("helium_alias", iw_helium_alias)
158 
159  print "InWebo. Prepare for step 1. Helium status:", iw_helium_enabled
160 
161  return True
162 

◆ validateInweboToken()

def InWeboExternalAuthenticator.PersonAuthentication.validateInweboToken (   self,
  iw_api_uri,
  iw_service_id,
  user_name,
  iw_token 
)
190  def validateInweboToken(self, iw_api_uri, iw_service_id, user_name, iw_token):
191  httpService = CdiUtil.bean(HttpService)
192  xmlService = CdiUtil.bean(XmlService)
193 
194  if StringHelper.isEmpty(iw_token):
195  print "InWebo. Token verification. iw_token is empty"
196  return False
197 
198  request_uri = iw_api_uri + "?action=authenticate" + "&serviceId=" + httpService.encodeUrl(iw_service_id) + "&userId=" + httpService.encodeUrl(user_name) + "&token=" + httpService.encodeUrl(iw_token)
199  print "InWebo. Token verification. Attempting to send authentication request:", request_uri
200  # Execute request
201  http_response = httpService.executeGet(self.client, request_uri)
202 
203  # Validate response code
204  response_validation = httpService.isResponseStastusCodeOk(http_response)
205  if response_validation == False:
206  print "InWebo. Token verification. Get unsuccessful response code"
207  return False
208 
209  authentication_response_bytes = httpService.getResponseContent(http_response)
210  print "InWebo. Token verification. Get response:", httpService.convertEntityToString(authentication_response_bytes)
211 
212  # Validate authentication response
213  response_validation = httpService.isContentTypeXml(http_response)
214  if response_validation == False:
215  print "InWebo. Token verification. Get invalid response"
216  return False
217 
218  # Parse XML response
219  try:
220  xmlDocument = xmlService.getXmlDocument(authentication_response_bytes)
221  except Exception, err:
222  print "InWebo. Token verification. Failed to parse XML response:", err
223  return False
224 
225  result_code = xmlService.getNodeValue(xmlDocument, "/authenticate", None)
226  print "InWebo. Token verification. Result after parsing XML response:", result_code
227 
228  response_validation = StringHelper.equals(result_code, "OK")
229  print "InWebo. Token verification. Result validation:", response_validation
230 
231  return response_validation
232 

メンバ詳解

◆ client

InWeboExternalAuthenticator.PersonAuthentication.client

◆ currentTimeMillis

InWeboExternalAuthenticator.PersonAuthentication.currentTimeMillis

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