gluu
公開メンバ関数 | 公開変数類 | 全メンバ一覧
pwd_migration.PersonAuthentication クラス
pwd_migration.PersonAuthentication の継承関係図
Inheritance graph
pwd_migration.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 pwd_migration.PersonAuthentication.__init__ (   self,
  currentTimeMillis 
)
18  def __init__(self, currentTimeMillis):
19  self.currentTimeMillis = currentTimeMillis
20 

関数詳解

◆ authenticate()

def pwd_migration.PersonAuthentication.authenticate (   self,
  configurationAttributes,
  requestParameters,
  step 
)
40  def authenticate(self, configurationAttributes, requestParameters, step):
41 
42  authenticationService = CdiUtil.bean(AuthenticationService)
43 
44  if (step == 1):
45  print "BCrypt Auth. Authenticate for step 1"
46 
47  identity = CdiUtil.bean(Identity)
48  credentials = identity.getCredentials()
49 
50  user_name = credentials.getUsername()
51  user_password = credentials.getPassword()
52 
53  logged_in = False
54 
55  if (StringHelper.isNotEmptyString(user_name) and StringHelper.isNotEmptyString(user_password)):
56  userService = CdiUtil.bean(UserService)
57  user = userService.getUser(user_name)
58  hashed_stored_pass = user.getAttribute("userPassword")
59 
60  password_schema = ''
61 
62  # Determine password schema
63  # Example for BCrypt: {BCRYPT}$2b$08$71gBXNKJ/iUBXqLjEdEXFesoUYQm5vrpKefi8YhV7ITGfAd9VNFaG
64  for char in hashed_stored_pass:
65  if char == '{':
66  continue
67  if char == '}':
68  break
69  password_schema = password_schema + char
70  print("Password Schema is: " + password_schema)
71 
72  # OpenDJ's SSHA(512)
73  if 'SSHA' in password_schema:
74  # Returns True if authenticated on the backend
75  logged_in = authenticationService.authenticate(user_name, user_password)
76 
77  # Pattern match BCRYPT and rewrite to SSHA
78  elif 'BCRYPT' in password_schema:
79  # Pull salt from the stored hashed password
80  salt = hashed_stored_pass[8:]
81  salt = salt.split("$")[3].strip()
82  salt = salt[0:22]
83  salt = '$2a$08$' + salt
84 
85  # Create BCrypt hash of challenge cleartext password using the gathered salt
86  challenge = BCrypt.hashpw(user_password,salt)
87 
88  # Strip unnecessary revision($2a$) and rounds(08$) from both hashed passwords for comparison.
89  challenge = challenge.split("$")[3].strip()
90  stored = hashed_stored_pass.split("$")[3].strip()
91 
92  print("Challenge Salt+Hash: " + challenge)
93  print("Stored Salt+Hash: " + stored)
94 
95  # Compare the hashses and update hash if there is a match.
96  if challenge in stored:
97 
98  # Users hashed challenge password matches the stored hashed password in the backend
99  # Therefore we update the users password to the backend's password schema by passing it to OpenDJ
100  print("Updating hash..")
101  user.setAttribute("userPassword",user_password)
102  user = userService.updateUser(user)
103  print("Logging in..")
104 
105  # Returns True
106  logged_in = authenticationService.authenticate(user_name)
107 
108  # Catch unknown schema types and output to oxauth_script.log
109  # This script can be expanded to include other password schemas.
110  else:
111  print("Unrecognized algorithm: " + password_schema)
112 
113  # If there is no match, logged_in will still be False and authentication will fail.
114  if (not logged_in):
115  return False
116  logged_in = authenticationService.authenticate(user_name)
117  return logged_in
118  else:
119  return False
120 

◆ destroy()

def pwd_migration.PersonAuthentication.destroy (   self,
  configurationAttributes 
)
26  def destroy(self, configurationAttributes):
27  print "BCrypt Auth. Destroy"
28  print "BCrypt Auth. Destroyed successfully"
29  return True
30 

◆ getAlternativeAuthenticationMethod()

def pwd_migration.PersonAuthentication.getAlternativeAuthenticationMethod (   self,
  usageType,
  configurationAttributes 
)
37  def getAlternativeAuthenticationMethod(self, usageType, configurationAttributes):
38  return None
39 

◆ getApiVersion()

def pwd_migration.PersonAuthentication.getApiVersion (   self)
31  def getApiVersion(self):
32  return 1
33 

◆ getCountAuthenticationSteps()

def pwd_migration.PersonAuthentication.getCountAuthenticationSteps (   self,
  configurationAttributes 
)
131  def getCountAuthenticationSteps(self, configurationAttributes):
132  return 1
133 

◆ getExtraParametersForStep()

def pwd_migration.PersonAuthentication.getExtraParametersForStep (   self,
  configurationAttributes,
  step 
)
128  def getExtraParametersForStep(self, configurationAttributes, step):
129  return None
130 

◆ getPageForStep()

def pwd_migration.PersonAuthentication.getPageForStep (   self,
  configurationAttributes,
  step 
)
134  def getPageForStep(self, configurationAttributes, step):
135  return ""
136 

◆ init()

def pwd_migration.PersonAuthentication.init (   self,
  configurationAttributes 
)
21  def init(self, configurationAttributes):
22  print "BCrypt Auth. Initialization"
23  print "BCrypt Auth. Initialized successfully"
24  return True
25 

◆ isValidAuthenticationMethod()

def pwd_migration.PersonAuthentication.isValidAuthenticationMethod (   self,
  usageType,
  configurationAttributes 
)
34  def isValidAuthenticationMethod(self, usageType, configurationAttributes):
35  return True
36 

◆ logout()

def pwd_migration.PersonAuthentication.logout (   self,
  configurationAttributes,
  requestParameters 
)
137  def logout(self, configurationAttributes, requestParameters):
138  return True
139 

◆ prepareForStep()

def pwd_migration.PersonAuthentication.prepareForStep (   self,
  configurationAttributes,
  requestParameters,
  step 
)
121  def prepareForStep(self, configurationAttributes, requestParameters, step):
122  if (step == 1):
123  print "BCrypt Auth. Prepare for Step 1"
124  return True
125  else:
126  return False
127 

メンバ詳解

◆ currentTimeMillis

pwd_migration.PersonAuthentication.currentTimeMillis

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