mirror of
https://github.com/hs-web/hsweb-framework.git
synced 2026-05-22 17:07:12 +08:00
sonar bug fix
This commit is contained in:
@@ -44,16 +44,17 @@ public class DefaultAopMethodAuthorizeDefinitionParser implements AopMethodAutho
|
||||
CacheKey key = buildCacheKey(paramContext);
|
||||
|
||||
AuthorizeDefinition definition = cache.get(key);
|
||||
if (definition != null) return definition instanceof EmptyAuthorizeDefinition ? null : definition;
|
||||
if (definition != null && (definition instanceof EmptyAuthorizeDefinition)) {
|
||||
return null;
|
||||
}
|
||||
//使用自定义
|
||||
if (!CollectionUtils.isEmpty(parserCustomers)) {
|
||||
definition = parserCustomers.stream()
|
||||
.map(customer -> customer.parse(paramContext))
|
||||
.filter(Objects::nonNull)
|
||||
.findAny().orElse(null);
|
||||
if (definition != null) {
|
||||
if(definition instanceof EmptyAuthorizeDefinition)return null;
|
||||
return definition;
|
||||
if (definition == null || definition instanceof EmptyAuthorizeDefinition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package org.hswebframework.web.authorization.basic.configuration;
|
||||
|
||||
import org.hswebframework.web.authorization.access.DataAccessController;
|
||||
import org.hswebframework.web.authorization.basic.aop.AopAuthorizingController;
|
||||
import org.hswebframework.web.authorization.basic.aop.AopMethodAuthorizeDefinitionParser;
|
||||
import org.hswebframework.web.authorization.basic.aop.DefaultAopMethodAuthorizeDefinitionParser;
|
||||
import org.hswebframework.web.authorization.basic.handler.AuthorizingHandler;
|
||||
import org.hswebframework.web.authorization.basic.handler.DefaultAuthorizingHandler;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
@@ -10,7 +10,6 @@ import org.hswebframework.web.authorization.basic.handler.access.DefaultDataAcce
|
||||
import org.hswebframework.web.authorization.basic.web.*;
|
||||
import org.hswebframework.web.authorization.token.MemoryUserTokenManager;
|
||||
import org.hswebframework.web.authorization.token.UserTokenManager;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
@@ -24,9 +23,10 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* TODO 完成注释
|
||||
* 权限控制自动配置类
|
||||
*
|
||||
* @author zhouhao
|
||||
* @since 3.0
|
||||
*/
|
||||
@Configuration
|
||||
public class AuthorizingHandlerAutoConfiguration {
|
||||
@@ -53,7 +53,7 @@ public class AuthorizingHandlerAutoConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SessionIdUserTokenGenerator sessionIdUserTokenGenerator(){
|
||||
public SessionIdUserTokenGenerator sessionIdUserTokenGenerator() {
|
||||
return new SessionIdUserTokenGenerator();
|
||||
}
|
||||
|
||||
@@ -93,12 +93,12 @@ public class AuthorizingHandlerAutoConfiguration {
|
||||
private DefaultDataAccessController defaultDataAccessController;
|
||||
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) {
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) {
|
||||
if (bean instanceof DataAccessHandler) {
|
||||
defaultDataAccessController.addHandler(((DataAccessHandler) bean));
|
||||
}
|
||||
|
||||
@@ -14,7 +14,10 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Created by zhouhao on 2017/8/13.
|
||||
* 默认权限权限定义
|
||||
*
|
||||
* @author zhouhao
|
||||
* @since 3.0
|
||||
*/
|
||||
public class DefaultBasicAuthorizeDefinition implements AuthorizeDefinition {
|
||||
private boolean dataAccessControl;
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.springframework.stereotype.Component;
|
||||
public class ApplicationContextHolder {
|
||||
private static ApplicationContext context;
|
||||
|
||||
public static final ApplicationContext get() {
|
||||
public static ApplicationContext get() {
|
||||
if (null == context) {
|
||||
throw new UnsupportedOperationException("ApplicationContext not ready!");
|
||||
}
|
||||
@@ -22,7 +22,8 @@ public class ApplicationContextHolder {
|
||||
|
||||
@Autowired
|
||||
public void setContext(ApplicationContext context) {
|
||||
if (null == ApplicationContextHolder.context)
|
||||
if (null == ApplicationContextHolder.context) {
|
||||
ApplicationContextHolder.context = context;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,5 +302,8 @@ public class SpringBootExample
|
||||
relationInfo.setRelationId("leader");
|
||||
relationInfoService.insert(relationInfo);
|
||||
|
||||
// relationInfoService
|
||||
// .getRelations("person","王伟")
|
||||
// .findRev("直属上级");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.List;
|
||||
@RequestMapping("${hsweb.web.mappings.dynamic/form/column:dynamic/form/column}")
|
||||
@Authorize(permission = "dynamic-form")
|
||||
@AccessLogger("动态表单")
|
||||
@Api(tags = "dynamic-form", description = "动态表单")
|
||||
@Api(tags = "dynamic-form", value = "动态表单")
|
||||
public class DynamicFormColumnController {
|
||||
|
||||
private DynamicFormService dynamicFormService;
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.util.Objects;
|
||||
@RequestMapping("${hsweb.web.mappings.dynamic/form:dynamic/form}")
|
||||
@Authorize(permission = "dynamic-form")
|
||||
@AccessLogger("动态表单")
|
||||
@Api(tags = "dynamic-form", description = "动态表单")
|
||||
@Api(tags = "dynamic-form", value = "动态表单")
|
||||
public class DynamicFormController implements SimpleGenericEntityController<DynamicFormEntity, String, QueryParamEntity> {
|
||||
|
||||
private DynamicFormService dynamicFormService;
|
||||
|
||||
@@ -51,6 +51,7 @@ import static java.util.Optional.ofNullable;
|
||||
@RequestMapping("${hsweb.web.mappings.file:file}")
|
||||
@Authorize(permission = "file")
|
||||
@AccessLogger("文件")
|
||||
@SuppressWarnings("all")
|
||||
public class FileController {
|
||||
|
||||
private FileService fileService;
|
||||
@@ -87,6 +88,7 @@ public class FileController {
|
||||
@RequestParam("data") String dataStr,
|
||||
HttpServletResponse response) throws IOException {
|
||||
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
||||
|
||||
response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(name, "utf-8"));
|
||||
ZIPWriter writer = Compress.zip();
|
||||
List<Map<String, String>> data = (List) JSON.parseArray(dataStr, Map.class);
|
||||
@@ -245,7 +247,7 @@ public class FileController {
|
||||
if (params.get("charset") == null) {
|
||||
try {
|
||||
fileName = new String(file.getOriginalFilename().getBytes("ISO-8859-1"), "utf-8");
|
||||
} catch (UnsupportedEncodingException ignore) {
|
||||
} catch (@SuppressWarnings("all")UnsupportedEncodingException ignore) {
|
||||
}
|
||||
}
|
||||
if (logger.isInfoEnabled())
|
||||
|
||||
@@ -366,7 +366,9 @@ public class SimplePersonService extends GenericEntityService<PersonEntity, Stri
|
||||
@Cacheable(cacheNames = "person", key = "'auth:user-id'+#userId")
|
||||
public PersonnelAuthorization getPersonnelAuthorizationByUserId(String userId) {
|
||||
PersonEntity entity = createQuery().where(PersonEntity.userId, userId).single();
|
||||
assertNotNull(entity);
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
return getPersonnelAuthorizationByPersonId(entity.getId());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user