diff --git a/common/src/java/com/zimbra/common/util/Constants.java b/common/src/java/com/zimbra/common/util/Constants.java index 56bc74cda85..cd3cfebbfae 100644 --- a/common/src/java/com/zimbra/common/util/Constants.java +++ b/common/src/java/com/zimbra/common/util/Constants.java @@ -50,4 +50,5 @@ public class Constants { public static final String BEARER= "Bearer"; public static final String JWT_SALT_SEPARATOR = "|"; + public static final String PRIMARY_EMAIL = "email"; } diff --git a/store/src/java-test/com/zimbra/cs/account/MockProvisioning.java b/store/src/java-test/com/zimbra/cs/account/MockProvisioning.java index 750308fef6b..54ed1ca0793 100644 --- a/store/src/java-test/com/zimbra/cs/account/MockProvisioning.java +++ b/store/src/java-test/com/zimbra/cs/account/MockProvisioning.java @@ -972,7 +972,7 @@ public String sendMdmEmail(String status, String timeInterval) throws ServiceExc } @Override - public void checkIsAliasToBeHidden(NamedEntry entry, List email) throws ServiceException { + public void excludePrivateAliases(NamedEntry entry, List email) throws ServiceException { //Not yet implemenmted } } diff --git a/store/src/java/com/zimbra/cs/account/Provisioning.java b/store/src/java/com/zimbra/cs/account/Provisioning.java index b262bdef4eb..476f27e0428 100644 --- a/store/src/java/com/zimbra/cs/account/Provisioning.java +++ b/store/src/java/com/zimbra/cs/account/Provisioning.java @@ -28,7 +28,6 @@ import com.zimbra.common.service.ServiceException; import com.zimbra.common.util.ExceptionToString; import com.zimbra.common.util.L10nUtil; -import com.zimbra.common.util.Pair; import com.zimbra.common.util.StringUtil; import com.zimbra.common.util.ZimbraLog; import com.zimbra.cs.account.accesscontrol.Right; @@ -2796,6 +2795,6 @@ public String createAddressList(Domain domain, String name, String desc, Map email) throws ServiceException; + public abstract void excludePrivateAliases(NamedEntry entry, List email) throws ServiceException; } diff --git a/store/src/java/com/zimbra/cs/account/ldap/LdapProvisioning.java b/store/src/java/com/zimbra/cs/account/ldap/LdapProvisioning.java index cb20ce6c0a9..f792bef4832 100644 --- a/store/src/java/com/zimbra/cs/account/ldap/LdapProvisioning.java +++ b/store/src/java/com/zimbra/cs/account/ldap/LdapProvisioning.java @@ -11729,25 +11729,25 @@ public String sendMdmEmail(String status, String timeInterval) throws ServiceExc @Override - public void checkIsAliasToBeHidden(NamedEntry entry, List aliases) throws ServiceException { - ZimbraLog.mailbox.debug("checkIsAliasToBeHidden %s ", aliases); + public void excludePrivateAliases(NamedEntry entry, List aliases) throws ServiceException { - LdapUsage ldapUsage = LdapUsage.ADD_ALIAS_ACCOUNT; + LdapUsage ldapUsage = LdapUsage.GAL_SEARCH; ZLdapContext zlc = LdapClient.getContext(LdapServerType.MASTER, ldapUsage); - for (String alias : new ArrayList(aliases)) { + for (String alias : new ArrayList<>(aliases)) { + if (null != alias) { String parts[] = alias.split("@"); String aliasName = parts[0]; String aliasDomain = parts[1]; - ZimbraLog.mailbox.debug("checkIsAliasToBeHidden2 %s ", alias); - - String targetDomainName = ((Account) entry).getDomainName(); + String targetDomainName = ((Account) entry).getDomainName(); String aliasDn = mDIT.aliasDN(((LdapEntry) entry).getDN(), targetDomainName, aliasName, aliasDomain); + ZimbraLog.mailbox.info("excludePrivateAliases alias - %s , aliasname - %s ,aliasDomain %s ,Target Domain - %s , aliasDn -%s ", alias, aliasName, aliasDomain, targetDomainName, aliasDn); + ZAttributes attrs = helper.getAttributes(zlc, aliasDn); Alias aliasEntryLocal = makeAlias(aliasDn, attrs); @@ -11763,7 +11763,6 @@ public void checkIsAliasToBeHidden(NamedEntry entry, List aliases) throw aliasEntryLocal.getAttr(Provisioning.A_zimbraHideAliasInGal), isSame); } } - } } diff --git a/store/src/java/com/zimbra/cs/account/soap/SoapProvisioning.java b/store/src/java/com/zimbra/cs/account/soap/SoapProvisioning.java index a1bc882c625..ec8ca4d635d 100644 --- a/store/src/java/com/zimbra/cs/account/soap/SoapProvisioning.java +++ b/store/src/java/com/zimbra/cs/account/soap/SoapProvisioning.java @@ -3313,7 +3313,8 @@ public String sendMdmEmail(String status, String timeInterval) throws ServiceExc return L10nUtil.getMessage(L10nUtil.MsgKey.sendMDMNotificationEmailSuccess); } - @Override public void checkIsAliasToBeHidden(NamedEntry entry, List email) throws ServiceException { - + @Override + public void excludePrivateAliases(NamedEntry entry, List email) throws ServiceException { + //not yet implemented } } \ No newline at end of file diff --git a/store/src/java/com/zimbra/cs/mailbox/ContactAutoComplete.java b/store/src/java/com/zimbra/cs/mailbox/ContactAutoComplete.java index bfc063d6f70..c09df982462 100644 --- a/store/src/java/com/zimbra/cs/mailbox/ContactAutoComplete.java +++ b/store/src/java/com/zimbra/cs/mailbox/ContactAutoComplete.java @@ -40,13 +40,13 @@ import com.zimbra.common.soap.Element; import com.zimbra.common.soap.MailConstants; import com.zimbra.common.soap.SoapProtocol; +import com.zimbra.common.util.Constants; import com.zimbra.common.util.Pair; import com.zimbra.common.util.StringUtil; import com.zimbra.common.util.ZimbraLog; import com.zimbra.cs.account.Account; import com.zimbra.cs.account.GalContact; import com.zimbra.cs.account.Provisioning; -import com.zimbra.cs.account.ldap.LdapProvisioning; import com.zimbra.cs.gal.GalGroup; import com.zimbra.cs.gal.GalGroupInfoProvider; import com.zimbra.cs.gal.GalSearchControl; @@ -712,9 +712,9 @@ public void addMatchedContacts(String query, Map attrs List allowedEmailsList = new ArrayList<>(); for(String emailKey: mEmailKeys) { - if (!emailKey.equals("email")) { + if (!emailKey.equals(Constants.PRIMARY_EMAIL)) { + //check if all aliases of an account need to be bypassed if (account.isHideAliasesInGal()) { - //condition for allowing primary email address only break; } } @@ -722,15 +722,10 @@ public void addMatchedContacts(String query, Map attrs } ZimbraLog.mailbox.info("allowed list 1 is %s", allowedEmailsList); - try { - Provisioning.getInstance().checkIsAliasToBeHidden(account, allowedEmailsList.subList( 1, allowedEmailsList.size())); - } catch (ServiceException e) { - throw new RuntimeException(e); - } + Provisioning.getInstance().excludePrivateAliases(account, allowedEmailsList.subList( 1, allowedEmailsList.size())); ZimbraLog.mailbox.info("allowed list 2 is %s", allowedEmailsList); - for (String email : allowedEmailsList) { if (email != null && (nameMatches || matchesEmail(tokens, email))) { ContactEntry entry = new ContactEntry();