From 0f1695c2df8145fd355243f2972ae457e9d6ba0b Mon Sep 17 00:00:00 2001 From: wayne <wayne8692wayne8692@gmail.com> Date: 星期一, 29 十一月 2021 19:57:41 +0800 Subject: [PATCH] [update] 調整EService的錯誤回覆代碼與訊息規格 --- pamapi/src/main/java/com/pollex/pam/web/rest/errors/EServiceErrorException.java | 11 +++++++++++ pamapi/src/doc/登入API/顧問登入ByEService.txt | 7 +++++-- pamapi/src/main/java/com/pollex/pam/security/provider/EServiceAuthenticationProvider.java | 7 ++++--- pamapi/src/main/java/com/pollex/pam/web/rest/EServiceResource.java | 3 --- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git "a/pamapi/src/doc/\347\231\273\345\205\245API/\351\241\247\345\225\217\347\231\273\345\205\245ByEService.txt" "b/pamapi/src/doc/\347\231\273\345\205\245API/\351\241\247\345\225\217\347\231\273\345\205\245ByEService.txt" index 1c0158e..ecfe805 100644 --- "a/pamapi/src/doc/\347\231\273\345\205\245API/\351\241\247\345\225\217\347\231\273\345\205\245ByEService.txt" +++ "b/pamapi/src/doc/\347\231\273\345\205\245API/\351\241\247\345\225\217\347\231\273\345\205\245ByEService.txt" @@ -8,11 +8,14 @@ } ����憿批����ngela���10�“��葫閰西��� -瑼��:PCA-Matching Platform-test-data 1108.xlsx +瑼��:PCA-Matching Platform-test-data.xlsx 撣唾��xcel銝��憛怠神嚗�Ⅳ�dev蝡臭蒂�敺Service瑼X嚗隞亦��� -response body: +response body: ��������200 { "id_token": "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJEMjY1MjYwNjYyIiwiYXV0aCI6IlJPTEVfVVNFUiIsImRldGFpbHMiOnsiQ29uc3VsdGFudEFnZW50Tm8iOiJEMjY1MjYwNjYyIiwiQ29uc3VsdGFudE5hbWUiOiLmnpfmiJDlrIwiLCJDb25zdWx0YW50SWQiOiI1In0sImV4cCI6MTYzNzY0OTQ5NX0.BjLiA-nuJOsUtD6UqyONr3brPXbdhjA_5srFBS2qgcvFhfznSOCZMlHtl4NtphiZ1CAk2jyg79QFlqGvM6Uk1A" } + +���Service http status 200嚗��隤斗���401 +�擗�Service����erver error����500 diff --git a/pamapi/src/main/java/com/pollex/pam/security/provider/EServiceAuthenticationProvider.java b/pamapi/src/main/java/com/pollex/pam/security/provider/EServiceAuthenticationProvider.java index a23c399..0a3db3b 100644 --- a/pamapi/src/main/java/com/pollex/pam/security/provider/EServiceAuthenticationProvider.java +++ b/pamapi/src/main/java/com/pollex/pam/security/provider/EServiceAuthenticationProvider.java @@ -8,6 +8,7 @@ import com.pollex.pam.security.token.EServiceAuthenticationToken; import com.pollex.pam.service.LoginRecordService; import com.pollex.pam.service.dto.EServiceResponse; +import com.pollex.pam.web.rest.errors.EServiceErrorException; import org.apache.http.conn.ssl.NoopHostnameVerifier; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.impl.client.CloseableHttpClient; @@ -74,15 +75,15 @@ } else { loginRecordService.saveEServiceLoginFailRecord(account, eServiceResponse.getMsg()); - throw new RuntimeException("eService login failed, eService response code = " + eServiceResponse.getCode() + ", eService response msg = " + eServiceResponse.getMsg()); + throw new EServiceErrorException(eServiceResponse.getMsg()); } } throw new RuntimeException("eService http error!, response http status code = " + responseEntity.getStatusCode()); } catch (JsonProcessingException e) { - throw new AuthenticationServiceException("convert to json processing error!"); + throw new RuntimeException("convert to json processing error!"); } catch (GeneralSecurityException e) { - throw new AuthenticationServiceException("General Security SSL error!"); + throw new RuntimeException("General Security SSL error!"); } } diff --git a/pamapi/src/main/java/com/pollex/pam/web/rest/EServiceResource.java b/pamapi/src/main/java/com/pollex/pam/web/rest/EServiceResource.java index 1ee9eed..840b8c9 100644 --- a/pamapi/src/main/java/com/pollex/pam/web/rest/EServiceResource.java +++ b/pamapi/src/main/java/com/pollex/pam/web/rest/EServiceResource.java @@ -28,9 +28,6 @@ @PostMapping("/authenticate") public ResponseEntity<UserJWTController.JWTToken> authorize(@RequestBody EServiceLoginVM eServiceLoginVM) { - // todo 撽�Ⅳ隤�� - - EServiceAuthenticationToken authenticationToken = new EServiceAuthenticationToken( eServiceLoginVM.getUsername(), eServiceLoginVM.getPassword() diff --git a/pamapi/src/main/java/com/pollex/pam/web/rest/errors/EServiceErrorException.java b/pamapi/src/main/java/com/pollex/pam/web/rest/errors/EServiceErrorException.java new file mode 100644 index 0000000..ceef292 --- /dev/null +++ b/pamapi/src/main/java/com/pollex/pam/web/rest/errors/EServiceErrorException.java @@ -0,0 +1,11 @@ +package com.pollex.pam.web.rest.errors; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ResponseStatus; + +@ResponseStatus(code = HttpStatus.UNAUTHORIZED) +public class EServiceErrorException extends RuntimeException{ + public EServiceErrorException(String message) { + super(message); + } +} -- Gitblit v1.8.0