Removed mail configuration (#764)
Change-Id: Ic065c5f86c898b659040b4b8065dfad39d6193fe
diff --git a/Changes b/Changes
index 85d9ba2..cf11729 100644
--- a/Changes
+++ b/Changes
@@ -15,6 +15,8 @@
- Removed GroupMemberStatus (#764)
- Replace invite and subscribe to add member (#764)
- Remove unsubscribe member (#764)
+- Added deprecation messages to deprecated services
+- Removed mail configuration (#764)
# version 0.74
diff --git a/pom.xml b/pom.xml
index f2055f1..47ca42a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -139,8 +139,6 @@
<exclude>com.novell.ldap</exclude>
<exclude>com.unboundid</exclude>
<exclude>org.glassfish.jersey.test-framework*</exclude>
- <exclude>org.apache.velocity*</exclude>
- <exclude>com.sun.mail</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
@@ -419,11 +417,6 @@
</dependency>
<dependency>
<groupId>org.springframework</groupId>
- <artifactId>spring-context-support</artifactId>
- <version>${spring.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>compile</scope>
@@ -620,37 +613,6 @@
<version>6.0.11</version>
</dependency>
- <!-- velocity -->
- <dependency>
- <groupId>org.apache.velocity</groupId>
- <artifactId>velocity-engine-core</artifactId>
- <version>2.3</version>
- </dependency>
- <dependency>
- <groupId>org.apache.velocity.tools</groupId>
- <artifactId>velocity-tools-generic</artifactId>
- <version>3.1</version>
- <exclusions>
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <!-- Mail -->
- <dependency>
- <groupId>com.sun.mail</groupId>
- <artifactId>jakarta.mail</artifactId>
- <version>2.0.1</version>
- </dependency>
-
- <dependency>
- <groupId>jakarta.activation</groupId>
- <artifactId>jakarta.activation-api</artifactId>
- <version>2.1.2</version>
- </dependency>
-
<!-- OAuth -->
<dependency>
<groupId>com.nimbusds</groupId>
diff --git a/src/main/java/de/ids_mannheim/korap/authentication/AuthenticationManager.java b/src/main/java/de/ids_mannheim/korap/authentication/AuthenticationManager.java
index 6ee6dc6..1ebbce9 100644
--- a/src/main/java/de/ids_mannheim/korap/authentication/AuthenticationManager.java
+++ b/src/main/java/de/ids_mannheim/korap/authentication/AuthenticationManager.java
@@ -72,7 +72,4 @@
return "provider list: " + this.providers.toString();
}
- public abstract User getUser (String username, String method)
- throws KustvaktException;
-
}
diff --git a/src/main/java/de/ids_mannheim/korap/authentication/DummyAuthenticationManager.java b/src/main/java/de/ids_mannheim/korap/authentication/DummyAuthenticationManager.java
index 83b979c..21379b2 100644
--- a/src/main/java/de/ids_mannheim/korap/authentication/DummyAuthenticationManager.java
+++ b/src/main/java/de/ids_mannheim/korap/authentication/DummyAuthenticationManager.java
@@ -62,12 +62,4 @@
// TODO Auto-generated method stub
}
-
- @Override
- public User getUser (String username, String method)
- throws KustvaktException {
- // TODO Auto-generated method stub
- return null;
- }
-
}
diff --git a/src/main/java/de/ids_mannheim/korap/authentication/KustvaktAuthenticationManager.java b/src/main/java/de/ids_mannheim/korap/authentication/KustvaktAuthenticationManager.java
index e5f5a54..031c3c1 100644
--- a/src/main/java/de/ids_mannheim/korap/authentication/KustvaktAuthenticationManager.java
+++ b/src/main/java/de/ids_mannheim/korap/authentication/KustvaktAuthenticationManager.java
@@ -131,24 +131,6 @@
// 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(),
@@ -315,6 +297,7 @@
return user;
}
+ @Deprecated
// todo: what if attributes null?
private User authenticate (String username, String password,
Map<String, Object> attr) throws KustvaktException {
diff --git a/src/main/java/de/ids_mannheim/korap/config/FullConfiguration.java b/src/main/java/de/ids_mannheim/korap/config/FullConfiguration.java
index 6a55ece..75c6162 100644
--- a/src/main/java/de/ids_mannheim/korap/config/FullConfiguration.java
+++ b/src/main/java/de/ids_mannheim/korap/config/FullConfiguration.java
@@ -27,13 +27,6 @@
public class FullConfiguration extends KustvaktConfiguration {
public static Logger jlog = LogManager.getLogger(FullConfiguration.class);
- // mail configuration
- private boolean isMailEnabled;
- private String testEmail;
- private String noReply;
- private String emailAddressRetrieval;
-
- private String groupInvitationTemplate;
private String ldapConfig;
@@ -85,7 +78,6 @@
// EM: pattern for matching availability in Krill matches
setLicensePatterns(properties);
- setMailConfiguration(properties);
ldapConfig = properties.getProperty("ldap.config");
setSecurityConfiguration(properties);
@@ -149,21 +141,6 @@
.getProperty("oauth2.refresh.token.long.expiry", "365D")));
}
- private void setMailConfiguration (Properties properties) {
- setMailEnabled(Boolean
- .valueOf(properties.getProperty("mail.enabled", "false")));
- if (isMailEnabled) {
- // other properties must be set in the kustvakt.conf
- 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"));
- }
- }
-
private void setLicensePatterns (Properties properties) {
setFreeLicensePattern(compilePattern(getFreeOnlyRegex()));
setPublicLicensePattern(compilePattern(
@@ -293,46 +270,6 @@
this.allOnlyRegex = allOnlyRegex;
}
- public String getTestEmail () {
- return testEmail;
- }
-
- public void setTestEmail (String testEmail) {
- this.testEmail = testEmail;
- }
-
- public boolean isMailEnabled () {
- return isMailEnabled;
- }
-
- public void setMailEnabled (boolean isMailEnabled) {
- this.isMailEnabled = isMailEnabled;
- }
-
- public String getNoReply () {
- return noReply;
- }
-
- public void setNoReply (String noReply) {
- this.noReply = noReply;
- }
-
- public String getGroupInvitationTemplate () {
- return groupInvitationTemplate;
- }
-
- public void setGroupInvitationTemplate (String groupInvitationTemplate) {
- this.groupInvitationTemplate = groupInvitationTemplate;
- }
-
- public String getEmailAddressRetrieval () {
- return emailAddressRetrieval;
- }
-
- public void setEmailAddressRetrieval (String emailAddressRetrieval) {
- this.emailAddressRetrieval = emailAddressRetrieval;
- }
-
public EncryptionIface.Encryption getSecureHashAlgorithm () {
return secureHashAlgorithm;
}
diff --git a/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java b/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java
index a1ccd11..0482d7e 100644
--- a/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java
+++ b/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java
@@ -62,7 +62,6 @@
private int returnhits;
private String keystoreLocation;
private String keystorePassword;
- private Properties mailProperties;
private String host;
private String shibUserMapping;
private String userConfig;
@@ -71,10 +70,6 @@
private long loginAttemptNum;
private boolean allowMultiLogIn;
private int loadFactor;
- @Deprecated
- private int validationStringLength;
- @Deprecated
- private int validationEmaillength;
// EM: determine if search and match info services restricted
// to logged in users. This replaces @SearchResourceFilters
@@ -212,10 +207,6 @@
loadFactor = Integer.valueOf(
properties.getProperty("security.encryption.loadFactor", "15"));
- validationStringLength = Integer.valueOf(properties
- .getProperty("security.validation.stringLength", "150"));
- validationEmaillength = Integer.valueOf(properties
- .getProperty("security.validation.emailLength", "40"));
sharedSecret = properties.getProperty("security.sharedSecret", "")
.getBytes();
diff --git a/src/main/java/de/ids_mannheim/korap/service/MailAuthenticator.java b/src/main/java/de/ids_mannheim/korap/service/MailAuthenticator.java
deleted file mode 100644
index 21f2202..0000000
--- a/src/main/java/de/ids_mannheim/korap/service/MailAuthenticator.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package de.ids_mannheim.korap.service;
-
-import jakarta.mail.Authenticator;
-import jakarta.mail.PasswordAuthentication;
-
-/**
- * Defines Authenticator for creating javax.mail.Session.
- *
- * @see src/main/resources/default-config.xml
- *
- * @author margaretha
- *
- */
-public class MailAuthenticator extends Authenticator {
-
- private PasswordAuthentication passwordAuthentication;
-
- public MailAuthenticator (String username, String password) {
- passwordAuthentication = new PasswordAuthentication(username, password);
-
- }
-
- @Override
- protected PasswordAuthentication getPasswordAuthentication () {
- return passwordAuthentication;
- }
-
-}
diff --git a/src/main/java/de/ids_mannheim/korap/service/MailService.java b/src/main/java/de/ids_mannheim/korap/service/MailService.java
deleted file mode 100644
index 7619a25..0000000
--- a/src/main/java/de/ids_mannheim/korap/service/MailService.java
+++ /dev/null
@@ -1,91 +0,0 @@
-package de.ids_mannheim.korap.service;
-
-import java.io.StringWriter;
-import java.nio.charset.StandardCharsets;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.VelocityEngine;
-import org.apache.velocity.context.Context;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.mail.javamail.JavaMailSender;
-import org.springframework.mail.javamail.MimeMessageHelper;
-import org.springframework.mail.javamail.MimeMessagePreparator;
-import org.springframework.stereotype.Service;
-
-import de.ids_mannheim.korap.authentication.AuthenticationManager;
-import de.ids_mannheim.korap.config.FullConfiguration;
-import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.user.User;
-import de.ids_mannheim.korap.utils.ParameterChecker;
-import jakarta.mail.internet.InternetAddress;
-import jakarta.mail.internet.MimeMessage;
-
-/**
- * Manages mail related services, such as sending group member
- * invitations per email.
- *
- * @author margaretha
- *
- */
-@Service
-public class MailService {
-
- public static Logger jlog = LogManager.getLogger(MailService.class);
- public static boolean DEBUG = false;
-
- @Autowired
- private AuthenticationManager authenticationManager;
- @Autowired
- private JavaMailSender mailSender;
- @Autowired
- private VelocityEngine velocityEngine;
- @Autowired
- private FullConfiguration config;
-
- public void sendMemberInvitationNotification (String inviteeName,
- String groupName, String inviter) throws KustvaktException {
-
- ParameterChecker.checkStringValue(inviteeName, "inviteeName");
- ParameterChecker.checkStringValue(groupName, "groupName");
- ParameterChecker.checkStringValue(inviter, "inviter");
-
- MimeMessagePreparator preparator = new MimeMessagePreparator() {
-
- public void prepare (MimeMessage mimeMessage) throws Exception {
-
- User invitee = authenticationManager.getUser(inviteeName,
- config.getEmailAddressRetrieval());
-
- MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
- message.setTo(new InternetAddress(invitee.getEmail()));
- message.setFrom(config.getNoReply());
- message.setSubject("Invitation to join " + groupName);
- message.setText(prepareGroupInvitationText(inviteeName,
- groupName, inviter), true);
- }
-
- };
- mailSender.send(preparator);
- }
-
- private String prepareGroupInvitationText (String username,
- String groupName, String inviter) {
- Context context = new VelocityContext();
- context.put("username", username);
- context.put("group", groupName);
- context.put("inviter", inviter);
-
- StringWriter stringWriter = new StringWriter();
-
- velocityEngine.mergeTemplate(
- "templates/" + config.getGroupInvitationTemplate(),
- StandardCharsets.UTF_8.name(), context, stringWriter);
-
- String message = stringWriter.toString();
- if (DEBUG)
- jlog.debug(message);
- return message;
- }
-}
diff --git a/src/main/resources/default-config.xml b/src/main/resources/default-config.xml
index 0e12214..08a2a65 100644
--- a/src/main/resources/default-config.xml
+++ b/src/main/resources/default-config.xml
@@ -289,40 +289,4 @@
<!-- <property name="dataSource" ref="c3p0DataSource" /> -->
</bean>
- <!-- mail -->
- <bean id="authenticator"
- class="de.ids_mannheim.korap.service.MailAuthenticator">
- <constructor-arg index="0" value="${mail.username}" />
- <constructor-arg index="1" value="${mail.password}" />
- </bean>
- <bean id="smtpSession" class="jakarta.mail.Session"
- factory-method="getInstance">
- <constructor-arg index="0">
- <props>
- <prop key="mail.smtp.submitter">${mail.username}</prop>
- <prop key="mail.smtp.auth">${mail.auth}</prop>
- <prop key="mail.smtp.host">${mail.host}</prop>
- <prop key="mail.smtp.port">${mail.port}</prop>
- <prop key="mail.smtp.starttls.enable">${mail.starttls.enable}</prop>
- <prop key="mail.smtp.connectiontimeout">${mail.connectiontimeout}</prop>
- </props>
- </constructor-arg>
- <constructor-arg index="1" ref="authenticator" />
- </bean>
- <bean id="mailSender"
- class="org.springframework.mail.javamail.JavaMailSenderImpl">
- <property name="username" value="${mail.username}" />
- <property name="password" value="${mail.password}" />
- <property name="session" ref="smtpSession" />
- </bean>
- <bean id="velocityEngine"
- class="org.apache.velocity.app.VelocityEngine">
- <constructor-arg index="0">
- <props>
- <prop key="resource.loader">class</prop>
- <prop key="class.resource.loader.class">org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
- </prop>
- </props>
- </constructor-arg>
- </bean>
</beans>
diff --git a/src/main/resources/kustvakt.conf b/src/main/resources/kustvakt.conf
index e90c513..96a5823 100644
--- a/src/main/resources/kustvakt.conf
+++ b/src/main/resources/kustvakt.conf
@@ -21,15 +21,6 @@
server.port=8089
server.host=localhost
-# mail settings
-mail.enabled = false
-mail.receiver = test@localhost
-mail.sender = noreply@ids-mannheim.de
-mail.address.retrieval = test
-
-# mail.templates
-template.group.invitation = notification.vm
-
# default foundries for specific layers
default.foundry.partOfSpeech = tt
default.foundry.lemma = tt
diff --git a/src/main/resources/properties/mail.properties b/src/main/resources/properties/mail.properties
deleted file mode 100644
index 29d1ca1..0000000
--- a/src/main/resources/properties/mail.properties
+++ /dev/null
@@ -1,7 +0,0 @@
-mail.host = localhost
-mail.port = 25
-mail.connectiontimeout = 3000
-mail.auth = false
-mail.starttls.enable = false
-mail.username = username
-mail.password = password
\ No newline at end of file
diff --git a/src/test/resources/kustvakt-dnb.conf b/src/test/resources/kustvakt-dnb.conf
index 54e0edf..c940eb8 100644
--- a/src/test/resources/kustvakt-dnb.conf
+++ b/src/test/resources/kustvakt-dnb.conf
@@ -30,17 +30,6 @@
server.port=8089
server.host=localhost
-# Mail settings
-#
-mail.enabled = false
-mail.receiver = test@localhost
-mail.sender = noreply@ids-mannheim.de
-mail.address.retrieval = test
-
-# Mail.templates
-#
-template.group.invitation = notification.vm
-
# Default foundries for specific layers (optional)
#
default.foundry.partOfSpeech = tt
diff --git a/src/test/resources/kustvakt-icc.conf b/src/test/resources/kustvakt-icc.conf
index 354022e..9714955 100644
--- a/src/test/resources/kustvakt-icc.conf
+++ b/src/test/resources/kustvakt-icc.conf
@@ -21,15 +21,6 @@
server.port=8089
server.host=localhost
-# mail settings
-mail.enabled = false
-mail.receiver = test@localhost
-mail.sender = noreply@ids-mannheim.de
-mail.address.retrieval = test
-
-# mail.templates
-template.group.invitation = notification.vm
-
# default foundries for specific layers
default.foundry.partOfSpeech = tt
default.foundry.lemma = tt
diff --git a/src/test/resources/kustvakt-test.conf b/src/test/resources/kustvakt-test.conf
index 317b720..6185b29 100644
--- a/src/test/resources/kustvakt-test.conf
+++ b/src/test/resources/kustvakt-test.conf
@@ -28,17 +28,6 @@
server.port=8089
server.host=localhost
-# Mail settings
-#
-mail.enabled = false
-mail.receiver = test@localhost
-mail.sender = noreply@ids-mannheim.de
-mail.address.retrieval = test
-
-# Mail.templates
-#
-template.group.invitation = notification.vm
-
# Default foundries for specific layers (optional)
#
default.foundry.partOfSpeech = tt
diff --git a/src/test/resources/test-config-dnb.xml b/src/test/resources/test-config-dnb.xml
index 53c8b8a..c991f71 100644
--- a/src/test/resources/test-config-dnb.xml
+++ b/src/test/resources/test-config-dnb.xml
@@ -321,38 +321,4 @@
<property name="dataSource" ref="dataSource" />
</bean>
- <!-- mail -->
- <bean id="authenticator"
- class="de.ids_mannheim.korap.service.MailAuthenticator">
- <constructor-arg index="0" value="${mail.username}" />
- <constructor-arg index="1" value="${mail.password}" />
- </bean>
- <bean id="smtpSession" class="jakarta.mail.Session"
- factory-method="getInstance">
- <constructor-arg index="0">
- <props>
- <prop key="mail.smtp.submitter">${mail.username}</prop>
- <prop key="mail.smtp.auth">${mail.auth}</prop>
- <prop key="mail.smtp.host">${mail.host}</prop>
- <prop key="mail.smtp.port">${mail.port}</prop>
- <prop key="mail.smtp.starttls.enable">${mail.starttls.enable}</prop>
- <prop key="mail.smtp.connectiontimeout">${mail.connectiontimeout}</prop>
- </props>
- </constructor-arg>
- <constructor-arg index="1" ref="authenticator" />
- </bean>
- <bean id="mailSender"
- class="org.springframework.mail.javamail.JavaMailSenderImpl">
- <property name="session" ref="smtpSession" />
- </bean>
- <bean id="velocityEngine"
- class="org.apache.velocity.app.VelocityEngine">
- <constructor-arg index="0">
- <props>
- <prop key="resource.loader">class</prop>
- <prop key="class.resource.loader.class">org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
- </prop>
- </props>
- </constructor-arg>
- </bean>
</beans>
diff --git a/src/test/resources/test-config-icc.xml b/src/test/resources/test-config-icc.xml
index d418f05..252ba8a 100644
--- a/src/test/resources/test-config-icc.xml
+++ b/src/test/resources/test-config-icc.xml
@@ -314,38 +314,4 @@
<property name="dataSource" ref="dataSource" />
</bean>
- <!-- mail -->
- <bean id="authenticator"
- class="de.ids_mannheim.korap.service.MailAuthenticator">
- <constructor-arg index="0" value="${mail.username}" />
- <constructor-arg index="1" value="${mail.password}" />
- </bean>
- <bean id="smtpSession" class="jakarta.mail.Session"
- factory-method="getInstance">
- <constructor-arg index="0">
- <props>
- <prop key="mail.smtp.submitter">${mail.username}</prop>
- <prop key="mail.smtp.auth">${mail.auth}</prop>
- <prop key="mail.smtp.host">${mail.host}</prop>
- <prop key="mail.smtp.port">${mail.port}</prop>
- <prop key="mail.smtp.starttls.enable">${mail.starttls.enable}</prop>
- <prop key="mail.smtp.connectiontimeout">${mail.connectiontimeout}</prop>
- </props>
- </constructor-arg>
- <constructor-arg index="1" ref="authenticator" />
- </bean>
- <bean id="mailSender"
- class="org.springframework.mail.javamail.JavaMailSenderImpl">
- <property name="session" ref="smtpSession" />
- </bean>
- <bean id="velocityEngine"
- class="org.apache.velocity.app.VelocityEngine">
- <constructor-arg index="0">
- <props>
- <prop key="resource.loader">class</prop>
- <prop key="class.resource.loader.class">org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
- </prop>
- </props>
- </constructor-arg>
- </bean>
</beans>
diff --git a/src/test/resources/test-config.xml b/src/test/resources/test-config.xml
index f79f967..3b6f5d1 100644
--- a/src/test/resources/test-config.xml
+++ b/src/test/resources/test-config.xml
@@ -41,7 +41,6 @@
<value>classpath:test-jdbc.properties</value>
<value>file:./test-jdbc.properties</value>
<value>classpath:properties/mail.properties</value>
- <value>file:./mail.properties</value>
<value>classpath:test-hibernate.properties</value>
<value>file:./kustvakt-test.conf</value>
<value>classpath:kustvakt-test.conf</value>
@@ -289,41 +288,4 @@
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
-
- <!-- mail -->
- <bean id="authenticator"
- class="de.ids_mannheim.korap.service.MailAuthenticator">
- <constructor-arg index="0" value="${mail.username}" />
- <constructor-arg index="1" value="${mail.password}" />
- </bean>
- <bean id="smtpSession" class="jakarta.mail.Session"
- factory-method="getInstance">
- <constructor-arg index="0">
- <props>
- <prop key="mail.smtp.submitter">${mail.username}</prop>
- <prop key="mail.smtp.auth">${mail.auth}</prop>
- <prop key="mail.smtp.host">${mail.host}</prop>
- <prop key="mail.smtp.port">${mail.port}</prop>
- <prop key="mail.smtp.starttls.enable">${mail.starttls.enable}</prop>
- <prop key="mail.smtp.connectiontimeout">${mail.connectiontimeout}</prop>
- </props>
- </constructor-arg>
- <constructor-arg index="1" ref="authenticator" />
- </bean>
- <bean id="mailSender"
- class="org.springframework.mail.javamail.JavaMailSenderImpl">
- <property name="username" value="${mail.username}" />
- <property name="password" value="${mail.password}" />
- <property name="session" ref="smtpSession" />
- </bean>
- <bean id="velocityEngine"
- class="org.apache.velocity.app.VelocityEngine">
- <constructor-arg index="0">
- <props>
- <prop key="resource.loader">class</prop>
- <prop key="class.resource.loader.class">org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
- </prop>
- </props>
- </constructor-arg>
- </bean>
</beans>