use of com.zimbra.cs.account.Config in project zm-mailbox by Zimbra.
the class TestAutoProvision method eagerModeTimer.
@Test
public void eagerModeTimer() throws Exception {
Config config = prov.getConfig();
config.setAutoProvPollingInterval("1000ms");
String testName = getTestName();
final String externalPassword = "test456";
int totalAccts = 4;
int batchSize = 1;
String extAcctLocalPart1 = testName + "_11";
String extAcctLocalPart2 = "zzz";
String extAcctLocalPart3 = testName + "_13";
String extAcctLocalPart4 = testName + "_14";
String extAcctLocalPart5 = testName + "_15";
createExternalAcctEntry(extAcctLocalPart1, externalPassword, null);
createExternalAcctEntry(extAcctLocalPart2, externalPassword, null);
createExternalAcctEntry(extAcctLocalPart3, externalPassword, null);
createExternalAcctEntry(extAcctLocalPart4, externalPassword, null);
createExternalAcctEntry(extAcctLocalPart5, externalPassword, null);
Map<String, Object> zimbraDomainAttrs = AutoProvisionTestUtil.commonZimbraDomainAttrs();
// setup auto prov
zimbraDomainAttrs.put(Provisioning.A_zimbraAutoProvLdapSearchBase, extDomainDn);
zimbraDomainAttrs.put(Provisioning.A_zimbraAutoProvLdapSearchFilter, "(&(uid=%u)(mail=eagerMode*)" + AutoProvisionTestUtil.MarkEntryProvisionedListener.NOT_PROVED_FILTER + ")");
zimbraDomainAttrs.put(Provisioning.A_zimbraAutoProvAccountNameMap, Provisioning.A_uid);
zimbraDomainAttrs.put(Provisioning.A_zimbraAutoProvBatchSize, "" + batchSize);
zimbraDomainAttrs.put(Provisioning.A_zimbraAutoProvListenerClass, AutoProvisionTestUtil.MarkEntryProvisionedListener.class.getName());
Domain zimbraDomain = createZimbraDomain(testName, zimbraDomainAttrs);
// schedule the domain on local server
prov.getLocalServer().addAutoProvScheduledDomains(zimbraDomain.getName());
new MockAutoProvisionThread().start();
//wait for eager thread to finish
Thread.sleep(10000);
List<Account> zimbraAccts = prov.getAllAccounts(zimbraDomain);
assertEquals(totalAccts, zimbraAccts.size());
Set<String> acctNames = new HashSet<String>();
for (Account acct : zimbraAccts) {
acctNames.add(acct.getName());
}
assertTrue(acctNames.contains(TestUtil.getAddress(extAcctLocalPart1, zimbraDomain.getName()).toLowerCase()));
assertTrue(acctNames.contains(TestUtil.getAddress(extAcctLocalPart3, zimbraDomain.getName()).toLowerCase()));
assertTrue(acctNames.contains(TestUtil.getAddress(extAcctLocalPart4, zimbraDomain.getName()).toLowerCase()));
assertTrue(acctNames.contains(TestUtil.getAddress(extAcctLocalPart5, zimbraDomain.getName()).toLowerCase()));
// clear scheduled domains on the local server
prov.getLocalServer().unsetAutoProvScheduledDomains();
}
use of com.zimbra.cs.account.Config in project zm-mailbox by Zimbra.
the class LdapProvisioning method getZMGProxyDataSourceAttrs.
private Map<String, Object> getZMGProxyDataSourceAttrs(String emailAddr, String password, boolean encryptPassword, String dsId) throws ServiceException {
Map<String, Object> testAttrs = new HashMap<String, Object>();
Config config = getConfig();
testAttrs.put(Provisioning.A_zimbraDataSourceEnabled, LdapConstants.LDAP_TRUE);
testAttrs.put(Provisioning.A_zimbraDataSourceIsZmgProxy, LdapConstants.LDAP_TRUE);
testAttrs.put(Provisioning.A_zimbraDataSourceHost, config.getMobileGatewayProxyImapHost());
testAttrs.put(Provisioning.A_zimbraDataSourcePort, Integer.toString(config.getMobileGatewayProxyImapPort()));
testAttrs.put(Provisioning.A_zimbraDataSourceConnectionType, config.getMobileGatewayProxyImapConnectionType().toString());
testAttrs.put(Provisioning.A_zimbraDataSourceUsername, emailAddr);
testAttrs.put(Provisioning.A_zimbraDataSourcePassword, encryptPassword ? DataSource.encryptData(dsId, password) : password);
testAttrs.put(Provisioning.A_zimbraDataSourceSmtpEnabled, LdapConstants.LDAP_TRUE);
testAttrs.put(Provisioning.A_zimbraDataSourceSmtpHost, config.getMobileGatewayProxySmtpHost());
testAttrs.put(Provisioning.A_zimbraDataSourceSmtpPort, Integer.toString(config.getMobileGatewayProxySmtpPort()));
testAttrs.put(Provisioning.A_zimbraDataSourceSmtpConnectionType, config.getMobileGatewayProxySmtpConnectionType().toString());
testAttrs.put(Provisioning.A_zimbraDataSourceSmtpAuthRequired, LdapConstants.LDAP_TRUE);
return testAttrs;
}
use of com.zimbra.cs.account.Config in project zm-mailbox by Zimbra.
the class LdapProvisioning method updateLastLogon.
private void updateLastLogon(Account acct) throws ServiceException {
if (EphemeralStore.getFactory() instanceof LdapEphemeralStore.Factory) {
Config config = Provisioning.getInstance().getConfig();
long freq = config.getLastLogonTimestampFrequency();
// never update timestamp if frequency is 0
if (freq == 0) {
return;
}
Date lastLogon = acct.getLastLogonTimestamp();
// hasn't passed since the last timestamp was logged
if (lastLogon != null && (lastLogon.getTime() + freq > System.currentTimeMillis())) {
return;
}
}
try {
acct.setLastLogonTimestamp(new Date());
} catch (ServiceException e) {
ZimbraLog.account.warn("error updating zimbraLastLogonTimestamp", e);
}
}
use of com.zimbra.cs.account.Config in project zm-mailbox by Zimbra.
the class ZimbraLmtpBackend method checkDedupeCacheSize.
/**
* If the configured Message-ID cache size has changed, create a new cache and copy
* values from the old one.
*/
private void checkDedupeCacheSize() {
try {
Config config = Provisioning.getInstance().getConfig();
int cacheSize = config.getMessageIdDedupeCacheSize();
long entryTimeout = config.getMessageIdDedupeCacheTimeout();
synchronized (ZimbraLmtpBackend.class) {
Map<String, Set<Integer>> newMap = null;
if (receivedMessageIDs == null) {
// if non-zero entry timeout is specified then use a timeout map, else use an lru map
receivedMessageIDs = entryTimeout == 0 ? new LruMap<String, Set<Integer>>(cacheSize) : new TimeoutMap<String, Set<Integer>>(entryTimeout);
} else if (receivedMessageIDs instanceof LruMap) {
if (entryTimeout != 0) {
// change to a timeout map
newMap = MapUtil.newTimeoutMap(entryTimeout);
} else if (((LruMap) receivedMessageIDs).getMaxSize() != cacheSize) {
// adjust lru map size
newMap = MapUtil.newLruMap(cacheSize);
}
} else if (receivedMessageIDs instanceof TimeoutMap) {
if (entryTimeout == 0) {
// change to a lru map
newMap = MapUtil.newLruMap(cacheSize);
} else {
((TimeoutMap) receivedMessageIDs).setTimeout(entryTimeout);
}
}
if (newMap != null) {
// Copy entries from the old map to the new one. The old map
// is iterated in order from least-recently accessed to last accessed.
// If the new map size is smaller, we'll get the latest entries.
newMap.putAll(receivedMessageIDs);
receivedMessageIDs = newMap;
}
}
} catch (ServiceException e) {
ZimbraLog.lmtp.warn("Unable to update dedupe cache size.", e);
// create an empty lru map if it doesn't exist already.
synchronized (ZimbraLmtpBackend.class) {
if (receivedMessageIDs == null) {
receivedMessageIDs = new LruMap<String, Set<Integer>>(0);
}
}
}
}
use of com.zimbra.cs.account.Config in project zm-mailbox by Zimbra.
the class TestJaxbProvisioning method testGetConfig.
@Test
public void testGetConfig() throws Exception {
ZimbraLog.test.debug("Starting test %s", testName());
Config cfg = prov.getConfig();
assertNotNull("Config", cfg);
cfg = prov.getConfig("zimbra_user");
assertNotNull("Config", cfg);
}
Aggregations