增加权限控制定义,用于实现自定义拦截权限控制,不局限与注解方式

This commit is contained in:
zhouhao
2017-08-11 18:56:48 +08:00
parent ad330da9f4
commit 7cc6a4d25b
4 changed files with 80 additions and 0 deletions

View File

@@ -29,6 +29,7 @@ import java.lang.annotation.*;
*
* @author zhouhao
* @see org.hswebframework.web.authorization.Authentication
* @see org.hswebframework.web.authorization.define.AuthorizeDefinition
* @since 3.0
*/
@Target({ElementType.TYPE, ElementType.METHOD})

View File

@@ -0,0 +1,32 @@
package org.hswebframework.web.authorization.define;
import org.hswebframework.web.authorization.annotation.Logical;
import java.util.Set;
/**
* 权限控制定义,定义权限控制的方式
*
* @author zhouhao
* @see AuthorizeDefinitionParser
* @since 3.0
*/
public interface AuthorizeDefinition {
int getPriority();
boolean isDataAccessControll();
Set<String> getPermissions();
Set<String> getActions();
Set<String> getRroles();
Set<String> getUser();
Script getScript();
String getMessage();
Logical getLogical();
}

View File

@@ -0,0 +1,20 @@
package org.hswebframework.web.authorization.define;
import org.hswebframework.web.boost.aop.context.MethodInterceptorParamContext;
/**
* 权限控制定义解析器,用于解析被拦截的请求是否需要进行权限控制,以及权限控制的方式
*
* @author zhouhao
* @see AuthorizeDefinition
*/
public interface AuthorizeDefinitionParser {
/**
* 解析权限控制定义
*
* @param paramContext 被拦截的方法上下文
* @return 权限控制定义, 如果不进行权限控制则返回{@code null}
*/
AuthorizeDefinition parse(MethodInterceptorParamContext paramContext);
}

View File

@@ -0,0 +1,27 @@
package org.hswebframework.web.authorization.define;
import java.util.Map;
/**
* 使用脚本进行权限控制
*
* @author zhouhao
* @since 3.0
*/
public interface Script {
/**
* @return 脚本语言, js,groovy,spel等
*/
String getLanguage();
/**
* js:
* <pre>
* return auth.hasRole("admin");
* </pre>
*
* @return 脚本内容
*/
String getScript();
}