use of com.zimbra.cs.account.Config in project zm-mailbox by Zimbra.
the class SpamHandler method isSpam.
/**
* Returns <tt>false</tt> if the value of the header named <tt>zimbraSpamWhitelistHeader</tt>
* matches the pattern specified by <tt>zimbraSpamWhitelistHeaderValue</tt>.
*
* If <tt>zimbraSpamWhitelistHeader</tt> does not match, returns <tt>true</tt> if the value of the
* header named <tt>zimbraSpamHeader</tt> matches the pattern specified by <tt>zimbraSpamHeaderValue</tt>.
*/
public static boolean isSpam(MimeMessage msg) {
try {
Config config = Provisioning.getInstance().getConfig();
String whitelistHeader = config.getSpamWhitelistHeader();
if (whitelistHeader != null) {
String whitelistHeaderValue = config.getSpamWhitelistHeaderValue();
if (whitelistHeaderValue != null) {
if (!whitelistHeaderValue.equals(SpamHandler.whitelistHeaderValue)) {
// Value has changed. Recompile pattern.
SpamHandler.whitelistHeaderValue = whitelistHeaderValue;
whitelistPattern = Pattern.compile(whitelistHeaderValue);
}
String[] values = Mime.getHeaders(msg, whitelistHeader);
boolean matched = false;
for (String val : values) {
Matcher m = whitelistPattern.matcher(val);
if (m.matches()) {
matched = true;
} else {
matched = false;
break;
}
}
if (matched) {
return false;
}
}
}
String spamHeader = config.getSpamHeader();
if (spamHeader != null) {
String spamHeaderValue = config.getSpamHeaderValue();
if (spamHeaderValue != null) {
if (!spamHeaderValue.equals(SpamHandler.spamHeaderValue)) {
// Value has changed. Recompile pattern.
SpamHandler.spamHeaderValue = spamHeaderValue;
spamPattern = Pattern.compile(spamHeaderValue);
}
String[] values = Mime.getHeaders(msg, spamHeader);
for (String val : values) {
Matcher m = spamPattern.matcher(val);
if (m.matches()) {
return true;
}
}
}
}
} catch (Exception e) {
ZimbraLog.mailbox.warn("Unable to determine whether the message is spam.", e);
}
return false;
}
use of com.zimbra.cs.account.Config in project zm-mailbox by Zimbra.
the class BUG_11562 method upgradeZimbraGalLdapFilterDef.
@SuppressWarnings("unchecked")
private void upgradeZimbraGalLdapFilterDef() throws ServiceException {
Config config = prov.getConfig();
Pair[] values = { new Pair<String, String>("ad:(&(|(displayName=*%s*)(cn=*%s*)(sn=*%s*)(givenName=*%s*)(mail=*%s*))(!(msExchHideFromAddressLists=TRUE))(mailnickname=*)(|(&(objectCategory=person)(objectClass=user)(!(homeMDB=*))(!(msExchHomeServerName=*)))(&(objectCategory=person)(objectClass=user)(|(homeMDB=*)(msExchHomeServerName=*)))(&(objectCategory=person)(objectClass=contact))(objectCategory=group)(objectCategory=publicFolder)(objectCategory=msExchDynamicDistributionList)))", "ad:(&(|(displayName=*%s*)(cn=*%s*)(sn=*%s*)(givenName=*%s*)(mail=*%s*))(!(msExchHideFromAddressLists=TRUE))(|(&(objectCategory=person)(objectClass=user)(!(homeMDB=*))(!(msExchHomeServerName=*)))(&(objectCategory=person)(objectClass=user)(|(homeMDB=*)(msExchHomeServerName=*)))(&(objectCategory=person)(objectClass=contact))(objectCategory=group)(objectCategory=publicFolder)(objectCategory=msExchDynamicDistributionList)))"), new Pair<String, String>("adAutoComplete:(&(|(displayName=%s*)(cn=%s*)(sn=%s*)(givenName=%s*)(mail=%s*))(!(msExchHideFromAddressLists=TRUE))(mailnickname=*)(|(&(objectCategory=person)(objectClass=user)(!(homeMDB=*))(!(msExchHomeServerName=*)))(&(objectCategory=person)(objectClass=user)(|(homeMDB=*)(msExchHomeServerName=*)))(&(objectCategory=person)(objectClass=contact))(objectCategory=group)(objectCategory=publicFolder)(objectCategory=msExchDynamicDistributionList)))", "adAutoComplete:(&(|(displayName=%s*)(cn=%s*)(sn=%s*)(givenName=%s*)(mail=%s*))(!(msExchHideFromAddressLists=TRUE))(|(&(objectCategory=person)(objectClass=user)(!(homeMDB=*))(!(msExchHomeServerName=*)))(&(objectCategory=person)(objectClass=user)(|(homeMDB=*)(msExchHomeServerName=*)))(&(objectCategory=person)(objectClass=contact))(objectCategory=group)(objectCategory=publicFolder)(objectCategory=msExchDynamicDistributionList)))") };
Set<String> curValues = config.getMultiAttrSet(Provisioning.A_zimbraGalLdapFilterDef);
Map<String, Object> attrs = new HashMap<String, Object>();
for (Pair<String, String> change : values) {
String oldValue = change.getFirst();
String newValue = change.getSecond();
if (curValues.contains(oldValue)) {
StringUtil.addToMultiMap(attrs, "-" + Provisioning.A_zimbraGalLdapFilterDef, oldValue);
StringUtil.addToMultiMap(attrs, "+" + Provisioning.A_zimbraGalLdapFilterDef, newValue);
}
}
modifyAttrs(config, attrs);
}
use of com.zimbra.cs.account.Config in project zm-mailbox by Zimbra.
the class BUG_14531 method doUpgrade.
@Override
void doUpgrade() throws ServiceException {
Config config = prov.getConfig();
String value = "zimbraSync:(&(|(displayName=*)(cn=*)(sn=*)(gn=*)(mail=*)(zimbraMailDeliveryAddress=*)(zimbraMailAlias=*))(|(objectclass=zimbraAccount)(objectclass=zimbraDistributionList))(!(zimbraHideInGal=TRUE))(!(zimbraIsSystemResource=TRUE)))";
Map<String, Object> attr = new HashMap<String, Object>();
attr.put("+" + Provisioning.A_zimbraGalLdapFilterDef, value);
printer.println("Adding zimbraSync filter to global config " + Provisioning.A_zimbraGalLdapFilterDef);
prov.modifyAttrs(config, attr);
}
use of com.zimbra.cs.account.Config in project zm-mailbox by Zimbra.
the class BUG_27075 method doGlobalConfig.
private void doGlobalConfig(ZLdapContext zlc) throws ServiceException {
Config config = prov.getConfig();
doEntry(zlc, config, "global config", AttributeClass.globalConfig);
doBug79208(config);
doBug83551(config);
}
use of com.zimbra.cs.account.Config in project zm-mailbox by Zimbra.
the class RenameDomain method updateGlobalConfigSettings.
// TODO: should modify FlushCache to take more than one entry types, so that we
// can also flsuh the global config cache in the same request when we flush accounts.
private void updateGlobalConfigSettings(String curDefaultDomainName) {
try {
Config config = mProv.getConfig();
HashMap<String, Object> attrMap = new HashMap<String, Object>();
updateSystemAccount(config, Provisioning.A_zimbraNotebookAccount, attrMap);
updateSystemAccount(config, Provisioning.A_zimbraSpamIsSpamAccount, attrMap);
updateSystemAccount(config, Provisioning.A_zimbraSpamIsNotSpamAccount, attrMap);
updateSystemAccount(config, Provisioning.A_zimbraAmavisQuarantineAccount, attrMap);
String newDomainName = getNewDomain(curDefaultDomainName);
if (curDefaultDomainName != null && newDomainName != null)
attrMap.put(Provisioning.A_zimbraDefaultDomainName, newDomainName);
mProv.modifyAttrs(config, attrMap);
flushCacheOnAllServers(CacheEntryType.config);
} catch (ServiceException e) {
// just log it an continue
warn("failed to update system accounts on global config", e);
}
}
Aggregations