优化权限控制

This commit is contained in:
zhouhao
2017-02-24 18:19:09 +08:00
parent 4124897ec5
commit ef26546f03
5 changed files with 21 additions and 4 deletions

View File

@@ -61,6 +61,16 @@ public interface Permission extends Serializable {
*/
String ACTION_EXPORT = "export";
/**
* 禁用
*/
String ACTION_DISABLE = "disable";
/**
* 启用
*/
String ACTION_ENABLE = "enable";
/**
* 获取权限ID权限的唯一标识
*

View File

@@ -36,5 +36,8 @@ public interface UserAuthorizationListener {
default void onAuthorizeFail(String username) {
}
default void onLoginOut(Authorization authorization){
}
void onAuthorizeSuccess(boolean isRemembered, Authorization authorization);
}

View File

@@ -67,6 +67,13 @@ public class ListenerAuthorizingRealm extends AuthorizingRealm implements UserAu
authorization.getUser().getName());
}
@Override
public void onLoginOut(Authorization authorization) {
if (null != authorization)
getCache(authorization.getUser().getUsername()).clear();
SecurityUtils.getSubject().logout();
}
@Override
public void onAuthorizeSuccess(boolean isRemembered, Authorization authorization) {
SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo();

View File

@@ -65,6 +65,7 @@ public class SimpleAuthorizeMethodInterceptor extends AuthorizingAnnotationMetho
if (!(a instanceof Authorize)) return;
MethodInterceptorHolder holder = MethodInterceptorHolder.current();
if (null == holder) {
logger.warn("MethodInterceptorHolder is null,maybe config is error!");
return;
}
AuthorizeConfig authorizeConfig = new AuthorizeConfig(holder.getArgs());

View File

@@ -61,10 +61,6 @@ public class TestController implements QueryController<UserEntity, String, Query
return ResponseMessage.ok(entity);
}
public static void main(String[] args) throws NoSuchMethodException {
System.out.println(UserController.class.getMethod("list", Entity.class));
}
@Override
public TestService getService() {
return new TestService();