Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
SpringBlade
提交
66d59e40
S
SpringBlade
项目概览
int
/
SpringBlade
12 个月 前同步成功
通知
16
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SpringBlade
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
66d59e40
编写于
9月 18, 2016
作者:
Z
zhuangqian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
更新readme
上级
def0299d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
15 addition
and
21 deletion
+15
-21
README.md
README.md
+2
-1
src/main/java/com/smallchill/core/aop/PermissionAop.java
src/main/java/com/smallchill/core/aop/PermissionAop.java
+2
-6
src/main/java/com/smallchill/core/interfaces/ICheck.java
src/main/java/com/smallchill/core/interfaces/ICheck.java
+3
-6
src/main/java/com/smallchill/core/toolbox/check/PermissionCheckFactory.java
...smallchill/core/toolbox/check/PermissionCheckFactory.java
+4
-2
src/main/java/com/smallchill/core/toolbox/check/PermissionCheckManager.java
...smallchill/core/toolbox/check/PermissionCheckManager.java
+4
-6
未找到文件。
README.md
浏览文件 @
66d59e40
...
@@ -9,8 +9,9 @@ PS:因为喜欢刀锋战士所以取名了SpringBlade,当中有一个类也命
...
@@ -9,8 +9,9 @@ PS:因为喜欢刀锋战士所以取名了SpringBlade,当中有一个类也命
2.[
eova
](
http://www.oschina.net/p/eova
)
2.[
eova
](
http://www.oschina.net/p/eova
)
3.[
hutool
](
http://www.oschina.net/p/hutool
)
3.[
hutool
](
http://www.oschina.net/p/hutool
)
4.[
beetl
](
http://www.oschina.net/p/beetl
)
4.[
beetl
](
http://www.oschina.net/p/beetl
)
4.[
beetlsql
](
http://www.oschina.net/p/beetlsql
)
5.[
dreamlu
](
http://www.oschina.net/p/dreamlu
)
5.[
dreamlu
](
http://www.oschina.net/p/dreamlu
)
6.[
kisso
](
http
s://git.oschina.net/baomidou
/kisso
)
6.[
kisso
](
http
://www.oschina.net/p
/kisso
)
## 内置功能
## 内置功能
...
...
src/main/java/com/smallchill/core/aop/PermissionAop.java
浏览文件 @
66d59e40
...
@@ -17,8 +17,6 @@ package com.smallchill.core.aop;
...
@@ -17,8 +17,6 @@ package com.smallchill.core.aop;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Method
;
import
javax.servlet.http.HttpServletRequest
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.annotation.Around
;
import
org.aspectj.lang.annotation.Around
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Aspect
;
...
@@ -30,7 +28,6 @@ import com.smallchill.core.annotation.Permission;
...
@@ -30,7 +28,6 @@ import com.smallchill.core.annotation.Permission;
import
com.smallchill.core.exception.NoPermissionException
;
import
com.smallchill.core.exception.NoPermissionException
;
import
com.smallchill.core.toolbox.Func
;
import
com.smallchill.core.toolbox.Func
;
import
com.smallchill.core.toolbox.check.PermissionCheckManager
;
import
com.smallchill.core.toolbox.check.PermissionCheckManager
;
import
com.smallchill.core.toolbox.kit.HttpKit
;
/**
/**
* AOP 权限自定义检查
* AOP 权限自定义检查
...
@@ -46,7 +43,6 @@ public class PermissionAop {
...
@@ -46,7 +43,6 @@ public class PermissionAop {
@Around
(
"cutPermission()"
)
@Around
(
"cutPermission()"
)
public
Object
doPermission
(
ProceedingJoinPoint
point
)
throws
Throwable
{
public
Object
doPermission
(
ProceedingJoinPoint
point
)
throws
Throwable
{
HttpServletRequest
request
=
HttpKit
.
getRequest
();
MethodSignature
ms
=
(
MethodSignature
)
point
.
getSignature
();
MethodSignature
ms
=
(
MethodSignature
)
point
.
getSignature
();
Method
method
=
ms
.
getMethod
();
Method
method
=
ms
.
getMethod
();
Permission
permission
=
method
.
getAnnotation
(
Permission
.
class
);
Permission
permission
=
method
.
getAnnotation
(
Permission
.
class
);
...
@@ -54,7 +50,7 @@ public class PermissionAop {
...
@@ -54,7 +50,7 @@ public class PermissionAop {
if
((
permissions
.
length
==
1
&&
Func
.
toStr
(
permissions
[
0
]).
equals
(
"ALL"
))
if
((
permissions
.
length
==
1
&&
Func
.
toStr
(
permissions
[
0
]).
equals
(
"ALL"
))
||
permissions
==
null
||
permissions
.
length
==
0
)
{
||
permissions
==
null
||
permissions
.
length
==
0
)
{
//检查全体角色
//检查全体角色
boolean
result
=
PermissionCheckManager
.
checkAll
(
request
);
boolean
result
=
PermissionCheckManager
.
checkAll
();
if
(
result
)
{
if
(
result
)
{
return
point
.
proceed
();
return
point
.
proceed
();
}
else
{
}
else
{
...
@@ -62,7 +58,7 @@ public class PermissionAop {
...
@@ -62,7 +58,7 @@ public class PermissionAop {
}
}
}
else
{
}
else
{
//检查指定角色
//检查指定角色
boolean
result
=
PermissionCheckManager
.
check
(
permissions
,
request
);
boolean
result
=
PermissionCheckManager
.
check
(
permissions
);
if
(
result
)
{
if
(
result
)
{
return
point
.
proceed
();
return
point
.
proceed
();
}
else
{
}
else
{
...
...
src/main/java/com/smallchill/core/interfaces/ICheck.java
浏览文件 @
66d59e40
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
*/
*/
package
com.smallchill.core.interfaces
;
package
com.smallchill.core.interfaces
;
import
javax.servlet.http.HttpServletRequest
;
/**
/**
* 检查用接口
* 检查用接口
...
@@ -24,16 +23,14 @@ public interface ICheck {
...
@@ -24,16 +23,14 @@ public interface ICheck {
/**
/**
* 检查指定角色
* 检查指定角色
* @param
request
* @param
permissions
* @return boolean
* @return boolean
*/
*/
boolean
check
(
Object
[]
permissions
,
HttpServletRequest
request
);
boolean
check
(
Object
[]
permissions
);
/**
/**
* 检查全体角色
* 检查全体角色
* @param permissions
* @param request
* @return boolean
* @return boolean
*/
*/
boolean
checkAll
(
HttpServletRequest
request
);
boolean
checkAll
();
}
}
src/main/java/com/smallchill/core/toolbox/check/PermissionCheckFactory.java
浏览文件 @
66d59e40
...
@@ -22,6 +22,7 @@ import com.smallchill.core.constant.Cst;
...
@@ -22,6 +22,7 @@ import com.smallchill.core.constant.Cst;
import
com.smallchill.core.interfaces.ICheck
;
import
com.smallchill.core.interfaces.ICheck
;
import
com.smallchill.core.shiro.ShiroKit
;
import
com.smallchill.core.shiro.ShiroKit
;
import
com.smallchill.core.toolbox.kit.CollectionKit
;
import
com.smallchill.core.toolbox.kit.CollectionKit
;
import
com.smallchill.core.toolbox.kit.HttpKit
;
/**
/**
* @title 权限自定义检查
* @title 权限自定义检查
...
@@ -33,7 +34,7 @@ import com.smallchill.core.toolbox.kit.CollectionKit;
...
@@ -33,7 +34,7 @@ import com.smallchill.core.toolbox.kit.CollectionKit;
public
class
PermissionCheckFactory
implements
ICheck
{
public
class
PermissionCheckFactory
implements
ICheck
{
@Override
@Override
public
boolean
check
(
Object
[]
permissions
,
HttpServletRequest
request
)
{
public
boolean
check
(
Object
[]
permissions
)
{
ShiroUser
user
=
ShiroKit
.
getUser
();
ShiroUser
user
=
ShiroKit
.
getUser
();
if
(
null
==
user
)
{
if
(
null
==
user
)
{
return
false
;
return
false
;
...
@@ -46,7 +47,8 @@ public class PermissionCheckFactory implements ICheck {
...
@@ -46,7 +47,8 @@ public class PermissionCheckFactory implements ICheck {
}
}
@Override
@Override
public
boolean
checkAll
(
HttpServletRequest
request
)
{
public
boolean
checkAll
()
{
HttpServletRequest
request
=
HttpKit
.
getRequest
();
ShiroUser
user
=
ShiroKit
.
getUser
();
ShiroUser
user
=
ShiroKit
.
getUser
();
if
(
null
==
user
)
{
if
(
null
==
user
)
{
return
false
;
return
false
;
...
...
src/main/java/com/smallchill/core/toolbox/check/PermissionCheckManager.java
浏览文件 @
66d59e40
...
@@ -15,8 +15,6 @@
...
@@ -15,8 +15,6 @@
*/
*/
package
com.smallchill.core.toolbox.check
;
package
com.smallchill.core.toolbox.check
;
import
javax.servlet.http.HttpServletRequest
;
import
com.smallchill.core.constant.Cst
;
import
com.smallchill.core.constant.Cst
;
import
com.smallchill.core.interfaces.ICheck
;
import
com.smallchill.core.interfaces.ICheck
;
...
@@ -47,11 +45,11 @@ public class PermissionCheckManager {
...
@@ -47,11 +45,11 @@ public class PermissionCheckManager {
this
.
defaultCheckFactory
=
defaultCheckFactory
;
this
.
defaultCheckFactory
=
defaultCheckFactory
;
}
}
public
static
boolean
check
(
Object
[]
permissions
,
HttpServletRequest
request
)
{
public
static
boolean
check
(
Object
[]
permissions
)
{
return
me
.
defaultCheckFactory
.
check
(
permissions
,
request
);
return
me
.
defaultCheckFactory
.
check
(
permissions
);
}
}
public
static
boolean
checkAll
(
HttpServletRequest
request
)
{
public
static
boolean
checkAll
()
{
return
me
.
defaultCheckFactory
.
checkAll
(
request
);
return
me
.
defaultCheckFactory
.
checkAll
();
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录