Search in sources :

Example 11 with Context

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();
}
Also used : UserIndexKey(org.onebusaway.users.model.UserIndexKey) IndexedUserDetails(org.onebusaway.users.model.IndexedUserDetails) DefaultUserAuthenticationToken(org.onebusaway.users.impl.authentication.DefaultUserAuthenticationToken) ActionContext(com.opensymphony.xwork2.ActionContext)

Example 12 with Context

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;
}
Also used : ActionContext(com.opensymphony.xwork2.ActionContext)

Example 13 with Context

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);
}
Also used : WebApplicationContext(org.springframework.web.context.WebApplicationContext) Inject(com.opensymphony.xwork2.inject.Inject)

Example 14 with Context

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");
}
Also used : ActionContext(com.opensymphony.xwork2.ActionContext)

Example 15 with Context

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";
}
Also used : ActionProxy(com.opensymphony.xwork2.ActionProxy) ActionInvocation(com.opensymphony.xwork2.ActionInvocation) ActionContext(com.opensymphony.xwork2.ActionContext)

Aggregations

ActionContext (com.opensymphony.xwork2.ActionContext)21 ValueStack (com.opensymphony.xwork2.util.ValueStack)14 AgiActionName (org.onebusaway.probablecalls.AgiActionName)7 List (java.util.List)5 ActionProxy (com.opensymphony.xwork2.ActionProxy)4 HttpServletResponse (javax.servlet.http.HttpServletResponse)4 ActionInvocation (com.opensymphony.xwork2.ActionInvocation)3 StopBean (org.onebusaway.transit_data.model.StopBean)3 XWorkException (com.opensymphony.xwork2.XWorkException)2 Inject (com.opensymphony.xwork2.inject.Inject)2 Constructor (java.lang.reflect.Constructor)2 DateFormat (java.text.DateFormat)2 ParseException (java.text.ParseException)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 Map (java.util.Map)2 ServletActionContext (org.apache.struts2.ServletActionContext)2 SessionAware (org.apache.struts2.interceptor.SessionAware)2 XWorkRequestAttributes (org.onebusaway.presentation.impl.users.XWorkRequestAttributes)2 BookmarkWithStopsBean (org.onebusaway.presentation.model.BookmarkWithStopsBean)2