use of com.opensymphony.xwork2.inject.Context 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 com.opensymphony.xwork2.inject.Context in project onebusaway-application-modules by camsys.
the class RequestContextInterceptor method intercept.
@Override
public String intercept(ActionInvocation invocation) throws Exception {
ActionContext context = invocation.getInvocationContext();
String id = getSessionId(context);
XWorkRequestAttributes attributes = new XWorkRequestAttributes(context, id);
RequestContextHolder.setRequestAttributes(attributes);
String result = invocation.invoke();
RequestContextHolder.resetRequestAttributes();
attributes.requestCompleted();
return result;
}
use of com.opensymphony.xwork2.inject.Context in project onebusaway-application-modules by camsys.
the class ConfigurationValueFunction method setServletContext.
@Inject(required = true)
public void setServletContext(ServletContext servletContext) {
WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(servletContext);
context.getAutowireCapableBeanFactory().autowireBean(this);
}
use of com.opensymphony.xwork2.inject.Context in project onebusaway-application-modules by camsys.
the class ApiKeyInterceptor method isAllowed.
private ApiKeyPermissionService.Status isAllowed(ActionInvocation invocation) {
ActionContext context = invocation.getInvocationContext();
Map<String, Object> parameters = context.getParameters();
String[] keys = (String[]) parameters.get("key");
if (keys == null || keys.length == 0)
return ApiKeyPermissionService.Status.UNAUTHORIZED;
return _keyService.getPermission(keys[0], "api");
}
use of com.opensymphony.xwork2.inject.Context in project onebusaway-application-modules by camsys.
the class VehicleStatusMapAction method execute.
@Override
public String execute() {
ActionContext context = ActionContext.getContext();
ActionInvocation invocation = context.getActionInvocation();
ActionProxy proxy = invocation.getProxy();
String name = proxy.getActionName().toLowerCase();
String namespace = proxy.getNamespace().toLowerCase();
// return the 404 message if so. There has to be a better way than this?
if ((name.equals("") || name.equals("index")) && (namespace.equals("") || namespace.equals("/"))) {
return SUCCESS;
}
return "NotFound";
}
Aggregations