This is an automated email from the ASF dual-hosted git repository. btellier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 89251a2f685b9b6f885335631b7e1833d5eb63c4 Author: Benoit Tellier <[email protected]> AuthorDate: Mon Nov 18 14:33:32 2019 +0700 JAMES-2949 JamesUser is no longer implemented Specific handling, as well as this model, is thus no longer required, after removal of JamesUsersRepository & UsersFileRepository See https://github.com/linagora/james-project/pull/2843 --- .../user/api/UsersRepositoryManagementMBean.java | 51 ------------- .../org/apache/james/user/api/model/JamesUser.java | 88 ---------------------- .../james/user/lib/UsersRepositoryManagement.java | 69 ----------------- .../james/transport/mailets/WhiteListManager.java | 27 ------- .../matchers/AbstractSQLWhitelistMatcher.java | 21 ------ 5 files changed, 256 deletions(-) diff --git a/server/data/data-api/src/main/java/org/apache/james/user/api/UsersRepositoryManagementMBean.java b/server/data/data-api/src/main/java/org/apache/james/user/api/UsersRepositoryManagementMBean.java index 8e262b1..08fc593 100644 --- a/server/data/data-api/src/main/java/org/apache/james/user/api/UsersRepositoryManagementMBean.java +++ b/server/data/data-api/src/main/java/org/apache/james/user/api/UsersRepositoryManagementMBean.java @@ -19,8 +19,6 @@ package org.apache.james.user.api; -import org.apache.james.core.Username; - /** * Expose user account management functionality through JMX. */ @@ -92,55 +90,6 @@ public interface UsersRepositoryManagementMBean { void setPassword(String userName, String password) throws Exception; /** - * Removes a user's alias which terminates local mail forwarding - * - * - * @param userName - * The name of the user whose alias is unset - * @throws UsersRepositoryException - * if error - */ - @Deprecated - void unsetAlias(Username userName) throws Exception; - - /** - * Retrieves the user's alias, if set - * - * - * @return User's alias, or NULL, if no alias is set - * @throws UsersRepositoryException - * if error - */ - @Deprecated - String getAlias(Username userName) throws Exception; - - /** - * Removes a user's forward email address which terminates remote mail - * forwarding - * - * - * @param userName - * The name of the user whose forward is unset - * @throws UsersRepositoryException - * if error - */ - @Deprecated - void unsetForwardAddress(Username userName) throws Exception; - - /** - * Retrieves the user's forward, if set - * - * - * @param userName - * The name of the user whose forward is set - * @return User's forward email address, or NULL, if no forward is set - * @throws UsersRepositoryException - * if error - */ - @Deprecated - String getForwardAddress(Username userName) throws Exception; - - /** * Return true if the UserRepository has VirtualHosting enabled * * @return virtual diff --git a/server/data/data-api/src/main/java/org/apache/james/user/api/model/JamesUser.java b/server/data/data-api/src/main/java/org/apache/james/user/api/model/JamesUser.java deleted file mode 100644 index 1db501d..0000000 --- a/server/data/data-api/src/main/java/org/apache/james/user/api/model/JamesUser.java +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one * - * or more contributor license agreements. See the NOTICE file * - * distributed with this work for additional information * - * regarding copyright ownership. The ASF licenses this file * - * to you under the Apache License, Version 2.0 (the * - * "License"); you may not use this file except in compliance * - * with the License. You may obtain a copy of the License at * - * * - * http://www.apache.org/licenses/LICENSE-2.0 * - * * - * Unless required by applicable law or agreed to in writing, * - * software distributed under the License is distributed on an * - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * - * KIND, either express or implied. See the License for the * - * specific language governing permissions and limitations * - * under the License. * - ****************************************************************/ - -package org.apache.james.user.api.model; - -import org.apache.james.core.MailAddress; - -/** - * Interface for objects representing users of an email/ messaging system. - * - * @deprecated Just use the User interface for Users. Forwarding and Aliasing - * should get done via RecipientRewriteTable - */ -@Deprecated -public interface JamesUser extends User { - - /** - * Indicate if mail for this user should be forwarded to some other mail - * server. - * - * @param forward - * whether email for this user should be forwarded - */ - void setForwarding(boolean forward); - - /** - * Return true if mail for this user should be forwarded - */ - boolean getForwarding(); - - /** - * <p> - * Set destination for forwading mail - * </p> - * <p> - * TODO: Should we use a MailAddress? - * </p> - * - * @param address - * the forwarding address for this user - */ - boolean setForwardingDestination(MailAddress address); - - /** - * Return the destination to which email should be forwarded - */ - MailAddress getForwardingDestination(); - - /** - * Indicate if mail received for this user should be delivered locally to a - * different address. - */ - void setAliasing(boolean alias); - - /** - * Return true if emails should be delivered locally to an alias. - */ - boolean getAliasing(); - - /** - * Set local address to which email should be delivered. - * - * @return true if successful - */ - boolean setAlias(String address); - - /** - * Get local address to which mail should be delivered. - */ - String getAlias(); - -} diff --git a/server/data/data-library/src/main/java/org/apache/james/user/lib/UsersRepositoryManagement.java b/server/data/data-library/src/main/java/org/apache/james/user/lib/UsersRepositoryManagement.java index ad5d55a..dded302 100644 --- a/server/data/data-library/src/main/java/org/apache/james/user/lib/UsersRepositoryManagement.java +++ b/server/data/data-library/src/main/java/org/apache/james/user/lib/UsersRepositoryManagement.java @@ -30,10 +30,8 @@ import org.apache.james.core.Username; import org.apache.james.user.api.UsersRepository; import org.apache.james.user.api.UsersRepositoryException; import org.apache.james.user.api.UsersRepositoryManagementMBean; -import org.apache.james.user.api.model.JamesUser; import org.apache.james.user.api.model.User; -@SuppressWarnings("deprecation") public class UsersRepositoryManagement extends StandardMBean implements UsersRepositoryManagementMBean { /** @@ -50,18 +48,6 @@ public class UsersRepositoryManagement extends StandardMBean implements UsersRep super(UsersRepositoryManagementMBean.class); } - private JamesUser getJamesUser(Username userName) throws UsersRepositoryException { - User baseuser = usersRepository.getUserByName(userName); - if (baseuser == null) { - throw new IllegalArgumentException("user not found: " + userName.asString()); - } - if (!(baseuser instanceof JamesUser)) { - throw new IllegalArgumentException("user is not of type JamesUser: " + userName.asString()); - } - - return (JamesUser) baseuser; - } - @Override public void addUser(String rawUsername, String password) throws Exception { try { @@ -135,61 +121,6 @@ public class UsersRepositoryManagement extends StandardMBean implements UsersRep } @Override - public void unsetAlias(Username userName) throws Exception { - try { - JamesUser user = getJamesUser(userName); - if (!user.getAliasing()) { - throw new UsersRepositoryException("User " + user + " is no alias"); - } - user.setAliasing(false); - usersRepository.updateUser(user); - } catch (UsersRepositoryException e) { - throw new Exception(e.getMessage()); - } - } - - @Override - public String getAlias(Username userName) throws Exception { - try { - JamesUser user = getJamesUser(userName); - if (!user.getAliasing()) { - return null; - } - return user.getAlias(); - } catch (UsersRepositoryException e) { - throw new Exception(e.getMessage()); - - } - } - - @Override - public void unsetForwardAddress(Username userName) throws Exception { - try { - JamesUser user = getJamesUser(userName); - if (!user.getForwarding()) { - throw new UsersRepositoryException("User " + user + " is no forward"); - } - user.setForwarding(false); - usersRepository.updateUser(user); - } catch (UsersRepositoryException e) { - throw new Exception(e.getMessage()); - } - } - - @Override - public String getForwardAddress(Username userName) throws Exception { - try { - JamesUser user = getJamesUser(userName); - if (!user.getForwarding()) { - return null; - } - return user.getForwardingDestination().toString(); - } catch (UsersRepositoryException e) { - throw new Exception(e.getMessage()); - } - } - - @Override public boolean getVirtualHostingEnabled() throws Exception { try { return usersRepository.supportVirtualHosting(); diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/WhiteListManager.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/WhiteListManager.java index 12c35a0..4e78ea1 100644 --- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/WhiteListManager.java +++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/WhiteListManager.java @@ -48,9 +48,7 @@ import javax.sql.DataSource; import org.apache.james.core.Domain; import org.apache.james.core.MailAddress; -import org.apache.james.core.Username; import org.apache.james.user.api.UsersRepository; -import org.apache.james.user.api.model.JamesUser; import org.apache.james.util.sql.JDBCUtil; import org.apache.james.util.sql.SqlResources; import org.apache.mailet.Experimental; @@ -296,8 +294,6 @@ public class WhiteListManager extends GenericMailet { String senderUser = senderMailAddress.getLocalPart().toLowerCase(Locale.US); Domain senderHost = senderMailAddress.getDomain(); - senderUser = getPrimaryName(senderUser); - Connection conn = null; PreparedStatement selectStmt = null; PreparedStatement insertStmt = null; @@ -380,8 +376,6 @@ public class WhiteListManager extends GenericMailet { String senderUser = senderMailAddress.getLocalPart().toLowerCase(Locale.US); Domain senderHost = senderMailAddress.getDomain(); - senderUser = getPrimaryName(senderUser); - Connection conn = null; PreparedStatement selectStmt = null; ResultSet selectRS = null; @@ -428,8 +422,6 @@ public class WhiteListManager extends GenericMailet { String senderUser = senderMailAddress.getLocalPart().toLowerCase(Locale.US); Domain senderHost = senderMailAddress.getDomain(); - senderUser = getPrimaryName(senderUser); - Connection conn = null; PreparedStatement selectStmt = null; PreparedStatement insertStmt = null; @@ -549,8 +541,6 @@ public class WhiteListManager extends GenericMailet { String senderUser = senderMailAddress.getLocalPart().toLowerCase(Locale.US); Domain senderHost = senderMailAddress.getDomain(); - senderUser = getPrimaryName(senderUser); - Connection conn = null; PreparedStatement selectStmt = null; PreparedStatement deleteStmt = null; @@ -718,23 +708,6 @@ public class WhiteListManager extends GenericMailet { } /** - * Gets the main name of a local customer, handling alias - */ - private String getPrimaryName(String originalUsername) { - String username; - try { - username = originalUsername; - JamesUser user = (JamesUser) localusers.getUserByName(Username.of(username)); - if (user.getAliasing()) { - username = user.getAlias(); - } - } catch (Exception e) { - username = originalUsername; - } - return username; - } - - /** * Initializes the sql query environment from the SqlResources file. Will * look for conf/sqlResources.xml. * diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractSQLWhitelistMatcher.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractSQLWhitelistMatcher.java index d088f1c..409ff3c 100644 --- a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractSQLWhitelistMatcher.java +++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractSQLWhitelistMatcher.java @@ -36,11 +36,9 @@ import javax.sql.DataSource; import org.apache.james.core.Domain; import org.apache.james.core.MailAddress; -import org.apache.james.core.Username; import org.apache.james.filesystem.api.FileSystem; import org.apache.james.transport.mailets.WhiteListManager; import org.apache.james.user.api.UsersRepository; -import org.apache.james.user.api.model.JamesUser; import org.apache.james.util.sql.JDBCUtil; import org.apache.james.util.sql.SqlResources; import org.apache.mailet.Experimental; @@ -162,8 +160,6 @@ public abstract class AbstractSQLWhitelistMatcher extends GenericMatcher { continue; } - recipientUser = getPrimaryName(recipientUser); - if (matchedWhitelist(recipientMailAddress, mail)) { // This address was already in the list inWhiteList.add(recipientMailAddress); @@ -178,23 +174,6 @@ public abstract class AbstractSQLWhitelistMatcher extends GenericMatcher { protected abstract boolean matchedWhitelist(MailAddress recipient, Mail mail) throws MessagingException; /** - * Gets the main name of a local customer, handling alias - */ - protected String getPrimaryName(String originalUsername) { - String username; - try { - username = originalUsername; - JamesUser user = (JamesUser) localusers.getUserByName(Username.of(username)); - if (user.getAliasing()) { - username = user.getAlias(); - } - } catch (Exception e) { - username = originalUsername; - } - return username; - } - - /** * Initializes the sql query environment from the SqlResources file.<br> * Will look for conf/sqlResources.xml.<br> * Will <strong>not</<strong> create the database resources, if missing<br> --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
