securityinterceptor.java

来自「华为java接口反编译结果!其中包含其所有接口实现过程」· Java 代码 · 共 53 行

JAVA
53
字号
package com.kelefa.sms.interceptor;

import com.opensymphony.xwork.Action;
import com.opensymphony.xwork.ActionInvocation;
import com.opensymphony.xwork.ActionSupport;
import com.opensymphony.xwork.interceptor.Interceptor;

public class SecurityInterceptor
    implements Interceptor

{
  public SecurityInterceptor()
  {
  }

  public void destroy()
  {
  }

  public void init()
  {
  }

  public String intercept( ActionInvocation invocation )
      throws Exception
  {
    if ( !isAuthorized( invocation ) ) {
      return Action.LOGIN;
    }

    return invocation.invoke();
  }

  protected boolean isAuthorized( ActionInvocation actionInvocation )
  {
    boolean logined = "true".equals( actionInvocation
	.getInvocationContext()
	.getSession()
	.get( "login" ) );


    if ( !logined ) {
      ActionSupport action = ( ActionSupport ) actionInvocation.getAction();
      action.addActionError( "请你先登陆" );

      return false;
    }

    return true;
  }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?