保誠-保戶業務員媒合平台
wayne
2021-11-25 e28415e8f6d76ddcf0c936027669c22ed2b2e05d
pamapi/src/main/java/com/pollex/pam/security/provider/EServiceAuthenticationProvider.java
@@ -1,5 +1,6 @@
package com.pollex.pam.security.provider;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.pollex.pam.config.ApplicationProperties;
import com.pollex.pam.domain.Consultant;
@@ -20,6 +21,7 @@
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.security.authentication.AuthenticationCredentialsNotFoundException;
import org.springframework.security.authentication.AuthenticationServiceException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
@@ -30,6 +32,7 @@
import org.springframework.web.client.RestTemplate;
import javax.net.ssl.SSLContext;
import java.security.GeneralSecurityException;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
@@ -63,11 +66,15 @@
                if(E_SERVICE_LOGIN_SUCCESS_CODE.equals(eServiceResponse.getCode())){
                    return getConsultantToken(account, credentials);
                }
                throw new RuntimeException("eService login failed, eService response code = " + eServiceResponse.getCode());
            }
            throw new AuthenticationCredentialsNotFoundException("");
        } catch (Exception e) {
            throw new AuthenticationCredentialsNotFoundException("");
            throw new RuntimeException("eService http error!, response http status code = " + responseEntity.getStatusCode());
        } catch (JsonProcessingException e) {
            throw new AuthenticationServiceException("convert to json processing error!");
        } catch (GeneralSecurityException e) {
            throw new AuthenticationServiceException("General Security SSL error!");
        }
    }
@@ -86,7 +93,7 @@
        return authenticationToken;
    }
    private ResponseEntity<EServiceResponse> loginByEService(String account, String paxxword) throws Exception{
    private ResponseEntity<EServiceResponse> loginByEService(String account, String paxxword) throws JsonProcessingException, GeneralSecurityException {
        EServiceRequest dto = new EServiceRequest();
        dto.setFunc("ValidateUserLogin");
        dto.setId(account);