Browse Source

优化权限控制

zhouhao 8 years ago
parent
commit
ef26546f03

+ 10 - 0
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/Permission.java

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

+ 3 - 0
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/listener/UserAuthorizationListener.java

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

+ 7 - 0
hsweb-authorization/hsweb-authorization-shiro/src/main/java/org/hswebframework/web/authorization/shiro/ListenerAuthorizingRealm.java

@@ -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();

+ 1 - 0
hsweb-authorization/hsweb-authorization-shiro/src/main/java/org/hswebframework/web/authorization/shiro/boost/SimpleAuthorizeMethodInterceptor.java

@@ -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());

+ 0 - 4
hsweb-examples/hsweb-examples-simple/src/main/java/org/hswebframework/web/example/simple/TestController.java

@@ -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();