All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nutz.integration.shiro.NutShiroMethodInterceptor Maven / Gradle / Ivy

There is a newer version: 1.r.69.v20220215
Show newest version
package org.nutz.integration.shiro;

import java.util.Collection;

import org.apache.shiro.aop.MethodInvocation;
import org.apache.shiro.authz.AuthorizationException;
import org.apache.shiro.authz.aop.AnnotationsAuthorizingMethodInterceptor;
import org.apache.shiro.authz.aop.AuthorizingAnnotationMethodInterceptor;
import org.nutz.aop.InterceptorChain;
import org.nutz.aop.MethodInterceptor;
import org.nutz.integration.shiro.aop.NutzPermissionAnnotationMethodInterceptor;
import org.nutz.ioc.loader.annotation.IocBean;

/**
 * 将Shiro注解,映射为NutAop的拦截器
 * 
 * @author wendal
 *
 */
@IocBean
public class NutShiroMethodInterceptor extends AnnotationsAuthorizingMethodInterceptor implements MethodInterceptor {

	public NutShiroMethodInterceptor(Collection interceptors) {
		super.getMethodInterceptors().addAll(interceptors);
	}

	public NutShiroMethodInterceptor() {
		super.getMethodInterceptors().add(new NutzPermissionAnnotationMethodInterceptor());
	}

	@Override
	public void filter(InterceptorChain chain) throws Throwable {
		assertAuthorized(new NutShiroInterceptor(chain));
		chain.doChain();
	}

	// 暴露父类的方法
	@Override
	public void assertAuthorized(MethodInvocation methodInvocation) throws AuthorizationException {
		super.assertAuthorized(methodInvocation);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy