Java Code Examples for com.opensymphony.xwork2.Action#LOGIN

The following examples show how to use com.opensymphony.xwork2.Action#LOGIN . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AuthenticationInterceptor.java    From journaldev with MIT License 6 votes vote down vote up
@Override
public String intercept(ActionInvocation actionInvocation)
		throws Exception {
	System.out.println("inside auth interceptor");
	Map<String, Object> sessionAttributes = actionInvocation.getInvocationContext().getSession();
	
	User user = (User) sessionAttributes.get("USER");
	
	if(user == null){
		return Action.LOGIN;
	}else{
		Action action = (Action) actionInvocation.getAction();
		if(action instanceof UserAware){
			((UserAware) action).setUser(user);
		}
		return actionInvocation.invoke();
	}
}
 
Example 2
Source File: SecurityInterceptor.java    From OA with GNU General Public License v3.0 6 votes vote down vote up
public String intercept(ActionInvocation invocation) throws Exception {
		HttpSession session = ServletActionContext.getRequest().getSession();
		HttpServletRequest request=ServletActionContext.getRequest();
		String clazz=invocation.getAction().getClass().getName();
		System.out.println("clazz is "+clazz);
//		System.out.println(clazz+invocation.getAction());
		
		if (session.getAttribute("admin") == null ){
			if(UserAction.class.getName().equals(clazz)){
				System.out.println("if admin is null");
				return invocation.invoke(); 
			}
			System.out.println("admin is null");
			return Action.LOGIN;
		}else {
			if(UserAction.class.getName().equals(clazz)){
				Map parameters = invocation.getInvocationContext().getParameters();
				if(parameters.get("user.account")!=null){
					System.out.println("-====");
					System.out.println("user.account");
					session.removeAttribute("admin");
				}
			}
			return invocation.invoke();
		}
	}
 
Example 3
Source File: UserLoginInterceptor.java    From hrms with Apache License 2.0 5 votes vote down vote up
@Override
public String intercept(ActionInvocation actionInvocation) throws Exception {
ActionContext actionContext = actionInvocation.getInvocationContext();
  Object user = actionContext.getSession().get("user");   
     if(user != null){   
          return actionInvocation.invoke();   
     } else{
   	  actionContext.put("loginMessage", "您尚未登陆,请先登陆");
         return Action.LOGIN;   
     }   

}