gluu
公開メンバ関数 | 公開変数類 | 全メンバ一覧
PasswordExpiration.PersonAuthentication クラス
PasswordExpiration.PersonAuthentication の継承関係図
Inheritance graph
PasswordExpiration.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)
 

公開変数類

 currentTimeMillis
 

詳解

構築子と解体子

◆ __init__()

def PasswordExpiration.PersonAuthentication.__init__ (   self,
  currentTimeMillis 
)
16  def __init__(self, currentTimeMillis):
17  self.currentTimeMillis = currentTimeMillis
18 

関数詳解

◆ authenticate()

def PasswordExpiration.PersonAuthentication.authenticate (   self,
  configurationAttributes,
  requestParameters,
  step 
)
38  def authenticate(self, configurationAttributes, requestParameters, step):
39  authenticationService = CdiUtil.bean(AuthenticationService)
40  userService = CdiUtil.bean(UserService)
41 
42  identity = CdiUtil.bean(Identity)
43  credentials = identity.getCredentials()
44  if step == 1:
45  print "Basic (with password update). Authenticate for step 1"
46  user_name = credentials.getUsername()
47  user_password = credentials.getPassword()
48 
49  logged_in = False
50  if StringHelper.isNotEmptyString(user_name) and StringHelper.isNotEmptyString(user_password):
51  logged_in = authenticationService.authenticate(user_name, user_password)
52 
53  if not logged_in:
54  return False
55 
56  find_user_by_uid = authenticationService.getAuthenticatedUser()
57  user_expDate = find_user_by_uid.getAttribute("oxPasswordExpirationDate", False)
58 
59  if user_expDate == None:
60  print "Basic (with password update). Authenticate for step 1. User has no oxPasswordExpirationDate date"
61  return False
62 
63  dt = StaticUtils.decodeGeneralizedTime(user_expDate)
64 
65  # Get Current Date
66  calendar = GregorianCalendar(TimeZone.getTimeZone("UTC"));
67  now = calendar.getTime()
68  if now.compareTo(dt) > 0:
69  # Add 90 Days to current date
70  calendar.setTime(now)
71  calendar.add(calendar.DATE, 90)
72  dt_plus_90 = calendar.getTime()
73  expDate = StaticUtils.encodeGeneralizedTime(dt_plus_90)
74  identity.setWorkingParameter("expDate", expDate)
75 
76  return True
77  elif step == 2:
78  print "Basic (with password update). Authenticate for step 2"
79  user = authenticationService.getAuthenticatedUser()
80  if user == None:
81  print "Basic (with password update). Authenticate for step 2. Failed to determine user name"
82  return False
83 
84  user_name = user.getUserId()
85  find_user_by_uid = userService.getUser(user_name)
86  newExpDate = identity.getWorkingParameter("expDate")
87 
88  if find_user_by_uid == None:
89  print "Basic (with password update). Authenticate for step 2. Failed to find user"
90  return False
91 
92  print "Basic (with password update). Authenticate for step 2"
93  update_button = requestParameters.get("loginForm:updateButton")
94 
95  if ArrayHelper.isEmpty(update_button):
96  return True
97 
98  find_user_by_uid.setAttribute("oxPasswordExpirationDate", newExpDate)
99  new_password_array = requestParameters.get("new_password")
100  if ArrayHelper.isEmpty(new_password_array) or StringHelper.isEmpty(new_password_array[0]):
101  print "Basic (with password update). Authenticate for step 2. New password is empty"
102  return False
103 
104  new_password = new_password_array[0]
105  find_user_by_uid.setAttribute("userPassword", new_password)
106  print "Basic (with password update). Authenticate for step 2. Attempting to set new user '%s' password" % user_name
107 
108  userService.updateUser(find_user_by_uid)
109  print "Basic (with password update). Authenticate for step 2. Password updated successfully"
110 
111  return True
112  else:
113  return False
114 

◆ destroy()

def PasswordExpiration.PersonAuthentication.destroy (   self,
  configurationAttributes 
)
24  def destroy(self, configurationAttributes):
25  print "Basic (with password update). Destroy"
26  print "Basic (with password update). Destroyed successfully"
27  return True
28 

◆ getAlternativeAuthenticationMethod()

def PasswordExpiration.PersonAuthentication.getAlternativeAuthenticationMethod (   self,
  usageType,
  configurationAttributes 
)
35  def getAlternativeAuthenticationMethod(self, usageType, configurationAttributes):
36  return None
37 

◆ getApiVersion()

def PasswordExpiration.PersonAuthentication.getApiVersion (   self)
29  def getApiVersion(self):
30  return 1
31 

◆ getCountAuthenticationSteps()

def PasswordExpiration.PersonAuthentication.getCountAuthenticationSteps (   self,
  configurationAttributes 
)
128  def getCountAuthenticationSteps(self, configurationAttributes):
129  identity = CdiUtil.bean(Identity)
130  if identity.isSetWorkingParameter("expDate"):
131  return 2
132  else:
133  return 1
134 

◆ getExtraParametersForStep()

def PasswordExpiration.PersonAuthentication.getExtraParametersForStep (   self,
  configurationAttributes,
  step 
)
125  def getExtraParametersForStep(self, configurationAttributes, step):
126  return Arrays.asList("expDate")
127 

◆ getPageForStep()

def PasswordExpiration.PersonAuthentication.getPageForStep (   self,
  configurationAttributes,
  step 
)
135  def getPageForStep(self, configurationAttributes, step):
136  if step == 2:
137  return "/auth/pwd/newpassword.xhtml"
138  return ""
139 

◆ init()

def PasswordExpiration.PersonAuthentication.init (   self,
  configurationAttributes 
)
19  def init(self, configurationAttributes):
20  print "Basic (with password update). Initialization"
21  print "Basic (with password update). Initialized successfully"
22  return True
23 

◆ isValidAuthenticationMethod()

def PasswordExpiration.PersonAuthentication.isValidAuthenticationMethod (   self,
  usageType,
  configurationAttributes 
)
32  def isValidAuthenticationMethod(self, usageType, configurationAttributes):
33  return True
34 

◆ logout()

def PasswordExpiration.PersonAuthentication.logout (   self,
  configurationAttributes,
  requestParameters 
)
140  def logout(self, configurationAttributes, requestParameters):
141  return True
142 

◆ prepareForStep()

def PasswordExpiration.PersonAuthentication.prepareForStep (   self,
  configurationAttributes,
  requestParameters,
  step 
)
115  def prepareForStep(self, configurationAttributes, requestParameters, step):
116  if step == 1:
117  print "Basic (with password update). Prepare for Step 1"
118  return True
119  elif step == 2:
120  print "Basic (with password update). Prepare for Step 2"
121  return True
122  else:
123  return False
124 

メンバ詳解

◆ currentTimeMillis

PasswordExpiration.PersonAuthentication.currentTimeMillis

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