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

公開変数類

 currentTimeMillis
 
 pf
 

詳解

構築子と解体子

◆ __init__()

def PhoneFactorExternalAuthenticator.PersonAuthentication.__init__ (   self,
  currentTimeMillis 
)
22  def __init__(self, currentTimeMillis):
23  self.currentTimeMillis = currentTimeMillis
24  self.pf = PFAuth()
25 

関数詳解

◆ authenticate()

def PhoneFactorExternalAuthenticator.PersonAuthentication.authenticate (   self,
  configurationAttributes,
  requestParameters,
  step 
)
66  def authenticate(self, configurationAttributes, requestParameters, step):
67  authenticationService = CdiUtil.bean(AuthenticationService)
68 
69  identity = CdiUtil.bean(Identity)
70  credentials = identity.getCredentials()
71 
72  user_name = credentials.getUsername()
73  if (step == 1):
74  print "PhoneFactor. Authenticate for step 1"
75 
76  user_password = credentials.getPassword()
77  logged_in = False
78  if (StringHelper.isNotEmptyString(user_name) and StringHelper.isNotEmptyString(user_password)):
79  userService = CdiUtil.bean(UserService)
80  logged_in = authenticationService.authenticate(user_name, user_password)
81 
82  if (not logged_in):
83  return False
84 
85  return True
86  elif (step == 2):
87  print "PhoneFactor. Authenticate for step 2"
88 
89  passed_step1 = self.isPassedDefaultAuthentication
90  if (not passed_step1):
91  return False
92 
93  pf_phone_number_attr = configurationAttributes.get("pf_phone_number_attr").getValue2()
94 
95  # Get user entry from credentials
96  authenticationService = CdiUtil.bean(AuthenticationService)
97  credentials_user = authenticationService.getAuthenticatedUser()
98 
99  userService = CdiUtil.bean(UserService)
100  phone_number_with_country_code_attr = userService.getCustomAttribute(credentials_user, pf_phone_number_attr)
101  if (phone_number_with_country_code_attr == None):
102  print "PhoneFactor. Authenticate for step 2. There is no phone number: ", user_name
103  return False
104 
105  phone_number_with_country_code = phone_number_with_country_code_attr.getValue()
106  if (phone_number_with_country_code == None):
107  print "PhoneFactor. Authenticate for step 2. There is no phone number: ", user_name
108  return False
109 
110  pf_country_delimiter = configurationAttributes.get("pf_country_delimiter").getValue2()
111 
112  phone_number_with_country_code_array = string.split(phone_number_with_country_code, pf_country_delimiter, 1)
113 
114  phone_number_with_country_code_array_len = len(phone_number_with_country_code_array)
115 
116  if (phone_number_with_country_code_array_len == 1):
117  country_code = ""
118  phone_number = phone_number_with_country_code_array[0]
119  else:
120  country_code = phone_number_with_country_code_array[0]
121  phone_number = phone_number_with_country_code_array[1]
122 
123  print "PhoneFactor. Authenticate for step 2. user_name: ", user_name, ", country_code: ", country_code, ", phone_number: ", phone_number
124 
125  pf_auth_result = None
126  try:
127  pf_auth_result = self.pf.authenticate(user_name, country_code, phone_number, None, None, None)
128  except SecurityException, err:
129  print "PhoneFactor. Authenticate for step 2. BAD AUTH -- Security issue: ", err
130  except TimeoutException, err:
131  print "PhoneFactor. Authenticate for step 2. BAD AUTH -- Server timeout: ", err
132  except PFException, err:
133  print "PhoneFactor. Authenticate for step 2. BAD AUTH -- PFAuth failed with a PFException: ", err
134 
135  if (pf_auth_result == None):
136  return False
137 
138  print "PhoneFactor. Authenticate for step 2. Call Status: ", pf_auth_result.getCallStatusString()
139  if (pf_auth_result.getAuthenticated()):
140  print "PhoneFactor. Authenticate for step 2. GOOD AUTH:", user_name
141 
142  if (pf_auth_result.getCallStatus() == PFAuthResult.CALL_STATUS_PIN_ENTERED):
143  print "PhoneFactor. Authenticate for step 2. I have detected that a PIN was entered"
144  elif (pf_auth_result.getCallStatus() == PFAuthResult.CALL_STATUS_NO_PIN_ENTERED):
145  print "PhoneFactor. Authenticate for step 2. I have detected that NO PIN was entered"
146 
147  return True
148  else:
149  print "PhoneFactor. Authenticate for step 2. BAD AUTH:", user_name
150 
151  if (pf_auth_result.getCallStatus() == PFAuthResult.CALL_STATUS_USER_HUNG_UP):
152  print "PhoneFactor. Authenticate for step 2. I have detected that the user hung up"
153  elif (pf_auth_result.getCallStatus() == PFAuthResult.CALL_STATUS_PHONE_BUSY):
154  print "PhoneFactor. Authenticate for step 2. I have detected that the phone was busy"
155 
156  if (pf_auth_result.getMessageErrorId() != 0):
157  print "PhoneFactor. Authenticate for step 2. Message Error ID: ", pf_auth_result.getMessageErrorId()
158 
159  message_error = pf_auth_result.getMessageError()
160  if (message_error != null):
161  print "PhoneFactor. Authenticate for step 2. Message Error: ", message_error
162 
163  return False
164  else:
165  return False
166 

◆ destroy()

def PhoneFactorExternalAuthenticator.PersonAuthentication.destroy (   self,
  configurationAttributes 
)
52  def destroy(self, configurationAttributes):
53  print "PhoneFactor. Destroy"
54  print "PhoneFactor. Destroyed successfully"
55  return True
56 

◆ getAlternativeAuthenticationMethod()

def PhoneFactorExternalAuthenticator.PersonAuthentication.getAlternativeAuthenticationMethod (   self,
  usageType,
  configurationAttributes 
)
63  def getAlternativeAuthenticationMethod(self, usageType, configurationAttributes):
64  return None
65 

◆ getApiVersion()

def PhoneFactorExternalAuthenticator.PersonAuthentication.getApiVersion (   self)
57  def getApiVersion(self):
58  return 1
59 

◆ getCountAuthenticationSteps()

def PhoneFactorExternalAuthenticator.PersonAuthentication.getCountAuthenticationSteps (   self,
  configurationAttributes 
)
182  def getCountAuthenticationSteps(self, configurationAttributes):
183  return 2
184 

◆ getExtraParametersForStep()

def PhoneFactorExternalAuthenticator.PersonAuthentication.getExtraParametersForStep (   self,
  configurationAttributes,
  step 
)
179  def getExtraParametersForStep(self, configurationAttributes, step):
180  return None
181 

◆ getPageForStep()

def PhoneFactorExternalAuthenticator.PersonAuthentication.getPageForStep (   self,
  configurationAttributes,
  step 
)
185  def getPageForStep(self, configurationAttributes, step):
186  if (step == 2):
187  return "/auth/phonefactor/pflogin.xhtml"
188  return ""
189 

◆ init()

def PhoneFactorExternalAuthenticator.PersonAuthentication.init (   self,
  configurationAttributes 
)
26  def init(self, configurationAttributes):
27  print "PhoneFactor. Initialization"
28  pf_cert_path = configurationAttributes.get("pf_cert_path").getValue2()
29  pf_creds_file = configurationAttributes.get("pf_creds_file").getValue2()
30 
31  # Load credentials from file
32  f = open(pf_creds_file, 'r')
33  try:
34  creds = json.loads(f.read())
35  except:
36  return False
37  finally:
38  f.close()
39 
40  certPassword = creds["CERT_PASSWORD"]
41  try:
42  encryptionService = CdiUtil.bean(EncryptionService)
43  certPassword = encryptionService.decrypt(certPassword)
44  except:
45  return False
46 
47  self.pf.initialize(pf_cert_path, certPassword)
48  print "PhoneFactor. Initialized successfully"
49 
50  return True
51 

◆ isPassedDefaultAuthentication()

def PhoneFactorExternalAuthenticator.PersonAuthentication.isPassedDefaultAuthentication (   self)
190  def isPassedDefaultAuthentication(self):
191  identity = CdiUtil.bean(Identity)
192  credentials = identity.getCredentials()
193 
194  user_name = credentials.getUsername()
195  passed_step1 = StringHelper.isNotEmptyString(user_name)
196 
197  return passed_step1
198 

◆ isValidAuthenticationMethod()

def PhoneFactorExternalAuthenticator.PersonAuthentication.isValidAuthenticationMethod (   self,
  usageType,
  configurationAttributes 
)
60  def isValidAuthenticationMethod(self, usageType, configurationAttributes):
61  return True
62 

◆ logout()

def PhoneFactorExternalAuthenticator.PersonAuthentication.logout (   self,
  configurationAttributes,
  requestParameters 
)
199  def logout(self, configurationAttributes, requestParameters):
200  return True
201 

◆ prepareForStep()

def PhoneFactorExternalAuthenticator.PersonAuthentication.prepareForStep (   self,
  configurationAttributes,
  requestParameters,
  step 
)
167  def prepareForStep(self, configurationAttributes, requestParameters, step):
168  if (step == 1):
169  print "PhoneFactor. Prepare for step 1"
170 
171  return True
172  elif (step == 2):
173  print "PhoneFactor. Prepare for step 2"
174 
175  return self.isPassedDefaultAuthentication
176  else:
177  return False
178 

メンバ詳解

◆ currentTimeMillis

PhoneFactorExternalAuthenticator.PersonAuthentication.currentTimeMillis

◆ pf

PhoneFactorExternalAuthenticator.PersonAuthentication.pf

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