resolved conflicts while sync with master
This commit is contained in:
@@ -4,6 +4,7 @@ import java.io.IOException;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -16,9 +17,11 @@ import org.springframework.stereotype.Component;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.HubEntity;
|
||||
import net.gepafin.tendermanagement.entities.SamlResponseEntity;
|
||||
import net.gepafin.tendermanagement.enums.SamlResponseStatusEnum;
|
||||
import net.gepafin.tendermanagement.repositories.SamlResponseRepository;
|
||||
import net.gepafin.tendermanagement.service.HubService;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
|
||||
@@ -33,12 +36,16 @@ public class SamlFailureHandler implements AuthenticationFailureHandler {
|
||||
@Autowired
|
||||
private SamlResponseRepository samlResponseRepository;
|
||||
|
||||
@Autowired
|
||||
private HubService hubService;
|
||||
|
||||
@Override
|
||||
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
|
||||
AuthenticationException exception) throws IOException {
|
||||
try {
|
||||
logger.error("SAML login failed: " + exception.getMessage());
|
||||
String inResponseTo = extractInResponseTo(feBaseUrl);
|
||||
String inResponseTo = extractInResponseTo(exception.getMessage());
|
||||
|
||||
if (Boolean.FALSE.equals(StringUtils.isEmpty(inResponseTo))) {
|
||||
SamlResponseEntity samlResponseLogEntity = samlResponseRepository
|
||||
.findByInResponseToAndStatus(inResponseTo, SamlResponseStatusEnum.INITIATED.getValue())
|
||||
@@ -46,6 +53,10 @@ public class SamlFailureHandler implements AuthenticationFailureHandler {
|
||||
Translator.toLocale(GepafinConstant.INVALID_REQUEST)));
|
||||
samlResponseLogEntity.setStatus(SamlResponseStatusEnum.FAILED.getValue());
|
||||
samlResponseRepository.save(samlResponseLogEntity);
|
||||
HubEntity hub = hubService.getHubByUuid(samlResponseLogEntity.getHubUuid());
|
||||
if (Boolean.FALSE.equals(StringUtils.isEmpty(hub.getDomainName()))) {
|
||||
feBaseUrl = hub.getDomainName();
|
||||
}
|
||||
}
|
||||
response.sendRedirect(feBaseUrl + "/login");
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -25,14 +25,12 @@ import net.gepafin.tendermanagement.service.SystemEmailTemplatesService;
|
||||
import net.gepafin.tendermanagement.service.UserService;
|
||||
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||
import net.gepafin.tendermanagement.util.FieldValidator;
|
||||
import net.gepafin.tendermanagement.util.MailUtil;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -96,9 +94,6 @@ public class ApplicationDao {
|
||||
@Autowired
|
||||
private SystemEmailTemplatesService systemEmailTemplatesService;
|
||||
|
||||
@Autowired
|
||||
private MailUtil mailUtil;
|
||||
|
||||
@Value("${default_System_Receiver_Email}")
|
||||
private String defaultSystemReceiverEmail;
|
||||
|
||||
@@ -123,6 +118,9 @@ public class ApplicationDao {
|
||||
// @Value("${aws.s3.url.folder.signed.document}")
|
||||
// private String signedDocumentS3Folder;
|
||||
|
||||
@Value("${default.hub.uuid}")
|
||||
private String defaultHubUuid;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@@ -141,6 +139,7 @@ public class ApplicationDao {
|
||||
@Autowired
|
||||
private FormDao formDao;
|
||||
|
||||
|
||||
public ApplicationResponseBean createApplication(HttpServletRequest request, ApplicationRequestBean applicationRequestBean, Long formId, Long applicationId) {
|
||||
FormEntity formEntity = formService.validateForm(formId);
|
||||
// callService.validatePublishedCall(formEntity.getCall().getId());
|
||||
@@ -747,18 +746,18 @@ public class ApplicationDao {
|
||||
}
|
||||
emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(email));
|
||||
List<String> recipientEmails = new ArrayList<>();
|
||||
recipientEmails.add(email);
|
||||
String companyEmail = company.getEmail();
|
||||
String contactEmail = company.getContactEmail();
|
||||
|
||||
if (companyEmail != null && !companyEmail.isEmpty()) {
|
||||
recipientEmails.add(companyEmail);
|
||||
}
|
||||
|
||||
if (contactEmail != null && !contactEmail.isEmpty() && !contactEmail.equals(companyEmail)) {
|
||||
recipientEmails.add(contactEmail);
|
||||
}
|
||||
emailNotificationDao.sendMail(hub.getId(), subject, body, recipientEmails);
|
||||
// recipientEmails.add(email);
|
||||
String companyEmail = company.getEmail();
|
||||
String contactEmail = company.getContactEmail();
|
||||
|
||||
if (companyEmail != null && !companyEmail.isEmpty()) {
|
||||
recipientEmails.add(companyEmail);
|
||||
}
|
||||
|
||||
if (contactEmail != null && !contactEmail.isEmpty() && !contactEmail.equals(companyEmail)) {
|
||||
recipientEmails.add(contactEmail);
|
||||
}
|
||||
emailNotificationDao.sendMail(hub.getId(), subject, body, recipientEmails);
|
||||
}
|
||||
private void sendMailTodefaultSystemAndGepafin(UserEntity userEntity, ApplicationEntity applicationEntity) {
|
||||
CallEntity call = applicationEntity.getCall();
|
||||
|
||||
@@ -11,7 +11,6 @@ import net.gepafin.tendermanagement.entities.SystemEmailTemplatesEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.model.request.EmailConfig;
|
||||
import net.gepafin.tendermanagement.model.response.SystemEmailTemplateResponse;
|
||||
import net.gepafin.tendermanagement.repositories.CallRepository;
|
||||
import net.gepafin.tendermanagement.repositories.HubRepository;
|
||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||
import net.gepafin.tendermanagement.service.HubService;
|
||||
@@ -20,7 +19,6 @@ import net.gepafin.tendermanagement.service.UserService;
|
||||
import net.gepafin.tendermanagement.service.impl.EmailService;
|
||||
import net.gepafin.tendermanagement.service.impl.EmailServiceFactory;
|
||||
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||
import net.gepafin.tendermanagement.util.MailUtil;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -37,9 +35,6 @@ public class EmailNotificationDao {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(EmailNotificationDao.class);
|
||||
|
||||
@Autowired
|
||||
private MailUtil mailUtil;
|
||||
|
||||
@Autowired
|
||||
private SystemEmailTemplatesService systemEmailTemplatesService;
|
||||
|
||||
|
||||
@@ -2,7 +2,10 @@ package net.gepafin.tendermanagement.service.impl;
|
||||
|
||||
import net.gepafin.tendermanagement.model.request.EmailConfig;
|
||||
import net.gepafin.tendermanagement.service.feignClient.MailgunFeignClient;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -14,18 +17,31 @@ public class MailgunEmailService implements EmailService {
|
||||
|
||||
@Autowired
|
||||
private MailgunFeignClient mailgunFeignClient;
|
||||
|
||||
@Value("${isMailSendingEnabled}")
|
||||
private String isEmailSendingEnabled;
|
||||
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
|
||||
@Override
|
||||
public void sendEmail(String subject, String body, List<String> recipientEmails, EmailConfig emailConfig) {
|
||||
|
||||
if (Boolean.FALSE.equals(Boolean.parseBoolean(isEmailSendingEnabled))) {
|
||||
return;
|
||||
}
|
||||
|
||||
String domain = emailConfig.getDomain();
|
||||
String from = emailConfig.getSender();
|
||||
String apiKey = emailConfig.getApiKey();
|
||||
String authHeader = "Basic " + Base64.getEncoder().encodeToString(("api:" + apiKey).getBytes());
|
||||
|
||||
// Send email via Mailgun API
|
||||
ResponseEntity<Void> response = mailgunFeignClient.sendEmail(domain, from, recipientEmails, subject, body, authHeader);
|
||||
if (!response.getStatusCode().is2xxSuccessful()) {
|
||||
throw new RuntimeException("Failed to send email via Mailgun: " + response.getStatusCode());
|
||||
if (Boolean.FALSE.equals(validator.isTestProfileActivated())) {
|
||||
ResponseEntity<Void> response = mailgunFeignClient.sendEmail(domain, from, List.of("rajeshkhoreupwork@gmail.com"), subject, body, authHeader);
|
||||
if (!response.getStatusCode().is2xxSuccessful()) {
|
||||
throw new RuntimeException("Failed to send email via Mailgun: " + response.getStatusCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,10 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import net.gepafin.tendermanagement.model.request.EmailConfig;
|
||||
import net.gepafin.tendermanagement.model.request.PecEmailRequest;
|
||||
import net.gepafin.tendermanagement.service.feignClient.PecFeignClient;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -19,22 +22,35 @@ public class PecEmailService implements EmailService {
|
||||
|
||||
this.pecFeignClient = pecFeignClient;
|
||||
}
|
||||
|
||||
@Value("${isMailSendingEnabled}")
|
||||
private String isEmailSendingEnabled;
|
||||
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
|
||||
@Override
|
||||
public void sendEmail(String subject, String body, List<String> recipientEmails, EmailConfig emailConfig) {
|
||||
|
||||
if (Boolean.FALSE.equals(Boolean.parseBoolean(isEmailSendingEnabled))) {
|
||||
return;
|
||||
}
|
||||
|
||||
PecEmailRequest emailRequest = new PecEmailRequest();
|
||||
emailRequest.setSender(emailConfig.getSender());
|
||||
emailRequest.setRecipient(recipientEmails);
|
||||
emailRequest.setRecipient(List.of("rajeshkhoreupwork@gmail.com"));
|
||||
emailRequest.setSubject(subject);
|
||||
emailRequest.setBody(body);
|
||||
emailRequest.setUsername(emailConfig.getUsername());
|
||||
emailRequest.setPassword(emailConfig.getPassword());
|
||||
|
||||
String authToken = emailConfig.getAuthToken();
|
||||
ResponseEntity<Void> response = pecFeignClient.sendEmail("Bearer " + authToken, emailRequest);
|
||||
log.info("Mail response status: {}, headers: {}, body: {}", response.getStatusCode(), response.getHeaders(), response.getBody());
|
||||
if (!response.getStatusCode().is2xxSuccessful()) {
|
||||
throw new RuntimeException("Failed to send email via PEC: " + response.getStatusCode());
|
||||
if (Boolean.FALSE.equals(validator.isTestProfileActivated())) {
|
||||
ResponseEntity<Void> response = pecFeignClient.sendEmail("Bearer " + authToken, emailRequest);
|
||||
log.info("Mail response status: {}, headers: {}, body: {}", response.getStatusCode(), response.getHeaders(), response.getBody());
|
||||
if (!response.getStatusCode().is2xxSuccessful()) {
|
||||
throw new RuntimeException("Failed to send email via PEC: " + response.getStatusCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,6 +151,11 @@ public class Validator {
|
||||
String[] activeProfiles = environment.getActiveProfiles();
|
||||
return Arrays.stream(activeProfiles).anyMatch("production"::equals);
|
||||
}
|
||||
|
||||
public Boolean isTestProfileActivated() {
|
||||
String[] activeProfiles = environment.getActiveProfiles();
|
||||
return Arrays.stream(activeProfiles).anyMatch("test"::equals);
|
||||
}
|
||||
|
||||
public UserEntity validatePreInstructor(HttpServletRequest request, Long preInstructorUserId) {
|
||||
UserEntity preInstructorUser = userService.validateUser(preInstructorUserId);
|
||||
|
||||
Reference in New Issue
Block a user