保誠-保戶業務員媒合平台
wayne
2021-11-29 0f1695c2df8145fd355243f2972ae457e9d6ba0b
[update] 調整EService的錯誤回覆代碼與訊息規格

修改3個檔案
新增1個檔案
28 ■■■■ 已變更過的檔案
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 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/web/rest/errors/EServiceErrorException.java 11 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/doc/µn¤JAPI/ÅU°Ýµn¤JByEService.txt
@@ -8,11 +8,14 @@
}
目前可用顧問可參考Angela的10個顧問測試資料
檔名:PCA-Matching Platform-test-data 1108.xlsx
檔名:PCA-Matching Platform-test-data.xlsx
帳號如Excel上面所填寫,密碼在dev端並未從EService檢核,可以直接登入
response body:
response body: è‹¥ç™»å…¥æˆåŠŸå›ž200
{
    "id_token": "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJEMjY1MjYwNjYyIiwiYXV0aCI6IlJPTEVfVVNFUiIsImRldGFpbHMiOnsiQ29uc3VsdGFudEFnZW50Tm8iOiJEMjY1MjYwNjYyIiwiQ29uc3VsdGFudE5hbWUiOiLmnpfmiJDlrIwiLCJDb25zdWx0YW50SWQiOiI1In0sImV4cCI6MTYzNzY0OTQ5NX0.BjLiA-nuJOsUtD6UqyONr3brPXbdhjA_5srFBS2qgcvFhfznSOCZMlHtl4NtphiZ1CAk2jyg79QFlqGvM6Uk1A"
}
若與EService http status 200,但有錯誤會回401
其餘非EService相關的Server error皆回500
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!");
        }
    }
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()
pamapi/src/main/java/com/pollex/pam/web/rest/errors/EServiceErrorException.java
¤ñ¹ï·sÀÉ®×
@@ -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);
    }
}