| | |
| | | import com.pollex.pam.config.ApplicationProperties; |
| | | import com.pollex.pam.domain.Consultant; |
| | | import com.pollex.pam.enums.ConsultantDetailEnum; |
| | | import com.pollex.pam.enums.ConsultantStatusEnum; |
| | | import com.pollex.pam.repository.ConsultantRepository; |
| | | 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.ConsultantDisableException; |
| | | import com.pollex.pam.web.rest.errors.EServiceErrorException; |
| | | import org.apache.http.conn.ssl.NoopHostnameVerifier; |
| | | import org.apache.http.conn.ssl.SSLConnectionSocketFactory; |
| | |
| | | import java.security.NoSuchAlgorithmException; |
| | | import java.security.cert.X509Certificate; |
| | | import java.util.*; |
| | | |
| | | import static com.pollex.pam.enums.ConsultantStatusEnum.DISABLE; |
| | | |
| | | @Component |
| | | public class EServiceAuthenticationProvider { |
| | |
| | | } |
| | | } |
| | | |
| | | private UsernamePasswordAuthenticationToken getConsultantToken(String account, String credential) { |
| | | private UsernamePasswordAuthenticationToken getConsultantToken(String account, String credential) throws ConsultantDisableException { |
| | | Consultant consultant = consultantRepository.findOneByAgentNo(account).orElseThrow(() -> new UsernameNotFoundException("該顧問資料並不存在於媒合平台系統中")); |
| | | |
| | | if(consultant.getStatus() == DISABLE) { |
| | | throw new ConsultantDisableException("顧問帳號目前停用中"); |
| | | } |
| | | |
| | | List<GrantedAuthority> grantedAuths = Arrays.asList(new SimpleGrantedAuthority("ROLE_USER")); |
| | | UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(account, credential, grantedAuths); |
| | | |