bug fixes

This commit is contained in:
Efstratios Giannopoulos 2023-10-19 13:01:29 +03:00
parent 07ff58fbd9
commit 16604a8a50
5 changed files with 12 additions and 64 deletions

View File

@ -81,7 +81,7 @@ public class MergeEmailConfirmationManager {
databaseRepository.getLoginConfirmationEmailDao(),
apiContext.getUtilitiesService().getMailService(),
email,
userId,
user,
provider
);
}

View File

@ -27,13 +27,11 @@ public class UnlinkEmailConfirmationManager {
private ApiContext apiContext;
private DatabaseRepository databaseRepository;
private final UserScope userScope;
@Autowired
public UnlinkEmailConfirmationManager(ApiContext apiContext, UserScope userScope) {
public UnlinkEmailConfirmationManager(ApiContext apiContext) {
this.apiContext = apiContext;
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
this.userScope = userScope;
}
@Transactional
@ -76,14 +74,14 @@ public class UnlinkEmailConfirmationManager {
}
public void sendConfirmationEmail(String email, UUID userId, Integer provider) throws InvalidApplicationException {
UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userScope.getUserId());
UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userId);
if (user.getEmail() != null && !user.getEmail().equals(email)) {
apiContext.getUtilitiesService().getConfirmationEmailService().createUnlinkConfirmationEmail(
databaseRepository.getLoginConfirmationEmailDao(),
apiContext.getUtilitiesService().getMailService(),
email,
userId,
user,
provider
);
}

View File

@ -2,6 +2,7 @@ package eu.eudat.logic.services.utilities;
import eu.eudat.data.dao.entities.EmailConfirmationDao;
import eu.eudat.data.old.EmailConfirmation;
import eu.eudat.data.old.UserInfo;
import javax.management.InvalidApplicationException;
import java.util.UUID;
@ -10,9 +11,9 @@ import java.util.concurrent.CompletableFuture;
public interface ConfirmationEmailService {
public void createConfirmationEmail(EmailConfirmationDao loginConfirmationEmailDao, MailService mailService, String email, UUID userId);
public void createMergeConfirmationEmail(EmailConfirmationDao loginConfirmationEmailDao, MailService mailService, String email, UUID userId, Integer provider) throws InvalidApplicationException;
public void createMergeConfirmationEmail(EmailConfirmationDao loginConfirmationEmailDao, MailService mailService, String email, UserInfo user, Integer provider) throws InvalidApplicationException;
public void createUnlinkConfirmationEmail(EmailConfirmationDao loginConfirmationEmailDao, MailService mailService, String email, UUID userId, Integer provider) throws InvalidApplicationException;
public void createUnlinkConfirmationEmail(EmailConfirmationDao loginConfirmationEmailDao, MailService mailService, String email, UserInfo user, Integer provider) throws InvalidApplicationException;
public CompletableFuture sentConfirmationEmail(EmailConfirmation confirmationEmail, MailService mailService);

View File

@ -27,13 +27,11 @@ public class ConfirmationEmailServiceImpl implements ConfirmationEmailService {
//private Logger logger;
private Environment environment;
private final UserScope userScope;
private final ApiContext apiContext;
public ConfirmationEmailServiceImpl(/*Logger logger,*/ Environment environment, UserScope userScope, ApiContext apiContext) {
public ConfirmationEmailServiceImpl(/*Logger logger,*/ Environment environment, UserScope userScope) {
// this.logger = logger;
this.environment = environment;
this.userScope = userScope;
this.apiContext = apiContext;
}
@Override
@ -146,7 +144,7 @@ public class ConfirmationEmailServiceImpl implements ConfirmationEmailService {
@Override
public void createMergeConfirmationEmail(EmailConfirmationDao loginConfirmationEmailDao, MailService mailService,
String email, UUID userId, Integer provider) throws InvalidApplicationException {
String email, UserInfo user, Integer provider) throws InvalidApplicationException {
EmailConfirmation confirmationEmail = new EmailConfirmation();
confirmationEmail.setEmail(email);
confirmationEmail.setExpiresAt(Date
@ -155,8 +153,7 @@ public class ConfirmationEmailServiceImpl implements ConfirmationEmailService {
.plusSeconds(Long.parseLong(this.environment.getProperty("conf_email.expiration_time_seconds")))
)
);
UserInfo user = this.apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(this.userScope.getUserId()); //TODO: Authz
confirmationEmail.setUserId(userId);
confirmationEmail.setUserId(user.getId());
try {
Map<String, Object> map = new HashMap<>();
map.put("userId", this.userScope.getUserId());
@ -174,8 +171,7 @@ public class ConfirmationEmailServiceImpl implements ConfirmationEmailService {
@Override
public void createUnlinkConfirmationEmail(EmailConfirmationDao loginConfirmationEmailDao, MailService mailService,
String email, UUID userId, Integer provider) throws InvalidApplicationException {
UserInfo user = this.apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(this.userScope.getUserId()); //TODO: Authz
String email, UserInfo user, Integer provider) throws InvalidApplicationException {
EmailConfirmation confirmationEmail = new EmailConfirmation();
confirmationEmail.setEmail(user.getEmail());
confirmationEmail.setExpiresAt(Date
@ -184,7 +180,7 @@ public class ConfirmationEmailServiceImpl implements ConfirmationEmailService {
.plusSeconds(Long.parseLong(this.environment.getProperty("conf_email.expiration_time_seconds")))
)
);
confirmationEmail.setUserId(userId);
confirmationEmail.setUserId(user.getId());
try {
Map<String, Object> map = new HashMap<>();
map.put("email", email);

View File

@ -1,47 +0,0 @@
package eu.eudat.models.data.saml2;
public class AuthnRequestModel {
String authnRequestXml;
String relayState;
String algorithm;
String signature;
public AuthnRequestModel() {}
public AuthnRequestModel(String authnRequestXml, String relayState, String algorithm, String signature) {
this.authnRequestXml = authnRequestXml;
this.relayState = relayState;
this.algorithm = algorithm;
this.signature = signature;
}
public String getAuthnRequestXml() {
return authnRequestXml;
}
public void setAuthnRequestXml(String authnRequestXml) {
this.authnRequestXml = authnRequestXml;
}
public String getRelayState() {
return relayState;
}
public void setRelayState(String relayState) {
this.relayState = relayState;
}
public String getAlgorithm() {
return algorithm;
}
public void setAlgorithm(String algorithm) {
this.algorithm = algorithm;
}
public String getSignature() {
return signature;
}
public void setSignature(String signature) {
this.signature = signature;
}
}