package com.pollex.pam.security.provider;
|
|
import com.pollex.pam.config.ApplicationProperties;
|
import com.pollex.pam.business.security.token.EServiceAuthenticationToken;
|
import com.pollex.pam.security.token.OtpAuthenticationToken;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.security.authentication.AbstractAuthenticationToken;
|
import org.springframework.security.authentication.AuthenticationProvider;
|
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.AuthenticationException;
|
import org.springframework.stereotype.Component;
|
|
|
@Component
|
public class CustomAuthenticationProvider implements AuthenticationProvider {
|
|
@Autowired
|
EServiceAuthenticationProvider eServiceAuthenticationProvider;
|
|
@Autowired
|
OtpAuthenticationProvider otpAuthenticationProvider;
|
|
@Autowired
|
ApplicationProperties applicationProperty;
|
|
@Override
|
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
if(authentication instanceof OtpAuthenticationToken) {
|
return otpAuthenticationProvider.authenticate((OtpAuthenticationToken) authentication);
|
}
|
else if(authentication instanceof EServiceAuthenticationToken) {
|
return eServiceAuthenticationProvider.authenticate((EServiceAuthenticationToken) authentication);
|
}
|
return null;
|
}
|
|
@Override
|
public boolean supports(Class<?> authentication) {
|
return AbstractAuthenticationToken.class.isAssignableFrom(authentication);
|
}
|
}
|