diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties
index 6c414f9e7..966184dca 100644
--- a/.mvn/wrapper/maven-wrapper.properties
+++ b/.mvn/wrapper/maven-wrapper.properties
@@ -1 +1 @@
-distributionUrl=https://downloads.apache.org/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.zip
\ No newline at end of file
+distributionUrl=https://archive.apache.org/dist/maven/maven-3/3.9.3/binaries/apache-maven-3.9.3-bin.zip
\ No newline at end of file
diff --git a/hsweb-authorization/hsweb-authorization-api/pom.xml b/hsweb-authorization/hsweb-authorization-api/pom.xml
index 9046b43f5..091ea494a 100644
--- a/hsweb-authorization/hsweb-authorization-api/pom.xml
+++ b/hsweb-authorization/hsweb-authorization-api/pom.xml
@@ -47,8 +47,8 @@
- javax.servlet
- javax.servlet-api
+ jakarta.servlet
+ jakarta.servlet-api
true
diff --git a/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/access/DataAccessController.java b/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/access/DataAccessController.java
index 1b66090a7..7fcd3093c 100644
--- a/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/access/DataAccessController.java
+++ b/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/access/DataAccessController.java
@@ -9,6 +9,7 @@ import org.hswebframework.web.authorization.define.AuthorizingContext;
* @author zhouhao
* @since 3.0
*/
+@Deprecated
public interface DataAccessController {
/**
* 执行权限控制
diff --git a/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/simple/SimpleUser.java b/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/simple/SimpleUser.java
index 46ab4bac6..3b9e01638 100644
--- a/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/simple/SimpleUser.java
+++ b/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/simple/SimpleUser.java
@@ -3,6 +3,7 @@ package org.hswebframework.web.authorization.simple;
import lombok.*;
import org.hswebframework.web.authorization.User;
+import java.io.Serial;
import java.io.Serializable;
import java.util.Map;
@@ -16,6 +17,7 @@ import java.util.Map;
@Builder
public class SimpleUser implements User {
+ @Serial
private static final long serialVersionUID = 2194541828191869091L;
private String id;
diff --git a/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/simple/builder/SimpleDataAccessConfigBuilderFactory.java b/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/simple/builder/SimpleDataAccessConfigBuilderFactory.java
index 670344235..d9ab8b89f 100644
--- a/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/simple/builder/SimpleDataAccessConfigBuilderFactory.java
+++ b/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/simple/builder/SimpleDataAccessConfigBuilderFactory.java
@@ -1,12 +1,12 @@
package org.hswebframework.web.authorization.simple.builder;
import com.alibaba.fastjson.JSON;
+import jakarta.annotation.PostConstruct;
import org.hswebframework.web.authorization.access.DataAccessConfig;
import org.hswebframework.web.authorization.builder.DataAccessConfigBuilder;
import org.hswebframework.web.authorization.builder.DataAccessConfigBuilderFactory;
import org.hswebframework.web.authorization.simple.*;
-import javax.annotation.PostConstruct;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
diff --git a/hsweb-authorization/hsweb-authorization-api/src/main/java9/module-info.java b/hsweb-authorization/hsweb-authorization-api/src/main/java9/module-info.java
new file mode 100644
index 000000000..a7ebdec30
--- /dev/null
+++ b/hsweb-authorization/hsweb-authorization-api/src/main/java9/module-info.java
@@ -0,0 +1,37 @@
+module hsweb.authorization.api {
+ requires spring.core;
+ requires hsweb.core;
+ requires spring.beans;
+ requires spring.boot.autoconfigure;
+ requires spring.context;
+ requires spring.boot;
+ requires static spring.data.redis;
+ requires reactor.core;
+ requires static lombok;
+ requires fastjson;
+ requires commons.collections;
+ requires com.fasterxml.jackson.annotation;
+ requires jakarta.annotation;
+ requires org.slf4j;
+
+
+ exports org.hswebframework.web.authorization;
+ exports org.hswebframework.web.authorization.access;
+ exports org.hswebframework.web.authorization.annotation;
+ exports org.hswebframework.web.authorization.token.redis;
+ exports org.hswebframework.web.authorization.token.event;
+ exports org.hswebframework.web.authorization.builder;
+ exports org.hswebframework.web.authorization.define;
+ exports org.hswebframework.web.authorization.dimension;
+ exports org.hswebframework.web.authorization.events;
+ exports org.hswebframework.web.authorization.exception;
+ exports org.hswebframework.web.authorization.setting;
+ exports org.hswebframework.web.authorization.simple;
+ exports org.hswebframework.web.authorization.simple.builder;
+ exports org.hswebframework.web.authorization.twofactor.defaults;
+ exports org.hswebframework.web.authorization.twofactor;
+
+ opens org.hswebframework.web.authorization.simple;
+ exports org.hswebframework.web.authorization.token;
+
+}
\ No newline at end of file
diff --git a/hsweb-authorization/hsweb-authorization-basic/pom.xml b/hsweb-authorization/hsweb-authorization-basic/pom.xml
index 50a2273dc..864564826 100644
--- a/hsweb-authorization/hsweb-authorization-basic/pom.xml
+++ b/hsweb-authorization/hsweb-authorization-basic/pom.xml
@@ -20,11 +20,6 @@
${project.version}
-
- org.hswebframework
- hsweb-expands-script
-
-
org.springframework.boot
spring-boot-starter-aop
@@ -69,8 +64,8 @@
- javax.servlet
- javax.servlet-api
+ jakarta.servlet
+ jakarta.servlet-api
true
@@ -103,6 +98,25 @@
test
+
+ jakarta.websocket
+ jakarta.websocket-api
+ test
+
+
+
+ jakarta.websocket
+ jakarta.websocket-client-api
+ test
+
+
+
+ org.glassfish.expressly
+ expressly
+ 5.0.0
+ test
+
+
\ No newline at end of file
diff --git a/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/configuration/AuthorizingHandlerAutoConfiguration.java b/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/configuration/AuthorizingHandlerAutoConfiguration.java
index 18f1928d3..935f377ca 100644
--- a/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/configuration/AuthorizingHandlerAutoConfiguration.java
+++ b/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/configuration/AuthorizingHandlerAutoConfiguration.java
@@ -3,33 +3,20 @@ package org.hswebframework.web.authorization.basic.configuration;
import org.hswebframework.web.authorization.AuthenticationManager;
import org.hswebframework.web.authorization.ReactiveAuthenticationManagerProvider;
import org.hswebframework.web.authorization.access.DataAccessController;
-import org.hswebframework.web.authorization.access.DataAccessHandler;
-import org.hswebframework.web.authorization.basic.aop.AopMethodAuthorizeDefinitionParser;
import org.hswebframework.web.authorization.basic.embed.EmbedAuthenticationProperties;
import org.hswebframework.web.authorization.basic.embed.EmbedReactiveAuthenticationManager;
import org.hswebframework.web.authorization.basic.handler.DefaultAuthorizingHandler;
import org.hswebframework.web.authorization.basic.handler.UserAllowPermissionHandler;
-import org.hswebframework.web.authorization.basic.handler.access.DefaultDataAccessController;
-import org.hswebframework.web.authorization.basic.twofactor.TwoFactorHandlerInterceptorAdapter;
import org.hswebframework.web.authorization.basic.web.*;
import org.hswebframework.web.authorization.token.UserTokenManager;
-import org.hswebframework.web.authorization.twofactor.TwoFactorValidatorManager;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.boot.autoconfigure.AutoConfiguration;
-import org.springframework.boot.autoconfigure.condition.*;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import org.springframework.core.Ordered;
-import org.springframework.core.annotation.Order;
-import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
-
-import javax.annotation.Nonnull;
-import java.util.List;
/**
* 权限控制自动配置类
@@ -41,14 +28,10 @@ import java.util.List;
@EnableConfigurationProperties(EmbedAuthenticationProperties.class)
public class AuthorizingHandlerAutoConfiguration {
- @Bean
- public DefaultDataAccessController dataAccessController() {
- return new DefaultDataAccessController();
- }
@Bean
- public DefaultAuthorizingHandler authorizingHandler(DataAccessController dataAccessController) {
- return new DefaultAuthorizingHandler(dataAccessController);
+ public DefaultAuthorizingHandler authorizingHandler() {
+ return new DefaultAuthorizingHandler(null);
}
@@ -93,27 +76,6 @@ public class AuthorizingHandlerAutoConfiguration {
return new BearerTokenParser();
}
- @Configuration
- public static class DataAccessHandlerProcessor implements BeanPostProcessor {
-
- @Autowired
- private DefaultDataAccessController defaultDataAccessController;
-
- @Override
- public Object postProcessBeforeInitialization(Object bean, String beanName) {
- return bean;
- }
-
- @Override
- public Object postProcessAfterInitialization(Object bean, String beanName) {
- if (bean instanceof DataAccessHandler) {
- defaultDataAccessController.addHandler(((DataAccessHandler) bean));
- }
- return bean;
- }
- }
-
-
@Configuration
@ConditionalOnProperty(prefix = "hsweb.authorize", name = "basic-authorization", havingValue = "true")
@ConditionalOnClass(UserTokenForTypeParser.class)
diff --git a/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/configuration/BasicAuthorizationTokenParser.java b/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/configuration/BasicAuthorizationTokenParser.java
index 0a896adfa..c25b63649 100644
--- a/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/configuration/BasicAuthorizationTokenParser.java
+++ b/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/configuration/BasicAuthorizationTokenParser.java
@@ -11,7 +11,7 @@ import org.hswebframework.web.authorization.token.UserToken;
import org.hswebframework.web.authorization.token.UserTokenManager;
import reactor.core.publisher.Mono;
-import javax.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletRequest;
public class BasicAuthorizationTokenParser implements UserTokenForTypeParser {
diff --git a/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/configuration/WebMvcAuthorizingConfiguration.java b/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/configuration/WebMvcAuthorizingConfiguration.java
index 7ff7373e0..bda225788 100644
--- a/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/configuration/WebMvcAuthorizingConfiguration.java
+++ b/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/configuration/WebMvcAuthorizingConfiguration.java
@@ -1,7 +1,6 @@
package org.hswebframework.web.authorization.basic.configuration;
import org.hswebframework.web.authorization.basic.aop.AopMethodAuthorizeDefinitionParser;
-import org.hswebframework.web.authorization.basic.twofactor.TwoFactorHandlerInterceptorAdapter;
import org.hswebframework.web.authorization.basic.web.*;
import org.hswebframework.web.authorization.token.UserTokenManager;
import org.hswebframework.web.authorization.twofactor.TwoFactorValidatorManager;
@@ -15,7 +14,7 @@ import org.springframework.core.annotation.Order;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
-import javax.annotation.Nonnull;
+import jakarta.annotation.Nonnull;
import java.util.List;
@AutoConfiguration
@@ -64,16 +63,4 @@ public class WebMvcAuthorizingConfiguration {
return new SessionIdUserTokenGenerator();
}
- @Bean
- @ConditionalOnProperty(prefix = "hsweb.authorize.two-factor", name = "enable", havingValue = "true")
- @Order(100)
- public WebMvcConfigurer twoFactorHandlerConfigurer(TwoFactorValidatorManager manager) {
- return new WebMvcConfigurer() {
- @Override
- public void addInterceptors(@Nonnull InterceptorRegistry registry) {
- registry.addInterceptor(new TwoFactorHandlerInterceptorAdapter(manager));
- }
- };
- }
-
}
\ No newline at end of file
diff --git a/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/embed/EmbedAuthenticationProperties.java b/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/embed/EmbedAuthenticationProperties.java
index 1b35e4b1a..9fd6e97b0 100644
--- a/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/embed/EmbedAuthenticationProperties.java
+++ b/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/embed/EmbedAuthenticationProperties.java
@@ -11,10 +11,8 @@ import org.hswebframework.web.authorization.simple.builder.SimpleDataAccessConfi
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.util.StringUtils;
-import reactor.core.publisher.Mono;
+import org.springframework.util.ObjectUtils;
-import javax.validation.ValidationException;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
@@ -36,10 +34,6 @@ import java.util.Optional;
* permissions:
* - id: user-manager
* actions: *
- * dataAccesses:
- * - action: query
- * type: DENY_FIELDS
- * fields: password,salt
*
*
* @author zhouhao
@@ -62,25 +56,9 @@ public class EmbedAuthenticationProperties implements InitializingBean {
@Override
public void afterPropertiesSet() {
users.forEach((id, properties) -> {
- if (StringUtils.isEmpty(properties.getId())) {
+ if (ObjectUtils.isEmpty(properties.getId())) {
properties.setId(id);
}
- for (EmbedAuthenticationInfo.PermissionInfo permissionInfo : properties.getPermissions()) {
- for (Map objectMap : permissionInfo.getDataAccesses()) {
- for (Map.Entry stringObjectEntry : objectMap.entrySet()) {
- if (stringObjectEntry.getValue() instanceof Map) {
- Map, ?> mapVal = ((Map) stringObjectEntry.getValue());
- boolean maybeIsList = mapVal
- .keySet()
- .stream()
- .allMatch(org.hswebframework.utils.StringUtils::isInt);
- if (maybeIsList) {
- stringObjectEntry.setValue(mapVal.values());
- }
- }
- }
- }
- }
authentications.put(id, properties.toAuthentication(dataAccessConfigBuilderFactory));
});
}
diff --git a/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/handler/DefaultAuthorizingHandler.java b/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/handler/DefaultAuthorizingHandler.java
index 1c957e70e..c27aef9c0 100644
--- a/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/handler/DefaultAuthorizingHandler.java
+++ b/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/handler/DefaultAuthorizingHandler.java
@@ -69,7 +69,6 @@ public class DefaultAuthorizingHandler implements AuthorizingHandler {
public void handleDataAccess(AuthorizingContext context) {
if (dataAccessController == null) {
- log.warn("dataAccessController is null,skip result access control!");
return;
}
if (context.getDefinition().getResources() == null) {
diff --git a/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/handler/access/DataAccessHandlerContext.java b/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/handler/access/DataAccessHandlerContext.java
deleted file mode 100644
index 7ecbf9dba..000000000
--- a/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/handler/access/DataAccessHandlerContext.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package org.hswebframework.web.authorization.basic.handler.access;
-
-import lombok.Getter;
-import lombok.Setter;
-import org.hswebframework.ezorm.rdb.mapping.ReactiveRepository;
-import org.hswebframework.utils.ClassUtils;
-import org.hswebframework.web.aop.MethodInterceptorContext;
-import org.hswebframework.web.authorization.Authentication;
-import org.hswebframework.web.authorization.Dimension;
-import org.hswebframework.web.authorization.DimensionType;
-import org.hswebframework.web.authorization.define.AuthorizeDefinition;
-import org.hswebframework.web.authorization.define.AuthorizingContext;
-import org.hswebframework.web.crud.web.reactive.*;
-
-import java.util.List;
-
-@Getter
-@Setter
-public class DataAccessHandlerContext {
-
- private Class> entityType;
-
- private ReactiveRepository, Object> repository;
-
- private Authentication authentication;
-
- private List dimensions;
-
- private MethodInterceptorContext paramContext;
-
- private AuthorizeDefinition definition;
-
- public static DataAccessHandlerContext of(AuthorizingContext context, String type) {
- DataAccessHandlerContext requestContext = new DataAccessHandlerContext();
- Authentication authentication = context.getAuthentication();
- requestContext.setDimensions(authentication.getDimensions(type));
- requestContext.setAuthentication(context.getAuthentication());
- requestContext.setParamContext(context.getParamContext());
- requestContext.setDefinition(context.getDefinition());
- Object target = context.getParamContext().getTarget();
- Class entityType = ClassUtils.getGenericType(org.springframework.util.ClassUtils.getUserClass(target));
- if (entityType != Object.class) {
- requestContext.setEntityType(entityType);
- }
-
- if (target instanceof ReactiveQueryController) {
- requestContext.setRepository(((ReactiveQueryController) target).getRepository());
- } else if (target instanceof ReactiveSaveController) {
- requestContext.setRepository(((ReactiveSaveController) target).getRepository());
- } else if (target instanceof ReactiveDeleteController) {
- requestContext.setRepository(((ReactiveDeleteController) target).getRepository());
- } else if (target instanceof ReactiveServiceQueryController) {
- requestContext.setRepository(((ReactiveServiceQueryController) target).getService().getRepository());
- } else if (target instanceof ReactiveServiceSaveController) {
- requestContext.setRepository(((ReactiveServiceSaveController) target).getService().getRepository());
- } else if (target instanceof ReactiveServiceDeleteController) {
- requestContext.setRepository(((ReactiveServiceDeleteController) target).getService().getRepository());
- }
- // TODO: 2019-11-18 not reactive implements
-
- return requestContext;
- }
-}
diff --git a/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/handler/access/DefaultDataAccessController.java b/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/handler/access/DefaultDataAccessController.java
deleted file mode 100644
index 5c67912c5..000000000
--- a/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/handler/access/DefaultDataAccessController.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package org.hswebframework.web.authorization.basic.handler.access;
-
-import org.hswebframework.web.authorization.access.DataAccessConfig;
-import org.hswebframework.web.authorization.access.DataAccessController;
-import org.hswebframework.web.authorization.access.DataAccessHandler;
-import org.hswebframework.web.authorization.define.AuthorizingContext;
-
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * 默认的行级权限控制.通过获取DataAccessHandler进行实际处理
- *
- * @author zhouhao
- * @see DataAccessHandler
- * @since 3.0
- */
-public final class DefaultDataAccessController implements DataAccessController {
-
- private DataAccessController parent;
-
- private List handlers = new LinkedList<>();
-
- public DefaultDataAccessController() {
- this(null);
- }
-
- public DefaultDataAccessController(DataAccessController parent) {
- if (parent == this) {
- throw new UnsupportedOperationException();
- }
- this.parent = parent;
- addHandler(new FieldFilterDataAccessHandler())
- .addHandler(new DimensionDataAccessHandler());
- }
-
- @Override
- public boolean doAccess(DataAccessConfig access, AuthorizingContext context) {
- if (parent != null) {
- parent.doAccess(access, context);
- }
- return handlers.stream()
- .filter(handler -> handler.isSupport(access))
- .allMatch(handler -> handler.handle(access, context));
- }
-
- public DefaultDataAccessController addHandler(DataAccessHandler handler) {
- handlers.add(handler);
- return this;
- }
-
- public void setHandlers(List handlers) {
- this.handlers = handlers;
- }
-
- public List getHandlers() {
- return handlers;
- }
-}
diff --git a/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/handler/access/DimensionDataAccessHandler.java b/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/handler/access/DimensionDataAccessHandler.java
deleted file mode 100644
index 2c3638975..000000000
--- a/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/handler/access/DimensionDataAccessHandler.java
+++ /dev/null
@@ -1,440 +0,0 @@
-package org.hswebframework.web.authorization.basic.handler.access;
-
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.SneakyThrows;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.collections.CollectionUtils;
-import org.hswebframework.ezorm.core.param.Param;
-import org.hswebframework.ezorm.core.param.QueryParam;
-import org.hswebframework.web.api.crud.entity.Entity;
-import org.hswebframework.web.api.crud.entity.QueryParamEntity;
-import org.hswebframework.web.authorization.Authentication;
-import org.hswebframework.web.authorization.Dimension;
-import org.hswebframework.web.authorization.Permission;
-import org.hswebframework.web.authorization.access.DataAccessConfig;
-import org.hswebframework.web.authorization.access.DataAccessHandler;
-import org.hswebframework.web.authorization.annotation.DimensionDataAccess;
-import org.hswebframework.web.authorization.define.AuthorizingContext;
-import org.hswebframework.web.authorization.define.Phased;
-import org.hswebframework.web.authorization.exception.AccessDenyException;
-import org.hswebframework.web.authorization.simple.DimensionDataAccessConfig;
-import org.hswebframework.web.bean.FastBeanCopier;
-import org.reactivestreams.Publisher;
-import org.springframework.core.annotation.AnnotatedElementUtils;
-import org.springframework.util.ClassUtils;
-import org.springframework.util.StringUtils;
-import reactor.core.publisher.Flux;
-import reactor.core.publisher.Mono;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-@Slf4j
-public class DimensionDataAccessHandler implements DataAccessHandler {
- @Override
- public boolean isSupport(DataAccessConfig access) {
- return access instanceof DimensionDataAccessConfig;
- }
-
- @Override
- public boolean handle(DataAccessConfig access, AuthorizingContext context) {
- DimensionDataAccessConfig config = ((DimensionDataAccessConfig) access);
- DataAccessHandlerContext requestContext = DataAccessHandlerContext.of(context, config.getScopeType());
- if (!checkSupported(config, requestContext)) {
- return false;
- }
- switch (access.getAction()) {
- case Permission.ACTION_QUERY:
- case Permission.ACTION_GET:
- return doHandleQuery(config, requestContext);
- case Permission.ACTION_ADD:
- case Permission.ACTION_SAVE:
- case Permission.ACTION_UPDATE:
- return doHandleUpdate(config, requestContext);
- case Permission.ACTION_DELETE:
- return doHandleDelete(config, requestContext);
- default:
- if (log.isDebugEnabled()) {
- log.debug("data access [{}] not support for {}", config.getType().getId(), access.getAction());
- }
- return true;
- }
-
- }
-
- @SneakyThrows
- protected String getProperty(DimensionDataAccessConfig cfg,
- DataAccessHandlerContext ct) {
- return Optional.ofNullable(
- getMappingInfo(ct).get(cfg.getScopeType()))
- .map(MappingInfo::getProperty)
- .orElseGet(() -> {
- log.warn("{} not supported dimension data access", ct.getParamContext().getMethod());
- return null;
- });
- }
-
- protected boolean checkSupported(DimensionDataAccessConfig cfg, DataAccessHandlerContext ctx) {
- Authentication authentication = ctx.getAuthentication();
-
- /*
- DataAccessHelper.assert()
- */
- if (CollectionUtils.isEmpty(ctx.getDimensions())) {
- log.warn("user:[{}] dimension not setup", authentication.getUser().getId());
- return false;
- }
-
- if (!getMappingInfo(ctx).containsKey(cfg.getScopeType())) {
- log.warn("{} not supported dimension data access.see annotation: @DimensionDataAccess", ctx.getParamContext().getMethod());
- return false;
- }
-
- return true;
- }
-
- protected boolean doHandleDelete(DimensionDataAccessConfig cfg,
- DataAccessHandlerContext context) {
-
-
- // TODO: 2019-11-18
- return doHandleUpdate(cfg, context);
-
- }
-
- @SuppressWarnings("all")
- protected Object handleById(DimensionDataAccessConfig config,
- DataAccessHandlerContext context,
- MappingInfo mappingInfo,
- Object id) {
-
- if (id instanceof Param || id instanceof Entity) {
-
- applyQueryParam(config, context, id);
- return id;
- }
-
- List dimensions = context.getDimensions();
-
- Set