created new api's for login with spid

This commit is contained in:
rajesh
2024-09-25 20:12:34 +05:30
parent cdbb9c0072
commit d5524b7cc9
24 changed files with 407 additions and 149 deletions

View File

@@ -4,23 +4,21 @@ import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
import org.springframework.stereotype.Component;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import net.gepafin.tendermanagement.entities.SamlResponseLogEntity;
import net.gepafin.tendermanagement.repositories.SamlResponseLogRepository;
@Component
public class SamlFailureHandler implements AuthenticationFailureHandler {
private final Logger logger = LoggerFactory.getLogger(SamlSuccessHandler.class);
@Autowired
private SamlResponseLogRepository samlResponseLogRepository;
@Value("fe.base.url")
private String feBaseUrl;
@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
@@ -28,15 +26,7 @@ public class SamlFailureHandler implements AuthenticationFailureHandler {
try {
logger.error("SAML login failed: " + exception.getMessage());
// Log the failure details to the database (Optional)
SamlResponseLogEntity samlResponseLogEntity = new SamlResponseLogEntity();
samlResponseLogEntity.setRequest(request.toString());
samlResponseLogEntity.setResponse(response.toString());
samlResponseLogEntity.setExceptionObject(exception.toString());
samlResponseLogRepository.save(samlResponseLogEntity);
// Handle failure redirection
response.sendRedirect("http://gepafin-staging-fe.s3-website.eu-central-1.amazonaws.com/login");
response.sendRedirect(feBaseUrl + "/login");
} catch (Exception e) {
logger.error("Error processing SAML failure handler", e);
}