| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | 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!"); |
| | | } |
| | | } |
| | | |
| | |
| | | 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); |