Enabled custom implementation for email address retrieval.
Change-Id: I9e45117dedf23c5005745ff81e60aa98bebfb34e
diff --git a/full/Changes b/full/Changes
index 7d83752..7c82ed6 100644
--- a/full/Changes
+++ b/full/Changes
@@ -1,9 +1,11 @@
version 0.60 release
-21/02/2018
+26/02/2018
- set up mail settings using localhost port 25 (margaretha)
- added mail template in kustvakt configuration (margaretha)
- added mail settings to readme (margaretha)
- disabled email notification for auto group (margaretha)
+ - added metadata retrieval (diewald)
+ - enabled custom implementation for email address retrieval (margaretha)
version 0.59.10
20/02/2018
diff --git a/full/src/main/java/de/ids_mannheim/korap/authentication/KustvaktAuthenticationManager.java b/full/src/main/java/de/ids_mannheim/korap/authentication/KustvaktAuthenticationManager.java
index 0015e89..8a8ac3d 100644
--- a/full/src/main/java/de/ids_mannheim/korap/authentication/KustvaktAuthenticationManager.java
+++ b/full/src/main/java/de/ids_mannheim/korap/authentication/KustvaktAuthenticationManager.java
@@ -139,11 +139,27 @@
//EM:copied from EntityDao
KorAPUser user = new KorAPUser(); // oder eigentlich new DemoUser oder new DefaultUser.
user.setUsername(username);
- // get user data
- user.setEmail(config.getTestEmail());
return user;
// return entHandler.getAccount(username);
}
+
+ @Override
+ public User getUser (String username, String method)
+ throws KustvaktException {
+ KorAPUser user = new KorAPUser();
+ user.setUsername(username);
+ String email = null;
+ switch (method.toLowerCase()) {
+ case "ldap":
+ email = config.getTestEmail();
+ break;
+ default:
+ email = config.getTestEmail();
+ break;
+ }
+ user.setEmail(email);
+ return user;
+ }
public TokenContext refresh(TokenContext context) throws KustvaktException {
AuthenticationIface provider = getProvider(context.getTokenType(), null);
diff --git a/full/src/main/java/de/ids_mannheim/korap/config/FullConfiguration.java b/full/src/main/java/de/ids_mannheim/korap/config/FullConfiguration.java
index 201fc4b..aee009b 100644
--- a/full/src/main/java/de/ids_mannheim/korap/config/FullConfiguration.java
+++ b/full/src/main/java/de/ids_mannheim/korap/config/FullConfiguration.java
@@ -18,7 +18,8 @@
private boolean isMailEnabled;
private String testEmail;
private String noReply;
-
+ private String emailAddressRetrieval;
+
private String groupInvitationTemplate;
private String ldapConfig;
@@ -64,9 +65,10 @@
setMailEnabled(Boolean.valueOf(properties.getProperty("mail.enabled", "false")));
if (isMailEnabled){
// other properties must be set in the kustvakt.conf
- setTestEmail(properties.getProperty("mail.receiver"));
+ setTestEmail(properties.getProperty("mail.receiver","test@localhost"));
setNoReply(properties.getProperty("mail.sender"));
setGroupInvitationTemplate(properties.getProperty("template.group.invitation"));
+ setEmailAddressRetrieval(properties.getProperty("mail.address.retrieval","test"));
}
}
@@ -269,4 +271,12 @@
this.groupInvitationTemplate = groupInvitationTemplate;
}
+ public String getEmailAddressRetrieval () {
+ return emailAddressRetrieval;
+ }
+
+ public void setEmailAddressRetrieval (String emailAddressRetrieval) {
+ this.emailAddressRetrieval = emailAddressRetrieval;
+ }
+
}
diff --git a/full/src/main/java/de/ids_mannheim/korap/service/MailService.java b/full/src/main/java/de/ids_mannheim/korap/service/MailService.java
index 866a0a9..5051815 100644
--- a/full/src/main/java/de/ids_mannheim/korap/service/MailService.java
+++ b/full/src/main/java/de/ids_mannheim/korap/service/MailService.java
@@ -42,7 +42,8 @@
public void prepare (MimeMessage mimeMessage) throws Exception {
- User invitee = authManager.getUser(inviteeName);
+ User invitee = authManager.getUser(inviteeName,
+ config.getEmailAddressRetrieval());
MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
message.setTo(new InternetAddress(invitee.getEmail()));
diff --git a/full/src/main/resources/kustvakt.conf b/full/src/main/resources/kustvakt.conf
index d737a06..ab20bad 100644
--- a/full/src/main/resources/kustvakt.conf
+++ b/full/src/main/resources/kustvakt.conf
@@ -18,6 +18,7 @@
mail.enabled = false
mail.receiver = test@localhost
mail.sender = noreply@ids-mannheim.de
+mail.address.retrieval = test
## mail.templates
template.group.invitation = notification.vm
diff --git a/full/src/test/resources/kustvakt-test.conf b/full/src/test/resources/kustvakt-test.conf
index ca6b233..1de6cb1 100644
--- a/full/src/test/resources/kustvakt-test.conf
+++ b/full/src/test/resources/kustvakt-test.conf
@@ -18,6 +18,7 @@
mail.enabled = false
mail.receiver = test@localhost
mail.sender = noreply@ids-mannheim.de
+mail.address.retrieval = test
## mail.templates
template.group.invitation = notification.vm