比對新檔案 |
| | |
| | | package com.pollex.pam.service; |
| | | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.authentication.AuthenticationCredentialsNotFoundException; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.pollex.pam.config.ApplicationProperties; |
| | | import com.pollex.pam.security.provider.OtpAuthenticationProvider; |
| | | import com.pollex.pam.service.dto.OtpResponseDTO; |
| | | |
| | | @Service |
| | | public class OtpUtilService { |
| | | |
| | | private static final Logger log = LoggerFactory.getLogger(OtpUtilService.class); |
| | | |
| | | @Autowired |
| | | ApplicationProperties applicationProperty; |
| | | |
| | | @Autowired |
| | | OtpWebService otpWebService; |
| | | |
| | | public void verifyOtp(String indexKey, String otpCode) { |
| | | if(applicationProperty.isMockLogin()){ |
| | | return; |
| | | } |
| | | |
| | | try { |
| | | OtpResponseDTO otpResponseDTO = otpWebService.verifyOTP(indexKey, otpCode); |
| | | if (!otpResponseDTO.isSuccess()) { |
| | | throw new AuthenticationCredentialsNotFoundException(""); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("Exception: ", e); |
| | | throw new AuthenticationCredentialsNotFoundException(""); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |