lixueqiang 2 лет назад
Родитель
Сommit
ad3c17e09d

+ 1 - 0
kxs-common/kxs-common-core/src/main/java/com/kxs/common/core/constant/enums/ErrorTypeEnum.java

@@ -26,6 +26,7 @@ public enum ErrorTypeEnum {
     PHONE_NOT_FOUND(-1, "手机号不存在"),
     PHONE_NOT_FOUND(-1, "手机号不存在"),
     VERIFICATION_CODE_IS_ILLEGAL(-1, "验证码不合法"),
     VERIFICATION_CODE_IS_ILLEGAL(-1, "验证码不合法"),
     VERIFICATION_CODE_IS_EMPTY(-1, "验证码不能为空"),
     VERIFICATION_CODE_IS_EMPTY(-1, "验证码不能为空"),
+    UNAUTHORIZED_CLIENT(-1, "客户端不允许登陆"),
 
 
 
 
 
 

+ 2 - 1
kxs-common/kxs-common-security/src/main/java/com/kxs/common/security/support/password/OAuth2ResourceOwnerPasswordAuthenticationProvider.java

@@ -1,5 +1,6 @@
 package com.kxs.common.security.support.password;
 package com.kxs.common.security.support.password;
 
 
+import com.kxs.common.core.constant.enums.ErrorTypeEnum;
 import com.kxs.common.security.support.base.OAuth2ResourceOwnerBaseAuthenticationProvider;
 import com.kxs.common.security.support.base.OAuth2ResourceOwnerBaseAuthenticationProvider;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.Logger;
@@ -57,7 +58,7 @@ public class OAuth2ResourceOwnerPasswordAuthenticationProvider
 	public void checkClient(RegisteredClient registeredClient) {
 	public void checkClient(RegisteredClient registeredClient) {
 		assert registeredClient != null;
 		assert registeredClient != null;
 		if (!registeredClient.getAuthorizationGrantTypes().contains(AuthorizationGrantType.JWT_BEARER)) {
 		if (!registeredClient.getAuthorizationGrantTypes().contains(AuthorizationGrantType.JWT_BEARER)) {
-			throw new OAuth2AuthenticationException(OAuth2ErrorCodes.UNAUTHORIZED_CLIENT);
+			throw new OAuth2AuthenticationException(ErrorTypeEnum.UNAUTHORIZED_CLIENT.getDescription());
 		}
 		}
 	}
 	}
 
 

+ 2 - 1
kxs-common/kxs-common-security/src/main/java/com/kxs/common/security/support/sms/OAuth2ResourceOwnerSmsAuthenticationProvider.java

@@ -1,6 +1,7 @@
 package com.kxs.common.security.support.sms;
 package com.kxs.common.security.support.sms;
 
 
 import com.kxs.common.core.constant.SecurityConstants;
 import com.kxs.common.core.constant.SecurityConstants;
+import com.kxs.common.core.constant.enums.ErrorTypeEnum;
 import com.kxs.common.security.support.base.OAuth2ResourceOwnerBaseAuthenticationProvider;
 import com.kxs.common.security.support.base.OAuth2ResourceOwnerBaseAuthenticationProvider;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.Logger;
@@ -53,7 +54,7 @@ public class OAuth2ResourceOwnerSmsAuthenticationProvider
 		assert registeredClient != null;
 		assert registeredClient != null;
 		if (!registeredClient.getAuthorizationGrantTypes()
 		if (!registeredClient.getAuthorizationGrantTypes()
 			.contains(new AuthorizationGrantType(SecurityConstants.MOBILE))) {
 			.contains(new AuthorizationGrantType(SecurityConstants.MOBILE))) {
-			throw new OAuth2AuthenticationException(OAuth2ErrorCodes.UNAUTHORIZED_CLIENT);
+			throw new OAuth2AuthenticationException(ErrorTypeEnum.UNAUTHORIZED_CLIENT.getDescription());
 		}
 		}
 	}
 	}