优化代码处理
This commit is contained in:
parent
33f2205f8e
commit
fe9c6a6dce
27
server/private.txt
Normal file
27
server/private.txt
Normal file
@ -0,0 +1,27 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEpQIBAAKCAQEA4jXKxEFsDsjng2nHppqCGTR1NQLfHJlGzc5hWalP/YgbJWIq
|
||||
dGXDy704Q2DuuoOe/t6KQcYI6/C7Ua9yumYpMoKZOA5b7gmh/k0SUfsCErKwzE93
|
||||
DIAnLbRoT/hkGJD1Dn7V7yTzYf2BjaFoY5ittZJ/UXM18TAqW7S1q0qCuv25Fb9N
|
||||
AEMh63EaX3N+DMW8rg51GBfRvtVfACbIyFo98PW2/wOQhppGWkxdzgJdJUwPhZ+F
|
||||
o9DZ18044hapYPNuZ31ordIGptYL6pB/0VKhkbDLk4oOnkhhWW0DmsTSFyhOiaQq
|
||||
tuxdrjPV7sqR1NokreZAtbUctVNezNBlYWoJTwIDAQABAoIBAEzioadw4QxpZp74
|
||||
3h4XV+6/MLMy5ahvxGwBIH98F68BitB6/BkR2amvB6eHE70bLXhNJUrTx4aCDPjn
|
||||
nCQUwx3i27b80mwmpAOuKHLq0LqQN51JyRnbmPVk4yuDLmpXIqOpoock1QBSTK1Z
|
||||
1gQ8CZa0U0fY09XFXDBNTI4KxkJNhPxAOGWhQoeXQ6qgAnhiOwEGhely2XRVCvUo
|
||||
tVhN04uMl+W5Vw3+X/2D41eA5eeDYi/kgi7n2cuZK/l8bV/arwpEm7ryxqwAV1RI
|
||||
M4cPwBTNoVf/h1tAGgmBCPGZ9RkSlNF+Rob7SaCvyKwqnwHH16041a2sEY8NZMsh
|
||||
e0REpgECgYEA8KqDEjkmlhpMPe6H5ykZgDTxFcqD9pHI+XmFROF39gNFE/auwqiK
|
||||
oVTMfvAlU58PKTc8P20gIdVdwN1CFcO21dXYD+I1kg/Tt6oYmnqzb4YUi/BFao01
|
||||
hAvPDr/K99VANluynnvPX+kzz+HD+Bi+XgHi3BCOMtsQAfKl5lBCJwECgYEA8J99
|
||||
gC8XBx+406OShRUm/zDpWHQmWtLHbO+2aih4ht6k+mV9B/txacoSdi/E6MnVrPRV
|
||||
nry3xGqd/wcRHDx6nKBcT4x/t28bNP76EH2OUpMom3f/4y/qMzFVKBIwJcaSEqOd
|
||||
xAZo6qVeEHa+abDQGlObAYyYUiLRLzhbZ50AAE8CgYEAiczIMeYBXw79urRaopRY
|
||||
4pztsdF8T/FXhuj60t7axkVHB1BG7nR8tDWOxdwRM1ku4CWdXJ/KNzUpcmX+EeI3
|
||||
TScdiLK4g8KGMnK1lbZOCbxXBW11AbaK/umYDFTrDY7QLo/ArZgsvDkWDqCxidv5
|
||||
HHCuCd183keqWcMrFL29swECgYEAhvpAsVY5CbL+wCHCwEqkTISIcSj+lvYkDnTN
|
||||
k/FN4wIj855Yq9CdxyUmhAu53ofSCCormVbtkw3nwTaan4dBlHjUL3916VU3Itxh
|
||||
NDzqSGHqZoPDFBM9wifLSCYjwh0ItdH4Xwzlb7MB+CRUHf+kTRBXJGBU1cZYJ6/q
|
||||
fk3wwTsCgYEA5rs2T67JO1R9vfmIQilB8SUn0bGlVo3Mrx3b3MqX4bDjjnsCyi8L
|
||||
VMOwzwA2aOJ4FJ50sDZVr1Yv4sygrQ0k8Qo4tKY4Z0qWDbiTxp/dFnH3WGjlR3uD
|
||||
HEhVf0kJ1LI9diDu5l6dyUL7Vzaj5R9icvVa+M3lNNiRjgZi9VVgeRw=
|
||||
-----END RSA PRIVATE KEY-----
|
9
server/public.txt
Normal file
9
server/public.txt
Normal file
@ -0,0 +1,9 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jXKxEFsDsjng2nHppqC
|
||||
GTR1NQLfHJlGzc5hWalP/YgbJWIqdGXDy704Q2DuuoOe/t6KQcYI6/C7Ua9yumYp
|
||||
MoKZOA5b7gmh/k0SUfsCErKwzE93DIAnLbRoT/hkGJD1Dn7V7yTzYf2BjaFoY5it
|
||||
tZJ/UXM18TAqW7S1q0qCuv25Fb9NAEMh63EaX3N+DMW8rg51GBfRvtVfACbIyFo9
|
||||
8PW2/wOQhppGWkxdzgJdJUwPhZ+Fo9DZ18044hapYPNuZ31ordIGptYL6pB/0VKh
|
||||
kbDLk4oOnkhhWW0DmsTSFyhOiaQqtuxdrjPV7sqR1NokreZAtbUctVNezNBlYWoJ
|
||||
TwIDAQAB
|
||||
-----END PUBLIC KEY-----
|
@ -48,11 +48,6 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- 集成redis-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>cn.zyjblogs.starter</groupId>-->
|
||||
<!-- <artifactId>zyjblogs-redis-spring-boot-starter</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>cn.zyjblogs.starter</groupId>
|
||||
<artifactId>zyjblogs-redis-spring-boot-starter</artifactId>
|
||||
@ -62,10 +57,6 @@
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter-test</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
@ -102,7 +93,6 @@
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>${maven-jar-plugin.version}</version>
|
||||
<configuration>
|
||||
<!--<outputDirectory>${jar_dir}</outputDirectory>-->
|
||||
<archive>
|
||||
<manifest>
|
||||
<!--启动类 such as: com.test.StartApp-->
|
||||
|
@ -86,14 +86,6 @@ public class AuthFilter implements GlobalFilter {
|
||||
if ("/user/login".equals(path)) {
|
||||
return chain.filter(exchange);
|
||||
}
|
||||
// if (!TokenUtil.checkToken(token)) {
|
||||
// return getErrorMono(response, ResponseStatus.UNAUTHORIZED, "invalid_token");
|
||||
// }
|
||||
/*boolean hasPermission = hasPermission(routeId, methodType, path);
|
||||
if (!hasPermission) {
|
||||
log.warn("无权限访问,path:{}", path);
|
||||
return getErrorMono(response, ResponseCode.FORBIDDEN, "no_access");
|
||||
}*/
|
||||
return chain.filter(build);
|
||||
}
|
||||
|
||||
@ -109,7 +101,7 @@ public class AuthFilter implements GlobalFilter {
|
||||
String jwt = token.substring(HttpHeaderConstant.BEARER_TYPE.length()).trim();
|
||||
try {
|
||||
JwtParsers jwtParsers = new JwtParsers(true);
|
||||
if (rsaKeyProperties.getEnable()) {
|
||||
if (Boolean.TRUE.equals(rsaKeyProperties.getEnable())) {
|
||||
String publicKeyStr = null;
|
||||
Object o = redisTemplateHandler.get(CommonRedisKeyConstant.REDIS_KEY_PUBLIC_RSA);
|
||||
if (Objects.isNull(o)) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.zyjblogs.server.user.handler;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.security.oauth2.common.OAuth2AccessToken;
|
||||
import org.springframework.security.oauth2.common.exceptions.InvalidRequestException;
|
||||
import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;
|
||||
@ -19,6 +20,10 @@ import java.util.*;
|
||||
* @author zhuyijun
|
||||
*/
|
||||
public class OauthRquestHander {
|
||||
|
||||
private OauthRquestHander() {
|
||||
|
||||
}
|
||||
/**
|
||||
* 处理
|
||||
*
|
||||
@ -27,6 +32,11 @@ public class OauthRquestHander {
|
||||
* @return
|
||||
*/
|
||||
public static AuthorizationRequest createAuthorizationRequest(Map<String, String> authorizationParameters, ClientDetails clientDetails) {
|
||||
return getAuthorizationRequest(authorizationParameters, clientDetails);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static AuthorizationRequest getAuthorizationRequest(Map<String, String> authorizationParameters, ClientDetails clientDetails) {
|
||||
String clientId = authorizationParameters.get(OAuth2Utils.CLIENT_ID);
|
||||
String state = authorizationParameters.get(OAuth2Utils.STATE);
|
||||
String redirectUri = authorizationParameters.get(OAuth2Utils.REDIRECT_URI);
|
||||
@ -45,8 +55,8 @@ public class OauthRquestHander {
|
||||
|
||||
public static String appendAccessToken(AuthorizationRequest authorizationRequest, OAuth2AccessToken accessToken) {
|
||||
|
||||
Map<String, Object> vars = new LinkedHashMap<String, Object>();
|
||||
Map<String, String> keys = new HashMap<String, String>();
|
||||
Map<String, Object> vars = new LinkedHashMap<>();
|
||||
Map<String, String> keys = new HashMap<>();
|
||||
|
||||
if (accessToken == null) {
|
||||
throw new InvalidRequestException("An implicit grant could not be made");
|
||||
@ -143,7 +153,7 @@ public class OauthRquestHander {
|
||||
if (authorizationCode == null) {
|
||||
throw new IllegalStateException("No authorization code found in the current request scope.");
|
||||
} else {
|
||||
Map<String, String> query = new LinkedHashMap();
|
||||
Map<String, String> query = new LinkedHashMap<>();
|
||||
query.put("code", authorizationCode);
|
||||
String state = authorizationRequest.getState();
|
||||
if (state != null) {
|
||||
@ -156,21 +166,14 @@ public class OauthRquestHander {
|
||||
|
||||
public static String getUnsuccessfulRedirect(AuthorizationRequest authorizationRequest, OAuth2Exception failure, boolean fragment) {
|
||||
if (authorizationRequest != null && authorizationRequest.getRedirectUri() != null) {
|
||||
Map<String, String> query = new LinkedHashMap();
|
||||
Map<String, String> query = new LinkedHashMap<>();
|
||||
query.put("error", failure.getOAuth2ErrorCode());
|
||||
query.put("error_description", failure.getMessage());
|
||||
if (authorizationRequest.getState() != null) {
|
||||
query.put("state", authorizationRequest.getState());
|
||||
}
|
||||
|
||||
if (failure.getAdditionalInformation() != null) {
|
||||
Iterator var5 = failure.getAdditionalInformation().entrySet().iterator();
|
||||
|
||||
while (var5.hasNext()) {
|
||||
Map.Entry<String, String> additionalInfo = (Map.Entry) var5.next();
|
||||
query.put(additionalInfo.getKey(), additionalInfo.getValue());
|
||||
}
|
||||
}
|
||||
getFailFedirect(failure, query);
|
||||
|
||||
return append(authorizationRequest.getRedirectUri(), query, fragment);
|
||||
} else {
|
||||
@ -180,19 +183,23 @@ public class OauthRquestHander {
|
||||
|
||||
public static String getUnsuccessfulRedirect(String redirectUri, OAuth2Exception failure, boolean fragment) {
|
||||
if (StringUtils.hasLength(redirectUri)) {
|
||||
Map<String, String> query = new LinkedHashMap();
|
||||
Map<String, String> query = new LinkedHashMap<>();
|
||||
query.put("error", failure.getOAuth2ErrorCode());
|
||||
query.put("error_description", failure.getMessage());
|
||||
if (failure.getAdditionalInformation() != null) {
|
||||
Iterator var5 = failure.getAdditionalInformation().entrySet().iterator();
|
||||
while (var5.hasNext()) {
|
||||
Map.Entry<String, String> additionalInfo = (Map.Entry) var5.next();
|
||||
query.put(additionalInfo.getKey(), additionalInfo.getValue());
|
||||
}
|
||||
}
|
||||
getFailFedirect(failure, query);
|
||||
return append(redirectUri, query, fragment);
|
||||
} else {
|
||||
throw new UnapprovedClientAuthenticationException("Authorization failure, and no redirect URI.", failure);
|
||||
}
|
||||
}
|
||||
|
||||
public static void getFailFedirect(OAuth2Exception failure, Map<String, String> query) {
|
||||
if (failure.getAdditionalInformation() != null) {
|
||||
Iterator<Map.Entry<String, String>> var5 = failure.getAdditionalInformation().entrySet().iterator();
|
||||
while (var5.hasNext()) {
|
||||
Map.Entry<String, String> additionalInfo = var5.next();
|
||||
query.put(additionalInfo.getKey(), additionalInfo.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,8 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static cn.zyjblogs.server.user.handler.OauthRquestHander.getAuthorizationRequest;
|
||||
|
||||
/**
|
||||
* @author zhuyijun
|
||||
*/
|
||||
@ -180,20 +182,7 @@ public class AuthServiceImpl implements AuthService {
|
||||
* @return
|
||||
*/
|
||||
public AuthorizationRequest createAuthorizationRequest(Map<String, String> authorizationParameters, ClientDetails clientDetails) {
|
||||
String clientId = authorizationParameters.get(OAuth2Utils.CLIENT_ID);
|
||||
String state = authorizationParameters.get(OAuth2Utils.STATE);
|
||||
String redirectUri = authorizationParameters.get(OAuth2Utils.REDIRECT_URI);
|
||||
Set<String> responseTypes = OAuth2Utils.parseParameterList(authorizationParameters
|
||||
.get(OAuth2Utils.RESPONSE_TYPE));
|
||||
Set<String> scopes = OAuth2Utils.parseParameterList(authorizationParameters.get(OAuth2Utils.SCOPE));
|
||||
if (CollectionUtils.isEmpty(scopes)) {
|
||||
scopes = clientDetails.getScope();
|
||||
}
|
||||
AuthorizationRequest request = new AuthorizationRequest(authorizationParameters,
|
||||
Collections.emptyMap(), clientId, scopes, null, null, false, state, redirectUri,
|
||||
responseTypes);
|
||||
request.setResourceIdsAndAuthoritiesFromClientDetails(clientDetails);
|
||||
return request;
|
||||
return getAuthorizationRequest(authorizationParameters, clientDetails);
|
||||
|
||||
}
|
||||
|
||||
|
@ -2,15 +2,10 @@ package cn.zyjblogs.sms.provider;
|
||||
|
||||
|
||||
import cn.zyjblogs.sms.common.SmsRequest;
|
||||
import cn.zyjblogs.sms.common.SmsResponse;
|
||||
import cn.zyjblogs.sms.task.constant.ProviderType;
|
||||
import cn.zyjblogs.sms.task.constant.TaskStatus;
|
||||
import cn.zyjblogs.sms.task.dto.TaskResultDTO;
|
||||
import cn.zyjblogs.starter.common.utils.collections.CollectionUtils;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author zhuyijun
|
||||
@ -18,7 +13,7 @@ import java.util.List;
|
||||
public abstract class AbstractSmsGranter implements SmsGranter {
|
||||
private final ProviderType PROVIDER_TYPE;
|
||||
|
||||
public AbstractSmsGranter(ProviderType providerType) {
|
||||
protected AbstractSmsGranter(ProviderType providerType) {
|
||||
this.PROVIDER_TYPE = providerType;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user