模板权限集成示例代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.3 KiB

package com.tptj.course.hg.auth.template;
import com.fr.decision.webservice.v10.template.TempAuthValidatorStatus;
import com.fr.invoke.Reflect;
import com.fr.third.net.sf.cglib.proxy.MethodInterceptor;
import com.fr.third.net.sf.cglib.proxy.MethodProxy;
import java.lang.reflect.Method;
/**
* @author 秃破天际
* @version 10.0
* Created by 秃破天际 on 2021/6/23
**/
public class MethodInterceptorImpl implements MethodInterceptor {
private Object source;
public MethodInterceptorImpl(Object source){
this.source = source;
}
@Override
public Object intercept( Object o, Method method, Object[] params, MethodProxy proxy ) throws Throwable {
if( method.getName().equals("templateAuth") ){
boolean rt = Reflect.on(SpTemplateAuthType.class).call("templateAuth",params).get();
if( rt ){
return ((TempAuthValidatorStatus)params[0]).directAccessTemp(true).needAuthorityCheck(false);
}
}else if( method.getName().equals("hyperlinkTokenValid") ){
boolean rt = Reflect.on(SpTemplateAuthType.class).call("hyperlinkTokenValid",params).get();
if( rt ){
return true;
}
}
return method.invoke(source,params);
}
}