Browse Source

移除RecordAopContext

zhouhao 8 years ago
parent
commit
a3635cbc7c

+ 4 - 4
hsweb-authorization/hsweb-authorization-api/README.md

@@ -21,8 +21,8 @@ _点击名称,查看源代码注释获得使用说明_
 
 | 类名       | 说明          | 
 | ------------- |:-------------:| 
-| [`Authorization`](src/main/java/org/hswebframework/web/authorization/Authorization.java)    | 用户的认证信息 | 
-| [`AuthorizationHolder`](src/main/java/org/hswebframework/web/authorization/AuthorizationHolder.java)      | 用于获取当前登录用户的认证信息      | 
+| [`Authentication`](src/main/java/org/hswebframework/web/authorization/Authentication.java)    | 用户的认证信息 | 
+| [`AuthenticationHolder`](src/main/java/org/hswebframework/web/authorization/AuthenticationHolder.java)      | 用于获取当前登录用户的认证信息      | 
 
 
 ### Listener
@@ -46,9 +46,9 @@ api提供[AuthorizationListener](src/main/java/org/hswebframework/web/authorizat
 public class CustomAuthorizationSuccessListener implements AuthorizationListener<AuthorizationSuccessEvent>{
         @Override
         public void on(AuthorizationSuccessEvent event) {
-            Authorization authorization=event.getAuthorization();
+            Authentication authentication=event.getAuthentication();
             //....
-            System.out.println(authorization.getUser().getName()+"登录啦");
+            System.out.println(authentication.getUser().getName()+"登录啦");
         }
 }
 ```

+ 7 - 1
hsweb-authorization/hsweb-authorization-api/pom.xml

@@ -10,5 +10,11 @@
     <modelVersion>4.0.0</modelVersion>
 
     <artifactId>hsweb-authorization-api</artifactId>
-
+    <dependencies>
+        <dependency>
+            <groupId>org.hswebframework.web</groupId>
+            <artifactId>hsweb-boost-aop</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
 </project>

+ 20 - 2
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/AuthenticationHolder.java

@@ -37,15 +37,33 @@ public final class AuthenticationHolder {
     private static AuthenticationSupplier supplier;
 
     /**
-     * @return 当前登录用户信息
+     * @return 当前登录用户权限信息
      */
     public static Authentication get() {
         if (null == supplier) {
-            throw new UnsupportedOperationException("AuthorizationSupplier is null!");
+            throw new UnsupportedOperationException("supplier is null!");
         }
         return supplier.get();
     }
 
+    /**
+     * 获取指定用户的权限信息
+     *
+     * @param userId 用户ID
+     * @return 权限信息
+     */
+    public static Authentication get(String userId) {
+        if (null == supplier) {
+            throw new UnsupportedOperationException("supplier is null!");
+        }
+        return supplier.get(userId);
+    }
+
+    /**
+     * 初始化 {@link AuthenticationSupplier}
+     *
+     * @param supplier
+     */
     public static void setSupplier(AuthenticationSupplier supplier) {
         if (null == AuthenticationHolder.supplier)
             AuthenticationHolder.supplier = supplier;

+ 1 - 0
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/AuthenticationSupplier.java

@@ -26,4 +26,5 @@ import java.util.function.Supplier;
  * @see AuthenticationHolder
  */
 public interface AuthenticationSupplier extends Supplier<Authentication> {
+    Authentication get(String userId);
 }

+ 0 - 2
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/annotation/Authorize.java

@@ -21,7 +21,6 @@ package org.hswebframework.web.authorization.annotation;
 import org.hswebframework.web.authorization.Permission;
 import org.hswebframework.web.authorization.Role;
 import org.hswebframework.web.authorization.User;
-import org.hswebframework.web.boost.aop.context.RecordAopContext;
 
 import java.lang.annotation.*;
 
@@ -35,7 +34,6 @@ import java.lang.annotation.*;
 @Retention(RetentionPolicy.RUNTIME)
 @Inherited
 @Documented
-@RecordAopContext
 public @interface Authorize {
 
     /**

+ 0 - 2
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/annotation/RequiresDataAccess.java

@@ -20,7 +20,6 @@ package org.hswebframework.web.authorization.annotation;
 import org.hswebframework.web.authorization.access.DataAccessConfig;
 import org.hswebframework.web.authorization.access.DataAccessController;
 import org.hswebframework.web.authorization.Permission;
-import org.hswebframework.web.boost.aop.context.RecordAopContext;
 
 import java.lang.annotation.*;
 
@@ -37,7 +36,6 @@ import java.lang.annotation.*;
 @Target({ElementType.TYPE, ElementType.METHOD})
 @Retention(RetentionPolicy.RUNTIME)
 @Documented
-@RecordAopContext
 public @interface RequiresDataAccess {
 
     /**

+ 0 - 3
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/annotation/RequiresExpression.java

@@ -17,8 +17,6 @@
 
 package org.hswebframework.web.authorization.annotation;
 
-import org.hswebframework.web.boost.aop.context.RecordAopContext;
-
 import java.lang.annotation.*;
 
 /**
@@ -30,7 +28,6 @@ import java.lang.annotation.*;
 @Target({ElementType.TYPE, ElementType.METHOD})
 @Retention(RetentionPolicy.RUNTIME)
 @Documented
-@RecordAopContext
 public @interface RequiresExpression {
 
     /**

+ 0 - 2
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/annotation/RequiresFieldAccess.java

@@ -19,7 +19,6 @@ package org.hswebframework.web.authorization.annotation;
 
 import org.hswebframework.web.authorization.Permission;
 import org.hswebframework.web.authorization.access.FieldAccessConfig;
-import org.hswebframework.web.boost.aop.context.RecordAopContext;
 
 import java.lang.annotation.*;
 
@@ -36,7 +35,6 @@ import java.lang.annotation.*;
 @Target({ElementType.TYPE, ElementType.METHOD})
 @Retention(RetentionPolicy.RUNTIME)
 @Documented
-@RecordAopContext
 public @interface RequiresFieldAccess {
 
     /**