gluu
公開メンバ関数 | 公開変数類 | 全メンバ一覧
compromised_password.PersonAuthentication クラス
compromised_password.PersonAuthentication の継承関係図
Inheritance graph
compromised_password.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 setRequestScopedParameters (self, identity)
 
def is_compromised (self, userid, password, configurationAttributes)
 
def AESCipherdecrypt (self, key, enc)
 

公開変数類

 currentTimeMillis
 
 secretquestion
 
 credentialfile
 
 secretanswer
 

詳解

構築子と解体子

◆ __init__()

def compromised_password.PersonAuthentication.__init__ (   self,
  currentTimeMillis 
)
22  def __init__(self, currentTimeMillis):
23  self.currentTimeMillis = currentTimeMillis
24 

関数詳解

◆ AESCipherdecrypt()

def compromised_password.PersonAuthentication.AESCipherdecrypt (   self,
  key,
  enc 
)
207  def AESCipherdecrypt(self, key, enc ):
208  enc, iv = enc.split(':')
209  cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING")
210  cipher.init(Cipher.DECRYPT_MODE, SecretKeySpec(key.decode("hex"), "AES"),IvParameterSpec(iv.decode("hex")))
211  decrypted_password = cipher.doFinal(enc.decode("hex"))
212  return decrypted_password.tostring()
213 

◆ authenticate()

def compromised_password.PersonAuthentication.authenticate (   self,
  configurationAttributes,
  requestParameters,
  step 
)
58  def authenticate(self, configurationAttributes, requestParameters, step):
59  identity = CdiUtil.bean(Identity)
60  userService = CdiUtil.bean(UserService)
61  authenticationService = CdiUtil.bean(AuthenticationService)
62 
63  if step == 1:
64  credentials = identity.getCredentials()
65  user_name = credentials.getUsername()
66  user_password = credentials.getPassword()
67  logged_in = False
68  if (StringHelper.isNotEmptyString(user_name) and StringHelper.isNotEmptyString(user_password)):
69  userService = CdiUtil.bean(UserService)
70  logged_in = authenticationService.authenticate(user_name, user_password)
71  if (not logged_in):
72  return False
73  else:
74  find_user_by_uid = authenticationService.getAuthenticatedUser()
75  status_attribute_value = userService.getCustomAttribute(find_user_by_uid, "mail")
76  user_mail = status_attribute_value.getValue()
77  self.setRequestScopedParameters(identity)
78  isCompromised = False
79  isCompromised = self.is_compromised(user_mail,user_password,configurationAttributes)
80  if(isCompromised):
81  identity.setWorkingParameter("pwd_compromised", isCompromised)
82  identity.setWorkingParameter("user_name", user_name)
83  return True
84  else:
85  return True
86  elif step == 2:
87  print "compromised_password. Authenticate for step 2"
88  form_answer_array = requestParameters.get("loginForm:question")
89  if ArrayHelper.isEmpty(form_answer_array):
90  return False
91  form_answer = form_answer_array[0]
92  if (form_answer == self.secretanswer):
93  return True
94  return False
95  elif step == 3:
96  authenticationService = CdiUtil.bean(AuthenticationService)
97  print "compromised_password (with password update). Authenticate for step 3"
98  userService = CdiUtil.bean(UserService)
99  update_button = requestParameters.get("loginForm:updateButton")
100  new_password_array = requestParameters.get("new_password")
101  if ArrayHelper.isEmpty(new_password_array) or StringHelper.isEmpty(new_password_array[0]):
102  print "compromised_password (with password update). Authenticate for step 3. New password is empty"
103  return False
104  new_password = new_password_array[0]
105 
106  user = authenticationService.getAuthenticatedUser()
107  if user == None:
108  print "compromised_password (with password update). Authenticate for step 3. Failed to determine user name"
109  return False
110 
111  user_name = user.getUserId()
112  print "compromised_password (with password update). Authenticate for step 3. Attempting to set new user '" + user_name + "' password"
113  find_user_by_uid = userService.getUser(user_name)
114  if (find_user_by_uid == None):
115  print "compromised_password (with password update). Authenticate for step 3. Failed to find user"
116  return False
117 
118  find_user_by_uid.setAttribute("userPassword", new_password)
119  userService.updateUser(find_user_by_uid)
120  print "compromised_password (with password update). Authenticate for step 3. Password updated successfully"
121  logged_in = authenticationService.authenticate(user_name)
122  return True
123 
do if[-f "$CONFIG"]
Definition: oxd-https-extension.init.d:165

◆ destroy()

def compromised_password.PersonAuthentication.destroy (   self,
  configurationAttributes 
)
44  def destroy(self, configurationAttributes):
45  print "compromised_password. Destroy"
46  print "compromised_password. Destroyed successfully"
47  return True
48 

◆ getAlternativeAuthenticationMethod()

def compromised_password.PersonAuthentication.getAlternativeAuthenticationMethod (   self,
  usageType,
  configurationAttributes 
)
55  def getAlternativeAuthenticationMethod(self, usageType, configurationAttributes):
56  return None
57 

◆ getApiVersion()

def compromised_password.PersonAuthentication.getApiVersion (   self)
49  def getApiVersion(self):
50  return 1
51 

◆ getCountAuthenticationSteps()

def compromised_password.PersonAuthentication.getCountAuthenticationSteps (   self,
  configurationAttributes 
)
144  def getCountAuthenticationSteps(self, configurationAttributes):
145  identity = CdiUtil.bean(Identity)
146  self.setRequestScopedParameters(identity)
147  self.setRequestScopedParameters(identity)
148  session_attributes = identity.getSessionId().getSessionAttributes()
149  pwdcompromised = session_attributes.get("pwd_compromised")
150  if(pwdcompromised != None):
151  return 3
152  return 1
153 
do if[-f "$CONFIG"]
Definition: oxd-https-extension.init.d:165

◆ getExtraParametersForStep()

def compromised_password.PersonAuthentication.getExtraParametersForStep (   self,
  configurationAttributes,
  step 
)
141  def getExtraParametersForStep(self, configurationAttributes, step):
142  return Arrays.asList("pwd_compromised","user_name")
143 

◆ getPageForStep()

def compromised_password.PersonAuthentication.getPageForStep (   self,
  configurationAttributes,
  step 
)
154  def getPageForStep(self, configurationAttributes, step):
155  identity = CdiUtil.bean(Identity)
156  session_attributes = identity.getSessionId().getSessionAttributes()
157  pwdcompromised = session_attributes.get("pwd_compromised")
158  if(pwdcompromised != None):
159  if step == 2:
160  return "/auth/compromised/complogin.xhtml"
161  elif step == 3:
162  return "/auth/compromised/newpassword.xhtml"
163  return ""
164  else:
165  return ""
do if[-f "$CONFIG"]
Definition: oxd-https-extension.init.d:165

◆ init()

def compromised_password.PersonAuthentication.init (   self,
  configurationAttributes 
)
25  def init(self, configurationAttributes):
26  print "compromised_password. Initialization"
27  if not configurationAttributes.containsKey("secret_question"):
28  print "compromised_password. Initialization. Property secret_question is mandatory"
29  return False
30  self.secretquestion = configurationAttributes.get("secret_question").getValue2()
31 
32  if not configurationAttributes.containsKey("credentials_file"):
33  print "credentials_file property not defined"
34  return False
35  self.credentialfile = configurationAttributes.get("credentials_file").getValue2()
36 
37  if not configurationAttributes.containsKey("secret_answer"):
38  print "compromised_password. Initialization. Property secret_answer is mandatory"
39  return False
40  self.secretanswer = configurationAttributes.get("secret_answer").getValue2()
41  print "compromised_password. Initialized successfully"
42  return True
43 

◆ is_compromised()

def compromised_password.PersonAuthentication.is_compromised (   self,
  userid,
  password,
  configurationAttributes 
)
172  def is_compromised(self, userid, password,configurationAttributes):
173  print "Vericloud APIs Initialization"
174 
175  vericloud_gluu_creds_file = self.credentialfile
176  # Load credentials from file
177  f = open(vericloud_gluu_creds_file, 'r')
178  try:
179  creds = json.loads(f.read())
180  except:
181  print "Vericloud API. Initialize notification services. Failed to load credentials from file:", vericloud_gluu_creds_file
182  return False
183  finally:
184  f.close()
185 
186  try:
187  url = str(creds["api_url"])
188  api_key=str(creds["api_key"])
189  api_secret= str(creds["api_secret"])
190  except:
191  print "Vericloud API. Initialize notification services. Invalid credentials file '%s' format:" % super_gluu_creds_file
192  return False
193 
194 
195  reqdata = {"mode":"search_leaked_password_with_userid", "api_key": api_key, "api_secret": api_secret, "userid": userid}
196  reqdata = urllib.urlencode(reqdata)
197  resp = urllib2.urlopen(urllib2.Request(url, reqdata)).read()
198  resp = json.loads(resp)
199  if resp['result'] != 'succeeded':
200  return None
201  for pass_enc in resp['passwords_encrypted']:
202  plaintext = self.AESCipherdecrypt(api_secret, pass_enc)
203  if (len(password), password[0], password[-1]) == (len(plaintext), plaintext[0], plaintext[-1]) :
204  return True
205  return False
206 

◆ isValidAuthenticationMethod()

def compromised_password.PersonAuthentication.isValidAuthenticationMethod (   self,
  usageType,
  configurationAttributes 
)
52  def isValidAuthenticationMethod(self, usageType, configurationAttributes):
53  return True
54 

◆ logout()

def compromised_password.PersonAuthentication.logout (   self,
  configurationAttributes,
  requestParameters 
)
166  def logout(self, configurationAttributes, requestParameters):
167  return True
168 

◆ prepareForStep()

def compromised_password.PersonAuthentication.prepareForStep (   self,
  configurationAttributes,
  requestParameters,
  step 
)
124  def prepareForStep(self, configurationAttributes, requestParameters, step):
125  identity = CdiUtil.bean(Identity)
126  self.setRequestScopedParameters(identity)
127  session_attributes = identity.getSessionId().getSessionAttributes()
128  pwdcompromised = session_attributes.get("pwd_compromised")
129  if(pwdcompromised != None):
130  if step == 1:
131  print "compromised_password. Prepare for step 1"
132  return True
133  elif step == 2:
134  print "compromised_password. Prepare for step 2"
135  return True
136  return False
137  else:
138  print "compromised_password. Prepare for step 1"
139  return True
140 
do if[-f "$CONFIG"]
Definition: oxd-https-extension.init.d:165

◆ setRequestScopedParameters()

def compromised_password.PersonAuthentication.setRequestScopedParameters (   self,
  identity 
)
169  def setRequestScopedParameters(self, identity):
170  identity.setWorkingParameter("question_label", self.secretquestion)
171 

メンバ詳解

◆ credentialfile

compromised_password.PersonAuthentication.credentialfile

◆ currentTimeMillis

compromised_password.PersonAuthentication.currentTimeMillis

◆ secretanswer

compromised_password.PersonAuthentication.secretanswer

◆ secretquestion

compromised_password.PersonAuthentication.secretquestion

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