移除RecordAopContext

This commit is contained in:
zhouhao
2017-03-28 15:03:55 +08:00
parent 35319457e1
commit a3635cbc7c
8 changed files with 32 additions and 16 deletions

View File

@@ -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()+"登录啦");
}
}
```

View File

@@ -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>

View File

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

View File

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

View File

@@ -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 {
/**

View File

@@ -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 {
/**

View File

@@ -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 {
/**

View File

@@ -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 {
/**