Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZCS-15079 POC | Hide alias in GAL #1635

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions common/src/java/com/zimbra/common/account/ZAttrProvisioning.java
Original file line number Diff line number Diff line change
Expand Up @@ -7508,9 +7508,9 @@ public static TwoFactorAuthSecretEncoding fromString(String s) throws ServiceExc
public static final String A_zimbraFeatureSearchHistoryEnabled = "zimbraFeatureSearchHistoryEnabled";

/**
* Feature to enable/disable the mobile sync for shared folders. Default
* value is TRUE. The option to sync the shared folders to the Mobile
* will be enabled for the users in the webclient. The option will only
* Feature to enable/disable the mobile sync for shared folders. Default
* value is TRUE. The option to sync the shared folders to the Mobile
* will be enabled for the users in the webclient. The option will only
* be enabled for shared folders having Admin or Manager permission
*
* @since ZCS 10.1.0
Expand Down Expand Up @@ -8586,6 +8586,14 @@ public static TwoFactorAuthSecretEncoding fromString(String s) throws ServiceExc
@ZAttr(id=4116)
public static final String A_zimbraHideAliasesInGal = "zimbraHideAliasesInGal";

/**
* Option to hide/show alias in GAL
*
* @since ZCS 10.1.1
*/
@ZAttr(id=4135)
public static final String A_zimbraHideAliasInGal = "zimbraHideAliasInGal";

/**
* hide entry in Global Address List
*/
Expand Down
4 changes: 4 additions & 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,8 @@ public class Constants {
public static final String BEARER= "Bearer";
public static final String JWT_SALT_SEPARATOR = "|";

public static final String PRIMARY_EMAIL = "email";

public static final String TRUE_VALUE = "TRUE";

}
7 changes: 6 additions & 1 deletion store/conf/attrs/zimbra-attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10474,7 +10474,7 @@ TODO: delete them permanently from here
<desc>Define body: field for 2FA email in html format</desc>
</attr>

<attr id="4116" name="zimbraHideAliasesInGal" type="boolean" cardinality="single" optionalIn="account" flags="accountInfo" since="10.1.0">
<attr id="4116" name="zimbraHideAliasesInGal" type="boolean" cardinality="single" optionalIn="account,cos,domain" flags="accountInfo" since="10.1.0">
<desc>When set to True, all aliases will be hidden for particular account</desc>
</attr>

Expand Down Expand Up @@ -10555,4 +10555,9 @@ TODO: delete them permanently from here
<defaultCOSValue>TRUE</defaultCOSValue>
<desc>Feature to enable/disable the mobile sync for shared folders. Default value is TRUE. The option to sync the shared folders to the Mobile will be enabled for the users in the webclient. The option will only be enabled for shared folders having Admin or Manager permission</desc>
</attr>

<attr id="4135" name="zimbraHideAliasInGal" type="boolean" cardinality="single" requiredIn="alias" since="10.1.1">
<desc> Option to hide/show alias in GAL</desc>

</attr>
</attrs>
Original file line number Diff line number Diff line change
Expand Up @@ -970,4 +970,9 @@ public void resetPassword(Account acct, String newPassword, boolean dryRun) thro
public String sendMdmEmail(String status, String timeInterval) throws ServiceException {
return null;
}

@Override
public void excludePrivateAliases(NamedEntry entry, List<String> email) throws ServiceException {
//Not yet implemenmted
}
}
4 changes: 3 additions & 1 deletion 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 @@ -2795,4 +2794,7 @@ public String createAddressList(Domain domain, String name, String desc, Map<Str
}

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

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

}
30 changes: 15 additions & 15 deletions store/src/java/com/zimbra/cs/account/ZAttrAccount.java
Original file line number Diff line number Diff line change
Expand Up @@ -21018,9 +21018,9 @@ public Map<String,Object> unsetFeatureSearchHistoryEnabled(Map<String,Object> at
}

/**
* Feature to enable/disable the mobile sync for shared folders. Default
* value is TRUE. The option to sync the shared folders to the Mobile
* will be enabled for the users in the webclient. The option will only
* Feature to enable/disable the mobile sync for shared folders. Default
* value is TRUE. The option to sync the shared folders to the Mobile
* will be enabled for the users in the webclient. The option will only
* be enabled for shared folders having Admin or Manager permission
*
* @return zimbraFeatureSharedFolderMobileSyncEnabled, or true if unset
Expand All @@ -21033,9 +21033,9 @@ public boolean isFeatureSharedFolderMobileSyncEnabled() {
}

/**
* Feature to enable/disable the mobile sync for shared folders. Default
* value is TRUE. The option to sync the shared folders to the Mobile
* will be enabled for the users in the webclient. The option will only
* Feature to enable/disable the mobile sync for shared folders. Default
* value is TRUE. The option to sync the shared folders to the Mobile
* will be enabled for the users in the webclient. The option will only
* be enabled for shared folders having Admin or Manager permission
*
* @param zimbraFeatureSharedFolderMobileSyncEnabled new value
Expand All @@ -21051,9 +21051,9 @@ public void setFeatureSharedFolderMobileSyncEnabled(boolean zimbraFeatureSharedF
}

/**
* Feature to enable/disable the mobile sync for shared folders. Default
* value is TRUE. The option to sync the shared folders to the Mobile
* will be enabled for the users in the webclient. The option will only
* Feature to enable/disable the mobile sync for shared folders. Default
* value is TRUE. The option to sync the shared folders to the Mobile
* will be enabled for the users in the webclient. The option will only
* be enabled for shared folders having Admin or Manager permission
*
* @param zimbraFeatureSharedFolderMobileSyncEnabled new value
Expand All @@ -21070,9 +21070,9 @@ public Map<String,Object> setFeatureSharedFolderMobileSyncEnabled(boolean zimbra
}

/**
* Feature to enable/disable the mobile sync for shared folders. Default
* value is TRUE. The option to sync the shared folders to the Mobile
* will be enabled for the users in the webclient. The option will only
* Feature to enable/disable the mobile sync for shared folders. Default
* value is TRUE. The option to sync the shared folders to the Mobile
* will be enabled for the users in the webclient. The option will only
* be enabled for shared folders having Admin or Manager permission
*
* @throws com.zimbra.common.service.ServiceException if error during update
Expand All @@ -21087,9 +21087,9 @@ public void unsetFeatureSharedFolderMobileSyncEnabled() throws com.zimbra.common
}

/**
* Feature to enable/disable the mobile sync for shared folders. Default
* value is TRUE. The option to sync the shared folders to the Mobile
* will be enabled for the users in the webclient. The option will only
* Feature to enable/disable the mobile sync for shared folders. Default
* value is TRUE. The option to sync the shared folders to the Mobile
* will be enabled for the users in the webclient. The option will only
* be enabled for shared folders having Admin or Manager permission
*
* @param attrs existing map to populate, or null to create a new map
Expand Down
30 changes: 15 additions & 15 deletions store/src/java/com/zimbra/cs/account/ZAttrCos.java
Original file line number Diff line number Diff line change
Expand Up @@ -15407,9 +15407,9 @@ public Map<String,Object> unsetFeatureSearchHistoryEnabled(Map<String,Object> at
}

/**
* Feature to enable/disable the mobile sync for shared folders. Default
* value is TRUE. The option to sync the shared folders to the Mobile
* will be enabled for the users in the webclient. The option will only
* Feature to enable/disable the mobile sync for shared folders. Default
* value is TRUE. The option to sync the shared folders to the Mobile
* will be enabled for the users in the webclient. The option will only
* be enabled for shared folders having Admin or Manager permission
*
* @return zimbraFeatureSharedFolderMobileSyncEnabled, or true if unset
Expand All @@ -15422,9 +15422,9 @@ public boolean isFeatureSharedFolderMobileSyncEnabled() {
}

/**
* Feature to enable/disable the mobile sync for shared folders. Default
* value is TRUE. The option to sync the shared folders to the Mobile
* will be enabled for the users in the webclient. The option will only
* Feature to enable/disable the mobile sync for shared folders. Default
* value is TRUE. The option to sync the shared folders to the Mobile
* will be enabled for the users in the webclient. The option will only
* be enabled for shared folders having Admin or Manager permission
*
* @param zimbraFeatureSharedFolderMobileSyncEnabled new value
Expand All @@ -15440,9 +15440,9 @@ public void setFeatureSharedFolderMobileSyncEnabled(boolean zimbraFeatureSharedF
}

/**
* Feature to enable/disable the mobile sync for shared folders. Default
* value is TRUE. The option to sync the shared folders to the Mobile
* will be enabled for the users in the webclient. The option will only
* Feature to enable/disable the mobile sync for shared folders. Default
* value is TRUE. The option to sync the shared folders to the Mobile
* will be enabled for the users in the webclient. The option will only
* be enabled for shared folders having Admin or Manager permission
*
* @param zimbraFeatureSharedFolderMobileSyncEnabled new value
Expand All @@ -15459,9 +15459,9 @@ public Map<String,Object> setFeatureSharedFolderMobileSyncEnabled(boolean zimbra
}

/**
* Feature to enable/disable the mobile sync for shared folders. Default
* value is TRUE. The option to sync the shared folders to the Mobile
* will be enabled for the users in the webclient. The option will only
* Feature to enable/disable the mobile sync for shared folders. Default
* value is TRUE. The option to sync the shared folders to the Mobile
* will be enabled for the users in the webclient. The option will only
* be enabled for shared folders having Admin or Manager permission
*
* @throws com.zimbra.common.service.ServiceException if error during update
Expand All @@ -15476,9 +15476,9 @@ public void unsetFeatureSharedFolderMobileSyncEnabled() throws com.zimbra.common
}

/**
* Feature to enable/disable the mobile sync for shared folders. Default
* value is TRUE. The option to sync the shared folders to the Mobile
* will be enabled for the users in the webclient. The option will only
* Feature to enable/disable the mobile sync for shared folders. Default
* value is TRUE. The option to sync the shared folders to the Mobile
* will be enabled for the users in the webclient. The option will only
* be enabled for shared folders having Admin or Manager permission
*
* @param attrs existing map to populate, or null to create a new map
Expand Down
29 changes: 29 additions & 0 deletions store/src/java/com/zimbra/cs/account/ldap/LdapProvisioning.java
Original file line number Diff line number Diff line change
Expand Up @@ -2497,6 +2497,7 @@ private void addAliasInternal(NamedEntry entry, String alias) throws ServiceExce
zlc.createEntry(aliasDn, "zimbraAlias",
new String[] { Provisioning.A_uid, aliasName,
Provisioning.A_zimbraId, aliasUuid,
Provisioning.A_zimbraHideAliasInGal, String.valueOf(new Random().nextBoolean()).toUpperCase(),// to be modified
Provisioning.A_zimbraCreateTimestamp, LdapDateUtil.toGeneralizedTime(new Date()),
Provisioning.A_zimbraAliasTargetId, targetEntryId} );
} catch (LdapEntryAlreadyExistException e) {
Expand Down Expand Up @@ -11726,4 +11727,32 @@ public void modifyAddressList(AddressList addressList, String name, Map<String,
public String sendMdmEmail(String status, String timeInterval) throws ServiceException {
return L10nUtil.getMessage(L10nUtil.MsgKey.sendMDMNotificationEmailFailure);
}


@Override
public void excludePrivateAliases(NamedEntry entry, List<String> emailAndAliases) throws ServiceException {
LdapUsage ldapUsage = LdapUsage.GAL_SEARCH;
ZLdapContext zlc = LdapClient.getContext(LdapServerType.MASTER, ldapUsage);
for (String alias : new ArrayList<>(
emailAndAliases.subList(1, emailAndAliases.size()))) { // exclude primay email here
if (null != alias) {
String parts[] = alias.split("@");
String aliasName = parts[0];
String aliasDomain = parts[1];
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 aliasEntry = makeAlias(aliasDn, attrs);
if (Constants.TRUE_VALUE.equalsIgnoreCase(aliasEntry.getAttr(Provisioning.A_zimbraHideAliasInGal))) {
emailAndAliases.remove(alias);
}
ZimbraLog.mailbox.info("alias attribute for %s is %s", alias,
aliasEntry.getAttr(Provisioning.A_zimbraHideAliasInGal));
}
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -3312,4 +3312,9 @@ public String sendMdmEmail(String status, String timeInterval) throws ServiceExc

return L10nUtil.getMessage(L10nUtil.MsgKey.sendMDMNotificationEmailSuccess);
}

@Override
public void excludePrivateAliases(NamedEntry entry, List<String> email) throws ServiceException {
//not yet implemented
}
}
Loading