Skip to content

Commit

Permalink
zcs
Browse files Browse the repository at this point in the history
  • Loading branch information
rendurama committed Jul 5, 2024
1 parent d905cee commit 30b9f7a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 22 deletions.
1 change: 1 addition & 0 deletions common/src/java/com/zimbra/common/util/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ public String sendMdmEmail(String status, String timeInterval) throws ServiceExc
}

@Override
public void checkIsAliasToBeHidden(NamedEntry entry, List<String> email) throws ServiceException {
public void excludePrivateAliases(NamedEntry entry, List<String> email) throws ServiceException {
//Not yet implemenmted
}
}
3 changes: 1 addition & 2 deletions store/src/java/com/zimbra/cs/account/Provisioning.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -2796,6 +2795,6 @@ public String createAddressList(Domain domain, String name, String desc, Map<Str

public abstract String sendMdmEmail(String status, String timeInterval) throws ServiceException;

public abstract void checkIsAliasToBeHidden(NamedEntry entry, List<String> email) throws ServiceException;
public abstract void excludePrivateAliases(NamedEntry entry, List<String> email) throws ServiceException;

}
15 changes: 7 additions & 8 deletions store/src/java/com/zimbra/cs/account/ldap/LdapProvisioning.java
Original file line number Diff line number Diff line change
Expand Up @@ -11729,25 +11729,25 @@ public String sendMdmEmail(String status, String timeInterval) throws ServiceExc


@Override
public void checkIsAliasToBeHidden(NamedEntry entry, List<String> aliases) throws ServiceException {
ZimbraLog.mailbox.debug("checkIsAliasToBeHidden %s ", aliases);
public void excludePrivateAliases(NamedEntry entry, List<String> 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<String>(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);
Expand All @@ -11763,7 +11763,6 @@ public void checkIsAliasToBeHidden(NamedEntry entry, List<String> aliases) throw
aliasEntryLocal.getAttr(Provisioning.A_zimbraHideAliasInGal), isSame);
}
}

}
}

Original file line number Diff line number Diff line change
Expand Up @@ -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<String> email) throws ServiceException {

@Override
public void excludePrivateAliases(NamedEntry entry, List<String> email) throws ServiceException {
//not yet implemented
}
}
13 changes: 4 additions & 9 deletions store/src/java/com/zimbra/cs/mailbox/ContactAutoComplete.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -712,25 +712,20 @@ public void addMatchedContacts(String query, Map<String, ? extends Object> attrs

List<String> 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;
}
}
allowedEmailsList.add(getFieldAsString(attrs, emailKey));
}
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();
Expand Down

0 comments on commit 30b9f7a

Please sign in to comment.