use of org.onebusaway.users.model.IndexedUserDetails in project onebusaway-application-modules by camsys.
the class AutoUserCurrentUserStrategyImpl method createAuthentication.
protected Authentication createAuthentication() {
UUID uuid = UUID.randomUUID();
UUID credentials = UUID.randomUUID();
UserIndexKey principal = new UserIndexKey(UserIndexTypes.WEB, uuid.toString());
IndexedUserDetails details = _userDetailsService.getOrCreateUserForIndexKey(principal, credentials.toString(), true);
return new DefaultUserAuthenticationToken(details);
}
use of org.onebusaway.users.model.IndexedUserDetails in project onebusaway-application-modules by camsys.
the class AutoUserCurrentUserStrategyImpl method getCurrentUserDetails.
@Override
public IndexedUserDetails getCurrentUserDetails(boolean createUserIfAppropriate) {
IndexedUserDetails details = super.getCurrentUserDetails(createUserIfAppropriate);
if (details == null && createUserIfAppropriate) {
Authentication authentication = createAuthentication();
details = getUserDetailsForAuthentication(authentication);
SecurityContextHolder.getContext().setAuthentication(authentication);
RequestAndResponseContext context = RequestAndResponseContext.getContext();
if (context != null)
_rememberMeServices.onLoginSuccess(context.getRequest(), context.getResponse(), authentication);
}
return details;
}
use of org.onebusaway.users.model.IndexedUserDetails in project onebusaway-application-modules by camsys.
the class CurrentUserServiceImpl method clearPhoneNumberRegistration.
@Override
public void clearPhoneNumberRegistration() {
IndexedUserDetails details = _currentUserStrategy.getCurrentUserDetails(false);
if (details == null)
return;
_userService.clearPhoneNumberRegistration(details.getUserIndexKey());
}
use of org.onebusaway.users.model.IndexedUserDetails in project onebusaway-application-modules by camsys.
the class PhoneNumberLoginInterceptor method isCurrentUserLoggedInWithKey.
private boolean isCurrentUserLoggedInWithKey(UserIndexKey key) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication == null)
return false;
Object principal = authentication.getPrincipal();
if (!(principal instanceof IndexedUserDetails))
return false;
IndexedUserDetails details = (IndexedUserDetails) principal;
UserIndexKey indexKey = details.getUserIndexKey();
return indexKey.equals(key);
}
use of org.onebusaway.users.model.IndexedUserDetails in project onebusaway-application-modules by camsys.
the class PhoneNumberLoginInterceptor method intercept.
@Override
public String intercept(ActionInvocation invocation) throws Exception {
ActionContext context = invocation.getInvocationContext();
Map<String, Object> params = context.getParameters();
String phoneNumber = getPhoneNumber(params);
phoneNumber = PhoneNumberLibrary.normalizePhoneNumber(phoneNumber);
if (phoneNumber != null && phoneNumber.length() > 0) {
UserIndexKey key = new UserIndexKey(UserIndexTypes.PHONE_NUMBER, phoneNumber);
if (params.containsKey(RESET_USER))
_indexedUserDetailsService.resetUserForIndexKey(key);
// Ensure that we have authentication, even if it's anonymous
if (!isCurrentUserLoggedInWithKey(key)) {
IndexedUserDetails userDetails = _indexedUserDetailsService.getOrCreateUserForIndexKey(key, "", false);
DefaultUserAuthenticationToken token = new DefaultUserAuthenticationToken(userDetails);
SecurityContextHolder.getContext().setAuthentication(token);
}
}
return invocation.invoke();
}
Aggregations