gluu
公開メンバ関数 | 非公開メンバ関数 | 非公開変数類 | 静的非公開変数類 | 全メンバ一覧
org.xdi.oxauth.service.AuthenticationService クラス
org.xdi.oxauth.service.AuthenticationService 連携図
Collaboration graph

公開メンバ関数

boolean authenticate (String userName, String password)
 
boolean authenticate (String keyValue, String password, String primaryKey, String localPrimaryKey)
 
boolean authenticate (GluuLdapConfiguration ldapAuthConfig, PersistenceEntryManager ldapAuthEntryManager, String keyValue, String password, String primaryKey, String localPrimaryKey)
 
boolean authenticate (String userName)
 
SessionId configureSessionUser (SessionId sessionId, Map< String, String > sessionIdAttributes)
 
SessionId configureEventUser ()
 
void configureEventUser (SessionId sessionId)
 
void quietLogin (String userName)
 
User getAuthenticatedUser ()
 
String getAuthenticatedUserId ()
 
Client configureSessionClient ()
 
void configureSessionClient (Client client)
 
void onSuccessfulLogin (SessionId sessionUser)
 
User getUserOrRemoveSession (SessionId p_sessionId)
 
String parametersAsString () throws UnsupportedEncodingException
 
Map< String, String > getParametersMap (List< String > extraParameters)
 
boolean isParameterExists (String p_name)
 

非公開メンバ関数

void setAuthenticatedUserSessionAttribute (String userName, boolean authenticated)
 
boolean localAuthenticate (String userName, String password)
 
boolean externalAuthenticate (String keyValue, String password)
 
User getUserByAttribute (PersistenceEntryManager ldapAuthEntryManager, String baseDn, String attributeName, String attributeValue)
 
boolean checkUserStatus (User user)
 
void updateLastLogonUserTime (User user)
 
HttpServletRequest getHttpRequest ()
 
void configureAuthenticatedUser (User user)
 

非公開変数類

Logger log
 
AppConfiguration appConfiguration
 
Identity identity
 
Credentials credentials
 
List< GluuLdapConfiguration > ldapAuthConfigs
 
PersistenceEntryManager ldapEntryManager
 
List< PersistenceEntryManager > ldapAuthEntryManagers
 
UserService userService
 
ClientService clientService
 
SessionIdService sessionIdService
 
ExternalAuthenticationService externalAuthenticationService
 
MetricService metricService
 
ExternalContext externalContext
 
FacesService facesService
 
RequestParameterService requestParameterService
 
AuthenticationProtectionService authenticationProtectionService
 

静的非公開変数類

static final String EVENT_CONTEXT_AUTHENTICATED_USER = "authenticatedUser"
 

詳解

Authentication service methods

著者
Yuriy Movchan
Javier Rojas Blum
バージョン
November 23, 2017

関数詳解

◆ authenticate() [1/4]

boolean org.xdi.oxauth.service.AuthenticationService.authenticate ( String  userName,
String  password 
)
inline

Authenticate user.

引数
userNameThe username.
passwordThe user's password.
戻り値
true if success, otherwise false.
124  {
125  log.debug("Authenticating user with LDAP: username: '{}', credentials: '{}'", userName, System.identityHashCode(credentials));
126 
127  boolean authenticated = false;
128 
129  com.codahale.metrics.Timer.Context timerContext = metricService.getTimer(MetricType.OXAUTH_USER_AUTHENTICATION_RATE).time();
130  try {
131  if ((this.ldapAuthConfigs == null) || (this.ldapAuthConfigs.size() == 0)) {
132  authenticated = localAuthenticate(userName, password);
133  } else {
134  authenticated = externalAuthenticate(userName, password);
135  }
136  } finally {
137  timerContext.stop();
138  }
139 
140  String userId = userName;
141  if ((identity.getUser() != null) && StringHelper.isNotEmpty(identity.getUser().getUserId())) {
142  userId = identity.getUser().getUserId();
143  }
144  setAuthenticatedUserSessionAttribute(userId, authenticated);
145 
146  MetricType metricType;
147  if (authenticated) {
148  metricType = MetricType.OXAUTH_USER_AUTHENTICATION_SUCCESS;
149  } else {
150  metricType = MetricType.OXAUTH_USER_AUTHENTICATION_FAILURES;
151  }
152 
153  metricService.incCounter(metricType);
154 
156  authenticationProtectionService.storeAttempt(userName, authenticated);
157  authenticationProtectionService.doDelayIfNeeded(userName);
158  }
159 
160  return authenticated;
161  }
User getUser()
Definition: Identity.java:38
boolean isEnabled()
Definition: AuthenticationProtectionService.java:55
void setAuthenticatedUserSessionAttribute(String userName, boolean authenticated)
Definition: AuthenticationService.java:163
AuthenticationProtectionService authenticationProtectionService
Definition: AuthenticationService.java:115
boolean localAuthenticate(String userName, String password)
Definition: AuthenticationService.java:174
boolean externalAuthenticate(String keyValue, String password)
Definition: AuthenticationService.java:196
Identity identity
Definition: AuthenticationService.java:74
List< GluuLdapConfiguration > ldapAuthConfigs
Definition: AuthenticationService.java:81
MetricService metricService
Definition: AuthenticationService.java:103
Credentials credentials
Definition: AuthenticationService.java:77
Logger log
Definition: AuthenticationService.java:68

◆ authenticate() [2/4]

boolean org.xdi.oxauth.service.AuthenticationService.authenticate ( String  keyValue,
String  password,
String  primaryKey,
String  localPrimaryKey 
)
inline
220  {
221  if (this.ldapAuthConfigs == null) {
222  return authenticate(null, ldapEntryManager, keyValue, password, primaryKey, localPrimaryKey);
223  }
224 
225  boolean authenticated = false;
226 
227  com.codahale.metrics.Timer.Context timerContext = metricService.getTimer(MetricType.OXAUTH_USER_AUTHENTICATION_RATE).time();
228  try {
229  for (int i = 0; i < this.ldapAuthConfigs.size(); i++) {
230  GluuLdapConfiguration ldapAuthConfig = this.ldapAuthConfigs.get(i);
231  PersistenceEntryManager ldapAuthEntryManager = this.ldapAuthEntryManagers.get(i);
232 
233  authenticated = authenticate(ldapAuthConfig, ldapAuthEntryManager, keyValue, password, primaryKey, localPrimaryKey);
234  if (authenticated) {
235  break;
236  }
237  }
238  } finally {
239  timerContext.stop();
240  }
241 
242  MetricType metricType;
243  if (authenticated) {
244  metricType = MetricType.OXAUTH_USER_AUTHENTICATION_SUCCESS;
245  } else {
246  metricType = MetricType.OXAUTH_USER_AUTHENTICATION_FAILURES;
247  }
248 
249  metricService.incCounter(metricType);
250 
251 
253  authenticationProtectionService.storeAttempt(keyValue, authenticated);
254  authenticationProtectionService.doDelayIfNeeded(keyValue);
255  }
256 
257  return authenticated;
258  }
boolean isEnabled()
Definition: AuthenticationProtectionService.java:55
AuthenticationProtectionService authenticationProtectionService
Definition: AuthenticationService.java:115
List< PersistenceEntryManager > ldapAuthEntryManagers
Definition: AuthenticationService.java:88
List< GluuLdapConfiguration > ldapAuthConfigs
Definition: AuthenticationService.java:81
MetricService metricService
Definition: AuthenticationService.java:103
PersistenceEntryManager ldapEntryManager
Definition: AuthenticationService.java:84
boolean authenticate(String userName, String password)
Definition: AuthenticationService.java:124

◆ authenticate() [3/4]

boolean org.xdi.oxauth.service.AuthenticationService.authenticate ( GluuLdapConfiguration  ldapAuthConfig,
PersistenceEntryManager  ldapAuthEntryManager,
String  keyValue,
String  password,
String  primaryKey,
String  localPrimaryKey 
)
inline
263  {
264  log.debug("Attempting to find userDN by primary key: '{}' and key value: '{}', credentials: '{}'", primaryKey, keyValue, System.identityHashCode(credentials));
265 
266  try {
267  List<?> baseDNs;
268  if (ldapAuthConfig == null) {
269  baseDNs = Arrays.asList(userService.getDnForUser(null));
270  } else {
271  baseDNs = ldapAuthConfig.getBaseDNs();
272  }
273 
274  if (baseDNs != null && !baseDNs.isEmpty()) {
275  for (Object baseDnProperty : baseDNs) {
276  String baseDn;
277  if (baseDnProperty instanceof SimpleProperty) {
278  baseDn = ((SimpleProperty) baseDnProperty).getValue();
279  } else {
280  baseDn = baseDnProperty.toString();
281  }
282 
283  User user = getUserByAttribute(ldapAuthEntryManager, baseDn, primaryKey, keyValue);
284  if (user != null) {
285  String userDn = user.getDn();
286  log.debug("Attempting to authenticate userDN: {}", userDn);
287  if (ldapAuthEntryManager.authenticate(userDn, password)) {
288  log.debug("User authenticated: {}", userDn);
289 
290  log.debug("Attempting to find userDN by local primary key: {}", localPrimaryKey);
291  User localUser = userService.getUserByAttribute(localPrimaryKey, keyValue);
292  if (localUser != null) {
293  if (!checkUserStatus(localUser)) {
294  return false;
295  }
296 
297  configureAuthenticatedUser(localUser);
298  updateLastLogonUserTime(localUser);
299 
300  log.trace("authenticate_external: credentials: '{}', credentials.userName: '{}', authenticatedUser.userId: '{}'", System.identityHashCode(credentials), credentials.getUsername(), getAuthenticatedUserId());
301 
302  return true;
303  }
304  }
305  }
306  }
307  } else {
308  log.error("There are no baseDns specified in authentication configuration.");
309  }
310  } catch (Exception e) {
311  log.error(e.getMessage());
312  }
313 
314  return false;
315  }
void updateLastLogonUserTime(User user)
Definition: AuthenticationService.java:396
User getUserByAttribute(String attributeName, String attributeValue)
Definition: UserService.java:192
void configureAuthenticatedUser(User user)
Definition: AuthenticationService.java:483
String getAuthenticatedUserId()
Definition: AuthenticationService.java:507
boolean checkUserStatus(User user)
Definition: AuthenticationService.java:385
String getDnForUser(String inum)
Definition: UserService.java:393
UserService userService
Definition: AuthenticationService.java:91
Credentials credentials
Definition: AuthenticationService.java:77
User getUserByAttribute(PersistenceEntryManager ldapAuthEntryManager, String baseDn, String attributeName, String attributeValue)
Definition: AuthenticationService.java:357
Logger log
Definition: AuthenticationService.java:68

◆ authenticate() [4/4]

boolean org.xdi.oxauth.service.AuthenticationService.authenticate ( String  userName)
inline
317  {
318  log.debug("Authenticating user with LDAP: username: '{}', credentials: '{}'", userName, System.identityHashCode(credentials));
319 
320  boolean authenticated = false;
321 
322  com.codahale.metrics.Timer.Context timerContext = metricService.getTimer(MetricType.OXAUTH_USER_AUTHENTICATION_RATE).time();
323  try {
324  User user = userService.getUser(userName);
325  if ((user != null) && checkUserStatus(user)) {
326  credentials.setUsername(user.getUserId());
329 
330  log.trace("Authenticate: credentials: '{}', credentials.userName: '{}', authenticatedUser.userId: '{}'", System.identityHashCode(credentials), credentials.getUsername(), getAuthenticatedUserId());
331 
332  authenticated = true;
333  }
334  } finally {
335  timerContext.stop();
336  }
337 
338  setAuthenticatedUserSessionAttribute(userName, authenticated);
339 
340  MetricType metricType;
341  if (authenticated) {
342  metricType = MetricType.OXAUTH_USER_AUTHENTICATION_SUCCESS;
343  } else {
344  metricType = MetricType.OXAUTH_USER_AUTHENTICATION_FAILURES;
345  }
346 
347  metricService.incCounter(metricType);
348 
350  authenticationProtectionService.storeAttempt(userName, authenticated);
351  authenticationProtectionService.doDelayIfNeeded(userName);
352  }
353 
354  return authenticated;
355  }
boolean isEnabled()
Definition: AuthenticationProtectionService.java:55
void setAuthenticatedUserSessionAttribute(String userName, boolean authenticated)
Definition: AuthenticationService.java:163
void updateLastLogonUserTime(User user)
Definition: AuthenticationService.java:396
AuthenticationProtectionService authenticationProtectionService
Definition: AuthenticationService.java:115
User getUser(String userId, String... returnAttributes)
Definition: UserService.java:87
void configureAuthenticatedUser(User user)
Definition: AuthenticationService.java:483
String getAuthenticatedUserId()
Definition: AuthenticationService.java:507
boolean checkUserStatus(User user)
Definition: AuthenticationService.java:385
MetricService metricService
Definition: AuthenticationService.java:103
UserService userService
Definition: AuthenticationService.java:91
Credentials credentials
Definition: AuthenticationService.java:77
Logger log
Definition: AuthenticationService.java:68

◆ checkUserStatus()

boolean org.xdi.oxauth.service.AuthenticationService.checkUserStatus ( User  user)
inlineprivate
385  {
386  CustomAttribute userStatus = userService.getCustomAttribute(user, "gluuStatus");
387 
388  if ((userStatus != null) && GluuStatus.ACTIVE.equals(GluuStatus.getByValue(userStatus.getValue()))) {
389  return true;
390  }
391 
392  log.warn("User '{}' was disabled", user.getUserId());
393  return false;
394  }
CustomAttribute getCustomAttribute(User user, String attributeName)
Definition: UserService.java:337
UserService userService
Definition: AuthenticationService.java:91
Logger log
Definition: AuthenticationService.java:68

◆ configureAuthenticatedUser()

void org.xdi.oxauth.service.AuthenticationService.configureAuthenticatedUser ( User  user)
inlineprivate
483  {
484  identity.setUser(user);
485  }
void setUser(User user)
Definition: Identity.java:42
Identity identity
Definition: AuthenticationService.java:74

◆ configureEventUser() [1/2]

SessionId org.xdi.oxauth.service.AuthenticationService.configureEventUser ( )
inline
449  {
450  User user = getAuthenticatedUser();
451  if (user == null) {
452  return null;
453  }
454 
455  log.debug("ConfigureEventUser: username: '{}', credentials: '{}'", user.getUserId(), System.identityHashCode(credentials));
456 
457  SessionId sessionId = sessionIdService.generateAuthenticatedSessionId(getHttpRequest(), user.getDn());
458 
459  identity.setSessionId(sessionId);
460 
461  return sessionId;
462  }
SessionIdService sessionIdService
Definition: AuthenticationService.java:97
HttpServletRequest getHttpRequest()
Definition: AuthenticationService.java:464
SessionId generateAuthenticatedSessionId(HttpServletRequest httpRequest, String userDn)
Definition: SessionIdService.java:378
User getAuthenticatedUser()
Definition: AuthenticationService.java:487
Identity identity
Definition: AuthenticationService.java:74
Credentials credentials
Definition: AuthenticationService.java:77
void setSessionId(SessionId sessionId)
Definition: Identity.java:34
Logger log
Definition: AuthenticationService.java:68

◆ configureEventUser() [2/2]

void org.xdi.oxauth.service.AuthenticationService.configureEventUser ( SessionId  sessionId)
inline
471  {
473 
474  identity.setSessionId(sessionId);
475  }
SessionIdService sessionIdService
Definition: AuthenticationService.java:97
Identity identity
Definition: AuthenticationService.java:74
boolean updateSessionId(final SessionId sessionId)
Definition: SessionIdService.java:534
void setSessionId(SessionId sessionId)
Definition: Identity.java:34

◆ configureSessionClient() [1/2]

Client org.xdi.oxauth.service.AuthenticationService.configureSessionClient ( )
inline
516  {
517  String clientInum = credentials.getUsername();
518  log.debug("ConfigureSessionClient: username: '{}', credentials: '{}'", clientInum, System.identityHashCode(credentials));
519 
520  Client client = clientService.getClient(clientInum);
521  configureSessionClient(client);
522  return client;
523  }
Client configureSessionClient()
Definition: AuthenticationService.java:516
ClientService clientService
Definition: AuthenticationService.java:94
Credentials credentials
Definition: AuthenticationService.java:77
Set< Client > getClient(Collection< String > clientIds, boolean silent)
Definition: ClientService.java:123
Logger log
Definition: AuthenticationService.java:68

◆ configureSessionClient() [2/2]

void org.xdi.oxauth.service.AuthenticationService.configureSessionClient ( Client  client)
inline
525  {
526  SessionClient sessionClient = new SessionClient();
527  sessionClient.setClient(client);
528 
529  identity.setSessionClient(sessionClient);
530 
531  clientService.updatAccessTime(client, true);
532  }
void updatAccessTime(Client client, boolean isUpdateLogonTime)
Definition: ClientService.java:306
ClientService clientService
Definition: AuthenticationService.java:94
Identity identity
Definition: AuthenticationService.java:74
void setSessionClient(SessionClient sessionClient)
Definition: Identity.java:46

◆ configureSessionUser()

SessionId org.xdi.oxauth.service.AuthenticationService.configureSessionUser ( SessionId  sessionId,
Map< String, String >  sessionIdAttributes 
)
inline
428  {
429  log.trace("configureSessionUser: credentials: '{}', sessionId: '{}', credentials.userName: '{}', authenticatedUser.userId: '{}'", System.identityHashCode(credentials), sessionId, credentials.getUsername(), getAuthenticatedUserId());
430 
431  User user = getAuthenticatedUser();
432 
433  SessionId newSessionId;
434  if (sessionId == null) {
435  newSessionId = sessionIdService.generateAuthenticatedSessionId(getHttpRequest(), user.getDn(), sessionIdAttributes);
436  } else {
437  // TODO: Remove after 2.4.5
438  String sessionAuthUser = sessionIdAttributes.get(Constants.AUTHENTICATED_USER);
439  log.trace("configureSessionUser sessionId: '{}', sessionId.auth_user: '{}'", sessionId, sessionAuthUser);
440 
441  newSessionId = sessionIdService.setSessionIdStateAuthenticated(getHttpRequest(), sessionId, user.getDn());
442  }
443 
444  identity.setSessionId(sessionId);
445 
446  return newSessionId;
447  }
SessionId setSessionIdStateAuthenticated(HttpServletRequest httpRequest, SessionId sessionId, String p_userDn)
Definition: SessionIdService.java:491
SessionIdService sessionIdService
Definition: AuthenticationService.java:97
HttpServletRequest getHttpRequest()
Definition: AuthenticationService.java:464
SessionId generateAuthenticatedSessionId(HttpServletRequest httpRequest, String userDn)
Definition: SessionIdService.java:378
User getAuthenticatedUser()
Definition: AuthenticationService.java:487
String getAuthenticatedUserId()
Definition: AuthenticationService.java:507
Identity identity
Definition: AuthenticationService.java:74
Credentials credentials
Definition: AuthenticationService.java:77
void setSessionId(SessionId sessionId)
Definition: Identity.java:34
Logger log
Definition: AuthenticationService.java:68

◆ externalAuthenticate()

boolean org.xdi.oxauth.service.AuthenticationService.externalAuthenticate ( String  keyValue,
String  password 
)
inlineprivate
196  {
197  for (int i = 0; i < this.ldapAuthConfigs.size(); i++) {
198  GluuLdapConfiguration ldapAuthConfig = this.ldapAuthConfigs.get(i);
199  PersistenceEntryManager ldapAuthEntryManager = this.ldapAuthEntryManagers.get(i);
200 
201  String primaryKey = "uid";
202  if (StringHelper.isNotEmpty(ldapAuthConfig.getPrimaryKey())) {
203  primaryKey = ldapAuthConfig.getPrimaryKey();
204  }
205 
206  String localPrimaryKey = "uid";
207  if (StringHelper.isNotEmpty(ldapAuthConfig.getLocalPrimaryKey())) {
208  localPrimaryKey = ldapAuthConfig.getLocalPrimaryKey();
209  }
210 
211  boolean authenticated = authenticate(ldapAuthConfig, ldapAuthEntryManager, keyValue, password, primaryKey, localPrimaryKey);
212  if (authenticated) {
213  return authenticated;
214  }
215  }
216 
217  return false;
218  }
List< PersistenceEntryManager > ldapAuthEntryManagers
Definition: AuthenticationService.java:88
List< GluuLdapConfiguration > ldapAuthConfigs
Definition: AuthenticationService.java:81
boolean authenticate(String userName, String password)
Definition: AuthenticationService.java:124

◆ getAuthenticatedUser()

User org.xdi.oxauth.service.AuthenticationService.getAuthenticatedUser ( )
inline
487  {
488  if (identity.getUser() != null) {
489  return identity.getUser();
490  } else {
491  SessionId sessionId = sessionIdService.getSessionId();
492  if (sessionId != null) {
493  Map<String, String> sessionIdAttributes = sessionId.getSessionAttributes();
494  String userId = sessionIdAttributes.get(Constants.AUTHENTICATED_USER);
495  if (StringHelper.isNotEmpty(userId)) {
496  User user = userService.getUser(userId);
497  identity.setUser(user);
498 
499  return user;
500  }
501  }
502  }
503 
504  return null;
505  }
Map< String, String > getSessionAttributes()
Definition: SessionId.java:196
User getUser()
Definition: Identity.java:38
SessionId getSessionId()
Definition: SessionIdService.java:360
void setUser(User user)
Definition: Identity.java:42
SessionIdService sessionIdService
Definition: AuthenticationService.java:97
User getUser(String userId, String... returnAttributes)
Definition: UserService.java:87
Identity identity
Definition: AuthenticationService.java:74
UserService userService
Definition: AuthenticationService.java:91

◆ getAuthenticatedUserId()

String org.xdi.oxauth.service.AuthenticationService.getAuthenticatedUserId ( )
inline
507  {
508  User authenticatedUser = getAuthenticatedUser();
509  if (authenticatedUser != null) {
510  return authenticatedUser.getUserId();
511  }
512 
513  return null;
514  }
User getAuthenticatedUser()
Definition: AuthenticationService.java:487

◆ getHttpRequest()

HttpServletRequest org.xdi.oxauth.service.AuthenticationService.getHttpRequest ( )
inlineprivate
464  {
465  if (externalContext == null) {
466  return null;
467  }
468  return (HttpServletRequest) externalContext.getRequest();
469  }
ExternalContext externalContext
Definition: AuthenticationService.java:106

◆ getParametersMap()

Map<String, String> org.xdi.oxauth.service.AuthenticationService.getParametersMap ( List< String >  extraParameters)
inline
583  {
584  final Map<String, String> parameterMap = new HashMap<String, String>(externalContext
585  .getRequestParameterMap());
586 
587  return requestParameterService.getParametersMap(extraParameters, parameterMap);
588  }
ExternalContext externalContext
Definition: AuthenticationService.java:106
RequestParameterService requestParameterService
Definition: AuthenticationService.java:112
Map< String, String > getParametersMap(List< String > extraParameters, final Map< String, String > parameterMap)
Definition: RequestParameterService.java:137

◆ getUserByAttribute()

User org.xdi.oxauth.service.AuthenticationService.getUserByAttribute ( PersistenceEntryManager  ldapAuthEntryManager,
String  baseDn,
String  attributeName,
String  attributeValue 
)
inlineprivate
357  {
358  log.debug("Getting user information from LDAP: attributeName = '{}', attributeValue = '{}'", attributeName, attributeValue);
359 
360  if (StringHelper.isEmpty(attributeValue)) {
361  return null;
362  }
363 
364  SimpleUser sampleUser = new SimpleUser();
365  sampleUser.setDn(baseDn);
366 
367  List<CustomAttribute> customAttributes = new ArrayList<CustomAttribute>();
368  customAttributes.add(new CustomAttribute(attributeName, attributeValue));
369 
370  sampleUser.setCustomAttributes(customAttributes);
371 
372  log.debug("Searching user by attributes: '{}', baseDn: '{}'", customAttributes, baseDn);
373  List<User> entries = ldapAuthEntryManager.findEntries(sampleUser, 1);
374  log.debug("Found '{}' entries", entries.size());
375 
376  if (entries.size() > 0) {
377  SimpleUser foundUser = entries.get(0);
378 
379  return ldapAuthEntryManager.find(User.class, foundUser.getDn());
380  } else {
381  return null;
382  }
383  }
Logger log
Definition: AuthenticationService.java:68

◆ getUserOrRemoveSession()

User org.xdi.oxauth.service.AuthenticationService.getUserOrRemoveSession ( SessionId  p_sessionId)
inline
557  {
558  if (p_sessionId != null) {
559  try {
560  if (StringUtils.isNotBlank(p_sessionId.getUserDn())) {
561  final User user = userService.getUserByDn(p_sessionId.getUserDn());
562  if (user != null) {
563  return user;
564  } else { // if there is no user than session is invalid
565  sessionIdService.remove(p_sessionId);
566  }
567  } else { // if there is no user than session is invalid
568  sessionIdService.remove(p_sessionId);
569  }
570  } catch (Exception e) {
571  log.trace(e.getMessage(), e);
572  }
573  }
574  return null;
575  }
SessionIdService sessionIdService
Definition: AuthenticationService.java:97
boolean remove(SessionId sessionId)
Definition: SessionIdService.java:683
UserService userService
Definition: AuthenticationService.java:91
User getUserByDn(String dn, String... returnAttributes)
Definition: UserService.java:66
Logger log
Definition: AuthenticationService.java:68

◆ isParameterExists()

boolean org.xdi.oxauth.service.AuthenticationService.isParameterExists ( String  p_name)
inline
590  {
591  return identity.isSetWorkingParameter(p_name);
592  }
Identity identity
Definition: AuthenticationService.java:74

◆ localAuthenticate()

boolean org.xdi.oxauth.service.AuthenticationService.localAuthenticate ( String  userName,
String  password 
)
inlineprivate
174  {
175  User user = userService.getUser(userName);
176  if (user != null) {
177  if (!checkUserStatus(user)) {
178  return false;
179  }
180 
181  // Use local LDAP server for user authentication
182  boolean authenticated = ldapEntryManager.authenticate(user.getDn(), password);
183  if (authenticated) {
186 
187  log.trace("Authenticate: credentials: '{}', credentials.userName: '{}', authenticatedUser.userId: '{}'", System.identityHashCode(credentials), credentials.getUsername(), getAuthenticatedUserId());
188  }
189 
190  return authenticated;
191  }
192 
193  return false;
194  }
void updateLastLogonUserTime(User user)
Definition: AuthenticationService.java:396
User getUser(String userId, String... returnAttributes)
Definition: UserService.java:87
void configureAuthenticatedUser(User user)
Definition: AuthenticationService.java:483
String getAuthenticatedUserId()
Definition: AuthenticationService.java:507
boolean checkUserStatus(User user)
Definition: AuthenticationService.java:385
UserService userService
Definition: AuthenticationService.java:91
PersistenceEntryManager ldapEntryManager
Definition: AuthenticationService.java:84
Credentials credentials
Definition: AuthenticationService.java:77
Logger log
Definition: AuthenticationService.java:68

◆ onSuccessfulLogin()

void org.xdi.oxauth.service.AuthenticationService.onSuccessfulLogin ( SessionId  sessionUser)
inline
535  {
536  log.info("Attempting to redirect user: SessionUser: {}", sessionUser);
537 
538  if ((sessionUser == null) || StringUtils.isBlank(sessionUser.getUserDn())) {
539  return;
540  }
541 
542  User user = userService.getUserByDn(sessionUser.getUserDn());
543 
544  log.info("Attempting to redirect user: User: {}", user);
545 
546  if (user != null) {
547  final Map<String, String> result = sessionUser.getSessionAttributes();
548  Map<String, String> allowedParameters = requestParameterService.getAllowedParameters(result);
549 
550  result.put(SESSION_ID, sessionUser.getId());
551 
552  log.trace("Logged in successfully! User: {}, page: /authorize.xhtml, map: {}", user, allowedParameters);
553  facesService.redirect("/authorize.xhtml", (Map) allowedParameters);
554  }
555  }
FacesService facesService
Definition: AuthenticationService.java:109
RequestParameterService requestParameterService
Definition: AuthenticationService.java:112
Map< String, String > getAllowedParameters(@Nonnull final Map< String, String > requestParameterMap)
Definition: RequestParameterService.java:81
UserService userService
Definition: AuthenticationService.java:91
User getUserByDn(String dn, String... returnAttributes)
Definition: UserService.java:66
Logger log
Definition: AuthenticationService.java:68

◆ parametersAsString()

String org.xdi.oxauth.service.AuthenticationService.parametersAsString ( ) throws UnsupportedEncodingException
inline
577  {
578  final Map<String, String> parameterMap = getParametersMap(null);
579 
580  return requestParameterService.parametersAsString(parameterMap);
581  }
RequestParameterService requestParameterService
Definition: AuthenticationService.java:112
Map< String, String > getParametersMap(List< String > extraParameters)
Definition: AuthenticationService.java:583
String parametersAsString(final Map< String, String > parameterMap)
Definition: RequestParameterService.java:120

◆ quietLogin()

void org.xdi.oxauth.service.AuthenticationService.quietLogin ( String  userName)
inline
477  {
478  Principal principal = new SimplePrincipal(userName);
479  identity.acceptExternallyAuthenticatedPrincipal(principal);
480  identity.quietLogin();
481  }
Identity identity
Definition: AuthenticationService.java:74

◆ setAuthenticatedUserSessionAttribute()

void org.xdi.oxauth.service.AuthenticationService.setAuthenticatedUserSessionAttribute ( String  userName,
boolean  authenticated 
)
inlineprivate
163  {
164  SessionId sessionId = sessionIdService.getSessionId();
165  if (sessionId != null) {
166  Map<String, String> sessionIdAttributes = sessionId.getSessionAttributes();
167  if (authenticated) {
168  sessionIdAttributes.put(Constants.AUTHENTICATED_USER, userName);
169  }
170  sessionIdService.updateSessionIdIfNeeded(sessionId, authenticated);
171  }
172  }
Map< String, String > getSessionAttributes()
Definition: SessionId.java:196
SessionId getSessionId()
Definition: SessionIdService.java:360
void updateSessionIdIfNeeded(SessionId sessionId, boolean modified)
Definition: SessionIdService.java:631
SessionIdService sessionIdService
Definition: AuthenticationService.java:97

◆ updateLastLogonUserTime()

void org.xdi.oxauth.service.AuthenticationService.updateLastLogonUserTime ( User  user)
inlineprivate
396  {
398  return;
399  }
400 
401  CustomEntry customEntry = new CustomEntry();
402  customEntry.setDn(user.getDn());
403 
404  List<String> personCustomObjectClassList = appConfiguration.getPersonCustomObjectClassList();
405  if ((personCustomObjectClassList != null) && !personCustomObjectClassList.isEmpty()) {
406  // Combine object classes from LDAP and configuration in one list
407  Set<Object> customPersonCustomObjectClassList = new HashSet<Object>(personCustomObjectClassList);
408  customPersonCustomObjectClassList.add("gluuPerson");
409  customPersonCustomObjectClassList.addAll(Arrays.asList(user.getCustomObjectClasses()));
410 
411  customEntry.setCustomObjectClasses(customPersonCustomObjectClassList.toArray(new String[customPersonCustomObjectClassList.size()]));
412  } else {
413  customEntry.setCustomObjectClasses(UserService.USER_OBJECT_CLASSES);
414  }
415 
416  Date now = new GregorianCalendar(TimeZone.getTimeZone("UTC")).getTime();
417  String nowDateString = ldapEntryManager.encodeTime(now);
418  CustomAttribute customAttribute = new CustomAttribute("oxLastLogonTime", nowDateString);
419  customEntry.getCustomAttributes().add(customAttribute);
420 
421  try {
422  ldapEntryManager.merge(customEntry);
423  } catch (EntryPersistenceException epe) {
424  log.error("Failed to update oxLastLogonTime of user '{}'", user.getUserId());
425  }
426  }
AppConfiguration appConfiguration
Definition: AuthenticationService.java:71
Boolean getUpdateUserLastLogonTime()
Definition: AppConfiguration.java:1285
List< String > getPersonCustomObjectClassList()
Definition: AppConfiguration.java:968
PersistenceEntryManager ldapEntryManager
Definition: AuthenticationService.java:84
Logger log
Definition: AuthenticationService.java:68

メンバ詳解

◆ appConfiguration

AppConfiguration org.xdi.oxauth.service.AuthenticationService.appConfiguration
private

◆ authenticationProtectionService

AuthenticationProtectionService org.xdi.oxauth.service.AuthenticationService.authenticationProtectionService
private

◆ clientService

ClientService org.xdi.oxauth.service.AuthenticationService.clientService
private

◆ credentials

Credentials org.xdi.oxauth.service.AuthenticationService.credentials
private

◆ EVENT_CONTEXT_AUTHENTICATED_USER

final String org.xdi.oxauth.service.AuthenticationService.EVENT_CONTEXT_AUTHENTICATED_USER = "authenticatedUser"
staticprivate

◆ externalAuthenticationService

ExternalAuthenticationService org.xdi.oxauth.service.AuthenticationService.externalAuthenticationService
private

◆ externalContext

ExternalContext org.xdi.oxauth.service.AuthenticationService.externalContext
private

◆ facesService

FacesService org.xdi.oxauth.service.AuthenticationService.facesService
private

◆ identity

Identity org.xdi.oxauth.service.AuthenticationService.identity
private

◆ ldapAuthConfigs

List<GluuLdapConfiguration> org.xdi.oxauth.service.AuthenticationService.ldapAuthConfigs
private

◆ ldapAuthEntryManagers

List<PersistenceEntryManager> org.xdi.oxauth.service.AuthenticationService.ldapAuthEntryManagers
private

◆ ldapEntryManager

PersistenceEntryManager org.xdi.oxauth.service.AuthenticationService.ldapEntryManager
private

◆ log

Logger org.xdi.oxauth.service.AuthenticationService.log
private

◆ metricService

MetricService org.xdi.oxauth.service.AuthenticationService.metricService
private

◆ requestParameterService

RequestParameterService org.xdi.oxauth.service.AuthenticationService.requestParameterService
private

◆ sessionIdService

SessionIdService org.xdi.oxauth.service.AuthenticationService.sessionIdService
private

◆ userService

UserService org.xdi.oxauth.service.AuthenticationService.userService
private

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