use of org.onebusaway.users.impl.authentication.DefaultUserAuthenticationToken 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.impl.authentication.DefaultUserAuthenticationToken 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();
}
use of org.onebusaway.users.impl.authentication.DefaultUserAuthenticationToken in project onebusaway-application-modules by camsys.
the class CurrentUserStrategyImpl method setCurrentUser.
@Override
public void setCurrentUser(UserIndex userIndex) {
IndexedUserDetails userDetails = new IndexedUserDetailsImpl(_authoritiesService, userIndex);
DefaultUserAuthenticationToken token = new DefaultUserAuthenticationToken(userDetails);
SecurityContextHolder.getContext().setAuthentication(token);
}
Aggregations