Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Pig
提交
fed4d460
P
Pig
项目概览
int
/
Pig
上一次同步 12 个月
通知
8
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Pig
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fed4d460
编写于
3月 21, 2019
作者:
L
lishangbu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
♻
Refactoring code.use "@SneakyThrows" annotation
上级
c8ff9b70
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
49 addition
and
31 deletion
+49
-31
pig-auth/src/main/java/com/pig4cloud/pig/auth/config/AuthorizationServerConfig.java
.../pig4cloud/pig/auth/config/AuthorizationServerConfig.java
+3
-1
pig-auth/src/main/java/com/pig4cloud/pig/auth/config/WebSecurityConfigurer.java
.../com/pig4cloud/pig/auth/config/WebSecurityConfigurer.java
+5
-2
pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/datascope/DataScopeInterceptor.java
...cloud/pig/common/core/datascope/DataScopeInterceptor.java
+3
-1
pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/util/SpringContextHolder.java
...m/pig4cloud/pig/common/core/util/SpringContextHolder.java
+3
-1
pig-common/pig-common-log/src/main/java/com/pig4cloud/pig/common/log/aspect/SysLogAspect.java
...ava/com/pig4cloud/pig/common/log/aspect/SysLogAspect.java
+3
-1
pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/component/PigAccessDeniedHandler.java
...pig/common/security/component/PigAccessDeniedHandler.java
+3
-5
pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/component/PigResourceServerAutoConfiguration.java
...ecurity/component/PigResourceServerAutoConfiguration.java
+3
-3
pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/component/PigWebResponseExceptionTranslator.java
...security/component/PigWebResponseExceptionTranslator.java
+3
-1
pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/component/ResourceAuthExceptionEntryPoint.java
...n/security/component/ResourceAuthExceptionEntryPoint.java
+3
-2
pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/service/PigClientDetailsService.java
.../pig/common/security/service/PigClientDetailsService.java
+3
-2
pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/service/PigUserDetailsServiceImpl.java
...ig/common/security/service/PigUserDetailsServiceImpl.java
+3
-2
pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/util/AuthUtils.java
...ava/com/pig4cloud/pig/common/security/util/AuthUtils.java
+5
-7
pig-eureka/src/main/java/com/pig4cloud/pig/eureka/security/WebSecurityConfig.java
.../com/pig4cloud/pig/eureka/security/WebSecurityConfig.java
+3
-1
pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/SysGeneratorController.java
...4cloud/pig/codegen/controller/SysGeneratorController.java
+3
-1
pig-visual/pig-monitor/src/main/java/com/pig4cloud/pig/monitor/config/WebSecurityConfigurer.java
...m/pig4cloud/pig/monitor/config/WebSecurityConfigurer.java
+3
-1
未找到文件。
pig-auth/src/main/java/com/pig4cloud/pig/auth/config/AuthorizationServerConfig.java
浏览文件 @
fed4d460
...
...
@@ -20,6 +20,7 @@ import com.pig4cloud.pig.common.core.constant.SecurityConstants;
import
com.pig4cloud.pig.common.security.component.PigWebResponseExceptionTranslator
;
import
com.pig4cloud.pig.common.security.service.PigClientDetailsService
;
import
lombok.AllArgsConstructor
;
import
lombok.SneakyThrows
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.redis.connection.RedisConnectionFactory
;
...
...
@@ -55,7 +56,8 @@ public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdap
private
final
RedisConnectionFactory
redisConnectionFactory
;
@Override
public
void
configure
(
ClientDetailsServiceConfigurer
clients
)
throws
Exception
{
@SneakyThrows
public
void
configure
(
ClientDetailsServiceConfigurer
clients
)
{
PigClientDetailsService
clientDetailsService
=
new
PigClientDetailsService
(
dataSource
);
clientDetailsService
.
setSelectClientDetailsSql
(
SecurityConstants
.
DEFAULT_SELECT_STATEMENT
);
clientDetailsService
.
setFindClientDetailsSql
(
SecurityConstants
.
DEFAULT_FIND_STATEMENT
);
...
...
pig-auth/src/main/java/com/pig4cloud/pig/auth/config/WebSecurityConfigurer.java
浏览文件 @
fed4d460
...
...
@@ -18,6 +18,7 @@ package com.pig4cloud.pig.auth.config;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.pig4cloud.pig.common.security.handler.MobileLoginSuccessHandler
;
import
lombok.SneakyThrows
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
...
...
@@ -51,7 +52,8 @@ public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter {
private
AuthorizationServerTokenServices
defaultAuthorizationServerTokenServices
;
@Override
protected
void
configure
(
HttpSecurity
http
)
throws
Exception
{
@SneakyThrows
protected
void
configure
(
HttpSecurity
http
)
{
http
.
authorizeRequests
()
.
antMatchers
(
...
...
@@ -63,7 +65,8 @@ public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter {
@Bean
@Override
public
AuthenticationManager
authenticationManagerBean
()
throws
Exception
{
@SneakyThrows
public
AuthenticationManager
authenticationManagerBean
()
{
return
super
.
authenticationManagerBean
();
}
...
...
pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/datascope/DataScopeInterceptor.java
浏览文件 @
fed4d460
...
...
@@ -20,6 +20,7 @@ import cn.hutool.core.collection.CollectionUtil;
import
cn.hutool.core.util.StrUtil
;
import
com.baomidou.mybatisplus.core.toolkit.PluginUtils
;
import
com.baomidou.mybatisplus.extension.handlers.AbstractSqlParserHandler
;
import
lombok.SneakyThrows
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.ibatis.executor.statement.StatementHandler
;
import
org.apache.ibatis.mapping.BoundSql
;
...
...
@@ -46,7 +47,8 @@ import java.util.Properties;
public
class
DataScopeInterceptor
extends
AbstractSqlParserHandler
implements
Interceptor
{
@Override
public
Object
intercept
(
Invocation
invocation
)
throws
Throwable
{
@SneakyThrows
public
Object
intercept
(
Invocation
invocation
)
{
StatementHandler
statementHandler
=
(
StatementHandler
)
PluginUtils
.
realTarget
(
invocation
.
getTarget
());
MetaObject
metaObject
=
SystemMetaObject
.
forObject
(
statementHandler
);
this
.
sqlParser
(
metaObject
);
...
...
pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/util/SpringContextHolder.java
浏览文件 @
fed4d460
...
...
@@ -16,6 +16,7 @@
package
com.pig4cloud.pig.common.core.util
;
import
lombok.SneakyThrows
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.DisposableBean
;
import
org.springframework.context.ApplicationContext
;
...
...
@@ -92,7 +93,8 @@ public class SpringContextHolder implements ApplicationContextAware, DisposableB
* 实现DisposableBean接口, 在Context关闭时清理静态变量.
*/
@Override
public
void
destroy
()
throws
Exception
{
@SneakyThrows
public
void
destroy
()
{
SpringContextHolder
.
clearHolder
();
}
...
...
pig-common/pig-common-log/src/main/java/com/pig4cloud/pig/common/log/aspect/SysLogAspect.java
浏览文件 @
fed4d460
...
...
@@ -20,6 +20,7 @@ import com.pig4cloud.pig.common.core.util.SpringContextHolder;
import
com.pig4cloud.pig.common.log.annotation.SysLog
;
import
com.pig4cloud.pig.common.log.event.SysLogEvent
;
import
com.pig4cloud.pig.common.log.util.SysLogUtils
;
import
lombok.SneakyThrows
;
import
lombok.extern.slf4j.Slf4j
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.annotation.Around
;
...
...
@@ -35,7 +36,8 @@ import org.aspectj.lang.annotation.Aspect;
public
class
SysLogAspect
{
@Around
(
"@annotation(sysLog)"
)
public
Object
around
(
ProceedingJoinPoint
point
,
SysLog
sysLog
)
throws
Throwable
{
@SneakyThrows
public
Object
around
(
ProceedingJoinPoint
point
,
SysLog
sysLog
)
{
String
strClassName
=
point
.
getTarget
().
getClass
().
getName
();
String
strMethodName
=
point
.
getSignature
().
getName
();
log
.
debug
(
"[类名]:{},[方法]:{}"
,
strClassName
,
strMethodName
);
...
...
pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/component/PigAccessDeniedHandler.java
浏览文件 @
fed4d460
...
...
@@ -27,15 +27,14 @@ import com.pig4cloud.pig.common.core.constant.CommonConstants;
import
com.pig4cloud.pig.common.core.exception.PigDeniedException
;
import
com.pig4cloud.pig.common.core.util.R
;
import
lombok.AllArgsConstructor
;
import
lombok.SneakyThrows
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.security.access.AccessDeniedException
;
import
org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler
;
import
org.springframework.stereotype.Component
;
import
javax.servlet.ServletException
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
/**
...
...
@@ -55,11 +54,10 @@ public class PigAccessDeniedHandler extends OAuth2AccessDeniedHandler {
* @param request request
* @param response response
* @param authException authException
* @throws IOException IOException
* @throws ServletException ServletException
*/
@Override
public
void
handle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
AccessDeniedException
authException
)
throws
IOException
,
ServletException
{
@SneakyThrows
public
void
handle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
AccessDeniedException
authException
)
{
log
.
info
(
"授权失败,禁止访问 {}"
,
request
.
getRequestURI
());
response
.
setCharacterEncoding
(
CommonConstants
.
UTF8
);
response
.
setContentType
(
CommonConstants
.
CONTENT_TYPE
);
...
...
pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/component/PigResourceServerAutoConfiguration.java
浏览文件 @
fed4d460
...
...
@@ -16,6 +16,7 @@
package
com.pig4cloud.pig.common.security.component
;
import
lombok.SneakyThrows
;
import
org.springframework.cloud.client.loadbalancer.LoadBalanced
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.ComponentScan
;
...
...
@@ -25,8 +26,6 @@ import org.springframework.http.client.ClientHttpResponse;
import
org.springframework.web.client.DefaultResponseErrorHandler
;
import
org.springframework.web.client.RestTemplate
;
import
java.io.IOException
;
/**
* @author lengleng
* @date 2019/03/08
...
...
@@ -40,7 +39,8 @@ public class PigResourceServerAutoConfiguration {
RestTemplate
restTemplate
=
new
RestTemplate
();
restTemplate
.
setErrorHandler
(
new
DefaultResponseErrorHandler
()
{
@Override
public
void
handleError
(
ClientHttpResponse
response
)
throws
IOException
{
@SneakyThrows
public
void
handleError
(
ClientHttpResponse
response
)
{
if
(
response
.
getRawStatusCode
()
!=
HttpStatus
.
BAD_REQUEST
.
value
())
{
super
.
handleError
(
response
);
}
...
...
pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/component/PigWebResponseExceptionTranslator.java
浏览文件 @
fed4d460
...
...
@@ -17,6 +17,7 @@
package
com.pig4cloud.pig.common.security.component
;
import
com.pig4cloud.pig.common.security.exception.*
;
import
lombok.SneakyThrows
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpStatus
;
...
...
@@ -44,7 +45,8 @@ public class PigWebResponseExceptionTranslator implements WebResponseExceptionTr
private
ThrowableAnalyzer
throwableAnalyzer
=
new
DefaultThrowableAnalyzer
();
@Override
public
ResponseEntity
<
OAuth2Exception
>
translate
(
Exception
e
)
throws
Exception
{
@SneakyThrows
public
ResponseEntity
<
OAuth2Exception
>
translate
(
Exception
e
)
{
// Try to extract a SpringSecurityException from the stacktrace
Throwable
[]
causeChain
=
throwableAnalyzer
.
determineCauseChain
(
e
);
...
...
pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/component/ResourceAuthExceptionEntryPoint.java
浏览文件 @
fed4d460
...
...
@@ -21,6 +21,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import
com.pig4cloud.pig.common.core.constant.CommonConstants
;
import
com.pig4cloud.pig.common.core.util.R
;
import
lombok.AllArgsConstructor
;
import
lombok.SneakyThrows
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.security.core.AuthenticationException
;
import
org.springframework.security.web.AuthenticationEntryPoint
;
...
...
@@ -28,7 +29,6 @@ import org.springframework.stereotype.Component;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
/**
...
...
@@ -44,8 +44,9 @@ public class ResourceAuthExceptionEntryPoint implements AuthenticationEntryPoint
private
final
ObjectMapper
objectMapper
;
@Override
@SneakyThrows
public
void
commence
(
HttpServletRequest
request
,
HttpServletResponse
response
,
AuthenticationException
authException
)
throws
IOException
{
AuthenticationException
authException
)
{
response
.
setCharacterEncoding
(
CommonConstants
.
UTF8
);
response
.
setContentType
(
CommonConstants
.
CONTENT_TYPE
);
R
<
String
>
result
=
new
R
<>();
...
...
pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/service/PigClientDetailsService.java
浏览文件 @
fed4d460
...
...
@@ -17,6 +17,7 @@
package
com.pig4cloud.pig.common.security.service
;
import
com.pig4cloud.pig.common.core.constant.SecurityConstants
;
import
lombok.SneakyThrows
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.security.oauth2.common.exceptions.InvalidClientException
;
import
org.springframework.security.oauth2.provider.ClientDetails
;
...
...
@@ -41,11 +42,11 @@ public class PigClientDetailsService extends JdbcClientDetailsService {
*
* @param clientId
* @return
* @throws InvalidClientException
*/
@Override
@SneakyThrows
@Cacheable
(
value
=
SecurityConstants
.
CLIENT_DETAILS_KEY
,
key
=
"#clientId"
,
unless
=
"#result == null"
)
public
ClientDetails
loadClientByClientId
(
String
clientId
)
throws
InvalidClientException
{
public
ClientDetails
loadClientByClientId
(
String
clientId
)
{
return
super
.
loadClientByClientId
(
clientId
);
}
}
pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/service/PigUserDetailsServiceImpl.java
浏览文件 @
fed4d460
...
...
@@ -25,6 +25,7 @@ import com.pig4cloud.pig.common.core.constant.CommonConstants;
import
com.pig4cloud.pig.common.core.constant.SecurityConstants
;
import
com.pig4cloud.pig.common.core.util.R
;
import
lombok.AllArgsConstructor
;
import
lombok.SneakyThrows
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.cache.Cache
;
import
org.springframework.cache.CacheManager
;
...
...
@@ -57,10 +58,10 @@ public class PigUserDetailsServiceImpl implements UserDetailsService {
*
* @param username 用户名
* @return
* @throws UsernameNotFoundException
*/
@Override
public
UserDetails
loadUserByUsername
(
String
username
)
throws
UsernameNotFoundException
{
@SneakyThrows
public
UserDetails
loadUserByUsername
(
String
username
)
{
Cache
cache
=
cacheManager
.
getCache
(
"user_details"
);
if
(
cache
!=
null
&&
cache
.
get
(
username
)
!=
null
)
{
return
(
PigUser
)
cache
.
get
(
username
).
get
();
...
...
pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/util/AuthUtils.java
浏览文件 @
fed4d460
...
...
@@ -18,6 +18,7 @@ package com.pig4cloud.pig.common.security.util;
import
cn.hutool.core.codec.Base64
;
import
cn.hutool.core.util.CharsetUtil
;
import
lombok.SneakyThrows
;
import
lombok.experimental.UtilityClass
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.http.HttpHeaders
;
...
...
@@ -39,11 +40,9 @@ public class AuthUtils {
* 从header 请求中的clientId/clientsecect
*
* @param header header中的参数
* @throws RuntimeException if the Basic header is not present or is not valid
* Base64
*/
public
String
[]
extractAndDecodeHeader
(
String
header
)
throws
IOException
{
@SneakyThrows
public
String
[]
extractAndDecodeHeader
(
String
header
)
{
byte
[]
base64Token
=
header
.
substring
(
6
).
getBytes
(
"UTF-8"
);
byte
[]
decoded
;
...
...
@@ -69,10 +68,9 @@ public class AuthUtils {
*
* @param request
* @return
* @throws IOException
*/
public
String
[]
extractAndDecodeHeader
(
HttpServletRequest
request
)
throws
IOException
{
@SneakyThrows
public
String
[]
extractAndDecodeHeader
(
HttpServletRequest
request
)
{
String
header
=
request
.
getHeader
(
HttpHeaders
.
AUTHORIZATION
);
if
(
header
==
null
||
!
header
.
startsWith
(
BASIC_
))
{
...
...
pig-eureka/src/main/java/com/pig4cloud/pig/eureka/security/WebSecurityConfig.java
浏览文件 @
fed4d460
...
...
@@ -21,6 +21,7 @@ package com.pig4cloud.pig.eureka.security;
* @date 2019/2/1
*/
import
lombok.SneakyThrows
;
import
org.springframework.security.config.annotation.web.builders.HttpSecurity
;
import
org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
;
import
org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
;
...
...
@@ -28,7 +29,8 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur
@EnableWebSecurity
public
class
WebSecurityConfig
extends
WebSecurityConfigurerAdapter
{
@Override
protected
void
configure
(
HttpSecurity
http
)
throws
Exception
{
@SneakyThrows
protected
void
configure
(
HttpSecurity
http
)
{
http
.
csrf
().
disable
()
.
authorizeRequests
()
.
antMatchers
(
"/actuator/**"
).
permitAll
()
...
...
pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/SysGeneratorController.java
浏览文件 @
fed4d460
...
...
@@ -23,6 +23,7 @@ import com.pig4cloud.pig.codegen.entity.GenConfig;
import
com.pig4cloud.pig.codegen.service.SysGeneratorService
;
import
com.pig4cloud.pig.common.core.util.R
;
import
lombok.AllArgsConstructor
;
import
lombok.SneakyThrows
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletResponse
;
...
...
@@ -55,7 +56,8 @@ public class SysGeneratorController {
* 生成代码
*/
@PostMapping
(
"/code"
)
public
void
code
(
@RequestBody
GenConfig
genConfig
,
HttpServletResponse
response
)
throws
IOException
{
@SneakyThrows
public
void
code
(
@RequestBody
GenConfig
genConfig
,
HttpServletResponse
response
)
{
byte
[]
data
=
sysGeneratorService
.
generatorCode
(
genConfig
);
response
.
reset
();
...
...
pig-visual/pig-monitor/src/main/java/com/pig4cloud/pig/monitor/config/WebSecurityConfigurer.java
浏览文件 @
fed4d460
...
...
@@ -17,6 +17,7 @@
package
com.pig4cloud.pig.monitor.config
;
import
de.codecentric.boot.admin.server.config.AdminServerProperties
;
import
lombok.SneakyThrows
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.security.config.annotation.web.builders.HttpSecurity
;
import
org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
;
...
...
@@ -37,7 +38,8 @@ public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter {
}
@Override
protected
void
configure
(
HttpSecurity
http
)
throws
Exception
{
@SneakyThrows
protected
void
configure
(
HttpSecurity
http
)
{
// @formatter:off
SavedRequestAwareAuthenticationSuccessHandler
successHandler
=
new
SavedRequestAwareAuthenticationSuccessHandler
();
successHandler
.
setTargetUrlParameter
(
"redirectTo"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录