保誠-保戶業務員媒合平台
Jack
2021-11-26 6282fdfadbc9f22e3874f206cdd5e67014583991
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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("");
        }
        
        
    }
}